From 0c2cba9dc0c3ef95dd41427da9652c79511800cf Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Mon, 19 Dec 2016 09:06:00 -0800 Subject: [PATCH] UPSTREAM: riscv: enable counters via m[us]counteren The user and supervisor counters could not be safely enabled before as the register numbers were not finalized. Now that everyone agrees, we can enable them. Until we are sure the toolchains are caught up, we use the hardcode name with the register names in comments. As soon as toolchains settle down we'll do one more pass and convert to the symbolic names. Tested on lowrisc bitstream and SPIKE simulator. BUG=None BRANCH=None TEST=None Signed-off-by: Ronald G. Minnich Reviewed-on: https://review.coreboot.org/17920 Tested-by: build bot (Jenkins) Reviewed-by: Alex Bradbury Reviewed-by: Jonathan Neuschfer Reviewed-by: Andrew Waterman Change-Id: I21fe5cac44fafe4b7806e004c179aa27541be4b6 Reviewed-on: https://chromium-review.googlesource.com/422950 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/arch/riscv/virtual_memory.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/arch/riscv/virtual_memory.c b/src/arch/riscv/virtual_memory.c index aceb72eebd..2c440d24aa 100644 --- a/src/arch/riscv/virtual_memory.c +++ b/src/arch/riscv/virtual_memory.c @@ -310,14 +310,12 @@ void mstatus_init(void) set_csr(medeleg, delegate); - /* Enable all user/supervisor-mode counters */ - /* We'll turn these on once lowrisc gets their bitstream up to - * 1.9. Right now there's no agreement on the values for these - * architectural registers. - */ - // write_csr(mscounteren, 0b111); - // write_csr(mucounteren, 0b111); - - // for SPIKE: - // write_csr(/*mscounteren*/0x321, 0b111); + // Enable all user/supervisor-mode counters using + // v1.9.1 register addresses. + // They moved from the earlier spec. + // Until we trust our toolchain use the hardcoded constants. + // These were in flux and people who get the older toolchain + // will have difficult-to-debug failures. + write_csr(/*mucounteren*/0x320, 7); + write_csr(/*mscounteren*/0x321, 7); }