[PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base

Richard Henderson posted 33 patches 10 months, 4 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Laurent Vivier <laurent@vivier.eu>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, "Alex Bennée" <alex.bennee@linaro.org>, Yoshinori Sato <ysato@users.sourceforge.jp>
There is a newer version of this series
[PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base
Posted by Richard Henderson 10 months, 4 weeks ago
The host SHMLBA is by definition a multiple of the host page size.
Thus the remaining component of qemu_host_page_size is the
target page size.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/elfload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index f3c1e0fb64..4df565d64b 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2892,7 +2892,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr,
 
     /* Add any HI_COMMPAGE not covered by reserved_va. */
     if (reserved_va < HI_COMMPAGE) {
-        ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask;
+        ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size();
         ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1;
         n++;
     }
@@ -3074,7 +3074,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
                       abi_ulong guest_hiaddr)
 {
     /* In order to use host shmat, we must be able to honor SHMLBA.  */
-    uintptr_t align = MAX(SHMLBA, qemu_host_page_size);
+    uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE);
 
     /* Sanity check the guest binary. */
     if (reserved_va) {
-- 
2.34.1
Re: [PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base
Posted by Ilya Leoshkevich 10 months ago
On Tue, Jan 02, 2024 at 12:57:38PM +1100, Richard Henderson wrote:
> The host SHMLBA is by definition a multiple of the host page size.
> Thus the remaining component of qemu_host_page_size is the
> target page size.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/elfload.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index f3c1e0fb64..4df565d64b 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -2892,7 +2892,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr,
>  
>      /* Add any HI_COMMPAGE not covered by reserved_va. */
>      if (reserved_va < HI_COMMPAGE) {
> -        ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask;
> +        ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size();

Nit: qemu_real_host_page_mask() might be a bit more readable.

>          ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1;
>          n++;
>      }
> @@ -3074,7 +3074,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
>                        abi_ulong guest_hiaddr)
>  {
>      /* In order to use host shmat, we must be able to honor SHMLBA.  */
> -    uintptr_t align = MAX(SHMLBA, qemu_host_page_size);
> +    uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE);
>  
>      /* Sanity check the guest binary. */
>      if (reserved_va) {
> -- 
> 2.34.1

Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Re: [PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base
Posted by Pierrick Bouvier 10 months, 3 weeks ago
On 1/2/24 05:57, Richard Henderson wrote:
> The host SHMLBA is by definition a multiple of the host page size.
> Thus the remaining component of qemu_host_page_size is the
> target page size.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/elfload.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index f3c1e0fb64..4df565d64b 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -2892,7 +2892,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_loaddr,
>   
>       /* Add any HI_COMMPAGE not covered by reserved_va. */
>       if (reserved_va < HI_COMMPAGE) {
> -        ga->bounds[n][0] = HI_COMMPAGE & qemu_host_page_mask;
> +        ga->bounds[n][0] = HI_COMMPAGE & -qemu_real_host_page_size();
>           ga->bounds[n][1] = HI_COMMPAGE + TARGET_PAGE_SIZE - 1;
>           n++;
>       }
> @@ -3074,7 +3074,7 @@ void probe_guest_base(const char *image_name, abi_ulong guest_loaddr,
>                         abi_ulong guest_hiaddr)
>   {
>       /* In order to use host shmat, we must be able to honor SHMLBA.  */
> -    uintptr_t align = MAX(SHMLBA, qemu_host_page_size);
> +    uintptr_t align = MAX(SHMLBA, TARGET_PAGE_SIZE);
>   
>       /* Sanity check the guest binary. */
>       if (reserved_va) {

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>