Skip to content

Commit f352a28

Browse files
Merge patch series "riscv: report more ISA extensions through hwprobe"
Clément Léger <cleger@rivosinc.com> says: In order to be able to gather more information about the supported ISA extensions from userspace using the hwprobe syscall, add more ISA extensions report. This series adds the following ISA extensions parsing support: - Zfh[min] - Zvfh[min] - Zihintntl - Zbc - Zvbb - Zvbc - Zvkb - Zvkg - Zvkned - Zvknh[ab] - Zvksed - Zvksh - Zvkn - Zvknc - Zvkng - Zvks - Zvksc - Zvksg - Zvkt - Zfa - Zbkb - Zbkc - Zbkx - Zknd - Zkne - Zknh - Zkr - Zksed - Zksh - Zkt Some of these extensions are actually shorthands for other "sub" extensions. This series includes a patch from Conor/Evan that adds a way to specify such "bundled" extensions. When exposing these bundled extensions to userspace through hwprobe, only the "sub" extensions are exposed. In order to test it, one can use qemu and the small hwprobe utility provided[1]. Run qemu by specifying additional ISA extensions, for instance: $ qemu-system-riscv64 -cpu rv64,v=true,zk=true,zvksh=true,zvkned=true <whatever options you want> Then, run hwprobe: $ ./hwprobe Base system ISA: - IMA_FD - C - V Supported extensions: - Zba - Zbb - Zbs - Zbc - Zbkb - Zbkc - Zbkx - Zknd - Zkne - Zknh - Zkt - Zvkned - Zvksh - Zihintntl - Zfa * b4-shazam-merge: dt-bindings: riscv: add Zfa ISA extension description riscv: hwprobe: export Zfa ISA extension riscv: add ISA extension parsing for Zfa dt-bindings: riscv: add Zvfh[min] ISA extension description riscv: hwprobe: export Zvfh[min] ISA extensions riscv: add ISA extension parsing for Zvfh[min] dt-bindings: riscv: add Zihintntl ISA extension description riscv: hwprobe: export Zhintntl ISA extension riscv: add ISA extension parsing for Zihintntl dt-bindings: riscv: add Zfh[min] ISA extensions description riscv: hwprobe: export Zfh[min] ISA extensions riscv: add ISA extension parsing for Zfh/Zfh[min] dt-bindings: riscv: add vector crypto ISA extensions description riscv: hwprobe: export vector crypto ISA extensions riscv: add ISA extension parsing for vector crypto dt-bindings: riscv: add scalar crypto ISA extensions description riscv: hwprobe: add support for scalar crypto ISA extensions riscv: add ISA extension parsing for scalar crypto riscv: hwprobe: export missing Zbc ISA extension riscv: add ISA extension parsing for Zbc Link: https://lore.kernel.org/r/20231114141256.126749-1-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 parents b85ea95 + 9726acf commit f352a28

7 files changed

Lines changed: 551 additions & 25 deletions

File tree

Documentation/arch/riscv/hwprobe.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,87 @@ The following keys are defined:
8080
* :c:macro:`RISCV_HWPROBE_EXT_ZICBOZ`: The Zicboz extension is supported, as
8181
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
8282

83+
* :c:macro:`RISCV_HWPROBE_EXT_ZBC` The Zbc extension is supported, as defined
84+
in version 1.0 of the Bit-Manipulation ISA extensions.
85+
86+
* :c:macro:`RISCV_HWPROBE_EXT_ZBKB` The Zbkb extension is supported, as
87+
defined in version 1.0 of the Scalar Crypto ISA extensions.
88+
89+
* :c:macro:`RISCV_HWPROBE_EXT_ZBKC` The Zbkc extension is supported, as
90+
defined in version 1.0 of the Scalar Crypto ISA extensions.
91+
92+
* :c:macro:`RISCV_HWPROBE_EXT_ZBKX` The Zbkx extension is supported, as
93+
defined in version 1.0 of the Scalar Crypto ISA extensions.
94+
95+
* :c:macro:`RISCV_HWPROBE_EXT_ZKND` The Zknd extension is supported, as
96+
defined in version 1.0 of the Scalar Crypto ISA extensions.
97+
98+
* :c:macro:`RISCV_HWPROBE_EXT_ZKNE` The Zkne extension is supported, as
99+
defined in version 1.0 of the Scalar Crypto ISA extensions.
100+
101+
* :c:macro:`RISCV_HWPROBE_EXT_ZKNH` The Zknh extension is supported, as
102+
defined in version 1.0 of the Scalar Crypto ISA extensions.
103+
104+
* :c:macro:`RISCV_HWPROBE_EXT_ZKSED` The Zksed extension is supported, as
105+
defined in version 1.0 of the Scalar Crypto ISA extensions.
106+
107+
* :c:macro:`RISCV_HWPROBE_EXT_ZKSH` The Zksh extension is supported, as
108+
defined in version 1.0 of the Scalar Crypto ISA extensions.
109+
110+
* :c:macro:`RISCV_HWPROBE_EXT_ZKT` The Zkt extension is supported, as defined
111+
in version 1.0 of the Scalar Crypto ISA extensions.
112+
113+
* :c:macro:`RISCV_HWPROBE_EXT_ZVBB`: The Zvbb extension is supported as
114+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
115+
116+
* :c:macro:`RISCV_HWPROBE_EXT_ZVBC`: The Zvbc extension is supported as
117+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
118+
119+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKB`: The Zvkb extension is supported as
120+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
121+
122+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKG`: The Zvkg extension is supported as
123+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
124+
125+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKNED`: The Zvkned extension is supported as
126+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
127+
128+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKNHA`: The Zvknha extension is supported as
129+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
130+
131+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKNHB`: The Zvknhb extension is supported as
132+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
133+
134+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKSED`: The Zvksed extension is supported as
135+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
136+
137+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKSH`: The Zvksh extension is supported as
138+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
139+
140+
* :c:macro:`RISCV_HWPROBE_EXT_ZVKT`: The Zvkt extension is supported as
141+
defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
142+
143+
* :c:macro:`RISCV_HWPROBE_EXT_ZFH`: The Zfh extension version 1.0 is supported
144+
as defined in the RISC-V ISA manual.
145+
146+
* :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is
147+
supported as defined in the RISC-V ISA manual.
148+
149+
* :c:macro:`RISCV_HWPROBE_EXT_ZIHINTNTL`: The Zihintntl extension version 1.0
150+
is supported as defined in the RISC-V ISA manual.
151+
152+
* :c:macro:`RISCV_HWPROBE_EXT_ZVFH`: The Zvfh extension is supported as
153+
defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
154+
("Remove draft warnings from Zvfh[min]").
155+
156+
* :c:macro:`RISCV_HWPROBE_EXT_ZVFHMIN`: The Zvfhmin extension is supported as
157+
defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
158+
("Remove draft warnings from Zvfh[min]").
159+
160+
* :c:macro:`RISCV_HWPROBE_EXT_ZFA`: The Zfa extension is supported as
161+
defined in the RISC-V ISA manual starting from commit 056b6ff467c7
162+
("Zfa is ratified").
163+
83164
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
84165
information about the selected set of processors.
85166

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,111 @@ properties:
190190
multiplication as ratified at commit 6d33919 ("Merge pull request
191191
#158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
192192
193+
- const: zbkb
194+
description:
195+
The standard Zbkb bitmanip instructions for cryptography as ratified
196+
in version 1.0 of RISC-V Cryptography Extensions Volume I
197+
specification.
198+
199+
- const: zbkc
200+
description:
201+
The standard Zbkc carry-less multiply instructions as ratified
202+
in version 1.0 of RISC-V Cryptography Extensions Volume I
203+
specification.
204+
205+
- const: zbkx
206+
description:
207+
The standard Zbkx crossbar permutation instructions as ratified
208+
in version 1.0 of RISC-V Cryptography Extensions Volume I
209+
specification.
210+
193211
- const: zbs
194212
description: |
195213
The standard Zbs bit-manipulation extension for single-bit
196214
instructions as ratified at commit 6d33919 ("Merge pull request #158
197215
from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip.
198216
217+
- const: zfa
218+
description:
219+
The standard Zfa extension for additional floating point
220+
instructions, as ratified in commit 056b6ff ("Zfa is ratified") of
221+
riscv-isa-manual.
222+
223+
- const: zfh
224+
description:
225+
The standard Zfh extension for 16-bit half-precision binary
226+
floating-point instructions, as ratified in commit 64074bc ("Update
227+
version numbers for Zfh/Zfinx") of riscv-isa-manual.
228+
229+
- const: zfhmin
230+
description:
231+
The standard Zfhmin extension which provides minimal support for
232+
16-bit half-precision binary floating-point instructions, as ratified
233+
in commit 64074bc ("Update version numbers for Zfh/Zfinx") of
234+
riscv-isa-manual.
235+
236+
- const: zk
237+
description:
238+
The standard Zk Standard Scalar cryptography extension as ratified
239+
in version 1.0 of RISC-V Cryptography Extensions Volume I
240+
specification.
241+
242+
- const: zkn
243+
description:
244+
The standard Zkn NIST algorithm suite extensions as ratified in
245+
version 1.0 of RISC-V Cryptography Extensions Volume I
246+
specification.
247+
248+
- const: zknd
249+
description: |
250+
The standard Zknd for NIST suite: AES decryption instructions as
251+
ratified in version 1.0 of RISC-V Cryptography Extensions Volume I
252+
specification.
253+
254+
- const: zkne
255+
description: |
256+
The standard Zkne for NIST suite: AES encryption instructions as
257+
ratified in version 1.0 of RISC-V Cryptography Extensions Volume I
258+
specification.
259+
260+
- const: zknh
261+
description: |
262+
The standard Zknh for NIST suite: hash function instructions as
263+
ratified in version 1.0 of RISC-V Cryptography Extensions Volume I
264+
specification.
265+
266+
- const: zkr
267+
description:
268+
The standard Zkr entropy source extension as ratified in version
269+
1.0 of RISC-V Cryptography Extensions Volume I specification.
270+
This string being present means that the CSR associated to this
271+
extension is accessible at the privilege level to which that
272+
device-tree has been provided.
273+
274+
- const: zks
275+
description:
276+
The standard Zks ShangMi algorithm suite extensions as ratified in
277+
version 1.0 of RISC-V Cryptography Extensions Volume I
278+
specification.
279+
280+
- const: zksed
281+
description: |
282+
The standard Zksed for ShangMi suite: SM4 block cipher instructions
283+
as ratified in version 1.0 of RISC-V Cryptography Extensions
284+
Volume I specification.
285+
286+
- const: zksh
287+
description: |
288+
The standard Zksh for ShangMi suite: SM3 hash function instructions
289+
as ratified in version 1.0 of RISC-V Cryptography Extensions
290+
Volume I specification.
291+
292+
- const: zkt
293+
description:
294+
The standard Zkt for data independent execution latency as ratified
295+
in version 1.0 of RISC-V Cryptography Extensions Volume I
296+
specification.
297+
199298
- const: zicbom
200299
description:
201300
The standard Zicbom extension for base cache management operations as
@@ -246,6 +345,12 @@ properties:
246345
The standard Zihintpause extension for pause hints, as ratified in
247346
commit d8ab5c7 ("Zihintpause is ratified") of the riscv-isa-manual.
248347

348+
- const: zihintntl
349+
description:
350+
The standard Zihintntl extension for non-temporal locality hints, as
351+
ratified in commit 0dc91f5 ("Zihintntl is ratified") of the
352+
riscv-isa-manual.
353+
249354
- const: zihpm
250355
description:
251356
The standard Zihpm extension for hardware performance counters, as
@@ -258,5 +363,113 @@ properties:
258363
in commit 2e5236 ("Ztso is now ratified.") of the
259364
riscv-isa-manual.
260365

366+
- const: zvbb
367+
description:
368+
The standard Zvbb extension for vectored basic bit-manipulation
369+
instructions, as ratified in commit 56ed795 ("Update
370+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
371+
372+
- const: zvbc
373+
description:
374+
The standard Zvbc extension for vectored carryless multiplication
375+
instructions, as ratified in commit 56ed795 ("Update
376+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
377+
378+
- const: zvfh
379+
description:
380+
The standard Zvfh extension for vectored half-precision
381+
floating-point instructions, as ratified in commit e2ccd05
382+
("Remove draft warnings from Zvfh[min]") of riscv-v-spec.
383+
384+
- const: zvfhmin
385+
description:
386+
The standard Zvfhmin extension for vectored minimal half-precision
387+
floating-point instructions, as ratified in commit e2ccd05
388+
("Remove draft warnings from Zvfh[min]") of riscv-v-spec.
389+
390+
- const: zvkb
391+
description:
392+
The standard Zvkb extension for vector cryptography bit-manipulation
393+
instructions, as ratified in commit 56ed795 ("Update
394+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
395+
396+
- const: zvkg
397+
description:
398+
The standard Zvkg extension for vector GCM/GMAC instructions, as
399+
ratified in commit 56ed795 ("Update riscv-crypto-spec-vector.adoc")
400+
of riscv-crypto.
401+
402+
- const: zvkn
403+
description:
404+
The standard Zvkn extension for NIST algorithm suite instructions, as
405+
ratified in commit 56ed795 ("Update riscv-crypto-spec-vector.adoc")
406+
of riscv-crypto.
407+
408+
- const: zvknc
409+
description:
410+
The standard Zvknc extension for NIST algorithm suite with carryless
411+
multiply instructions, as ratified in commit 56ed795 ("Update
412+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
413+
414+
- const: zvkned
415+
description:
416+
The standard Zvkned extension for Vector AES block cipher
417+
instructions, as ratified in commit 56ed795 ("Update
418+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
419+
420+
- const: zvkng
421+
description:
422+
The standard Zvkng extension for NIST algorithm suite with GCM
423+
instructions, as ratified in commit 56ed795 ("Update
424+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
425+
426+
- const: zvknha
427+
description: |
428+
The standard Zvknha extension for NIST suite: vector SHA-2 secure,
429+
hash (SHA-256 only) instructions, as ratified in commit
430+
56ed795 ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto.
431+
432+
- const: zvknhb
433+
description: |
434+
The standard Zvknhb extension for NIST suite: vector SHA-2 secure,
435+
hash (SHA-256 and SHA-512) instructions, as ratified in commit
436+
56ed795 ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto.
437+
438+
- const: zvks
439+
description:
440+
The standard Zvks extension for ShangMi algorithm suite
441+
instructions, as ratified in commit 56ed795 ("Update
442+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
443+
444+
- const: zvksc
445+
description:
446+
The standard Zvksc extension for ShangMi algorithm suite with
447+
carryless multiplication instructions, as ratified in commit 56ed795
448+
("Update riscv-crypto-spec-vector.adoc") of riscv-crypto.
449+
450+
- const: zvksed
451+
description: |
452+
The standard Zvksed extension for ShangMi suite: SM4 block cipher
453+
instructions, as ratified in commit 56ed795 ("Update
454+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
455+
456+
- const: zvksh
457+
description: |
458+
The standard Zvksh extension for ShangMi suite: SM3 secure hash
459+
instructions, as ratified in commit 56ed795 ("Update
460+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
461+
462+
- const: zvksg
463+
description:
464+
The standard Zvksg extension for ShangMi algorithm suite with GCM
465+
instructions, as ratified in commit 56ed795 ("Update
466+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
467+
468+
- const: zvkt
469+
description:
470+
The standard Zvkt extension for vector data-independent execution
471+
latency, as ratified in commit 56ed795 ("Update
472+
riscv-crypto-spec-vector.adoc") of riscv-crypto.
473+
261474
additionalProperties: true
262475
...

arch/riscv/include/asm/cpufeature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct riscv_isa_ext_data {
5959
const unsigned int id;
6060
const char *name;
6161
const char *property;
62+
const unsigned int *subset_ext_ids;
63+
const unsigned int subset_ext_size;
6264
};
6365

6466
extern const struct riscv_isa_ext_data riscv_isa_ext[];
@@ -67,7 +69,7 @@ extern bool riscv_isa_fallback;
6769

6870
unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap);
6971

70-
bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit);
72+
bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned int bit);
7173
#define riscv_isa_extension_available(isa_bitmap, ext) \
7274
__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext)
7375

arch/riscv/include/asm/hwcap.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,36 @@
5757
#define RISCV_ISA_EXT_ZIHPM 42
5858
#define RISCV_ISA_EXT_SMSTATEEN 43
5959
#define RISCV_ISA_EXT_ZICOND 44
60+
#define RISCV_ISA_EXT_ZBC 45
61+
#define RISCV_ISA_EXT_ZBKB 46
62+
#define RISCV_ISA_EXT_ZBKC 47
63+
#define RISCV_ISA_EXT_ZBKX 48
64+
#define RISCV_ISA_EXT_ZKND 49
65+
#define RISCV_ISA_EXT_ZKNE 50
66+
#define RISCV_ISA_EXT_ZKNH 51
67+
#define RISCV_ISA_EXT_ZKR 52
68+
#define RISCV_ISA_EXT_ZKSED 53
69+
#define RISCV_ISA_EXT_ZKSH 54
70+
#define RISCV_ISA_EXT_ZKT 55
71+
#define RISCV_ISA_EXT_ZVBB 56
72+
#define RISCV_ISA_EXT_ZVBC 57
73+
#define RISCV_ISA_EXT_ZVKB 58
74+
#define RISCV_ISA_EXT_ZVKG 59
75+
#define RISCV_ISA_EXT_ZVKNED 60
76+
#define RISCV_ISA_EXT_ZVKNHA 61
77+
#define RISCV_ISA_EXT_ZVKNHB 62
78+
#define RISCV_ISA_EXT_ZVKSED 63
79+
#define RISCV_ISA_EXT_ZVKSH 64
80+
#define RISCV_ISA_EXT_ZVKT 65
81+
#define RISCV_ISA_EXT_ZFH 66
82+
#define RISCV_ISA_EXT_ZFHMIN 67
83+
#define RISCV_ISA_EXT_ZIHINTNTL 68
84+
#define RISCV_ISA_EXT_ZVFH 69
85+
#define RISCV_ISA_EXT_ZVFHMIN 70
86+
#define RISCV_ISA_EXT_ZFA 71
6087

61-
#define RISCV_ISA_EXT_MAX 64
88+
#define RISCV_ISA_EXT_MAX 128
89+
#define RISCV_ISA_EXT_INVALID U32_MAX
6290

6391
#ifdef CONFIG_RISCV_M_MODE
6492
#define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SMAIA

0 commit comments

Comments
 (0)