From: Weiwei Li Date: Wed, 17 May 2023 09:15:19 +0000 (+0800) Subject: target/riscv: Deny access if access is partially inside the PMP entry X-Git-Tag: v8.1.0-rc0~57^2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89fbbaddfb33556f3f669d40f917c65e75ea6768;p=thirdparty%2Fqemu.git target/riscv: Deny access if access is partially inside the PMP entry Access will fail if access is partially inside the PMP entry. However,only setting ret = false doesn't really mean pmp violation since pmp_hart_has_privs_default() may return true at the end of pmp_hart_has_privs(). Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang Reviewed-by: Alistair Francis Message-Id: <20230517091519.34439-13-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis --- diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 37e9985d6a3..418738afd8b 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -327,8 +327,8 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, if ((s + e) == 1) { qemu_log_mask(LOG_GUEST_ERROR, "pmp violation - access is partially inside\n"); - ret = false; - break; + *allowed_privs = 0; + return false; } /* fully inside */