Update files

This commit is contained in:
Alex 2022-11-18 06:46:43 +02:00
parent 1a6665fd67
commit fa921fe626
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 47 additions and 3 deletions

View File

@ -37,7 +37,15 @@ namespace InterruptDescriptorTable
extern "C" __attribute__((naked, used, no_stack_protector)) void ExceptionHandlerStub()
{
asm("cld\n" // clear direction flag
asm(
// "cmp $0x1000, %rsp\n" // Just in case the stack is corrupted
// "jng .skip_swap_check_1\n" /* if is not greater than */
// "cmpw $0x8, 0x8(%rsp)\n"
// "je .skip_swap_check_1\n"
// "swapgs\n"
// ".skip_swap_check_1:\n"
"cld\n" // clear direction flag
// push all registers
"pushq %rax\n"
@ -77,12 +85,31 @@ namespace InterruptDescriptorTable
"popq %rax\n"
"addq $16, %rsp\n"
// "cmp $0x1000, %rsp\n"
// "jng .skip_swap_check_2\n"
// "cmpw $0x8, 0x8(%rsp)\n"
// "je .skip_swap_check_2\n"
// "swapgs\n"
// ".skip_swap_check_2:\n"
"iretq"); // pop CS RIP RFLAGS SS ESP
}
extern "C" void WarnSwapgs() { warn("swapgs"); }
extern "C" __attribute__((naked, used, no_stack_protector)) void InterruptHandlerStub()
{
asm("cld\n"
asm(
// "cmp $0x1000, %rsp\n"
// "jng .skip_swap_check__1\n"
// "cmpw $0x8, 0x8(%rsp)\n"
// "je .skip_swap_check__1\n"
// "swapgs\n"
// "call WarnSwapgs\n"
// ".skip_swap_check__1:\n"
"cld\n"
"pushq %rax\n"
"pushq %rbx\n"
"pushq %rcx\n"
@ -119,6 +146,15 @@ namespace InterruptDescriptorTable
"popq %rax\n"
"addq $16, %rsp\n"
// "cmp $0x1000, %rsp\n"
// "jng .skip_swap_check__2\n"
// "cmpw $0x8, 0x8(%rsp)\n"
// "je .skip_swap_check__2\n"
// "call WarnSwapgs\n"
// "swapgs\n"
// ".skip_swap_check__2:\n"
"iretq");
}

View File

@ -111,7 +111,15 @@ prepare:
gzip -d Files/ter-powerline-v12n.psf.gz
build: $(KERNEL_FILENAME)
dump:
ifeq (,$(wildcard $(KERNEL_FILENAME)))
$(error $(KERNEL_FILENAME) does not exist)
endif
$(info Dumping $(KERNEL_FILENAME) in AT T syntax...)
$(OBJDUMP) -D -d $(KERNEL_FILENAME) > kernel_dump.map
$(info Dumping $(KERNEL_FILENAME) in Intel syntax...)
$(OBJDUMP) -M intel -D -d $(KERNEL_FILENAME) > kernel_dump_intel.map
$(KERNEL_FILENAME): $(OBJ)
$(CC) $(LDFLAGS) $(OBJ) -o $@
@ -160,4 +168,4 @@ endif
$(NM) $@
clean:
rm -f *.bin *.o *.elf *.sym kernel.map kernel_dump.map initrd.tar.gz $(OBJ) $(KERNEL_FILENAME)
rm -f *.bin *.o *.elf *.sym kernel.map kernel_dump.map kernel_dump_intel.map initrd.tar.gz $(OBJ) $(KERNEL_FILENAME)