No public description PiperOrigin-RevId: 705926911 Change-Id: I8d0239532be560860bc7994a7298c05e0df9329b
diff --git a/cheriot/cheriot_state.cc b/cheriot/cheriot_state.cc index 6dc3ca0..b1f5994 100644 --- a/cheriot/cheriot_state.cc +++ b/cheriot/cheriot_state.cc
@@ -17,7 +17,6 @@ #include <algorithm> #include <cstdint> #include <limits> -#include <new> #include <string> #include <string_view> #include <utility> @@ -57,6 +56,7 @@ using ::mpact::sim::riscv::RiscVCsrEnum; using ::mpact::sim::riscv::RiscVCsrInterface; using ::mpact::sim::riscv::RiscVPmp; +using ::mpact::sim::riscv::RiscVShadowCsr; using ::mpact::sim::riscv::RiscVSimpleCsr; using ::mpact::sim::riscv::RiscVXlen; @@ -197,24 +197,18 @@ auto *minstret = CreateCsr<RiscVCounterCsr<T, CheriotState>>( state, csr_vec, "minstret", RiscVCsrEnum ::kMInstret, state); CHECK_NE(minstret, nullptr); - if (sizeof(T) == sizeof(uint32_t)) { - CHECK_NE(CreateCsr<RiscVCounterCsrHigh<CheriotState>>( - state, csr_vec, "minstreth", RiscVCsrEnum::kMInstretH, state, - reinterpret_cast<RiscVCounterCsr<uint32_t, CheriotState> *>( - minstret)), - nullptr); - } + auto minstreth = CreateCsr<RiscVCounterCsrHigh<CheriotState>>( + state, csr_vec, "minstreth", RiscVCsrEnum::kMInstretH, state, + reinterpret_cast<RiscVCounterCsr<uint32_t, CheriotState> *>(minstret)); + CHECK_NE(minstreth, nullptr); // mcycle/mcycleh auto *mcycle = CreateCsr<RiscVCounterCsr<T, CheriotState>>( state, csr_vec, "mcycle", RiscVCsrEnum::kMCycle, state); CHECK_NE(mcycle, nullptr); - if (sizeof(T) == sizeof(uint32_t)) { - CHECK_NE(CreateCsr<RiscVCounterCsrHigh<CheriotState>>( - state, csr_vec, "mcycleh", RiscVCsrEnum::kMCycleH, state, - reinterpret_cast<RiscVCounterCsr<uint32_t, CheriotState> *>( - mcycle)), - nullptr); - } + auto *mcycleh = CreateCsr<RiscVCounterCsrHigh<CheriotState>>( + state, csr_vec, "mcycleh", RiscVCsrEnum::kMCycleH, state, + reinterpret_cast<RiscVCounterCsr<uint32_t, CheriotState> *>(mcycle)); + CHECK_NE(mcycleh, nullptr); // Stack high water mark CSRs. Mshwm gets updated automatically during // execution. mshwm @@ -241,7 +235,24 @@ // None in CHERIoT. // User level CSRs - // None in CHERIoT. + // instret/instreth + CHECK_NE(CreateCsr<RiscVShadowCsr<T>>( + state, csr_vec, "instret", RiscVCsrEnum ::kInstret, + std::numeric_limits<T>::max(), 0, state, minstret), + nullptr); + CHECK_NE(CreateCsr<RiscVShadowCsr<T>>( + state, csr_vec, "instreth", RiscVCsrEnum::kInstretH, + std::numeric_limits<T>::max(), 0, state, minstreth), + nullptr); + // cycle/cycleh + CHECK_NE(CreateCsr<RiscVShadowCsr<T>>( + state, csr_vec, "cycle", RiscVCsrEnum::kCycle, + std::numeric_limits<T>::max(), 0, state, mcycle), + nullptr); + CHECK_NE(CreateCsr<RiscVShadowCsr<T>>( + state, csr_vec, "cycleh", RiscVCsrEnum::kCycleH, + std::numeric_limits<T>::max(), 0, state, mcycleh), + nullptr); // PMP CSRs state->pmp_ = new RiscVPmp(state);