render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0003-riscv-Set-xPIE-to-1-after-xRET.patch

b98348
From: Yiting Wang <yiting.wang@windriver.com>
b98348
Date: Fri, 3 Jan 2020 11:53:42 +0800
1d442b
Subject: [PATCH] riscv: Set xPIE to 1 after xRET
b98348
b98348
When executing an xRET instruction, supposing xPP holds the
b98348
value y, xIE is set to xPIE; the privilege mode is changed to y;
b98348
xPIE is set to 1. But QEMU sets xPIE to 0 incorrectly.
b98348
b98348
Signed-off-by: Yiting Wang <yiting.wang@windriver.com>
b98348
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
b98348
Tested-by: Bin Meng <bmeng.cn@gmail.com>
b98348
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
b98348
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
b98348
---
b98348
 target/riscv/op_helper.c | 4 ++--
b98348
 1 file changed, 2 insertions(+), 2 deletions(-)
b98348
b98348
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
b98348
index 331cc36232..e87c9115bc 100644
b98348
--- a/target/riscv/op_helper.c
b98348
+++ b/target/riscv/op_helper.c
b98348
@@ -93,7 +93,7 @@ target_ulong helper_sret(CPURISCVState *env, target_ulong cpu_pc_deb)
b98348
         env->priv_ver >= PRIV_VERSION_1_10_0 ?
b98348
         MSTATUS_SIE : MSTATUS_UIE << prev_priv,
b98348
         get_field(mstatus, MSTATUS_SPIE));
b98348
-    mstatus = set_field(mstatus, MSTATUS_SPIE, 0);
b98348
+    mstatus = set_field(mstatus, MSTATUS_SPIE, 1);
b98348
     mstatus = set_field(mstatus, MSTATUS_SPP, PRV_U);
b98348
     riscv_cpu_set_mode(env, prev_priv);
b98348
     env->mstatus = mstatus;
b98348
@@ -118,7 +118,7 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
b98348
         env->priv_ver >= PRIV_VERSION_1_10_0 ?
b98348
         MSTATUS_MIE : MSTATUS_UIE << prev_priv,
b98348
         get_field(mstatus, MSTATUS_MPIE));
b98348
-    mstatus = set_field(mstatus, MSTATUS_MPIE, 0);
b98348
+    mstatus = set_field(mstatus, MSTATUS_MPIE, 1);
b98348
     mstatus = set_field(mstatus, MSTATUS_MPP, PRV_U);
b98348
     riscv_cpu_set_mode(env, prev_priv);
b98348
     env->mstatus = mstatus;