File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,14 @@ bool mseccfg_csr_t::get_rlb() const noexcept {
303
303
return (read () & MSECCFG_RLB);
304
304
}
305
305
306
+ bool mseccfg_csr_t::get_useed () const noexcept {
307
+ return (read () & MSECCFG_USEED);
308
+ }
309
+
310
+ bool mseccfg_csr_t::get_sseed () const noexcept {
311
+ return (read () & MSECCFG_SSEED);
312
+ }
313
+
306
314
bool mseccfg_csr_t::unlogged_write (const reg_t val) noexcept {
307
315
if (proc->n_pmp == 0 )
308
316
return false ;
@@ -1440,6 +1448,16 @@ void seed_csr_t::verify_permissions(insn_t insn, bool write) const {
1440
1448
if (!proc->extension_enabled (EXT_ZKR) || !write)
1441
1449
throw trap_illegal_instruction (insn.bits ());
1442
1450
csr_t::verify_permissions (insn, write);
1451
+
1452
+ if (state->v ) {
1453
+ if (state->mseccfg ->get_sseed () && write)
1454
+ throw trap_virtual_instruction (insn.bits ());
1455
+ else
1456
+ throw trap_illegal_instruction (insn.bits ());
1457
+ } else if ((state->prv == PRV_U && !state->mseccfg ->get_useed ()) ||
1458
+ (state->prv == PRV_S && !state->mseccfg ->get_sseed ())) {
1459
+ throw trap_illegal_instruction (insn.bits ());
1460
+ }
1443
1461
}
1444
1462
1445
1463
reg_t seed_csr_t::read () const noexcept {
Original file line number Diff line number Diff line change @@ -150,6 +150,8 @@ class mseccfg_csr_t: public basic_csr_t {
150
150
bool get_mml () const noexcept ;
151
151
bool get_mmwp () const noexcept ;
152
152
bool get_rlb () const noexcept ;
153
+ bool get_useed () const noexcept ;
154
+ bool get_sseed () const noexcept ;
153
155
protected:
154
156
virtual bool unlogged_write (const reg_t val) noexcept override ;
155
157
};
You can’t perform that action at this time.
0 commit comments