mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
target/riscv: Smepmp: Return error when access permission not allowed in PMP
On an address match, skip checking for default permissions and return error
based on access defined in PMP configuration.
v3 Changes:
o Removed explicit return of boolean value from comparision
of priv/allowed_priv
v2 Changes:
o Removed goto to return in place when address matches
o Call pmp_hart_has_privs_default at the end of the loop
Fixes: 90b1fafce0
("target/riscv: Smepmp: Skip applying default rules when address matches")
Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Message-Id: <20230605164548.715336-1-hchauhan@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
949b6bcb27
commit
a574b27af4
1 changed files with 2 additions and 8 deletions
|
@ -291,7 +291,6 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
|
||||||
pmp_priv_t *allowed_privs, target_ulong mode)
|
pmp_priv_t *allowed_privs, target_ulong mode)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool ret = false;
|
|
||||||
int pmp_size = 0;
|
int pmp_size = 0;
|
||||||
target_ulong s = 0;
|
target_ulong s = 0;
|
||||||
target_ulong e = 0;
|
target_ulong e = 0;
|
||||||
|
@ -435,17 +434,12 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
|
||||||
* defined with PMP must be used. We shouldn't fallback on
|
* defined with PMP must be used. We shouldn't fallback on
|
||||||
* finding default privileges.
|
* finding default privileges.
|
||||||
*/
|
*/
|
||||||
ret = true;
|
return (privs & *allowed_privs) == privs;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No rule matched */
|
/* No rule matched */
|
||||||
if (!ret) {
|
return pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
|
||||||
ret = pmp_hart_has_privs_default(env, privs, allowed_privs, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue