feat: kernel W^X (per-section perms, firmware unmapped, stack guard, boot check), halt on kernel faults, region W^X across processes
This commit is contained in:
@@ -16,6 +16,26 @@ pub fn init(uart: &Uart) -> &'static mut mmu::PageTable {
|
||||
let kernel_pt = mmu::init_kernel_page_table();
|
||||
mmu::activate(kernel_pt);
|
||||
uart.write_str("k-os: MMU enabled (Sv39)\n");
|
||||
match mmu::check_wx(kernel_pt) {
|
||||
Ok(code_pages) => {
|
||||
uart.write_str("k-os: W^X verified, ");
|
||||
uart.write_dec(code_pages);
|
||||
uart.write_str(" code pages\n");
|
||||
}
|
||||
Err(v) => {
|
||||
let (what, va) = match v {
|
||||
mmu::page_table::WxViolation::WritableCode(va) => ("writable code", va),
|
||||
mmu::page_table::WxViolation::ExecutableData(va) => ("executable data", va),
|
||||
mmu::page_table::WxViolation::MappedHole(va) => ("mapped hole", va),
|
||||
};
|
||||
uart.write_str("k-os: W^X violation: ");
|
||||
uart.write_str(what);
|
||||
uart.write_str(" at ");
|
||||
uart.write_hex(va);
|
||||
uart.put_char(b'\n');
|
||||
crate::halt(uart, "kernel page table violates W^X");
|
||||
}
|
||||
}
|
||||
|
||||
trap::init();
|
||||
crate::hw::timer::init();
|
||||
|
||||
Reference in New Issue
Block a user