]> Zhao Yanbai Git Server - minix.git/commitdiff
- exact magic values for entered/nonentered states in recursive enter check
authorBen Gras <ben@minix3.org>
Sat, 3 Oct 2009 12:17:46 +0000 (12:17 +0000)
committerBen Gras <ben@minix3.org>
Sat, 3 Oct 2009 12:17:46 +0000 (12:17 +0000)
 - read_*() functions to read segment selector values
 - decode loaded segments on panic

kernel/arch/i386/klib386.s
kernel/arch/i386/protect.c
kernel/debug.h
kernel/utility.c

index cc6cd748ef47e215a42f4d98637e5f3db22fa85a..d506059f99e6627f0c63af31da750b2f12ed15ec 100755 (executable)
@@ -41,6 +41,9 @@
 .define        _thecr3
 .define        _write_cr4
 .define        _catch_pagefaults
+.define        _read_ds
+.define        _read_cs
+.define        _read_ss
 
 ! The routines only guarantee to preserve the registers the C compiler
 ! expects to be preserved (ebx, esi, edi, ebp, esp, segment registers, and
@@ -573,6 +576,20 @@ _write_cr4:
        pop     ebp
        ret
 
+_read_ds:
+       mov     eax, 0
+       mov     ax, ds
+       ret
+
+_read_cs:
+       mov     eax, 0
+       mov     ax, cs
+       ret
+
+_read_ss:
+       mov     eax, 0
+       mov     ax, ss
+       ret
 
 !*===========================================================================*
 !*                             getcr3val                               *
index e0fa57619ba77bad551d6d8fa9695a50879dada5..c114baac26ddfdeb6ac2355472c047c72f1d51ee 100755 (executable)
@@ -403,6 +403,10 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector)
                        kprintf("invalid index in ldt\n");
                        return;
                }
+               if(!pr) {
+                       kprintf("local selector but unknown process\n");
+                       return;
+               }
                desc = &pr->p_seg.p_ldt[index];
        } else {
                kprintf("GDT");
index c170039d0af653e80b93d55f61e7eea6823aee59..978a311bc0167e3229ee1aac869940704bc811c7 100644 (file)
 #define TRACE(code, statement)
 #endif
 
+#define ENTERED                0xBA5E1514
+#define NOTENTERED     0x1415BEE1
+
 #define NOREC_ENTER(varname) \
-       static int varname = 0; \
+       static int varname = NOTENTERED;        \
        int mustunlock = 0; \
        if(!intr_disabled()) { lock; mustunlock = 1; } \
+       if(varname != ENTERED && varname != NOTENTERED) { \
+               printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\
+               minix_panic(#varname " bogus value on enter", varname); \
+       }       \
        if(magictest != MAGICTEST) {    \
+               printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\
                minix_panic(#varname " magictest failed", __LINE__); \
        }       \
-       if(varname) {   \
+       if(varname == ENTERED) {        \
                minix_panic(#varname " recursive enter", __LINE__); \
        } \
-       varname = 1;
+       varname = ENTERED;
 
 #define NOREC_RETURN(varname, v) do {  \
-       if(!varname)            \
-               minix_panic(#varname " flag off", __LINE__); \
        if(!intr_disabled())    \
                minix_panic(#varname " interrupts on", __LINE__); \
-       varname = 0;    \
+       if(magictest != MAGICTEST) {    \
+               printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\
+               minix_panic(#varname " magictest failed", __LINE__); \
+       }       \
+       if(varname != ENTERED && varname != NOTENTERED) { \
+               printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\
+               minix_panic(#varname " bogus value on return", varname); \
+       }       \
+       varname = NOTENTERED;   \
        if(mustunlock)  { unlock;       } \
        return v;       \
        } while(0)
index fa31cf3fe779e3d004585adc9a9dc39760d7a3a9..67a17f338d3eba641ce1c6c8a051cd0ed6537426 100755 (executable)
@@ -48,6 +48,12 @@ if (minix_panicing++) {
        kprintf("\n");
   }
 
+  printseg("cs: ", 1, NULL, read_cs());
+  printseg("ds: ", 0, NULL, read_ds());
+  if(read_ds() != read_ss()) {
+         printseg("ss: ", 0, NULL, read_ss());
+  }
+
   kprintf("kernel: ");
   util_stacktrace();