aboutsummaryrefslogtreecommitdiff
path: root/riscv/csrs.h
diff options
context:
space:
mode:
authorScott Johnson <scott.johnson@arilinc.com>2021-03-02 00:02:57 -0800
committerAndrew Waterman <aswaterman@gmail.com>2021-09-08 07:59:02 -0700
commit14219453156c573caa9dfc0936e1bdfd71138ea3 (patch)
treea67f9631ae7d71330fd6adf523438e0a5829c83c /riscv/csrs.h
parent4f008be2f747265d092e6a5fff2b046484d18625 (diff)
downloadspike-14219453156c573caa9dfc0936e1bdfd71138ea3.zip
spike-14219453156c573caa9dfc0936e1bdfd71138ea3.tar.gz
spike-14219453156c573caa9dfc0936e1bdfd71138ea3.tar.bz2
Use virtualized_csr_t for satp and vsatp
This was much more complicated than the others because of the mstatus.TVM and hstatus.VTVM bits, and because of the special WARL-ness of satp that doesn't apply to vsatp. It appears (based on reading the code) that the commitlog for these two was problematic. CSRW to satp when V=1 was reporting a write to satp instead of vsatp which was actually written. Also a CSRW to vsatp looks like it was not being logged at all. Both problems should be fixed now.
Diffstat (limited to 'riscv/csrs.h')
-rw-r--r--riscv/csrs.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/riscv/csrs.h b/riscv/csrs.h
index 6cb60ff..e78a612 100644
--- a/riscv/csrs.h
+++ b/riscv/csrs.h
@@ -143,6 +143,7 @@ class virtualized_csr_t: public csr_t {
csr_t_p virt_csr;
};
+typedef std::shared_ptr<virtualized_csr_t> virtualized_csr_t_p;
// For mepc, sepc, and vsepc
class epc_csr_t: public logged_csr_t {
@@ -390,4 +391,28 @@ class counteren_csr_t: public basic_csr_t {
virtual bool unlogged_write(const reg_t val) noexcept override;
};
+
+// For satp and vsatp
+// These are three classes in order to handle the [V]TVM bits permission checks
+class base_atp_csr_t: public basic_csr_t {
+ public:
+ base_atp_csr_t(processor_t* const proc, const reg_t addr);
+ protected:
+ virtual bool unlogged_write(const reg_t val) noexcept override;
+};
+
+class satp_csr_t: public base_atp_csr_t {
+ public:
+ satp_csr_t(processor_t* const proc, const reg_t addr);
+ virtual void verify_permissions(insn_t insn, bool write) const override;
+};
+
+class virtualized_satp_csr_t: public virtualized_csr_t {
+ public:
+ virtualized_satp_csr_t(processor_t* const proc, csr_t_p orig, csr_t_p virt);
+ virtual void verify_permissions(insn_t insn, bool write) const override;
+ virtual void write(const reg_t val) noexcept override;
+};
+
+
#endif