qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 8/9] bsd-user/mmap.c: Implement MAP_EXCL, required by jema


From: Richard Henderson
Subject: Re: [PATCH v2 8/9] bsd-user/mmap.c: Implement MAP_EXCL, required by jemalloc in head
Date: Thu, 23 Sep 2021 10:52:50 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

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.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]