mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Debug messages
This commit is contained in:
parent
aeb175f03b
commit
207eb77160
@ -115,6 +115,7 @@ namespace GlobalDescriptorTable
|
||||
: "memory", "rax");
|
||||
|
||||
CPUStackPointer[Core] = KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE));
|
||||
debug("CPU %d Stack Pointer: %#lx", Core, CPUStackPointer[Core]);
|
||||
|
||||
uint64_t Base = (uint64_t)&tss[Core];
|
||||
uint64_t Limit = Base + sizeof(TaskStateSegment);
|
||||
@ -136,12 +137,12 @@ namespace GlobalDescriptorTable
|
||||
asmv("mov %%rsp, %0"
|
||||
: "=r"(tss[Core].StackPointer[0]));
|
||||
|
||||
trace("GDT_KERNEL_CODE: %#lx", GDT_KERNEL_CODE);
|
||||
trace("GDT_KERNEL_DATA: %#lx", GDT_KERNEL_DATA);
|
||||
trace("GDT_USER_CODE: %#lx", GDT_USER_CODE);
|
||||
trace("GDT_USER_DATA: %#lx", GDT_USER_DATA);
|
||||
trace("GDT_TSS: %#lx", GDT_TSS);
|
||||
trace("Global Descriptor Table initialized");
|
||||
debug("GDT_KERNEL_CODE: %#lx", GDT_KERNEL_CODE);
|
||||
debug("GDT_KERNEL_DATA: %#lx", GDT_KERNEL_DATA);
|
||||
debug("GDT_USER_CODE: %#lx", GDT_USER_CODE);
|
||||
debug("GDT_USER_DATA: %#lx", GDT_USER_DATA);
|
||||
debug("GDT_TSS: %#lx", GDT_TSS);
|
||||
debug("Global Descriptor Table initialized");
|
||||
}
|
||||
|
||||
SafeFunction void SetKernelStack(void *Stack)
|
||||
|
@ -42,12 +42,19 @@ EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fai
|
||||
error("Stack smashing detected!");
|
||||
debug("Current stack check guard value: %#lx", __stack_chk_guard);
|
||||
KPrint("\eFF0000Stack smashing detected!");
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
void *Stack = nullptr;
|
||||
asmv("movq %%rsp, %0"
|
||||
: "=r"(Stack));
|
||||
error("Stack address: %#lx", Stack);
|
||||
|
||||
while (1)
|
||||
asmv("cli; hlt");
|
||||
#elif defined(__aarch64__)
|
||||
asmv("wfe");
|
||||
#endif
|
||||
CPU::Stop();
|
||||
}
|
||||
|
||||
// https://github.com/gcc-mirror/gcc/blob/master/libssp/ssp.c
|
||||
@ -57,6 +64,7 @@ EXTERNC __attribute__((weak, noreturn, no_stack_protector)) void __chk_fail(void
|
||||
for (short i = 0; i < 10; i++)
|
||||
error("Buffer overflow detected!");
|
||||
KPrint("\eFF0000Buffer overflow detected!");
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
while (1)
|
||||
asmv("cli; hlt");
|
||||
|
Loading…
x
Reference in New Issue
Block a user