1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 00:16:17 +04:00

Enable write protect bit to improve safety

This commit is contained in:
Philipp Oppermann 2017-04-18 12:33:53 +02:00
parent ffaddeb84e
commit 2a3ce863fd

View File

@ -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"]