[PATCH] target/riscv: Make Zcmt JVT loads endian-aware

Xu Liu posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/02050B1BBB8815BE+20260817083005.2392-1-liuxu@nucleisys.com
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>
target/riscv/tcg/zce_helper.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] target/riscv: Make Zcmt JVT loads endian-aware
Posted by Xu Liu 1 month, 1 week ago
The Zcmt specification says JVT table entries follow the current data
endianness. Support that behavior as described by the specification so
big-endian guests can use JVT tables stored in big-endian form.

Signed-off-by: Xu Liu <liuxu@nucleisys.com>
---
 target/riscv/tcg/zce_helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/riscv/tcg/zce_helper.c b/target/riscv/tcg/zce_helper.c
index 15bf0a99c8a..c6ba4c1a476 100644
--- a/target/riscv/tcg/zce_helper.c
+++ b/target/riscv/tcg/zce_helper.c
@@ -18,12 +18,14 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
+#include "internals.h"
 #include "exec/helper-proto.h"
 #include "accel/tcg/cpu-ldst.h"
 
 target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index)
 {
     unsigned mmu_index = cpu_mmu_index(env_cpu(env), true);
+    MemOp endian = mo_endian_env(env);
     MemOpIdx oi;
 
 #if !defined(CONFIG_USER_ONLY)
@@ -45,11 +47,11 @@ target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index)
     }
 
     if (xlen == 32) {
-        oi = make_memop_idx(MO_LEUL, mmu_index);
+        oi = make_memop_idx(MO_UL | endian, mmu_index);
         t0 = base + (index << 2);
         target = cpu_ldl_code_mmu(env, t0, oi, 0);
     } else {
-        oi = make_memop_idx(MO_LEUQ, mmu_index);
+        oi = make_memop_idx(MO_UQ | endian, mmu_index);
         t0 = base + (index << 3);
         target = cpu_ldq_code_mmu(env, t0, oi, 0);
     }
-- 
2.25.1
Re: [PATCH] target/riscv: Make Zcmt JVT loads endian-aware
Posted by Alistair Francis 1 month, 1 week ago
On Mon, 2026-08-17 at 16:30 +0800, Xu Liu wrote:
> The Zcmt specification says JVT table entries follow the current data
> endianness. Support that behavior as described by the specification
> so
> big-endian guests can use JVT tables stored in big-endian form.
> 
> Signed-off-by: Xu Liu <liuxu@nucleisys.com>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  target/riscv/tcg/zce_helper.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/target/riscv/tcg/zce_helper.c
> b/target/riscv/tcg/zce_helper.c
> index 15bf0a99c8a..c6ba4c1a476 100644
> --- a/target/riscv/tcg/zce_helper.c
> +++ b/target/riscv/tcg/zce_helper.c
> @@ -18,12 +18,14 @@
>  
>  #include "qemu/osdep.h"
>  #include "cpu.h"
> +#include "internals.h"
>  #include "exec/helper-proto.h"
>  #include "accel/tcg/cpu-ldst.h"
>  
>  target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index)
>  {
>      unsigned mmu_index = cpu_mmu_index(env_cpu(env), true);
> +    MemOp endian = mo_endian_env(env);
>      MemOpIdx oi;
>  
>  #if !defined(CONFIG_USER_ONLY)
> @@ -45,11 +47,11 @@ target_ulong HELPER(cm_jalt)(CPURISCVState *env,
> uint32_t index)
>      }
>  
>      if (xlen == 32) {
> -        oi = make_memop_idx(MO_LEUL, mmu_index);
> +        oi = make_memop_idx(MO_UL | endian, mmu_index);
>          t0 = base + (index << 2);
>          target = cpu_ldl_code_mmu(env, t0, oi, 0);
>      } else {
> -        oi = make_memop_idx(MO_LEUQ, mmu_index);
> +        oi = make_memop_idx(MO_UQ | endian, mmu_index);
>          t0 = base + (index << 3);
>          target = cpu_ldq_code_mmu(env, t0, oi, 0);
>      }
Re: [PATCH] target/riscv: Make Zcmt JVT loads endian-aware
Posted by Alistair Francis 1 month, 1 week ago
On Mon, 2026-08-17 at 16:30 +0800, Xu Liu wrote:
> The Zcmt specification says JVT table entries follow the current data
> endianness. Support that behavior as described by the specification
> so
> big-endian guests can use JVT tables stored in big-endian form.
> 
> Signed-off-by: Xu Liu <liuxu@nucleisys.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/tcg/zce_helper.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/target/riscv/tcg/zce_helper.c
> b/target/riscv/tcg/zce_helper.c
> index 15bf0a99c8a..c6ba4c1a476 100644
> --- a/target/riscv/tcg/zce_helper.c
> +++ b/target/riscv/tcg/zce_helper.c
> @@ -18,12 +18,14 @@
>  
>  #include "qemu/osdep.h"
>  #include "cpu.h"
> +#include "internals.h"
>  #include "exec/helper-proto.h"
>  #include "accel/tcg/cpu-ldst.h"
>  
>  target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index)
>  {
>      unsigned mmu_index = cpu_mmu_index(env_cpu(env), true);
> +    MemOp endian = mo_endian_env(env);
>      MemOpIdx oi;
>  
>  #if !defined(CONFIG_USER_ONLY)
> @@ -45,11 +47,11 @@ target_ulong HELPER(cm_jalt)(CPURISCVState *env,
> uint32_t index)
>      }
>  
>      if (xlen == 32) {
> -        oi = make_memop_idx(MO_LEUL, mmu_index);
> +        oi = make_memop_idx(MO_UL | endian, mmu_index);
>          t0 = base + (index << 2);
>          target = cpu_ldl_code_mmu(env, t0, oi, 0);
>      } else {
> -        oi = make_memop_idx(MO_LEUQ, mmu_index);
> +        oi = make_memop_idx(MO_UQ | endian, mmu_index);
>          t0 = base + (index << 3);
>          target = cpu_ldq_code_mmu(env, t0, oi, 0);
>      }