Skip to content

Commit 3fb3f71

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Fix enabling cbo.zero when running in M-mode
When the kernel is running in M-mode, the CBZE bit must be set in the menvcfg CSR, not in senvcfg. Cc: <stable@vger.kernel.org> Fixes: 43c16d5 ("RISC-V: Enable cbo.zero in usermode") Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20240228065559.3434837-2-samuel.holland@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 6613476 commit 3fb3f71

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/riscv/include/asm/csr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
# define CSR_STATUS CSR_MSTATUS
425425
# define CSR_IE CSR_MIE
426426
# define CSR_TVEC CSR_MTVEC
427+
# define CSR_ENVCFG CSR_MENVCFG
427428
# define CSR_SCRATCH CSR_MSCRATCH
428429
# define CSR_EPC CSR_MEPC
429430
# define CSR_CAUSE CSR_MCAUSE
@@ -448,6 +449,7 @@
448449
# define CSR_STATUS CSR_SSTATUS
449450
# define CSR_IE CSR_SIE
450451
# define CSR_TVEC CSR_STVEC
452+
# define CSR_ENVCFG CSR_SENVCFG
451453
# define CSR_SCRATCH CSR_SSCRATCH
452454
# define CSR_EPC CSR_SEPC
453455
# define CSR_CAUSE CSR_SCAUSE

arch/riscv/kernel/cpufeature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ arch_initcall(check_unaligned_access_all_cpus);
950950
void riscv_user_isa_enable(void)
951951
{
952952
if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_ZICBOZ))
953-
csr_set(CSR_SENVCFG, ENVCFG_CBZE);
953+
csr_set(CSR_ENVCFG, ENVCFG_CBZE);
954954
}
955955

956956
#ifdef CONFIG_RISCV_ALTERNATIVE

0 commit comments

Comments
 (0)