Minor changes to stack guard
This commit is contained in:
parent
f882e16db7
commit
74d0508b67
|
@ -341,21 +341,7 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
|
||||||
//
|
//
|
||||||
static void DoubleFaultHandler(ISRFrame_t *regs)
|
static void DoubleFaultHandler(ISRFrame_t *regs)
|
||||||
{
|
{
|
||||||
ulong StackGuardTwo = (ulong)MmGetStackGuards(1);
|
bprintf(BStdOut,
|
||||||
|
|
||||||
if (regs->rsp <= StackGuardTwo + 4*KB && (regs->rsp - 4*KB <= regs->cr2)) {
|
|
||||||
bprintf(BStdOut,
|
|
||||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Overflow\n\n"
|
|
||||||
" Double Fault Error code : %#x (%b)\n"
|
|
||||||
" Stack Guard bypassed : %#x",
|
|
||||||
|
|
||||||
VGA_COLOR_LIGHT_RED,
|
|
||||||
regs->ErrorCode,
|
|
||||||
regs->ErrorCode,
|
|
||||||
StackGuardTwo
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
bprintf(BStdOut,
|
|
||||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Double Fault Abort\n\n"
|
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Double Fault Abort\n\n"
|
||||||
" Error code : 0x%x (%b)",
|
" Error code : 0x%x (%b)",
|
||||||
|
|
||||||
|
@ -364,8 +350,6 @@ static void DoubleFaultHandler(ISRFrame_t *regs)
|
||||||
regs->ErrorCode
|
regs->ErrorCode
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
KeBrkDumpRegisters(regs);
|
KeBrkDumpRegisters(regs);
|
||||||
|
|
||||||
BStdOut->flusher(BStdOut);
|
BStdOut->flusher(BStdOut);
|
||||||
|
|
|
@ -45,6 +45,10 @@ void MmInitGdt(void)
|
||||||
gdt[1].access = 0x98;
|
gdt[1].access = 0x98;
|
||||||
gdt[1].flags = 0x20;
|
gdt[1].flags = 0x20;
|
||||||
|
|
||||||
|
gdt[2].lowLimit = 0xFFFF;
|
||||||
|
gdt[2].access = 0x98;
|
||||||
|
gdt[2].flags = 0x20;
|
||||||
|
|
||||||
tssDesc.access = 0x89;
|
tssDesc.access = 0x89;
|
||||||
tssDesc.flags = 0x40;
|
tssDesc.flags = 0x40;
|
||||||
tssDesc.lowBase = (ulong)&tss & 0xFFFF;
|
tssDesc.lowBase = (ulong)&tss & 0xFFFF;
|
||||||
|
|
|
@ -142,7 +142,8 @@ void *MmTranslateKPageToAddr(void *rank)
|
||||||
static void PagingHandler(ISRFrame_t *regs)
|
static void PagingHandler(ISRFrame_t *regs)
|
||||||
{
|
{
|
||||||
ulong StackGuardOne = (ulong)MmGetStackGuards(0);
|
ulong StackGuardOne = (ulong)MmGetStackGuards(0);
|
||||||
if (regs->cr2 >= StackGuardOne && (regs->rsp + 4*KB >= regs->cr2)) {
|
ulong StackGuardTwo = (ulong)MmGetStackGuards(1);
|
||||||
|
if ((regs->cr2 >= StackGuardOne) && (regs->cr2 <= StackGuardOne + 4*KB) && (regs->rsp <= regs->cr2)) {
|
||||||
bprintf(BStdOut,
|
bprintf(BStdOut,
|
||||||
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Underflow\n\n"
|
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Underflow\n\n"
|
||||||
" Double Fault Error code : %#x (%b)\n"
|
" Double Fault Error code : %#x (%b)\n"
|
||||||
|
@ -153,6 +154,17 @@ static void PagingHandler(ISRFrame_t *regs)
|
||||||
regs->ErrorCode,
|
regs->ErrorCode,
|
||||||
StackGuardOne
|
StackGuardOne
|
||||||
);
|
);
|
||||||
|
} else if ((regs->cr2 >= StackGuardTwo) && (regs->cr2 <= StackGuardTwo + 4*KB) && (regs->rsp >= regs->cr2)) {
|
||||||
|
bprintf(BStdOut,
|
||||||
|
"\n\n%CPANIC\n[ISR 0x8] Irrecoverable Kernel Stack Overflow\n\n"
|
||||||
|
" Double Fault Error code : %#x (%b)\n"
|
||||||
|
" Stack Guard bypassed : %#x",
|
||||||
|
|
||||||
|
VGA_COLOR_LIGHT_RED,
|
||||||
|
regs->ErrorCode,
|
||||||
|
regs->ErrorCode,
|
||||||
|
StackGuardTwo
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
//XXX page fault
|
//XXX page fault
|
||||||
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
|
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
|
||||||
|
|
Loading…
Reference in New Issue