Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RISC-V: Enable cbo.clean/flush in usermode

Enabling cbo.clean and cbo.flush in user mode makes it more
convenient to manage the cache state and achieve better performance.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Link: https://lore.kernel.org/r/20250226063206.71216-2-cuiyunhui@bytedance.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>

authored by

Yunhui Cui and committed by
Alexandre Ghiti
de70b532 2f2cd9f3

+8
+8
arch/riscv/kernel/cpufeature.c
··· 32 32 #define NUM_ALPHA_EXTS ('z' - 'a' + 1) 33 33 34 34 static bool any_cpu_has_zicboz; 35 + static bool any_cpu_has_zicbom; 35 36 36 37 unsigned long elf_hwcap __read_mostly; 37 38 ··· 101 100 pr_err("Zicbom disabled as cbom-block-size present, but is not a power-of-2\n"); 102 101 return -EINVAL; 103 102 } 103 + 104 + any_cpu_has_zicbom = true; 104 105 return 0; 105 106 } 106 107 ··· 1039 1036 current->thread.envcfg |= ENVCFG_CBZE; 1040 1037 else if (any_cpu_has_zicboz) 1041 1038 pr_warn("Zicboz disabled as it is unavailable on some harts\n"); 1039 + 1040 + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOM)) 1041 + current->thread.envcfg |= ENVCFG_CBCFE; 1042 + else if (any_cpu_has_zicbom) 1043 + pr_warn("Zicbom disabled as it is unavailable on some harts\n"); 1042 1044 } 1043 1045 1044 1046 #ifdef CONFIG_RISCV_ALTERNATIVE