diff options
-rw-r--r-- | i386/i386/db_interface.c | 8 | ||||
-rw-r--r-- | i386/i386/gdt.h | 4 | ||||
-rw-r--r-- | i386/i386/i386asm.sym | 2 | ||||
-rw-r--r-- | i386/i386/kttd_interface.c | 8 | ||||
-rw-r--r-- | i386/i386/seg.h | 6 |
5 files changed, 16 insertions, 12 deletions
diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index 29f03c9..252ad7e 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -134,7 +134,7 @@ kdb_trap( /* XXX Should switch to ddb`s own stack here. */ ddb_regs = *regs; - if ((regs->cs & 0x3) == 0) { + if ((regs->cs & 0x3) == KERNEL_RING) { /* * Kernel mode - esp and ss not saved */ @@ -152,7 +152,7 @@ kdb_trap( regs->ecx = ddb_regs.ecx; regs->edx = ddb_regs.edx; regs->ebx = ddb_regs.ebx; - if (regs->cs & 0x3) { + if ((regs->cs & 0x3) != KERNEL_RING) { /* * user mode - saved esp and ss valid */ @@ -205,7 +205,7 @@ kdb_kentry( if (db_enter()) #endif /* NCPUS > 1 */ { - if (is->cs & 0x3) { + if ((is->cs & 0x3) != KERNEL_RING) { ddb_regs.uesp = ((int *)(is+1))[0]; ddb_regs.ss = ((int *)(is+1))[1]; } @@ -232,7 +232,7 @@ kdb_kentry( db_task_trap(-1, 0, (ddb_regs.cs & 0x3) != 0); cnpollc(FALSE); - if (ddb_regs.cs & 0x3) { + if ((ddb_regs.cs & 0x3) != KERNEL_RING) { ((int *)(is+1))[0] = ddb_regs.uesp; ((int *)(is+1))[1] = ddb_regs.ss & 0xffff; } diff --git a/i386/i386/gdt.h b/i386/i386/gdt.h index 9b58427..50e01e6 100644 --- a/i386/i386/gdt.h +++ b/i386/i386/gdt.h @@ -38,8 +38,8 @@ /* * Kernel descriptors for Mach - 32-bit flat address space. */ -#define KERNEL_CS 0x08 /* kernel code */ -#define KERNEL_DS 0x10 /* kernel data */ +#define KERNEL_CS (0x08 | KERNEL_RING) /* kernel code */ +#define KERNEL_DS (0x10 | KERNEL_RING) /* kernel data */ #define KERNEL_LDT 0x18 /* master LDT */ #define KERNEL_TSS 0x20 /* master TSS (uniprocessor) */ #define USER_LDT 0x28 /* place for per-thread LDT */ diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym index 45f210e..868bf09 100644 --- a/i386/i386/i386asm.sym +++ b/i386/i386/i386asm.sym @@ -112,6 +112,8 @@ expr IDTSZ expr GDTSZ expr LDTSZ +expr KERNEL_RING + expr KERNEL_CS expr KERNEL_DS expr KERNEL_TSS diff --git a/i386/i386/kttd_interface.c b/i386/i386/kttd_interface.c index 9097061..b9e0624 100644 --- a/i386/i386/kttd_interface.c +++ b/i386/i386/kttd_interface.c @@ -395,7 +395,7 @@ boolean_t kttd_trap(int type, int code, struct i386_saved_state *regs) kttd_regs = *regs; - if ((regs->cs & 0x3) == 0) { + if ((regs->cs & 0x3) == KERNEL_RING) { /* * Kernel mode - esp and ss not saved */ @@ -442,7 +442,7 @@ boolean_t kttd_trap(int type, int code, struct i386_saved_state *regs) regs->ecx = kttd_regs.ecx; regs->edx = kttd_regs.edx; regs->ebx = kttd_regs.ebx; - if (regs->cs & 0x3) { + if ((regs->cs & 0x3) != KERNEL_RING) { /* * user mode - saved esp and ss valid */ @@ -513,7 +513,7 @@ kttd_netentry(int_regs) if (kttd_debug) printf("kttd_NETENTRY after slphigh()\n"); - if (is->cs & 0x3) { + if ((is->cs & 0x3) != KERNEL_RING) { /* * Interrupted from User Space */ @@ -546,7 +546,7 @@ kttd_netentry(int_regs) kttd_task_trap(-1, 0, (kttd_regs.cs & 0x3) != 0); kttd_active--; - if (kttd_regs.cs & 0x3) { + if ((kttd_regs.cs & 0x3) != KERNEL_RING) { ((int *)(is+1))[0] = kttd_regs.uesp; ((int *)(is+1))[1] = kttd_regs.ss & 0xffff; } diff --git a/i386/i386/seg.h b/i386/i386/seg.h index ad7a0f5..9a09af5 100644 --- a/i386/i386/seg.h +++ b/i386/i386/seg.h @@ -37,6 +37,8 @@ * i386 segmentation. */ +#define KERNEL_RING 0 + #ifndef __ASSEMBLER__ /* @@ -95,7 +97,7 @@ struct real_gate { #define ACC_CODE_CR 0x1e /* code, conforming, readable */ #define ACC_PL 0x60 /* access rights: */ -#define ACC_PL_K 0x00 /* kernel access only */ +#define ACC_PL_K (KERNEL_RING << 5) /* kernel access only */ #define ACC_PL_U 0x60 /* user access */ #define ACC_P 0x80 /* segment present */ @@ -104,7 +106,7 @@ struct real_gate { */ #define SEL_LDT 0x04 /* local selector */ #define SEL_PL 0x03 /* privilege level: */ -#define SEL_PL_K 0x00 /* kernel selector */ +#define SEL_PL_K KERNEL_RING /* kernel selector */ #define SEL_PL_U 0x03 /* user selector */ /* |