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: Warner Losh
Subject: Re: [PATCH v2 8/9] bsd-user/mmap.c: Implement MAP_EXCL, required by jemalloc in head
Date: Sun, 26 Sep 2021 12:38:08 -0600



On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <richard.henderson@linaro.org> wrote:
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 

reply via email to

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