Enable write protect bit to improve safety

toolchain_update
Philipp Oppermann 8 years ago
parent ffaddeb84e
commit 2a3ce863fd

@ -46,6 +46,7 @@ pub extern fn rust_main(multiboot_information_address: usize) {
multiboot_end, memory_map_tag.memory_areas());
enable_nxe_bit();
enable_write_protect_bit();
memory::remap_the_kernel(&mut frame_allocator, boot_info);
println!("It did not crash!");
@ -62,6 +63,12 @@ fn enable_nxe_bit() {
}
}
fn enable_write_protect_bit() {
use x86_64::registers::control_regs::{cr0, cr0_write, Cr0};
unsafe { cr0_write(cr0() | Cr0::WRITE_PROTECT) };
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"]

Loading…
Cancel
Save