aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2024-07-19 09:28:07 -0700
committerGitHub <noreply@github.com>2024-07-19 09:28:07 -0700
commit344a860ba01f358dae7f862ef292c89d969770e4 (patch)
tree5756420f30a62f27952f4dd21b902191a47b7121
parentf2181f040607602a0305d9c29996f7ea326f7724 (diff)
parentea5138d24deacf5d98acb79643a687224b3d4404 (diff)
downloadspike-344a860ba01f358dae7f862ef292c89d969770e4.zip
spike-344a860ba01f358dae7f862ef292c89d969770e4.tar.gz
spike-344a860ba01f358dae7f862ef292c89d969770e4.tar.bz2
Merge pull request #1724 from chihminchao/cif-sse-fix
The senvcfg.SSE will read (only) as zero when menvcfg.SSE is 0
-rw-r--r--riscv/csrs.cc14
-rw-r--r--riscv/csrs.h9
2 files changed, 19 insertions, 4 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc
index a1a5317..a3f088c 100644
--- a/riscv/csrs.cc
+++ b/riscv/csrs.cc
@@ -1585,6 +1585,18 @@ void senvcfg_csr_t::verify_permissions(insn_t insn, bool write) const {
masked_csr_t::verify_permissions(insn, write);
}
+// senvcfg.sse is read_only 0 when menvcfg.sse = 0
+reg_t senvcfg_csr_t::read() const noexcept {
+ reg_t envcfg = state->v ? state->henvcfg->read() : state->menvcfg->read();
+ return masked_csr_t::read() & ~(envcfg & MENVCFG_SSE ? 0 : MENVCFG_SSE);
+}
+
+bool senvcfg_csr_t::unlogged_write(const reg_t val) noexcept {
+ reg_t envcfg = state->v ? state->henvcfg->read() : state->menvcfg->read();
+ const reg_t mask = envcfg | ~MENVCFG_SSE;
+ return envcfg_csr_t::unlogged_write((masked_csr_t::read() & ~mask) | (val & mask));
+}
+
void henvcfg_csr_t::verify_permissions(insn_t insn, bool write) const {
if (proc->extension_enabled(EXT_SMSTATEEN)) {
if ((state->prv < PRV_M) && !(state->mstateen[0]->read() & MSTATEEN0_HENVCFG))
@@ -1595,7 +1607,7 @@ void henvcfg_csr_t::verify_permissions(insn_t insn, bool write) const {
}
bool henvcfg_csr_t::unlogged_write(const reg_t val) noexcept {
- const reg_t mask = menvcfg->read() | ~(MENVCFG_PBMTE | MENVCFG_STCE | MENVCFG_ADUE | MENVCFG_DTE);
+ const reg_t mask = menvcfg->read() | ~(MENVCFG_PBMTE | MENVCFG_STCE | MENVCFG_ADUE | MENVCFG_DTE | MENVCFG_SSE);
return envcfg_csr_t::unlogged_write((masked_csr_t::read() & ~mask) | (val & mask));
}
diff --git a/riscv/csrs.h b/riscv/csrs.h
index fd36992..dc89963 100644
--- a/riscv/csrs.h
+++ b/riscv/csrs.h
@@ -481,14 +481,13 @@ class envcfg_csr_t: public masked_csr_t {
// henvcfg.stce is read_only 0 when menvcfg.stce = 0
// henvcfg.hade is read_only 0 when menvcfg.hade = 0
// henvcfg.dte is read_only 0 when menvcfg.dte = 0
+// henvcfg.sse is read_only 0 when menvcfg.sse = 0
class henvcfg_csr_t final: public envcfg_csr_t {
public:
henvcfg_csr_t(processor_t* const proc, const reg_t addr, const reg_t mask, const reg_t init, csr_t_p menvcfg);
-
reg_t read() const noexcept override {
- return (menvcfg->read() | ~(MENVCFG_PBMTE | MENVCFG_STCE | MENVCFG_ADUE | MENVCFG_DTE)) & masked_csr_t::read();
+ return (menvcfg->read() | ~(MENVCFG_PBMTE | MENVCFG_STCE | MENVCFG_ADUE | MENVCFG_DTE | MENVCFG_SSE)) & masked_csr_t::read();
}
-
virtual void verify_permissions(insn_t insn, bool write) const override;
protected:
@@ -788,7 +787,11 @@ class sstateen_csr_t: public hstateen_csr_t {
class senvcfg_csr_t final: public envcfg_csr_t {
public:
senvcfg_csr_t(processor_t* const proc, const reg_t addr, const reg_t mask, const reg_t init);
+ reg_t read() const noexcept override;
virtual void verify_permissions(insn_t insn, bool write) const override;
+
+ protected:
+ virtual bool unlogged_write(const reg_t val) noexcept override;
};
class stimecmp_csr_t: public basic_csr_t {