[PATCH 5/8] target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper

Philippe Mathieu-Daudé posted 8 patches 1 month, 2 weeks ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Farhan Ali <alifm@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Matthew Rosato <mjrosato@linux.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>
[PATCH 5/8] target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
In preparation of removing the cpu_lduw_code() and cpu_ldl_code()
wrappers, inline them.

Since S390x instructions are always stored in big-endian order,
replace MO_TE -> MO_BE.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/s390x/tcg/mem_helper.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 507eb7feac7..ce9ced8275f 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -2430,15 +2430,18 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t r1, uint64_t addr)
 */
 void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
 {
+    CPUState *cs = env_cpu(env);
     uint64_t insn;
     uint8_t opc;
+    MemOpIdx oi;
 
     /* EXECUTE targets must be at even addresses.  */
     if (addr & 1) {
         tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC());
     }
 
-    insn = cpu_lduw_code(env, addr);
+    oi = make_memop_idx(MO_BEUW, cpu_mmu_index(cs, true));
+    insn = cpu_ldw_code_mmu(env, addr, oi, 0);
     opc = insn >> 8;
 
     /* Or in the contents of R1[56:63].  */
@@ -2450,10 +2453,11 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
     case 2:
         break;
     case 4:
-        insn |= (uint64_t)cpu_lduw_code(env, addr + 2) << 32;
+        insn |= (uint64_t)cpu_ldw_code_mmu(env, addr + 2, oi, 0) << 32;
         break;
     case 6:
-        insn |= (uint64_t)(uint32_t)cpu_ldl_code(env, addr + 2) << 16;
+        oi = make_memop_idx(MO_BEUL, cpu_mmu_index(cs, true));
+        insn |= (uint64_t)(uint32_t)cpu_ldl_code_mmu(env, addr + 2, oi, 0) << 16;
         break;
     default:
         g_assert_not_reached();
-- 
2.52.0


Re: [PATCH 5/8] target/s390x: Inline cpu_ld{uw, l}_code() calls in EX opcode helper
Posted by Manos Pitsidianakis 1 month, 1 week ago
On Wed, Dec 24, 2025 at 6:21 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> In preparation of removing the cpu_lduw_code() and cpu_ldl_code()
> wrappers, inline them.
>
> Since S390x instructions are always stored in big-endian order,
> replace MO_TE -> MO_BE.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>



>  target/s390x/tcg/mem_helper.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
> index 507eb7feac7..ce9ced8275f 100644
> --- a/target/s390x/tcg/mem_helper.c
> +++ b/target/s390x/tcg/mem_helper.c
> @@ -2430,15 +2430,18 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t r1, uint64_t addr)
>  */
>  void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
>  {
> +    CPUState *cs = env_cpu(env);
>      uint64_t insn;
>      uint8_t opc;
> +    MemOpIdx oi;
>
>      /* EXECUTE targets must be at even addresses.  */
>      if (addr & 1) {
>          tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC());
>      }
>
> -    insn = cpu_lduw_code(env, addr);
> +    oi = make_memop_idx(MO_BEUW, cpu_mmu_index(cs, true));
> +    insn = cpu_ldw_code_mmu(env, addr, oi, 0);
>      opc = insn >> 8;
>
>      /* Or in the contents of R1[56:63].  */
> @@ -2450,10 +2453,11 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
>      case 2:
>          break;
>      case 4:
> -        insn |= (uint64_t)cpu_lduw_code(env, addr + 2) << 32;
> +        insn |= (uint64_t)cpu_ldw_code_mmu(env, addr + 2, oi, 0) << 32;
>          break;
>      case 6:
> -        insn |= (uint64_t)(uint32_t)cpu_ldl_code(env, addr + 2) << 16;
> +        oi = make_memop_idx(MO_BEUL, cpu_mmu_index(cs, true));
> +        insn |= (uint64_t)(uint32_t)cpu_ldl_code_mmu(env, addr + 2, oi, 0) << 16;
>          break;
>      default:
>          g_assert_not_reached();
> --
> 2.52.0
>