Skip to contentSkip to conversation

target/riscv: make mnstatus.MNPELP writable with Zicfilp

PATCH Applied wangyang 2 participants 2 messages Oct 15 – Oct 22 RISC-V

lore
Share & tools
lore

wangyang

author
#0 lore raw

PATCH 1/1 target/riscv: make mnstatus.MNPELP writable with Zicfilp

Zicfilp adds MNPELP to mnstatus, and MNRET consumes it when restoring ELP. Include the field in write_mnstatus() when Zicfilp is implemented.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4222

---
 target/riscv/tcg/csr.c | 4 ++++
 1 file changed, 4 insertions(+)
target/riscv/tcg/csr.c +4 -0
index 061bc9d..fdb55b8 100644
@@ -5584,6 +5584,10 @@ static RISCVException write_mnstatus(CPURISCVState *env, int csrno,
         mask |= MNSTATUS_MNPV;
     }
 
+    if (env_archcpu(env)->cfg.ext_zicfilp) {
+        mask |= MNSTATUS_MNPELP;
+    }
+
     /* mnstatus.mnie can only be cleared by hardware. */
     env->mnstatus = (env->mnstatus & MNSTATUS_NMIE) | (val & mask);
     return RISCV_EXCP_NONE;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · wangyang

Zicfilp adds MNPELP to mnstatus, and MNRET consumes it when restoring ELP.
Include the field in write_mnstatus() when Zicfilp is implemented.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4222

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 20 lines

---
 target/riscv/tcg/csr.c | 4 ++++

 1 file changed, 4 insertions(+)
target/riscv/tcg/csr.c +0 -0
index 061bc9d..fdb55b8 100644
@@ -5584,6 +5584,10 @@ static RISCVException
 write_mnstatus(CPURISCVState *env, int csrno,
          mask |= MNSTATUS_MNPV;
      }


+    if (env_archcpu(env)->cfg.ext_zicfilp) {
+        mask |= MNSTATUS_MNPELP;
+    }
+
     /* mnstatus.mnie can only be cleared by hardware. */ env->mnstatus = (env->mnstatus & MNSTATUS_NMIE) | (val & mask); return RISCV_EXCP_NONE;