diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index d00cda1de7..e600cf2060 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -48,8 +48,8 @@ pub struct KernelArgs { bootstrap_base: usize, /// Size of contiguous bootstrap/initfs physical region, not necessarily page aligned. bootstrap_size: usize, - /// Entry point the kernel will jump to. - bootstrap_entry: usize, + /// Entry point the kernel will jump to. (deprecated) + _bootstrap_entry: usize, } /// The entry to Rust, all things must be initialized @@ -125,7 +125,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { { args.bootstrap_base }, args.bootstrap_base + args.bootstrap_size ); - info!("Bootstrap entry point: {:X}", { args.bootstrap_entry }); // Setup interrupt handlers core::arch::asm!( @@ -202,7 +201,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { args.bootstrap_base, )), page_count: args.bootstrap_size / crate::memory::PAGE_SIZE, - entry: args.bootstrap_entry, env, } }; diff --git a/src/arch/x86/start.rs b/src/arch/x86/start.rs index 6cfbcf8316..01a8f9466a 100644 --- a/src/arch/x86/start.rs +++ b/src/arch/x86/start.rs @@ -60,8 +60,8 @@ pub struct KernelArgs { bootstrap_base: u64, /// Size of contiguous bootstrap/initfs physical region, not necessarily page aligned. bootstrap_size: u64, - /// Entry point the kernel will jump to. - bootstrap_entry: u64, + /// Entry point the kernel will jump to. (deprecated) + _bootstrap_entry: u64, } /// The entry to Rust, all things must be initialized @@ -135,7 +135,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { { args.bootstrap_base }, { args.bootstrap_base } + { args.bootstrap_size } ); - info!("Bootstrap entry point: {:X}", { args.bootstrap_entry }); // Set up GDT before paging gdt::init(); @@ -224,7 +223,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { args.bootstrap_base as usize, )), page_count: (args.bootstrap_size as usize) / crate::memory::PAGE_SIZE, - entry: args.bootstrap_entry as usize, env, } }; diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index e6860d162c..d127f51ce5 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -60,8 +60,8 @@ pub struct KernelArgs { bootstrap_base: u64, /// Size of contiguous bootstrap/initfs physical region, not necessarily page aligned. bootstrap_size: u64, - /// Entry point the kernel will jump to. - bootstrap_entry: u64, + /// Entry point the kernel will jump to. (deprecated) + _bootstrap_entry: u64, } /// The entry to Rust, all things must be initialized @@ -135,7 +135,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { { args.bootstrap_base }, { args.bootstrap_base } + { args.bootstrap_size } ); - info!("Bootstrap entry point: {:X}", { args.bootstrap_entry }); // Set up GDT before paging gdt::init(); @@ -233,7 +232,6 @@ pub unsafe extern "C" fn kstart(args_ptr: *const KernelArgs) -> ! { args.bootstrap_base as usize, )), page_count: (args.bootstrap_size as usize) / crate::memory::PAGE_SIZE, - entry: args.bootstrap_entry as usize, env, } }; diff --git a/src/main.rs b/src/main.rs index 6e870f5beb..f6656cc1f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -172,7 +172,6 @@ extern "C" fn userspace_init() { struct Bootstrap { base: crate::memory::Frame, page_count: usize, - entry: usize, env: &'static [u8], } static BOOTSTRAP: spin::Once = spin::Once::new(); diff --git a/src/syscall/process.rs b/src/syscall/process.rs index e96ad2f27d..236c8b4ad8 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -594,13 +594,18 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap) -> ! { } // TODO: Not all arches do linear mapping + let bootstrap_slice = unsafe { bootstrap_mem(bootstrap) }; UserSliceWo::new(PAGE_SIZE, bootstrap.page_count * PAGE_SIZE) .expect("failed to create bootstrap user slice") - .copy_from_slice(unsafe { bootstrap_mem(bootstrap) }) + .copy_from_slice(bootstrap_slice) .expect("failed to copy memory to bootstrap"); + let bootstrap_entry = u64::from_le_bytes(bootstrap_slice[0x1a..0x22].try_into().unwrap()); + log::info!("Bootstrap entry point: {:X}", bootstrap_entry); + assert_ne!(bootstrap_entry, 0); + // Start in a minimal environment without any stack. - usermode(bootstrap.entry, 0, 0, 0); + usermode(bootstrap_entry.try_into().unwrap(), 0, 0, 0); } pub unsafe fn bootstrap_mem(bootstrap: &crate::Bootstrap) -> &'static [u8] {