[Top][All Lists]

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

Re: [PATCH] target/riscv: Smepmp: Return error when access permission no

From: Weiwei Li
Subject: Re: [PATCH] target/riscv: Smepmp: Return error when access permission not allowed in PMP
Date: Mon, 5 Jun 2023 17:16:23 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

On 2023/6/5 15:51, Himanshu Chauhan wrote:
On an address match, skip checking for default permissions and return error
based on access defined in PMP configuration.

Fixes: 90b1fafce06 ("target/riscv: Smepmp: Skip applying default rules when address 
Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
  target/riscv/pmp.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 418738afd8..6238528282 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -435,8 +435,8 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong 
               * defined with PMP must be used. We shouldn't fallback on
               * finding default privileges.
-            ret = true;
-            break;
+            ret = ((privs & *allowed_privs) == privs ? true : false);
+            goto _address_matched;

goto seems unnecessary. We can directly return (privs & *allowed_privs) == privs here.

And then we can directly return pmp_hart_has_privs_default(env, privs, allowed_privs, mode) after this loop.


Weiwei Li

@@ -445,6 +445,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
          ret = pmp_hart_has_privs_default(env, privs, allowed_privs, mode);

+ _address_matched:
      return ret;

reply via email to

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