qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY


From: Ilya Leoshkevich
Subject: Re: [PATCH v3 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY
Date: Tue, 30 Jan 2024 14:47:30 +0100

On Tue, Jan 02, 2024 at 12:58:04PM +1100, Richard Henderson wrote:
> If set, match the host and guest page sizes.
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/main.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

[...]

> @@ -794,6 +796,16 @@ int main(int argc, char **argv, char **envp)
>                                   opt_one_insn_per_tb, &error_abort);
>          ac->init_machine(NULL);
>      }
> +
> +    /*
> +     * Finalize page size before creating CPUs.
> +     * This will do nothing if !TARGET_PAGE_BITS_VARY.
> +     * The most efficient setting is to match the host.
> +     */
> +    host_page_size = qemu_real_host_page_size();
> +    set_preferred_target_page_bits(ctz32(host_page_size));
> +    finalize_target_page_bits();
> +
>      cpu = cpu_create(cpu_type);
>      env = cpu_env(cpu);
>      cpu_reset(cpu);

Not sure if that's an officially blessed use case, but I tried to
increase the alpha page size to 8k by doing

--- a/target/alpha/cpu-param.h
+++ b/target/alpha/cpu-param.h
@@ -20,7 +20,7 @@
  * a 4k minimum to match x86 host, which can minimize emulation issues.
  */
 # define TARGET_PAGE_BITS_VARY
-# define TARGET_PAGE_BITS_MIN 12
+# define TARGET_PAGE_BITS_MIN 13
 # define TARGET_VIRT_ADDR_SPACE_BITS  63
 #else
 # define TARGET_PAGE_BITS 13

and this triggered an assetion in set_preferred_target_page_bits().
I wonder if it would make sense to add something like the following to
this patch?

--- a/page-vary-target.c
+++ b/page-vary-target.c
@@ -26,8 +26,7 @@
 bool set_preferred_target_page_bits(int bits)
 {
 #ifdef TARGET_PAGE_BITS_VARY
-    assert(bits >= TARGET_PAGE_BITS_MIN);
-    return set_preferred_target_page_bits_common(bits);
+    return set_preferred_target_page_bits_common(MAX(TARGET_PAGE_BITS_MIN, 
bits));
 #else
     return true;
 #endif



reply via email to

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