[PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one

Philippe Mathieu-Daudé posted 12 patches 8 months, 2 weeks ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>
[PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one
Posted by Philippe Mathieu-Daudé 8 months, 2 weeks ago
Since we *might* have user emulation with softmmu,
replace the system emulation check by !user emulation one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tcg/sparc64/tcg-target.c.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc
index 176c98740b..56915a913b 100644
--- a/tcg/sparc64/tcg-target.c.inc
+++ b/tcg/sparc64/tcg-target.c.inc
@@ -78,7 +78,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
 #define TCG_REG_T2  TCG_REG_G2
 #define TCG_REG_T3  TCG_REG_O7
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 # define TCG_GUEST_BASE_REG TCG_REG_I5
 #endif
 
@@ -961,7 +961,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
     tcg_out32(s, SAVE | INSN_RD(TCG_REG_O6) | INSN_RS1(TCG_REG_O6) |
               INSN_IMM13(-frame_size));
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
     if (guest_base != 0) {
         tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG,
                          guest_base, true, TCG_REG_T1);
@@ -1075,7 +1075,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
     h->aa.align = MAX(h->aa.align, s_bits);
     a_mask = (1u << h->aa.align) - 1;
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     int mem_index = get_mmuidx(oi);
     int fast_off = tlb_mask_table_ofs(s, mem_index);
     int mask_off = fast_off + offsetof(CPUTLBDescFast, mask);
@@ -1147,7 +1147,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
         tcg_out_bpcc0(s, COND_NE, BPCC_PN | BPCC_ICC, 0);
     }
     h->base = guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0;
-#endif
+#endif /* CONFIG_USER_ONLY */
 
     /* If the guest address must be zero-extended, do in the delay slot.  */
     if (addr_type == TCG_TYPE_I32) {
-- 
2.41.0


Re: [PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one
Posted by Richard Henderson 8 months, 2 weeks ago
On 3/13/24 11:33, Philippe Mathieu-Daudé wrote:
> Since we *might* have user emulation with softmmu,
> replace the system emulation check by !user emulation one.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tcg/sparc64/tcg-target.c.inc | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Having read further, the ultimate goal is worthwhile.
It'll be easy to turn these into runtime tests when we get there.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

Re: [PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one
Posted by Richard Henderson 8 months, 2 weeks ago
On 3/13/24 11:33, Philippe Mathieu-Daudé wrote:
> Since we *might* have user emulation with softmmu,
> replace the system emulation check by !user emulation one.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tcg/sparc64/tcg-target.c.inc | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

This is all really softmmu.

If we ever grow user-only softmmu support, these will have to be runtime tests.  But until 
then the ifdefs are really pointing out softmmu uses.


r~

> 
> diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc
> index 176c98740b..56915a913b 100644
> --- a/tcg/sparc64/tcg-target.c.inc
> +++ b/tcg/sparc64/tcg-target.c.inc
> @@ -78,7 +78,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
>   #define TCG_REG_T2  TCG_REG_G2
>   #define TCG_REG_T3  TCG_REG_O7
>   
> -#ifndef CONFIG_SOFTMMU
> +#ifdef CONFIG_USER_ONLY
>   # define TCG_GUEST_BASE_REG TCG_REG_I5
>   #endif
>   
> @@ -961,7 +961,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
>       tcg_out32(s, SAVE | INSN_RD(TCG_REG_O6) | INSN_RS1(TCG_REG_O6) |
>                 INSN_IMM13(-frame_size));
>   
> -#ifndef CONFIG_SOFTMMU
> +#ifdef CONFIG_USER_ONLY
>       if (guest_base != 0) {
>           tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG,
>                            guest_base, true, TCG_REG_T1);
> @@ -1075,7 +1075,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
>       h->aa.align = MAX(h->aa.align, s_bits);
>       a_mask = (1u << h->aa.align) - 1;
>   
> -#ifdef CONFIG_SOFTMMU
> +#ifndef CONFIG_USER_ONLY
>       int mem_index = get_mmuidx(oi);
>       int fast_off = tlb_mask_table_ofs(s, mem_index);
>       int mask_off = fast_off + offsetof(CPUTLBDescFast, mask);
> @@ -1147,7 +1147,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
>           tcg_out_bpcc0(s, COND_NE, BPCC_PN | BPCC_ICC, 0);
>       }
>       h->base = guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0;
> -#endif
> +#endif /* CONFIG_USER_ONLY */
>   
>       /* If the guest address must be zero-extended, do in the delay slot.  */
>       if (addr_type == TCG_TYPE_I32) {