mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Fix sys_mprotect with page alignment, dynamic loading seems working
This commit is contained in:
parent
d285adf277
commit
08ba9261aa
@ -72,7 +72,7 @@ impl MemoryArea {
|
||||
.map(|s| String::from(s))
|
||||
}
|
||||
/// Test whether this area is (page) overlap with area [`start_addr`, `end_addr`]
|
||||
fn is_overlap_with(&self, start_addr: VirtAddr, end_addr: VirtAddr) -> bool {
|
||||
pub fn is_overlap_with(&self, start_addr: VirtAddr, end_addr: VirtAddr) -> bool {
|
||||
let p0 = Page::of_addr(self.start_addr);
|
||||
let p1 = Page::of_addr(self.end_addr - 1) + 1;
|
||||
let p2 = Page::of_addr(start_addr);
|
||||
|
@ -84,7 +84,7 @@ pub fn sys_mprotect(addr: usize, len: usize, prot: usize) -> SysResult {
|
||||
|
||||
// FIXME: properly set the attribute of the area
|
||||
// now some mut ptr check is fault
|
||||
let memory_area = proc.vm.iter().find(|area| area.contains(addr));
|
||||
let memory_area = proc.vm.iter().find(|area| area.is_overlap_with(addr, addr + len));
|
||||
if memory_area.is_none() {
|
||||
return Err(SysError::ENOMEM);
|
||||
}
|
||||
|
2
user
2
user
@ -1 +1 @@
|
||||
Subproject commit 4bcc820a8b316c177cc5d82ee5edbbe0ac551814
|
||||
Subproject commit 835568e2059ef872320e41517e826ced0768e357
|
Loading…
Reference in New Issue
Block a user