From fd557fb19c4ad25fbcb1368a73fddd91921496fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Tue, 18 Mar 2025 10:48:24 +0000 Subject: Fix invalid bit values in access byte and typo in create_segment_descriptor method --- .../arch/context_switching/descriptor_table/access_byte.hpp | 10 +++++----- .../descriptor_table/global_descriptor_table.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'arch') diff --git a/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp b/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp index bafce8d..646c2ca 100644 --- a/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp +++ b/arch/x86_64/include/arch/context_switching/descriptor_table/access_byte.hpp @@ -44,15 +44,15 @@ namespace teachos::arch::context_switching::descriptor_table TRAP_GATE = 15, ///< The actual type of sytem segment is a trap gate. CODE_OR_DATA_SEGMENT = 1U << 4U, ///< Defines a system segment (if 0) or a code/data segment (if 1). ACCESS_LEVEL_KERNEL = - 0U << 4U, ///< Highest privileged level used by the kernel to allow for full access of resources. + 0U << 5U, ///< Highest privileged level used by the kernel to allow for full access of resources. ACCESS_LEVEL_ADMIN = - 2U << 4U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more + 1U << 5U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more ///< than two privilege levels are required, otherwise using Level 3 and Level 0 is recommended. ACCESS_LEVEL_PRIVILEGED_USER = - 4U << 4U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more + 2U << 5U, ///< Restricts access to own application and thoose of lower privilege. Should only be used if more ///< than two privilege levels are required, otherwise using Level 3 and Level 0 is recommended. - ACCESS_LEVEL_USER = 6U << 4U, ///< Restricts access to only application and their specific memory. - PRESENT = 1U << 3U << 4U, ///< Present bit; Allows an entry to refer to a valid segment. + ACCESS_LEVEL_USER = 3U << 5U, ///< Restricts access to only application and their specific memory. + PRESENT = 1U << 7U, ///< Present bit; Allows an entry to refer to a valid segment. ///< Must be set (1) for any valid segment. }; diff --git a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp index b338d9d..578e264 100644 --- a/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp +++ b/arch/x86_64/src/context_switching/descriptor_table/global_descriptor_table.cpp @@ -19,7 +19,7 @@ namespace teachos::arch::context_switching::descriptor_table } else if (access_level == access_level::USER) { - access_level_bitset = access_byte::ACCESS_LEVEL_USER; + access_level_bitset |= access_byte::ACCESS_LEVEL_USER; } uint8_t gdt_flags_bitset = gdt_flags::GRANULARITY; -- cgit v1.2.3