From: Himanshu Chauhan Date: Thu, 9 Feb 2023 05:52:06 +0000 (+0530) Subject: target/riscv: Smepmp: Skip applying default rules when address matches X-Git-Tag: v8.0.0-rc0~45^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90b1fafce0602d46243a40d8eea3006ef57e24d8;p=thirdparty%2Fqemu.git target/riscv: Smepmp: Skip applying default rules when address matches When MSECCFG.MML is set, after checking the address range in PMP if the asked permissions are not same as programmed in PMP, the default permissions are applied. This should only be the case when there is no matching address is found. This patch skips applying default rules when matching address range is found. It returns the index of the match PMP entry. Fixes: 824cac681c3 (target/riscv: Fix PMP propagation for tlb) Signed-off-by: Himanshu Chauhan Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Message-Id: <20230209055206.229392-1-hchauhan@ventanamicro.com> Signed-off-by: Alistair Francis Signed-off-by: Palmer Dabbelt --- diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index d1126a60663..4bc41135313 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -441,9 +441,12 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, } } - if ((privs & *allowed_privs) == privs) { - ret = i; - } + /* + * If matching address range was found, the protection bits + * defined with PMP must be used. We shouldn't fallback on + * finding default privileges. + */ + ret = i; break; } }