Skip to content

Commit de70b53

Browse files
cuiyunhuiAlexandre Ghiti
authored andcommitted
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 <[email protected]> Signed-off-by: Yunhui Cui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]>
1 parent 2f2cd9f commit de70b53

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
3333

3434
static bool any_cpu_has_zicboz;
35+
static bool any_cpu_has_zicbom;
3536

3637
unsigned long elf_hwcap __read_mostly;
3738

@@ -100,6 +101,8 @@ static int riscv_ext_zicbom_validate(const struct riscv_isa_ext_data *data,
100101
pr_err("Zicbom disabled as cbom-block-size present, but is not a power-of-2\n");
101102
return -EINVAL;
102103
}
104+
105+
any_cpu_has_zicbom = true;
103106
return 0;
104107
}
105108

@@ -1036,6 +1039,11 @@ void __init riscv_user_isa_enable(void)
10361039
current->thread.envcfg |= ENVCFG_CBZE;
10371040
else if (any_cpu_has_zicboz)
10381041
pr_warn("Zicboz disabled as it is unavailable on some harts\n");
1042+
1043+
if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOM))
1044+
current->thread.envcfg |= ENVCFG_CBCFE;
1045+
else if (any_cpu_has_zicbom)
1046+
pr_warn("Zicbom disabled as it is unavailable on some harts\n");
10391047
}
10401048

10411049
#ifdef CONFIG_RISCV_ALTERNATIVE

0 commit comments

Comments
 (0)