Skip to content

Commit 07edc32

Browse files
ConchuODpalmer-dabbelt
authored andcommitted
RISC-V: always report presence of extensions formerly part of the base ISA
Of these four extensions, two were part of the base ISA when the port was written and are required by the kernel. The other two are implied when `i` is in riscv,isa on DT systems. There's not much that userspace can do with this extra information, but there is no harm in reporting an ISA string that closer resembles the current versions of the specifications either. Signed-off-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/20230607-nest-collision-5796b6be8be6@spud Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1e5cae9 commit 07edc32

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

arch/riscv/include/asm/hwcap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#define RISCV_ISA_EXT_ZICBOZ 34
4747
#define RISCV_ISA_EXT_SMAIA 35
4848
#define RISCV_ISA_EXT_SSAIA 36
49+
#define RISCV_ISA_EXT_ZICNTR 37
50+
#define RISCV_ISA_EXT_ZICSR 38
51+
#define RISCV_ISA_EXT_ZIFENCEI 39
52+
#define RISCV_ISA_EXT_ZIHPM 40
4953

5054
#define RISCV_ISA_EXT_MAX 64
5155
#define RISCV_ISA_EXT_NAME_LEN_MAX 32

arch/riscv/kernel/cpu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ arch_initcall(riscv_cpuinfo_init);
208208
static struct riscv_isa_ext_data isa_ext_arr[] = {
209209
__RISCV_ISA_EXT_DATA(zicbom, RISCV_ISA_EXT_ZICBOM),
210210
__RISCV_ISA_EXT_DATA(zicboz, RISCV_ISA_EXT_ZICBOZ),
211+
__RISCV_ISA_EXT_DATA(zicntr, RISCV_ISA_EXT_ZICNTR),
212+
__RISCV_ISA_EXT_DATA(zicsr, RISCV_ISA_EXT_ZICSR),
213+
__RISCV_ISA_EXT_DATA(zifencei, RISCV_ISA_EXT_ZIFENCEI),
211214
__RISCV_ISA_EXT_DATA(zihintpause, RISCV_ISA_EXT_ZIHINTPAUSE),
215+
__RISCV_ISA_EXT_DATA(zihpm, RISCV_ISA_EXT_ZIHPM),
212216
__RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB),
213217
__RISCV_ISA_EXT_DATA(smaia, RISCV_ISA_EXT_SMAIA),
214218
__RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA),

arch/riscv/kernel/cpufeature.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ void __init riscv_fill_hwcap(void)
311311
#undef SET_ISA_EXT_MAP
312312
}
313313

314+
/*
315+
* Linux requires the following extensions, so we may as well
316+
* always set them.
317+
*/
318+
set_bit(RISCV_ISA_EXT_ZICSR, this_isa);
319+
set_bit(RISCV_ISA_EXT_ZIFENCEI, this_isa);
320+
321+
/*
322+
* These ones were as they were part of the base ISA when the
323+
* port & dt-bindings were upstreamed, and so can be set
324+
* unconditionally where `i` is in riscv,isa on DT systems.
325+
*/
326+
if (acpi_disabled) {
327+
set_bit(RISCV_ISA_EXT_ZICNTR, this_isa);
328+
set_bit(RISCV_ISA_EXT_ZIHPM, this_isa);
329+
}
330+
314331
/*
315332
* All "okay" hart should have same isa. Set HWCAP based on
316333
* common capabilities of every "okay" hart, in case they don't

0 commit comments

Comments
 (0)