forked from rcore-os/zCore
Vmar.InvalidArgsTest related fixes
This commit is contained in:
parent
3e3b86c646
commit
bf26f0cf59
|
@ -287,6 +287,9 @@ impl VmAddressRegion {
|
|||
/// address space. If the requested range overlaps with a subregion,
|
||||
/// protect() will fail.
|
||||
pub fn protect(&self, addr: usize, len: usize, flags: MMUFlags) -> ZxResult {
|
||||
if !page_aligned(addr) || !page_aligned(len) {
|
||||
return Err(ZxError::INVALID_ARGS);
|
||||
}
|
||||
let mut guard = self.inner.lock();
|
||||
let inner = guard.as_mut().ok_or(ZxError::BAD_STATE)?;
|
||||
let end_addr = addr + len;
|
||||
|
|
|
@ -63,7 +63,7 @@ impl Syscall<'_> {
|
|||
|
||||
let size = roundup_pages(size as usize);
|
||||
// check `size`
|
||||
if size == 0usize {
|
||||
if size == 0 {
|
||||
return Err(ZxError::INVALID_ARGS);
|
||||
}
|
||||
let child = parent.allocate(offset, size, vmar_flags, align)?;
|
||||
|
@ -129,9 +129,19 @@ impl Syscall<'_> {
|
|||
"mmuflags: {:?}, is_specific {:?}",
|
||||
mapping_flags, is_specific
|
||||
);
|
||||
let len = pages(len) * PAGE_SIZE;
|
||||
let overwrite = options.contains(VmOptions::SPECIFIC_OVERWRITE);
|
||||
let map_range = options.contains(VmOptions::MAP_RANGE);
|
||||
if map_range && overwrite {
|
||||
return Err(ZxError::INVALID_ARGS);
|
||||
}
|
||||
// Note: we should reject non-page-aligned length here,
|
||||
// but since zCore use different memory layout from zircon,
|
||||
// we should not reject them and round up them instead
|
||||
// TODO: reject non-page-aligned length after we have the same memory layout with zircon
|
||||
let len = roundup_pages(len);
|
||||
if len == 0 {
|
||||
return Err(ZxError::INVALID_ARGS);
|
||||
}
|
||||
let vaddr = if is_specific {
|
||||
vmar.map_at_ext(
|
||||
vmar_offset,
|
||||
|
|
Loading…
Reference in New Issue