Page MenuHomeFreeBSD

D3015.id6757.diff
No OneTemporary

D3015.id6757.diff

Index: sys/amd64/amd64/fpu.c
===================================================================
--- sys/amd64/amd64/fpu.c
+++ sys/amd64/amd64/fpu.c
@@ -916,6 +916,7 @@
#define FPU_KERN_CTX_FPUINITDONE 0x01
#define FPU_KERN_CTX_DUMMY 0x02 /* avoided save for the kern thread */
+#define FPU_KERN_CTX_INUSE 0x04
struct fpu_kern_ctx {
struct savefpu *prev;
@@ -940,6 +941,7 @@
fpu_kern_free_ctx(struct fpu_kern_ctx *ctx)
{
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("free'ing inuse ctx"));
/* XXXKIB clear the memory ? */
free(ctx, M_FPUKERN_CTX);
}
@@ -959,14 +961,16 @@
{
struct pcb *pcb;
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("using inuse ctx"));
+
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
- ctx->flags = FPU_KERN_CTX_DUMMY;
+ ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
return (0);
}
pcb = td->td_pcb;
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
get_pcb_user_save_pcb(pcb), ("mangled pcb_save"));
- ctx->flags = 0;
+ ctx->flags = FPU_KERN_CTX_INUSE;
if ((pcb->pcb_flags & PCB_FPUINITDONE) != 0)
ctx->flags |= FPU_KERN_CTX_FPUINITDONE;
fpuexit(td);
@@ -982,8 +986,13 @@
{
struct pcb *pcb;
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) != 0,
+ ("leaving not inuse ctx"));
+ ctx->flags &= ~FPU_KERN_CTX_INUSE;
+
if (is_fpu_kern_thread(0) && (ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
return (0);
+ /* XXX - is this KASSERT needed? */
KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx"));
pcb = td->td_pcb;
critical_enter();
Index: sys/i386/isa/npx.c
===================================================================
--- sys/i386/isa/npx.c
+++ sys/i386/isa/npx.c
@@ -1263,6 +1263,7 @@
#define FPU_KERN_CTX_NPXINITDONE 0x01
#define FPU_KERN_CTX_DUMMY 0x02
+#define FPU_KERN_CTX_INUSE 0x04
struct fpu_kern_ctx {
union savefpu *prev;
@@ -1287,6 +1288,7 @@
fpu_kern_free_ctx(struct fpu_kern_ctx *ctx)
{
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("free'ing inuse ctx"));
/* XXXKIB clear the memory ? */
free(ctx, M_FPUKERN_CTX);
}
@@ -1306,14 +1308,16 @@
{
struct pcb *pcb;
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("using inuse ctx"));
+
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
- ctx->flags = FPU_KERN_CTX_DUMMY;
+ ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
return (0);
}
pcb = td->td_pcb;
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
get_pcb_user_save_pcb(pcb), ("mangled pcb_save"));
- ctx->flags = 0;
+ ctx->flags = FPU_KERN_CTX_INUSE;
if ((pcb->pcb_flags & PCB_NPXINITDONE) != 0)
ctx->flags |= FPU_KERN_CTX_NPXINITDONE;
npxexit(td);
@@ -1329,6 +1333,10 @@
{
struct pcb *pcb;
+ KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) != 0,
+ ("leaving not inuse ctx"));
+ ctx->flags &= ~FPU_KERN_CTX_INUSE;
+
if (is_fpu_kern_thread(0) && (ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
return (0);
pcb = td->td_pcb;

File Metadata

Mime Type
text/plain
Expires
Fri, May 15, 3:44 AM (12 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33072075
Default Alt Text
D3015.id6757.diff (2 KB)

Event Timeline