Skip to content

Commit fb0ff0a

Browse files
jones-drewpalmer-dabbelt
authored andcommitted
RISC-V: Introduce riscv_isa_extension_check
Currently any isa extension found in the isa string is set in the isa bitmap. An isa extension set in the bitmap indicates that the extension is present and may be used (a.k.a is enabled). However, when an extension cannot be used due to missing dependencies or errata it should not be added to the bitmap. Introduce a function where additional checks may be placed in order to determine if an extension should be enabled or not. Note, the checks may simply indicate an issue with the DT, but, since extensions may be used in early boot, it's not always possible to simply produce an error at the point the issue is determined. It's best to keep the extension disabled and produce an error. No functional change intended, as the function is only introduced and always returns true. A later patch will provide checks for an isa extension. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 7268555 commit fb0ff0a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

arch/riscv/kernel/cpufeature.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit)
6868
}
6969
EXPORT_SYMBOL_GPL(__riscv_isa_extension_available);
7070

71+
static bool riscv_isa_extension_check(int id)
72+
{
73+
return true;
74+
}
75+
7176
void __init riscv_fill_hwcap(void)
7277
{
7378
struct device_node *node;
@@ -189,7 +194,8 @@ void __init riscv_fill_hwcap(void)
189194
#define SET_ISA_EXT_MAP(name, bit) \
190195
do { \
191196
if ((ext_end - ext == sizeof(name) - 1) && \
192-
!memcmp(ext, name, sizeof(name) - 1)) \
197+
!memcmp(ext, name, sizeof(name) - 1) && \
198+
riscv_isa_extension_check(bit)) \
193199
set_bit(bit, this_isa); \
194200
} while (false) \
195201

@@ -198,8 +204,10 @@ void __init riscv_fill_hwcap(void)
198204
if (!ext_long) {
199205
int nr = *ext - 'a';
200206

201-
this_hwcap |= isa2hwcap[nr];
202-
set_bit(nr, this_isa);
207+
if (riscv_isa_extension_check(nr)) {
208+
this_hwcap |= isa2hwcap[nr];
209+
set_bit(nr, this_isa);
210+
}
203211
} else {
204212
SET_ISA_EXT_MAP("sscofpmf", RISCV_ISA_EXT_SSCOFPMF);
205213
SET_ISA_EXT_MAP("svpbmt", RISCV_ISA_EXT_SVPBMT);

0 commit comments

Comments
 (0)