diff --git a/build/targets/x86_64.json b/build/targets/x86_64.json index 31872419..cc48fd5b 100644 --- a/build/targets/x86_64.json +++ b/build/targets/x86_64.json @@ -1,22 +1,22 @@ { - "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", - "arch": "x86_64", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "os": "none", - "executables": true, - "linker-flavor": "ld.lld", - "linker": "rust-lld", - "disable-redzone": true, - "panic-strategy": "abort", - "features": "-mmx,-sse,+soft-float", - "code-model": "kernel", - "pre-link-args": { - "ld.lld": [ - "--gc-sections", - "--script=./build/linker-scripts/kernel.ld" - ] - } -} \ No newline at end of file + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "disable-redzone": true, + "panic-strategy": "abort", + "features": "-mmx,-sse,+soft-float", + "code-model": "kernel", + "pre-link-args": { + "ld.lld": [ + "--gc-sections", + "--script=./build/linker-scripts/kernel.ld" + ] + } +} diff --git a/crates/libxernel/src/lib.rs b/crates/libxernel/src/lib.rs index 2b78eeb7..f6e5f3eb 100644 --- a/crates/libxernel/src/lib.rs +++ b/crates/libxernel/src/lib.rs @@ -1,5 +1,4 @@ #![no_std] -#![feature(inline_const)] #![allow(unused)] pub mod boot; diff --git a/rust-toolchain b/rust-toolchain index 5951a259..bf867e0a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2024-01-01 +nightly diff --git a/xernel/kernel/src/arch/amd64/gdt.rs b/xernel/kernel/src/arch/amd64/gdt.rs index e7223e45..5fe46267 100644 --- a/xernel/kernel/src/arch/amd64/gdt.rs +++ b/xernel/kernel/src/arch/amd64/gdt.rs @@ -41,24 +41,24 @@ pub fn init() { let mut tss = TaskStateSegment::new(); tss.interrupt_stack_table[DOUBLE_FAULT_IST_INDEX as usize] = { let stack_start = VirtAddr::from_ptr(unsafe { addr_of!(BSP_IST_STACK) }); - stack_start + IST_STACK_SIZE + stack_start + IST_STACK_SIZE as u64 }; TSS.set_once(tss); let mut gdt = GlobalDescriptorTable::new(); - let code_selector = gdt.add_entry(Descriptor::kernel_code_segment()); - let data_selector = gdt.add_entry(Descriptor::kernel_data_segment()); + let code_selector = gdt.append(Descriptor::kernel_code_segment()); + let data_selector = gdt.append(Descriptor::kernel_data_segment()); // let kernel_data_flags = DescriptorFlags::USER_SEGMENT | DescriptorFlags::PRESENT | DescriptorFlags::WRITABLE; // let data_selector = gdt.add_entry(Descriptor::UserSegment(kernel_data_flags.bits())); // System segment descriptors (which the TSS descriptor is) are 16-bytes and take up 2 slots in the GDT // This results in user code having index 5, user data index 6 - let tss_selector = gdt.add_entry(Descriptor::tss_segment(&TSS)); - let user_data_selector = gdt.add_entry(Descriptor::user_data_segment()); - let user_code_selector = gdt.add_entry(Descriptor::user_code_segment()); + let tss_selector = gdt.append(Descriptor::tss_segment(&TSS)); + let user_data_selector = gdt.append(Descriptor::user_data_segment()); + let user_code_selector = gdt.append(Descriptor::user_code_segment()); GDT_BSP.set_once(( gdt, Selectors { @@ -85,10 +85,10 @@ pub fn init_ap(ap_id: usize) { let mut gdt_ap = GDT_AP.lock(); let gdt: &'static mut GlobalDescriptorTable = Box::leak(Box::new(GlobalDescriptorTable::new())); - let code_selector = gdt.add_entry(Descriptor::kernel_code_segment()); - let data_selector = gdt.add_entry(Descriptor::kernel_data_segment()); - let user_data_selector = gdt.add_entry(Descriptor::user_data_segment()); - let user_code_selector = gdt.add_entry(Descriptor::user_code_segment()); + let code_selector = gdt.append(Descriptor::kernel_code_segment()); + let data_selector = gdt.append(Descriptor::kernel_data_segment()); + let user_data_selector = gdt.append(Descriptor::user_data_segment()); + let user_code_selector = gdt.append(Descriptor::user_code_segment()); let mut boxed_tss = Box::new(TaskStateSegment::new()); @@ -97,7 +97,7 @@ pub fn init_ap(ap_id: usize) { unsafe { VirtAddr::from_ptr(ist0.add(IST_STACK_SIZE)) }; let tss: &'static mut TaskStateSegment = Box::leak(boxed_tss); - let tss_selector = gdt.add_entry(Descriptor::tss_segment(tss)); + let tss_selector = gdt.append(Descriptor::tss_segment(tss)); gdt_ap.push(Gdt { gdt, diff --git a/xernel/kernel/src/cpu.rs b/xernel/kernel/src/cpu.rs index 6b09f3e2..42c8115f 100644 --- a/xernel/kernel/src/cpu.rs +++ b/xernel/kernel/src/cpu.rs @@ -151,7 +151,7 @@ pub fn register_cpu() { })); // use KERNEL_GS_BASE to store the cpu_data - unsafe { wrmsr(KERNEL_GS_BASE, (cpu_data as *const Cpu).expose_addr() as u64) } + unsafe { wrmsr(KERNEL_GS_BASE, (cpu_data as *const Cpu).expose_provenance() as u64) } } pub fn current_cpu() -> Pin<&'static Cpu> { @@ -159,7 +159,7 @@ pub fn current_cpu() -> Pin<&'static Cpu> { panic!("current_cpu called before all cpus registered"); } - unsafe { Pin::new_unchecked(&*core::ptr::from_exposed_addr(rdmsr(KERNEL_GS_BASE) as usize)) } + unsafe { Pin::new_unchecked(&*core::ptr::with_exposed_provenance(rdmsr(KERNEL_GS_BASE) as usize)) } } pub fn current_thread() -> Arc { diff --git a/xernel/kernel/src/main.rs b/xernel/kernel/src/main.rs index c3b25abf..2084109f 100644 --- a/xernel/kernel/src/main.rs +++ b/xernel/kernel/src/main.rs @@ -2,7 +2,6 @@ #![no_main] #![feature(abi_x86_interrupt)] #![feature(naked_functions)] -#![feature(exclusive_range_pattern)] #![feature(let_chains)] #![feature(strict_provenance)] #![feature(exposed_provenance)] diff --git a/xernel/kernel/src/mem/vm.rs b/xernel/kernel/src/mem/vm.rs index 8c8f11cb..44c25dea 100644 --- a/xernel/kernel/src/mem/vm.rs +++ b/xernel/kernel/src/mem/vm.rs @@ -23,7 +23,7 @@ pub struct VmEntry { impl VmEntry { pub fn end(&self) -> VirtAddr { - self.start + self.length + self.start + self.length as u64 } pub fn unmap(&self) { @@ -72,8 +72,8 @@ impl Vm { pub fn is_available(&self, start: VirtAddr, length: usize) -> bool { !self.entries.iter().any(|(_, entry)| { entry.start < start && entry.end() + Size4KiB::SIZE > start - || start + length + Size4KiB::SIZE > entry.start - && (start + length + Size4KiB::SIZE).as_u64() < Size4KiB::SIZE + || start + length as u64 + Size4KiB::SIZE > entry.start + && (start + length as u64 + Size4KiB::SIZE).as_u64() < Size4KiB::SIZE }) }