[PATCH v4 3/5] target/sparc: Remove dubious swapping in LD_code() helper

Philippe Mathieu-Daudé posted 5 patches 5 days, 18 hours ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH v4 3/5] target/sparc: Remove dubious swapping in LD_code() helper
Posted by Philippe Mathieu-Daudé 5 days, 18 hours ago
Since the endianness is contained in %oi, cpu_ld*_code_mmu() has
already honored it. Swapping again makes no sense. Remove the
bswap() calls.

Fixes: 2786a3f8d3a ("Use GET_ASI_CODE for ASI_KERNELTXT / ASI_USERTXT")
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sparc/ldst_helper.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index e1178e53d51..10746b3c0f1 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -1166,21 +1166,12 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)
         break;
     case MO_16:
         ret = cpu_ldw_code_mmu(env, addr, oi, ra);
-        if ((mop & MO_BSWAP) != MO_TE) {
-            ret = bswap16(ret);
-        }
         break;
     case MO_32:
         ret = cpu_ldl_code_mmu(env, addr, oi, ra);
-        if ((mop & MO_BSWAP) != MO_TE) {
-            ret = bswap32(ret);
-        }
         break;
     case MO_64:
         ret = cpu_ldq_code_mmu(env, addr, oi, ra);
-        if ((mop & MO_BSWAP) != MO_TE) {
-            ret = bswap64(ret);
-        }
         break;
     default:
         g_assert_not_reached();
-- 
2.52.0


Re: [PATCH v4 3/5] target/sparc: Remove dubious swapping in LD_code() helper
Posted by Richard Henderson 5 days, 15 hours ago
On 2/4/26 09:00, Philippe Mathieu-Daudé wrote:
> Since the endianness is contained in %oi, cpu_ld*_code_mmu() has
> already honored it. Swapping again makes no sense. Remove the
> bswap() calls.
> 
> Fixes: 2786a3f8d3a ("Use GET_ASI_CODE for ASI_KERNELTXT / ASI_USERTXT")
> Reported-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/sparc/ldst_helper.c | 9 ---------
>   1 file changed, 9 deletions(-)

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

r~

> 
> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
> index e1178e53d51..10746b3c0f1 100644
> --- a/target/sparc/ldst_helper.c
> +++ b/target/sparc/ldst_helper.c
> @@ -1166,21 +1166,12 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)
>           break;
>       case MO_16:
>           ret = cpu_ldw_code_mmu(env, addr, oi, ra);
> -        if ((mop & MO_BSWAP) != MO_TE) {
> -            ret = bswap16(ret);
> -        }
>           break;
>       case MO_32:
>           ret = cpu_ldl_code_mmu(env, addr, oi, ra);
> -        if ((mop & MO_BSWAP) != MO_TE) {
> -            ret = bswap32(ret);
> -        }
>           break;
>       case MO_64:
>           ret = cpu_ldq_code_mmu(env, addr, oi, ra);
> -        if ((mop & MO_BSWAP) != MO_TE) {
> -            ret = bswap64(ret);
> -        }
>           break;
>       default:
>           g_assert_not_reached();