From 29d9666e0257941f6458933dee9fc1871701dd28 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 25 Jun 2021 22:36:17 +0200 Subject: Kernel: Fix GDT limits The GDT limits are inclusive, so for correctness we should subtract one from the structs' size. --- Kernel/Arch/x86/common/Processor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index 353b811af2..cb84c12ac7 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -1074,7 +1074,7 @@ UNMAP_AFTER_INIT void Processor::gdt_init() Descriptor fs_descriptor {}; fs_descriptor.set_base(VirtualAddress { this }); - fs_descriptor.set_limit(sizeof(Processor)); + fs_descriptor.set_limit(sizeof(Processor) - 1); fs_descriptor.dpl = 0; fs_descriptor.segment_present = 1; fs_descriptor.granularity = 0; @@ -1086,7 +1086,7 @@ UNMAP_AFTER_INIT void Processor::gdt_init() Descriptor tss_descriptor {}; tss_descriptor.set_base(VirtualAddress { &m_tss }); - tss_descriptor.set_limit(sizeof(TSS32)); + tss_descriptor.set_limit(sizeof(TSS32) - 1); tss_descriptor.dpl = 0; tss_descriptor.segment_present = 1; tss_descriptor.granularity = 0; -- cgit v1.2.3