From 3ba1b018b7dd9655e14b4da0b2d262aa033d1c7c Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 3 Aug 2022 11:08:18 -0600 Subject: [PATCH] Warn but otherwise allow unaligned sizes in funmap --- src/syscall/fs.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/syscall/fs.rs b/src/syscall/fs.rs index 353eab5..42ec136 100644 --- a/src/syscall/fs.rs +++ b/src/syscall/fs.rs @@ -5,6 +5,7 @@ use spin::RwLock; use crate::context::file::{FileDescriptor, FileDescription}; use crate::context; +use crate::memory::PAGE_SIZE; use crate::scheme::{self, FileHandle}; use crate::syscall::data::{Packet, Stat}; use crate::syscall::error::*; @@ -465,7 +466,12 @@ pub fn fstat(fd: FileHandle, stat: &mut Stat) -> Result { } pub fn funmap(virtual_address: usize, length: usize) -> Result { - let (page, page_count) = crate::syscall::validate::validate_region(virtual_address, length)?; + let length_aligned = ((length + (PAGE_SIZE - 1))/PAGE_SIZE) * PAGE_SIZE; + if length != length_aligned { + log::warn!("funmap passed length {:#x} instead of {:#x}", length, length_aligned); + } + + let (page, page_count) = crate::syscall::validate::validate_region(virtual_address, length_aligned)?; let addr_space = Arc::clone(context::current()?.read().addr_space()?); addr_space.write().munmap(page, page_count);