[PATCH 11/11] riscv: Add option to disable writes to mcounteren
Sean Anderson
seanga2 at gmail.com
Tue Dec 31 23:51:34 CET 2019
On the kendryte k210, writes to mcounteren result in an illegal instruction
exception.
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---
arch/riscv/cpu/cpu.c | 2 ++
board/sipeed/maix/Kconfig | 1 +
configs/sipeed_maix_bitm_config | 1 +
3 files changed, 4 insertions(+)
diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index e457f6acbf..df9eae663c 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -89,7 +89,9 @@ int arch_cpu_init_dm(void)
* Enable perf counters for cycle, time,
* and instret counters only
*/
+#ifndef CONFIG_SYS_RISCV_NOCOUNTER
csr_write(CSR_MCOUNTEREN, GENMASK(2, 0));
+#endif
/* Disable paging */
if (supports_extension('s'))
diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
index 6a25086ef4..c456c47fb2 100644
--- a/board/sipeed/maix/Kconfig
+++ b/board/sipeed/maix/Kconfig
@@ -37,6 +37,7 @@ config BOARD_SPECIFIC_OPTIONS
select SIFIVE_SERIAL
select ARCH_DEFAULT_RV64I
select ENV_IS_NOWHERE
+ select SYS_RISCV_NOCOUNTER
imply SIFIVE_CLINT
imply K210_SYSCTL
imply CLK_K210
diff --git a/configs/sipeed_maix_bitm_config b/configs/sipeed_maix_bitm_config
index 0088748ae0..73075e3016 100644
--- a/configs/sipeed_maix_bitm_config
+++ b/configs/sipeed_maix_bitm_config
@@ -30,6 +30,7 @@ CONFIG_RISCV_ISA_A=y
CONFIG_SIFIVE_CLINT=y
CONFIG_K210_SYSCTL=y
CONFIG_SHOW_REGS=y
+CONFIG_SYS_RISCV_NOCOUNTER=y
CONFIG_STACK_SIZE_SHIFT=14
CONFIG_LOCALVERSION=""
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
--
2.24.1
More information about the U-Boot
mailing list