[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] linux-user: Fix shmat emulation by honoring hos
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-devel] [PATCH] linux-user: Fix shmat emulation by honoring host SHMLBA |
Date: |
Tue, 10 Jul 2018 11:47:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
Le 09/07/2018 à 21:15, Richard Henderson a écrit :
> For those hosts with SHMLBA > getpagesize, we don't automatically
> select a guest address that is compatible with the host. We can
> achieve this by boosting the alignment of guest_base and by adding
> an extra alignment argument to mmap_find_vma.
>
> Signed-off-by: Richard Henderson <address@hidden>
> ---
...
> @@ -299,7 +303,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
> if (h2g_valid(ptr + size - 1)) {
> addr = h2g(ptr);
>
> - if ((addr & ~TARGET_PAGE_MASK) == 0) {
> + if ((addr & (align - 1)) == 0) {
so ~TARGET_PAGE_MASK is (align - 1)...
> /* Success. */
> if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) {
> mmap_next_start = addr + size;
> @@ -313,12 +317,12 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
> /* Assume the result that the kernel gave us is the
> first with enough free space, so start again at the
> next higher target page. */
> - addr = TARGET_PAGE_ALIGN(addr);
> + addr = ROUND_UP(addr, align);
> break;
> case 1:
> /* Sometimes the kernel decides to perform the allocation
> at the top end of memory instead. */
> - addr &= TARGET_PAGE_MASK;
> + addr &= align - 1;
and here TARGET_PAGE_MASK is also (align - 1)...
So I think it should be "addr &= -align".
Thanks,
Laurent