Skip to content

Commit 229b159

Browse files
committed
Fix ePMP checking on hlvx instructions
The hlvx instruction must grant PMP permissions of both execution and reading. Thus, with ePMP (mseccfg.MML==1), the hlvx instructions are only permitted with pmpcfg.RWXL=0111 from M-mode.
1 parent 6b89a49 commit 229b159

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

riscv/csrs.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ bool pmpaddr_csr_t::access_ok(access_type type, reg_t mode, bool hlvx) const noe
197197
if (mseccfg_mml) {
198198
if (cfgx && cfgw && cfgr && cfgl) {
199199
// Locked Shared data region: Read only on both M and S/U mode.
200-
return typer;
200+
return typer && !hlvx;
201201
} else {
202202
const bool mml_shared_region = !cfgr && cfgw;
203203
const bool mml_chk_normal = (prvm == cfgl) && normal_rwx;
204204
const bool mml_chk_shared =
205-
(!cfgl && cfgx && (typer || typew)) ||
206-
(!cfgl && !cfgx && (typer || (typew && prvm))) ||
205+
(!cfgl && cfgx && ((typer && !hlvx) || typew)) ||
206+
(!cfgl && !cfgx && ((typer && !hlvx) || (typew && prvm))) ||
207207
(cfgl && typex) ||
208208
(cfgl && typer && cfgx && prvm);
209209
return mml_shared_region ? mml_chk_shared : mml_chk_normal;

0 commit comments

Comments
 (0)