aboutsummaryrefslogtreecommitdiff
path: root/riscv/csrs.cc
AgeCommit message (Collapse)AuthorFilesLines
2023-11-29fix: dcsr.ebreak(v)[su] hardwired to 0 if unsupport corresponding privilege ↵YenHaoChen1-4/+4
modes
2023-11-24stimecmp: perform menvcfg.STCE permission check when accessing vstimecmp in ↵YenHaoChen1-2/+6
HS-mode The spec requires menvcfg.STCE=1 on accessing stimecmp or vstimecmp in a mode other than M-mode. The previous implementation does not check the permission on accessing vstimecmp in HS-mode. This commit fixes the issue by moveing the permission check from virtualized_stimecmp_csr_t to stimecmp_csr_t, which implements the vstimecmp.
2023-07-26Add Smcntrpmf functionalityAtul Khare1-4/+43
If Smcntrpmf is enabled, mcycle / minstret increment only if counting for the privilege level isn't inhibited in mcyclecfg / minstretcfg.
2023-07-25Merge pull request #1383 from rivosinc/sscrind_featureAndrew Waterman1-0/+62
Add Smcsrind / Sscsrind support
2023-07-25legalize henvcfg.CBIEYenHaoChen1-1/+1
The value 2 of henvcfg.CBIE is reserved. This commit legalizes it to 0. Reference: https://github.com/riscv/riscv-CMOs/issues/65
2023-07-25legalize senvcfg.CBIEYenHaoChen1-1/+1
The value 2 of senvcfg.CBIE is reserved. This commit legalizes it to 0. Reference: https://github.com/riscv/riscv-CMOs/issues/65
2023-07-25legalize menvcfg.CBIEYenHaoChen1-0/+13
The value 2 of menvcfg.CBIE is reserved. This commit legalizes it to 0 by adding a specialized class envcfg_csr_t. Reference: https://github.com/riscv/riscv-CMOs/issues/65
2023-07-19Add Smcsrind/Sscsrind supportAtul Khare1-0/+62
This adds the following CSRs: miselect (0x350), mireg (0x351), mireg2/3 (0x352, 0x353), mireg4-6 (0x355 - 0x357), siselect (0x150), sireg (0x151), sireg2/3 (0x152, 0x153), sireg4-6 (0x155 - 0x157), vsiselect (0x250), vsireg (0x251), mireg2/3 (0x252, 0x253), vsireg4-6 (0x255 - 0x257). Presently, attempts to read / write from ireg? registers will fail, and future extensions will provide proxy CSR mappings for the respective ?ireg CSRs.
2023-06-01dscr.ebreakh is now dcsr.ebreakv[su]Tim Newsome1-3/+6
This change was made ages ago in the spec. I did not actually test that the new privilege checks in ebreak and c.ebreak are correct, but all the existing debug tests still pass.
2023-05-25Implement dcsr.v and make DRET use itAndrew Waterman1-1/+7
Resolves #1365
2023-05-25Use more descriptive variable name in dcsr_csr_t::read; make it reg_tAndrew Waterman1-12/+12
2023-05-23Let mstatus.MPP initially be M-mode if unsupporting U-modeYenHaoChen1-0/+1
This commit lets the mstatus.MPP be a valid value if unsupporting U-mode. Without this commit, the mret may result in a corrupted state without properly setting the MPP to M-mode (if unsupporting U-mode).
2023-03-20Implement Smrnmi extensionAndrew Waterman1-0/+20
We don't model any sources of RNMI, so this is mostly vestigial.
2023-02-15Disable Zvfh when Zfhmin is disabledWeiwei Li1-1/+1
2023-02-15Disable Zvfh{min} when misa.V is clearedWeiwei Li1-0/+2
2023-02-15Disable Zfh{min} when misa.F is clearedWeiwei Li1-0/+2
2023-02-06Support dynamically disabling misa.C once againAndrew Waterman1-2/+15
Now, when misa.C is writable, clearing misa.C also disables any Zc* extension.
2023-02-06Make JVT CSR definition account for dynamically disabling ZcmtAndrew Waterman1-0/+3
No functional change yet.
2023-01-03Make misa.C read-onlyAndrew Waterman1-6/+1
This resolves the issue discussed in #1201. Prior to 0adf9307, clearing misa.C would disable compressed instructions and increase IALIGN to 32. Afterwards, clearing misa.C had essentially no effect because Zca and friends would stay enabled. While AFAICS this isn't technically incorrect, it certainly doesn't follow the principle of least surprise. Instead, remove the feature to toggle misa.C. The effect is that misa.C is 1 iff C is included in the ISA string, and IALIGN is independent of misa.C: specifically, IALIGN is 16 iff Zca is present. (And of course C implies Zca.) Removing the alignment check on misa writes is not a separate commit because these two changes should be made atomically. Not checking the alignment on misa writes goes hand-in-hand with misa.C being read-only.
2022-12-20Check commitlog-enable dynamicallly for csr_t::log_special_writeJerry Zhao1-4/+2
This incurs a negligible performance impact
2022-12-15Add config.h includes directly to source files instead of relying on header ↵Jerry Zhao1-0/+1
chaining This step is to ensure that removing config.h out of headers will not cause regressions.
2022-12-15Split decode.h into public decode.h and private decode_macros.hJerry Zhao1-1/+1
* decode.h contains constants/typedefs/classes. This should not depend on config.h * decode_macros.h contains internally used macros, and depends on config.h
2022-12-09triggers: implement tdata3 CSR fieldsYenHaoChen1-2/+2
2022-12-09refactor: add tdata3_csr_t; preparation for CSR textraYenHaoChen1-0/+12
2022-12-09refactor: remove proc parameter from functions of module_tYenHaoChen1-5/+5
2022-12-05clear mevent.VUINH and mevent.VSINH when misa.H is clearedYenHaoChen1-0/+4
2022-12-05add macro N_HPMCOUNTERS (29)YenHaoChen1-1/+1
2022-12-05use extension_enabled('H') instead of extension_enabled_const('H') since ↵YenHaoChen1-1/+1
misa.H is RW The masked_csr_t does not meet the behavior of mevent because the misa.H is not read-only (hardwired). h/t @kwalker27 reported at https://github.com/riscv-software-src/riscv-isa-sim/pull/1154
2022-12-05refactor: add custom CSR class, mevent_csr_tYenHaoChen1-0/+12
The masked_csr_t does not meet the behavior of mevent because the misa.H is not read-only (hardwired). (fix in the next commit) h/t @kwalker27 reported at https://github.com/riscv-software-src/riscv-isa-sim/pull/1154
2022-11-22Add tinfo register.Tim Newsome1-0/+8
Not very interesting while spike only supports one trigger type, but #1128 is about to change that. Without tinfo, it can become quite slow for a debugger to discover which types are supported.
2022-11-17add support for zcmtWeiwei Li1-0/+24
add suport for jvt: Table entries follow the current data endianness
2022-10-04Suppress most unused variable warningsAndrew Waterman1-3/+3
2022-10-04Fix remaining ignored-qualifiers warningAndrew Waterman1-1/+1
2022-09-20Merge pull request #1036 from plctlab/plct-sscofpmf-devAndrew Waterman1-4/+38
add support for sscofpmf extension v0.5.2
2022-08-11Unify PMPCFGx behaviour with PMPADDRx where PMP is disabled (#1068)Greg Chadwick1-0/+10
Previously any access to the PMPADDRx CSRs when no PMP regions were configured would result in an illegal instruction trap, whilst PMPCFGx registers would act as WARL, ignoring writes and reading as 0. This unifies the behaviour so both PMPADDRx and PMPCFGx CSRs produce an illegal instruction trap when accessed when no PMP regions are configured.
2022-08-09Fix exception type for accessing (v)stimecmp (#1061)liweiwei901-6/+7
Illegal instruciton trap should be raised when accessing if related bit of mcounteren.TM or menvcfg.STCE is zero in VS/VU mode
2022-08-09add support for sscofpmf extension v0.5.2Weiwei Li1-4/+38
since spike doesn't truly support counting of hardware performance events, only csr related read/write functions is supported currently
2022-08-08Merge pull request #831 from plctlab/plct-upstream-zfinxAndrew Waterman1-4/+4
add support for zfinx v1.0
2022-08-08Merge pull request #1059 from plctlab/plct-stateen-fixAndrew Waterman1-30/+20
add stateen related check to frm/fflags
2022-08-04Add stateen related check for float point instructionsWeiwei Li1-1/+1
2022-08-04Add flags for Zfinx/Zdinx/Zhinx{min}liweiwei1-3/+3
Hardwire mstatus_fs to zero when enable ZFinx
2022-08-03Add Sstc support. (#1057)i2h21-1/+36
2022-08-03Fix exception type for accessing senvcfg/henvcfg/hstateenWeiwei Li1-6/+5
Illegal instruciton trap should be raised when accessing senvcfg/ henvcfg/hstateen if related bit of mstateen is zero in VU mode
2022-08-03add stateen related check to frm/fflags and then apply to fcsr implicitlyWeiwei Li1-24/+15
2022-07-26Add additional bits to medeleg (#1050)Brendan Sweeney1-0/+6
Pursuant to https://github.com/riscv-software-src/riscv-isa-sim/issues/668 and https://github.com/riscv-software-src/riscv-isa-sim/issues/194, allowing for additional exceptions to be delegated from M-mode. It is implementation-defined whether these bits are defined or are read-only-zero. QEMU implements the added bits (Fetch/Load/StoreAMO access, Load/StoreAMO misalignment, and illegal instruction). (https://github.com/qemu/qemu/blob/f6cce6bcb2ef959cdd4da0e368f7c72045f21d6d/target/riscv/csr.c#L813) ECALL_FROM_M is not implemented here because it would have no effect, although QEMU does implement it. This allows Spike to emulate QEMU and other systems which allow for the delegation of such exceptions. Signed-off-by: Brendan Sweeney <mehnadnerd@gmail.com>
2022-07-21Merge pull request #1040 from plctlab/plct-priv-devAndrew Waterman1-19/+24
Update for counter related CSR
2022-07-21add base verify_permission in counter_proxy_csr_t::verify_permissionsWeiwei Li1-1/+3
Normally, csrs will reuse the checks in verify_permissions of its base csr type This modification will not cause any functional change, just reuse the check in csr_t class to check whether it writes to read-only csr instead of checking writes to counter_proxy_csr_t by itself.
2022-07-21add support for time/timeh/htimedelta/htimedeltah csrsWeiwei Li1-0/+19
2022-07-21modify minstret/mcycle/minstreth/mcycleh to reuse rv32_low/high_csr_tWeiwei Li1-25/+9
2022-07-18Merge pull request #1041 from plctlab/plct-new-csrsAndrew Waterman1-11/+15
add support for m/henvcfgh and mconfigptr CSRs