- exact magic values for entered/nonentered states in recursive enter check

- read_*() functions to read segment selector values
 - decode loaded segments on panic
This commit is contained in:
Ben Gras 2009-10-03 12:17:46 +00:00
parent fe35879325
commit 6bd3002f06
4 changed files with 47 additions and 6 deletions

View file

@ -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 *

View file

@ -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");

View file

@ -41,24 +41,38 @@
#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)

View file

@ -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();