Skip to content

Commit 1e74835

Browse files
AndybnACTpalmer-dabbelt
authored andcommitted
riscv: cpufeature: add zve32[xf] and zve64[xfd] isa detection
Multiple Vector subextensions are added. Also, the patch takes care of the dependencies of Vector subextensions by macro expansions. So, if some "embedded" platform only reports "zve64f" on the ISA string, the parser is able to expand it to zve32x zve32f zve64x and zve64f. Signed-off-by: Andy Chiu <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 037df29 commit 1e74835

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

arch/riscv/include/asm/hwcap.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
#define RISCV_ISA_EXT_ZTSO 72
8282
#define RISCV_ISA_EXT_ZACAS 73
8383
#define RISCV_ISA_EXT_XANDESPMU 74
84+
#define RISCV_ISA_EXT_ZVE32X 75
85+
#define RISCV_ISA_EXT_ZVE32F 76
86+
#define RISCV_ISA_EXT_ZVE64X 77
87+
#define RISCV_ISA_EXT_ZVE64F 78
88+
#define RISCV_ISA_EXT_ZVE64D 79
8489

8590
#define RISCV_ISA_EXT_XLINUXENVCFG 127
8691

arch/riscv/kernel/cpufeature.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,40 @@ static const unsigned int riscv_zvbb_exts[] = {
188188
RISCV_ISA_EXT_ZVKB
189189
};
190190

191+
#define RISCV_ISA_EXT_ZVE64F_IMPLY_LIST \
192+
RISCV_ISA_EXT_ZVE64X, \
193+
RISCV_ISA_EXT_ZVE32F, \
194+
RISCV_ISA_EXT_ZVE32X
195+
196+
#define RISCV_ISA_EXT_ZVE64D_IMPLY_LIST \
197+
RISCV_ISA_EXT_ZVE64F, \
198+
RISCV_ISA_EXT_ZVE64F_IMPLY_LIST
199+
200+
#define RISCV_ISA_EXT_V_IMPLY_LIST \
201+
RISCV_ISA_EXT_ZVE64D, \
202+
RISCV_ISA_EXT_ZVE64D_IMPLY_LIST
203+
204+
static const unsigned int riscv_zve32f_exts[] = {
205+
RISCV_ISA_EXT_ZVE32X
206+
};
207+
208+
static const unsigned int riscv_zve64f_exts[] = {
209+
RISCV_ISA_EXT_ZVE64F_IMPLY_LIST
210+
};
211+
212+
static const unsigned int riscv_zve64d_exts[] = {
213+
RISCV_ISA_EXT_ZVE64D_IMPLY_LIST
214+
};
215+
216+
static const unsigned int riscv_v_exts[] = {
217+
RISCV_ISA_EXT_V_IMPLY_LIST
218+
};
219+
220+
static const unsigned int riscv_zve64x_exts[] = {
221+
RISCV_ISA_EXT_ZVE32X,
222+
RISCV_ISA_EXT_ZVE64X
223+
};
224+
191225
/*
192226
* While the [ms]envcfg CSRs were not defined until version 1.12 of the RISC-V
193227
* privileged ISA, the existence of the CSRs is implied by any extension which
@@ -245,7 +279,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
245279
__RISCV_ISA_EXT_DATA(d, RISCV_ISA_EXT_d),
246280
__RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q),
247281
__RISCV_ISA_EXT_DATA(c, RISCV_ISA_EXT_c),
248-
__RISCV_ISA_EXT_DATA(v, RISCV_ISA_EXT_v),
282+
__RISCV_ISA_EXT_SUPERSET(v, RISCV_ISA_EXT_v, riscv_v_exts),
249283
__RISCV_ISA_EXT_DATA(h, RISCV_ISA_EXT_h),
250284
__RISCV_ISA_EXT_SUPERSET(zicbom, RISCV_ISA_EXT_ZICBOM, riscv_xlinuxenvcfg_exts),
251285
__RISCV_ISA_EXT_SUPERSET(zicboz, RISCV_ISA_EXT_ZICBOZ, riscv_xlinuxenvcfg_exts),
@@ -280,6 +314,11 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
280314
__RISCV_ISA_EXT_DATA(ztso, RISCV_ISA_EXT_ZTSO),
281315
__RISCV_ISA_EXT_SUPERSET(zvbb, RISCV_ISA_EXT_ZVBB, riscv_zvbb_exts),
282316
__RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC),
317+
__RISCV_ISA_EXT_SUPERSET(zve32f, RISCV_ISA_EXT_ZVE32F, riscv_zve32f_exts),
318+
__RISCV_ISA_EXT_DATA(zve32x, RISCV_ISA_EXT_ZVE32X),
319+
__RISCV_ISA_EXT_SUPERSET(zve64d, RISCV_ISA_EXT_ZVE64D, riscv_zve64d_exts),
320+
__RISCV_ISA_EXT_SUPERSET(zve64f, RISCV_ISA_EXT_ZVE64F, riscv_zve64f_exts),
321+
__RISCV_ISA_EXT_SUPERSET(zve64x, RISCV_ISA_EXT_ZVE64X, riscv_zve64x_exts),
283322
__RISCV_ISA_EXT_DATA(zvfh, RISCV_ISA_EXT_ZVFH),
284323
__RISCV_ISA_EXT_DATA(zvfhmin, RISCV_ISA_EXT_ZVFHMIN),
285324
__RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),

0 commit comments

Comments
 (0)