From f29f5e4d35a97d99e5a2feaf13bed6e974fd500f Mon Sep 17 00:00:00 2001 From: WangRunji Date: Thu, 18 Apr 2019 21:29:45 +0800 Subject: [PATCH] fix memory area alignment #41 --- crate/memory/src/memory_set/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crate/memory/src/memory_set/mod.rs b/crate/memory/src/memory_set/mod.rs index 77eddc1..94d8765 100644 --- a/crate/memory/src/memory_set/mod.rs +++ b/crate/memory/src/memory_set/mod.rs @@ -56,7 +56,9 @@ impl MemoryArea { } /// Check the array is within the readable memory fn check_read_array(&self, ptr: *const S, count: usize) -> bool { - ptr as usize >= self.start_addr && unsafe { ptr.add(count) as usize } <= self.end_addr + // page align + ptr as usize >= Page::of_addr(self.start_addr).start_address() + && unsafe { ptr.add(count) as usize } < Page::of_addr(self.end_addr + PAGE_SIZE - 1).start_address() } /// Check the array is within the writable memory fn check_write_array(&self, ptr: *mut S, count: usize) -> bool {