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 <[email protected]>
> ---
...
> @@ -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

Reply via email to