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 {
303303 return (read () & MSECCFG_RLB);
304304}
305305
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+
306314bool mseccfg_csr_t::unlogged_write (const reg_t val) noexcept {
307315 if (proc->n_pmp == 0 )
308316 return false ;
@@ -1440,6 +1448,16 @@ void seed_csr_t::verify_permissions(insn_t insn, bool write) const {
14401448 if (!proc->extension_enabled (EXT_ZKR) || !write)
14411449 throw trap_illegal_instruction (insn.bits ());
14421450 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+ }
14431461}
14441462
14451463reg_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 {
150150 bool get_mml () const noexcept ;
151151 bool get_mmwp () const noexcept ;
152152 bool get_rlb () const noexcept ;
153+ bool get_useed () const noexcept ;
154+ bool get_sseed () const noexcept ;
153155 protected:
154156 virtual bool unlogged_write (const reg_t val) noexcept override ;
155157};
You can’t perform that action at this time.
0 commit comments