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

Fix sys_mprotect with page alignment, dynamic loading seems working

This commit is contained in:
Jiajie Chen 2019-03-23 00:46:32 +08:00
parent d285adf277
commit 08ba9261aa
3 changed files with 3 additions and 3 deletions

View File

@ -72,7 +72,7 @@ impl MemoryArea {
.map(|s| String::from(s)) .map(|s| String::from(s))
} }
/// Test whether this area is (page) overlap with area [`start_addr`, `end_addr`] /// 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 p0 = Page::of_addr(self.start_addr);
let p1 = Page::of_addr(self.end_addr - 1) + 1; let p1 = Page::of_addr(self.end_addr - 1) + 1;
let p2 = Page::of_addr(start_addr); let p2 = Page::of_addr(start_addr);

View File

@ -84,7 +84,7 @@ pub fn sys_mprotect(addr: usize, len: usize, prot: usize) -> SysResult {
// FIXME: properly set the attribute of the area // FIXME: properly set the attribute of the area
// now some mut ptr check is fault // 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() { if memory_area.is_none() {
return Err(SysError::ENOMEM); return Err(SysError::ENOMEM);
} }

2
user

@ -1 +1 @@
Subproject commit 4bcc820a8b316c177cc5d82ee5edbbe0ac551814 Subproject commit 835568e2059ef872320e41517e826ced0768e357