Fix GPF from wrong TSS selector
All checks were successful
Continuous Integration / Check (push) Successful in 41s
Continuous Integration / Clippy (push) Successful in 40s

This commit is contained in:
August 2026-07-05 15:34:12 +00:00
parent f9fd19b6d0
commit 749a0d6bec
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
3 changed files with 6 additions and 11 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/build /build
.idea .idea
/log /log
a.out

View File

@ -78,7 +78,6 @@ lazy_static! {
// DO NOT REORDER // DO NOT REORDER
let sel_tss = gdt.append( let sel_tss = gdt.append(
Descriptor::tss_segment(&TSS).set_flags(DescriptorFlags::from_bits_retain(0b1010)) Descriptor::tss_segment(&TSS).set_flags(DescriptorFlags::from_bits_retain(0b1010))
.set_access(0b10001011), // This would set the TSS to Busy, but it causes a GPF.
); );
Selectors { Selectors {
sel_kernel_code: sel_k_cs, sel_kernel_code: sel_k_cs,

View File

@ -2,15 +2,10 @@ use x86_64::{VirtAddr, registers::rflags::RFlags, structures::idt::InterruptStac
use crate::{ use crate::{
arch::{ arch::{
asm::ltr, asm::ltr, x86_64::{
x86_64::{ gdt::SELECTORS, interrupts::IDT,
gdt::{SELECTORS, dump_gdt},
interrupts::IDT,
}, },
}, }, log::{LOGGER, LogLevel}, log_info, memory::alloc::format,
log::{LOGGER, LogLevel},
log_info,
memory::alloc::format,
}; };
pub fn init() -> Result<(), ()> { pub fn init() -> Result<(), ()> {
@ -27,8 +22,8 @@ pub fn init() -> Result<(), ()> {
SELECTORS.sel_kernel_stack, SELECTORS.sel_kernel_stack,
) )
.expect("Segment order in GDT is bad"); .expect("Segment order in GDT is bad");
dump_gdt(); //ltr(SELECTORS.sel_tss.index()) // THIS WILL CAUSE A GPF, YOU STUPID WHORE
ltr(SELECTORS.sel_tss.index()); ltr(SELECTORS.sel_tss.0);
Ok(()) Ok(())
} }