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:
parent
ffaddeb84e
commit
2a3ce863fd
@ -46,6 +46,7 @@ pub extern fn rust_main(multiboot_information_address: usize) {
|
|||||||
multiboot_end, memory_map_tag.memory_areas());
|
multiboot_end, memory_map_tag.memory_areas());
|
||||||
|
|
||||||
enable_nxe_bit();
|
enable_nxe_bit();
|
||||||
|
enable_write_protect_bit();
|
||||||
memory::remap_the_kernel(&mut frame_allocator, boot_info);
|
memory::remap_the_kernel(&mut frame_allocator, boot_info);
|
||||||
println!("It did not crash!");
|
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 = "eh_personality"] extern fn eh_personality() {}
|
||||||
|
|
||||||
#[lang = "panic_fmt"]
|
#[lang = "panic_fmt"]
|
||||||
|
Loading…
Reference in New Issue
Block a user