Mess with Userboot loading
Some checks failed
Continuous Integration / Check (push) Failing after 1m1s
Continuous Integration / Clippy (push) Failing after 59s

This commit is contained in:
August 2026-11-10 04:41:08 +00:00
parent 5e0075abc2
commit 2e626a33d1
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
3 changed files with 25 additions and 1 deletions

View File

@ -72,3 +72,18 @@ For page type capabilities, we can do something similar, except we use all 12
low bits for access rights. Keeping all capability types the same size allows
for convenient storage of capabilities in an array, as enum variants with
associated types. Boom!!!
Userboot will regrettably need to be moved to a different crate altogether, so
it might be wise to turn this repo back into a workspace. This is because the
same `build.rs` file gets used for both Userboot and the kernel, which causes
Userboot to be linked as a static, non-relocatable executable, to be loaded at
`0xffffffff80000000`. We cannot remap this address range, because it belongs to
the kernel, which must be loaded at all times to allow for interrupt handling.
There are a few ways I could fix this:
- Compile and link Userboot as a relocatable ELF, which necessitates adding an
ELF parser+loader to the kernel. I dislike this option.
- Compile and link Userboot with a different load address, which I can remap
via paging. By compiling the binary with a load address of `0x1000`, it would
be possible to map it to a clean address space that does not collide with the
kernel. Loading at `0x0` is impossible due to nullptr detection.

View File

@ -40,3 +40,11 @@ pub fn str() -> u16 {
}
result
}
pub fn halt() {
unsafe {
asm!(
"hlt"
)
}
}

View File

@ -61,10 +61,11 @@ unsafe extern "C" fn main() -> ! {
{
let ub = modules_list.modules()[0];
log_info!("Found userboot: {} {}", ub.path(), ub.cmdline());
// TODO: remap userboot as user pages
// TODO: remap userboot as user pages, map writable memory to stack
let start_addr = VirtAddr::from_ptr(ub.data() as *const [u8]);
log_trace!("Userboot start address: 0x{:x}", start_addr);
//arch::asm::halt(); // Uncomment this to examine behavior prior to usermode jump
arch::startup::jump_to_usermode(VirtAddr::new(0xffffffff80000000), start_addr)
} else {
panic!("Userboot not found, cannot boot!");