[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV

From: Weiwei Li
Subject: Re: [PATCH 2/4] target/riscv: Remove check on mode for MPRV
Date: Thu, 1 Jun 2023 14:43:07 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

On 2023/6/1 13:27, Alistair Francis wrote:
On Mon, May 29, 2023 at 10:19 PM Weiwei Li <liweiwei@iscas.ac.cn> wrote:
Normally, MPRV can be set to 1 only in M mode (It will be cleared
when returning to lower-privilege mode by MRET/SRET).

Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
  target/riscv/cpu_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index bd892c05d4..45baf95c77 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -44,7 +44,7 @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
      if (!ifetch) {
          uint64_t status = env->mstatus;

-        if (mode == PRV_M && get_field(status, MSTATUS_MPRV)) {
+        if (get_field(status, MSTATUS_MPRV)) {
The original check is correct though, why remove it?

Yeah. As described in the commit message, I think MPRV can only be set to 1 in M mode normally

which means check on MPRV is enough in this case. So I remove the check on mode here.


Weiwei Li


              mode = get_field(env->mstatus, MSTATUS_MPP);
              virt = get_field(env->mstatus, MSTATUS_MPV) &&
                     (mode != PRV_M);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]