Skip to contentSkip to conversation

target/riscv: Fix initialized value for cur_pmmask

PATCH Applied Weiwei Li 3 participants 3 messages Jun 10, 2023 – Jun 12, 2023 RISC-V

lore
Share & tools
lore

Weiwei Li

author
#0 lore raw

PATCH 1/1 target/riscv: Fix initialized value for cur_pmmask

We initialize cur_pmmask as -1(UINT32_MAX/UINT64_MAX) and regard it as if pointer mask is disabled in current implementation. However, the addresses for vector load/store will be adjusted to zero in this case and -1(UINT32_MAX/UINT64_MAX) is valid value for pmmask when pointer mask is enabled.

---
 target/riscv/cpu_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/cpu_helper.c +2 -2
index 09ea227ceb..acbcb7ed76 100644
@@ -133,7 +133,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
     flags = FIELD_DP32(flags, TB_FLAGS, FS, fs);
     flags = FIELD_DP32(flags, TB_FLAGS, VS, vs);
     flags = FIELD_DP32(flags, TB_FLAGS, XL, env->xl);
-    if (env->cur_pmmask < (env->xl == MXL_RV32 ? UINT32_MAX : UINT64_MAX)) {
+    if (env->cur_pmmask != 0) {
         flags = FIELD_DP32(flags, TB_FLAGS, PM_MASK_ENABLED, 1);
     }
     if (env->cur_pmbase != 0) {
@@ -145,7 +145,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
 
 void riscv_cpu_update_mask(CPURISCVState *env)
 {
-    target_ulong mask = -1, base = 0;
+    target_ulong mask = 0, base = 0;
     /*
      * TODO: Current RVJ spec does not specify
      * how the extension interacts with XLEN.
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Weiwei Li

We initialize cur_pmmask as -1(UINT32_MAX/UINT64_MAX) and regard it as if pointer mask is disabled in current implementation. However, the addresses for vector load/store will be adjusted to zero in this case and -1(UINT32_MAX/UINT64_MAX) is valid value for pmmask when pointer mask is enabled.

---
  target/riscv/cpu_helper.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/cpu_helper.c +1 -1
index 09ea227ceb..acbcb7ed76 100644
@@ -133,7 +133,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
      flags = FIELD_DP32(flags, TB_FLAGS, FS, fs);
      flags = FIELD_DP32(flags, TB_FLAGS, VS, vs);
      flags = FIELD_DP32(flags, TB_FLAGS, XL, env->xl);
-    if (env->cur_pmmask < (env->xl == MXL_RV32 ? UINT32_MAX : UINT64_MAX)) {
+    if (env->cur_pmmask != 0) {
          flags = FIELD_DP32(flags, TB_FLAGS, PM_MASK_ENABLED, 1);
      }
      if (env->cur_pmbase != 0) {

target/riscv/cpu_helper.c void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, · line 148

Quoted 5 lines
target/riscv/cpu_helper.c +1 -1
@@ -145,7 +145,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
 
  void riscv_cpu_update_mask(CPURISCVState *env)
  {
-    target_ulong mask = -1, base = 0;
+    target_ulong mask = 0, base = 0;

Zhiwei

Quoted 3 lines
target/riscv/cpu_helper.c +0 -0
      /*
       * TODO: Current RVJ spec does not specify
       * how the extension interacts with XLEN.
#2 lore raw
In reply to Weiwei Li
Quoted 9 lines · Weiwei Li

We initialize cur_pmmask as -1(UINT32_MAX/UINT64_MAX) and regard it as if pointer mask is disabled in current implementation. However, the addresses for vector load/store will be adjusted to zero in this case and -1(UINT32_MAX/UINT64_MAX) is valid value for pmmask when pointer mask is enabled.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 30 lines
---
 target/riscv/cpu_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/cpu_helper.c +2 -3
index 09ea227ceb..acbcb7ed76 100644
@@ -133,7 +133,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
     flags = FIELD_DP32(flags, TB_FLAGS, FS, fs);
     flags = FIELD_DP32(flags, TB_FLAGS, VS, vs);
     flags = FIELD_DP32(flags, TB_FLAGS, XL, env->xl);
-    if (env->cur_pmmask < (env->xl == MXL_RV32 ? UINT32_MAX : UINT64_MAX)) {
+    if (env->cur_pmmask != 0) {
         flags = FIELD_DP32(flags, TB_FLAGS, PM_MASK_ENABLED, 1);
     }
     if (env->cur_pmbase != 0) {
@@ -145,7 +145,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
 
 void riscv_cpu_update_mask(CPURISCVState *env)
 {
-    target_ulong mask = -1, base = 0;
+    target_ulong mask = 0, base = 0;
     /*
      * TODO: Current RVJ spec does not specify
      * how the extension interacts with XLEN.
--

2.25.1