@@ -285,7 +285,8 @@ mseccfg_csr_t::mseccfg_csr_t(processor_t* const proc, const reg_t addr):
285285
286286void mseccfg_csr_t::verify_permissions (insn_t insn, bool write) const {
287287 basic_csr_t::verify_permissions (insn, write);
288- if (!proc->extension_enabled (EXT_SMEPMP))
288+ if (!proc->extension_enabled (EXT_SMEPMP) &&
289+ !proc->extension_enabled (EXT_ZICFILP))
289290 throw trap_illegal_instruction (insn.bits ());
290291}
291292
@@ -322,6 +323,11 @@ bool mseccfg_csr_t::unlogged_write(const reg_t val) noexcept {
322323
323324 proc->get_mmu ()->flush_tlb ();
324325
326+ if (proc->extension_enabled (EXT_ZICFILP)) {
327+ new_val &= ~MSECCFG_MLPE;
328+ new_val |= (val & MSECCFG_MLPE);
329+ }
330+
325331 return basic_csr_t::unlogged_write (new_val);
326332}
327333
@@ -414,6 +420,7 @@ reg_t base_status_csr_t::compute_sstatus_write_mask() const noexcept {
414420 | (has_fs ? SSTATUS_FS : 0 )
415421 | (proc->any_custom_extensions () ? SSTATUS_XS : 0 )
416422 | (has_vs ? SSTATUS_VS : 0 )
423+ | (proc->extension_enabled (EXT_ZICFILP) ? SSTATUS_SPELP : 0 )
417424 ;
418425}
419426
@@ -497,7 +504,9 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
497504 | (proc->extension_enabled (' S' ) ? MSTATUS_TSR : 0 )
498505 | (has_page ? MSTATUS_TVM : 0 )
499506 | (has_gva ? MSTATUS_GVA : 0 )
500- | (has_mpv ? MSTATUS_MPV : 0 );
507+ | (has_mpv ? MSTATUS_MPV : 0 )
508+ | (proc->extension_enabled (EXT_ZICFILP) ? (MSTATUS_SPELP | MSTATUS_MPELP) : 0 )
509+ ;
501510
502511 const reg_t requested_mpp = proc->legalize_privilege (get_field (val, MSTATUS_MPP));
503512 const reg_t adjusted_val = set_field (val, MSTATUS_MPP, requested_mpp);
@@ -897,6 +906,7 @@ bool medeleg_csr_t::unlogged_write(const reg_t val) noexcept {
897906 | (1 << CAUSE_LOAD_PAGE_FAULT)
898907 | (1 << CAUSE_STORE_PAGE_FAULT)
899908 | (proc->extension_enabled (' H' ) ? hypervisor_exceptions : 0 )
909+ | (proc->extension_enabled (EXT_ZICFILP) ? (1 << CAUSE_SOFTWARE_CHECK_FAULT) : 0 )
900910 ;
901911 return basic_csr_t::unlogged_write ((read () & ~mask) | (val & mask));
902912}
@@ -1284,7 +1294,8 @@ dcsr_csr_t::dcsr_csr_t(processor_t* const proc, const reg_t addr):
12841294 ebreakvu(false ),
12851295 halt(false ),
12861296 v(false ),
1287- cause(0 ) {
1297+ cause(0 ),
1298+ pelp(elp_t ::NO_LP_EXPECTED) {
12881299}
12891300
12901301void dcsr_csr_t::verify_permissions (insn_t insn, bool write) const {
@@ -1307,6 +1318,7 @@ reg_t dcsr_csr_t::read() const noexcept {
13071318 result = set_field (result, DCSR_STEP, step);
13081319 result = set_field (result, DCSR_PRV, prv);
13091320 result = set_field (result, CSR_DCSR_V, v);
1321+ result = set_field (result, DCSR_PELP, pelp);
13101322 return result;
13111323}
13121324
@@ -1321,13 +1333,17 @@ bool dcsr_csr_t::unlogged_write(const reg_t val) noexcept {
13211333 ebreakvu = proc->extension_enabled (' H' ) ? get_field (val, CSR_DCSR_EBREAKVU) : false ;
13221334 halt = get_field (val, DCSR_HALT);
13231335 v = proc->extension_enabled (' H' ) ? get_field (val, CSR_DCSR_V) : false ;
1336+ pelp = proc->extension_enabled (EXT_ZICFILP) ?
1337+ static_cast <elp_t >(get_field (val, DCSR_PELP)) : elp_t ::NO_LP_EXPECTED;
13241338 return true ;
13251339}
13261340
1327- void dcsr_csr_t::write_cause_and_prv (uint8_t cause, reg_t prv, bool v) noexcept {
1341+ void dcsr_csr_t::update_fields (const uint8_t cause, const reg_t prv,
1342+ const bool v, const elp_t pelp) noexcept {
13281343 this ->cause = cause;
13291344 this ->prv = prv;
13301345 this ->v = v;
1346+ this ->pelp = pelp;
13311347 log_write ();
13321348}
13331349
0 commit comments