Skip to content

Commit fd0a927

Browse files
authored
Merge pull request #1848 from riscv-software-src/fix-1846
Fix FCSR accesses under Zfinx
2 parents f0d4d42 + 1adf60f commit fd0a927

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

riscv/csrs.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,9 @@ float_csr_t::float_csr_t(processor_t* const proc, const reg_t addr, const reg_t
14101410

14111411
void float_csr_t::verify_permissions(insn_t insn, bool write) const {
14121412
masked_csr_t::verify_permissions(insn, write);
1413-
require_fs;
1414-
if (!proc->extension_enabled('F') && !proc->extension_enabled(EXT_ZFINX))
1413+
1414+
if (!((proc->extension_enabled('F') && STATE.sstatus->enabled(SSTATUS_FS))
1415+
|| proc->extension_enabled(EXT_ZFINX)))
14151416
throw trap_illegal_instruction(insn.bits());
14161417

14171418
if (proc->extension_enabled(EXT_SMSTATEEN) && proc->extension_enabled(EXT_ZFINX)) {
@@ -1431,7 +1432,8 @@ void float_csr_t::verify_permissions(insn_t insn, bool write) const {
14311432
}
14321433

14331434
bool float_csr_t::unlogged_write(const reg_t val) noexcept {
1434-
dirty_fp_state;
1435+
if (!proc->extension_enabled(EXT_ZFINX))
1436+
dirty_fp_state;
14351437
return masked_csr_t::unlogged_write(val);
14361438
}
14371439

riscv/decode_macros.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ static inline bool is_aligned(const unsigned val, const unsigned pos)
165165
#define require_extension(s) require(p->extension_enabled(s))
166166
#define require_either_extension(A,B) require(p->extension_enabled(A) || p->extension_enabled(B));
167167
#define require_impl(s) require(p->supports_impl(s))
168-
#define require_fs require(STATE.sstatus->enabled(SSTATUS_FS))
169168
#define require_fp STATE.fflags->verify_permissions(insn, false)
170169
#define require_accelerator require(STATE.sstatus->enabled(SSTATUS_XS))
171170
#define require_vector_vs require(p->any_vector_extensions() && STATE.sstatus->enabled(SSTATUS_VS))

0 commit comments

Comments
 (0)