aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorYunhui Cui <cuiyunhui@bytedance.com>2025-02-26 14:32:04 +0800
committerAlexandre Ghiti <alexghiti@rivosinc.com>2025-03-18 12:35:14 +0000
commitde70b532f91bbcfa9f4100f1a2cd62810c799239 (patch)
tree33a2d525f12800104ccde3748ab3c31ec45fb954
parentMerge patch series "riscv: Add bfloat16 instruction support" (diff)
downloadwireguard-linux-de70b532f91bbcfa9f4100f1a2cd62810c799239.tar.xz
wireguard-linux-de70b532f91bbcfa9f4100f1a2cd62810c799239.zip
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>
-rw-r--r--arch/riscv/kernel/cpufeature.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 0ff97cf4dc2a..ef34622902bf 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -32,6 +32,7 @@
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
static bool any_cpu_has_zicboz;
+static bool any_cpu_has_zicbom;
unsigned long elf_hwcap __read_mostly;
@@ -100,6 +101,8 @@ static int riscv_ext_zicbom_validate(const struct riscv_isa_ext_data *data,
pr_err("Zicbom disabled as cbom-block-size present, but is not a power-of-2\n");
return -EINVAL;
}
+
+ any_cpu_has_zicbom = true;
return 0;
}
@@ -1036,6 +1039,11 @@ void __init riscv_user_isa_enable(void)
current->thread.envcfg |= ENVCFG_CBZE;
else if (any_cpu_has_zicboz)
pr_warn("Zicboz disabled as it is unavailable on some harts\n");
+
+ if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOM))
+ current->thread.envcfg |= ENVCFG_CBCFE;
+ else if (any_cpu_has_zicbom)
+ pr_warn("Zicbom disabled as it is unavailable on some harts\n");
}
#ifdef CONFIG_RISCV_ALTERNATIVE