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

wangyang posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/6AD0895A.0F1C22.05843@cstnet.cn
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/csr.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] target/riscv: make mnstatus.MNPELP writable with Zicfilp
Posted by wangyang 1 month, 1 week ago
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
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: wangyang <wangyang25@otcaix.iscas.ac.cn>
---
 target/riscv/tcg/csr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/riscv/tcg/csr.c b/target/riscv/tcg/csr.c
index 061bc9d..fdb55b8 100644
--- a/target/riscv/tcg/csr.c
+++ b/target/riscv/tcg/csr.c
@@ -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;
-- 
2.43.0
Re: [PATCH] target/riscv: make mnstatus.MNPELP writable with Zicfilp
Posted by Alistair Francis 1 month ago
On Thu, 2026-10-15 at 08:05 +0000, wangyang wrote:
> 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
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
> Signed-off-by: wangyang <wangyang25@otcaix.iscas.ac.cn>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  target/riscv/tcg/csr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/target/riscv/tcg/csr.c b/target/riscv/tcg/csr.c
> index 061bc9d..fdb55b8 100644
> --- a/target/riscv/tcg/csr.c
> +++ b/target/riscv/tcg/csr.c
> @@ -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;