arch-riscv: Implement MHARTID CSR
authorAlec Roelke <alec.roelke@gmail.com>
Sun, 3 Mar 2019 20:13:51 +0000 (15:13 -0500)
committerAlec Roelke <alec.roelke@gmail.com>
Sat, 4 May 2019 04:37:19 +0000 (04:37 +0000)
This patch implements the MHARTID CSR by intercepting attempts to access
it, similar to the way accesses to the performance counters are
intercepted, to return the thread's context ID.

Change-Id: Ie14a31036fbe0e49fb3347ac0c3c508d9427a10d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/16988
Reviewed-by: Alec Roelke <alec.roelke@gmail.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Alec Roelke <alec.roelke@gmail.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/riscv/isa.cc

index 4e36d55968d4f98e5a3441f5f21e459edc488ab7..cc86752ab4e6eaf068314cac8bea3be91be6f1d2 100644 (file)
@@ -112,6 +112,8 @@ RegVal
 ISA::readMiscReg(int misc_reg, ThreadContext *tc)
 {
     switch (misc_reg) {
+      case MISCREG_HARTID:
+        return tc->contextId();
       case MISCREG_CYCLE:
         if (hpmCounterEnabled(MISCREG_CYCLE)) {
             DPRINTF(RiscvMisc, "Cycle counter at: %llu.\n",