On 9/21/21 9:56 PM, Warner Losh wrote:
> + /* Reject the mapping if any page within the range is mapped */
> + if (flags & MAP_EXCL) {
> + for (addr = start; addr < end; addr++) {
> + if (page_get_flags(addr) != 0)
> + goto fail;
> + }
> + }
How about
if ((flags & MAP_EXCL) &&
page_check_range(start, len, 0) < 0) {
goto fail;
}
Hmm. This (and your page_get_flags check) could assert due to out-of-range guest address.
You're currently attempting that,
/*
* Test if requested memory area fits target address space
* It can fail only on 64-bit host with 32-bit target.
* On any other target/host host mmap() handles this error correctly.
*/
#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
if ((unsigned long)start + len - 1 > (abi_ulong) -1) {
errno = EINVAL;
goto fail;
}
#endif
but the test isn't correct. Note that reserved_va may be applied to 64-bit guests, and
certainly may be smaller than (abi_ulong)-1.
You want guest_range_valid_untagged here.
Great! Thanks for the tip!
Warner