diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-27 14:43:31 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-04-27 14:43:31 +0000 |
| commit | 95c299db969b29eb4a4742ff7715adecfe138bd5 (patch) | |
| tree | 037935ce91a8e74d4ea4f8283f9bed807f9ee13f /arch | |
| parent | a8a8e09ed39268839ca838c44489bb1352892fef (diff) | |
| download | teachos-95c299db969b29eb4a4742ff7715adecfe138bd5.tar.xz teachos-95c299db969b29eb4a4742ff7715adecfe138bd5.zip | |
test different values
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/src/context_switching/main.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp index 287ced4..4e13b1c 100644 --- a/arch/x86_64/src/context_switching/main.cpp +++ b/arch/x86_64/src/context_switching/main.cpp @@ -62,7 +62,16 @@ namespace teachos::arch::context_switching uint64_t const syscall_function = reinterpret_cast<uint64_t>(syscall_handler); kernel::cpu::write_msr(IA32_LSTAR_ADDRESS, syscall_function); kernel::cpu::write_msr(IA32_FMASK_ADDRESS, 0U); + + uint64_t kernel_cs = KERNEL_CODE_SEGMENT_SELECTOR; // Your 64-bit kernel code segment selector + uint64_t user_cs = USER_CODE_SEGMENT_SELECTOR + 0x3; // User mode code segment selector (RPL=3) + + uint64_t star_value = (user_cs << 48) | (kernel_cs << 32); + + kernel::cpu::write_msr(IA32_STAR_ADDRESS, star_value); kernel::cpu::write_msr(IA32_STAR_ADDRESS, KERNEL_CODE_SEGMENT_SELECTOR); + + // kernel::cpu::write_msr(IA32_STAR_ADDRESS, KERNEL_CODE_SEGMENT_SELECTOR); kernel::cpu::set_efer_bit(kernel::cpu::efer_flags::SCE); } |
