riscv: report more ISA extensions through hwprobe
Subsystems (3)
v2 cover riscv: report more ISA extensions through hwprobe
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_dump:
$ ./hwprobe_dump Base system ISA: - IMA_FD - C - V Supported extensions: - Zba - Zbb - Zbs - Zbc - Zbkb - Zbkc - Zbkx - Zknd - Zkne - Zknh - Zkt - Zvkned - Zvksh - Zihintntl - Zfa
---
Changes in V2:
- Fix typo in first commit title (fatorize->factorize)
- Add Zfa support
- Fix missing uppercase for Zvkt naming in dt-bindings
- Add Conor Acked-by on dt-bindings commits
- Add scalar crypto support from Conor/Evan.
- Use reporting of bunbled extensions for vector crypto
Clément Léger (18):
riscv: hwprobe: factorize hwprobe ISA extension reporting
riscv: hwprobe: add support for scalar crypto ISA extensions
dt-bindings: riscv: add scalar crypto ISA extensions description
riscv: add ISA extension parsing for vector crypto extensions
riscv: hwprobe: export vector crypto ISA extensions
dt-bindings: riscv: add vector crypto ISA extensions description
riscv: add ISA extension parsing for Zfh/Zfhmin
riscv: hwprobe: export Zfh/Zfhmin ISA extensions
dt-bindings: riscv: add Zfh[min] ISA extensions description
riscv: add ISA extension parsing for Zihintntl
riscv: hwprobe: export Zhintntl ISA extension
dt-bindings: riscv: add Zihintntl ISA extension description
riscv: add ISA extension parsing for Zvfh[min]
riscv: hwprobe: export Zvfh[min] ISA extensions
dt-bindings: riscv: add Zvfh[min] ISA extension description
riscv: add ISA extension parsing for Zfa
riscv: hwprobe: export Zfa ISA extension
dt-bindings: riscv: add Zfa ISA extension description
Evan Green (1):
riscv: add ISA extension parsing for scalar crypto
.../devicetree/bindings/riscv/extensions.yaml | 210 ++++++++++++++++++ Documentation/riscv/hwprobe.rst | 81 +++++++ arch/riscv/include/asm/hwcap.h | 33 ++- arch/riscv/include/uapi/asm/hwprobe.h | 26 +++ arch/riscv/kernel/cpufeature.c | 165 ++++++++++++-- arch/riscv/kernel/sys_riscv.c | 64 ++++-- 6 files changed, 543 insertions(+), 36 deletions(-)
Signature · 1 line
2.42.0
PATCH v2 1/19 riscv: hwprobe: factorize hwprobe ISA extension reporting
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)
arch/riscv/kernel/sys_riscv.c +18 -14
@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) + +/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. +*/ +CHECK_ISA_EXT (ZBA ); +CHECK_ISA_EXT (ZBB ); +CHECK_ISA_EXT (ZBS ); +#undef CHECK_ISA_EXT }/* Now turn off reporting features if any CPU is missing it. */
Signature · 1 line
2.42.0
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 35 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +3
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 10 lines
arch/riscv/kernel/sys_riscv.c +10
-0+ pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + }while (false) + +/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made.
This comment alludes to a dangerous trap, but I'm having trouble understanding what it is. Perhaps some rewording to more explicitly state the danger would be appropriate. Other than that:
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 41 lines · Evan Green
Quoted 40 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +8
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) +
Quoted 8 lines
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 5 lines
arch/riscv/kernel/sys_riscv.c +5
-0+/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Quoted 4 lines
Perhaps some rewording to more explicitly state the danger would be appropriate. Other than that:
Reviewed-by Evan Green <[email protected]>
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 51 lines · Conor Dooley
Quoted 41 lines · Evan Green
Quoted 40 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +8
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) +Quoted 8 lines
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 5 lines
arch/riscv/kernel/sys_riscv.c +5
-0+/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
Quoted 3 lines
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these CHECK_ISA_EXT() macros are used wrapped in has_vector(). The code looks valid to me, since has_vector() contains the Kconfig check, but does fly in the face of this comment.
Quoted 5 lines
Quoted 5 lines
Perhaps some rewording to more explicitly state the danger would be appropriate. Other than that:
Reviewed-by Evan Green <[email protected]>
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 53 lines · Conor Dooley
Quoted 51 lines · Conor Dooley
Quoted 49 lines · Evan Green
Quoted 35 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +3
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 10 lines
arch/riscv/kernel/sys_riscv.c +10
-0+ pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + }while (false) + +/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
Quoted 8 lines
Quoted 3 lines
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these
CHECK_ISA_EXT()macros are used wrapped inhas_vector(). The code looks valid to me, sincehas_vector()contains theKconfigcheck, but does fly in the face of this comment.
Ohh, got it. The word "can" is doing a lot of heavy lifting in that comment. So maybe something like: "This macro performs little in the way of extension-specific kernel readiness checks. It's assumed other gating factors like required Kconfig settings have already been confirmed to support exposing the given extension to usermode". ... But, you know, make it sparkle.
-Evan
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 64 lines · Evan Green
Quoted 53 lines · Conor Dooley
Quoted 51 lines · Conor Dooley
Quoted 49 lines · Evan Green
Quoted 35 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +3
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 10 lines
arch/riscv/kernel/sys_riscv.c +10
-0+ pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + }while (false) + +/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
Quoted 8 lines
Quoted 3 lines
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these
CHECK_ISA_EXT()macros are used wrapped inhas_vector(). The code looks valid to me, sincehas_vector()contains theKconfigcheck, but does fly in the face of this comment.
Quoted 6 lines
Ohh, got it. The word "can" is doing a lot of heavy lifting in that comment. So maybe something like: "This macro performs little in the way of extension-specific kernel readiness checks. It's assumed other gating factors like required
Kconfigsettings have already been confirmed to support exposing the given extension to usermode". ... But, you know, make it sparkle.
Hi Even,
Indeed the comment was a bit misleading, is this more clear ?
/*
* Only use CHECK_ISA_EXT() for extensions which are usable by
* userspace with respect to the kernel current configuration.
* For instance, ISA extensions that uses float operations
* should not be exposed when CONFIG_FPU is not set. */
Clément
Quoted 2 lines
-Evan
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 6 lines · Clément Léger
Indeed the comment was a bit misleading, is this more clear ?
/*
* Only useCHECK_ISA_EXT()for extensions which are usable by
* userspace with respect to the kernel current configuration.
* For instance, ISA extensions that uses float operations
s/that uses/that use/
Quoted 1 line
* should not be exposed when
CONFIG_FPUis not set.
s/is not set/is not enabled/
But yeah, definitely more clear, thanks.
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 9 lines · Conor Dooley
Quoted 6 lines · Clément Léger
Indeed the comment was a bit misleading, is this more clear ?
/*
* Only useCHECK_ISA_EXT()for extensions which are usable by
* userspace with respect to the kernel current configuration.
* For instance, ISA extensions that uses float operations
Quoted 7 lines
s/that uses/that use/
Quoted 1 line
* should not be exposed when
CONFIG_FPUis not set.s/is not set/is not enabled/
But yeah, definitely more clear, thanks.
Looks good to me too. Thanks, Clément!
-Evan
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
In reply to Conor DooleyQuoted 52 lines · Conor Dooley
Quoted 51 lines · Conor Dooley
Quoted 49 lines · Evan Green
Quoted 35 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +3
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 10 lines
arch/riscv/kernel/sys_riscv.c +10
-0+ pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + }while (false) + +/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
Quoted 8 lines
Quoted 3 lines
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these
CHECK_ISA_EXT()macros are used wrapped inhas_vector(). The code looks valid to me, sincehas_vector()contains theKconfigcheck, but does fly in the face of this comment.
Yes, the KConfig checks are already done by the headers, adding #ifdef would be redundant even if more coherent with the comment. BTW, wouldn't it make more sense to get rid out of the unsupported extensions directly at ISA string parsing ? ie, if kernel is compiled without V support, then do not set the bits corresponding to these in the riscv_isa_ext[] array ? But the initial intent was probably to be able to report the full string through cpuinfo.
Clément
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Perhaps some rewording to more explicitly state the danger would be appropriate. Other than that:
Reviewed-by Evan Green <[email protected]>
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 59 lines · Clément Léger
Quoted 56 lines · Conor Dooley
Quoted 54 lines · Conor Dooley
Quoted 41 lines · Evan Green
Quoted 40 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +8
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) +Quoted 8 lines
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 5 lines
arch/riscv/kernel/sys_riscv.c +5
-0+/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Quoted 7 lines
Quoted 4 lines
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these
CHECK_ISA_EXT()macros are used wrapped inhas_vector(). The code looks valid to me, sincehas_vector()contains theKconfigcheck, but does fly in the face of this comment.Yes, the KConfig checks are already done by the headers, adding #ifdef would be redundant even if more coherent with the comment
I don't really understand what the first part of this means, or why using avoidable ifdeffery here would be desirable.
Quoted 6 lines
BTW, wouldn't
it make more sense to get rid out of the unsupported extensions directly at ISA string parsing ? ie, if kernel is compiled without V support, then do not set the bits corresponding to these in the riscv_isa_ext[] array ? But the initial intent was probably to be able to report the full string through cpuinfo.
Yeah, hysterical raisins I guess, it's always been that way. I don't think anyone originally thought about such configurations and that is how the cpuinfo stuff behaves. I strongly dislike the riscv_isa_extension_available() interface, but one of Drew's patches does at least improve things a bit. Kinda waiting for some of the patches in flight to settle down before deciding if I want to refactor stuff to be less of a potential for shooting oneself in the foot.
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
Quoted 65 lines · Conor Dooley
Quoted 63 lines · Clément Léger
Quoted 60 lines · Conor Dooley
Quoted 51 lines · Conor Dooley
Quoted 41 lines · Evan Green
Quoted 40 lines · Clément Léger
Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily.
Signed-off-by Clément Léger <[email protected]>--- arch/riscv/kernel/sys_riscv.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)arch/riscv/kernel/sys_riscv.c +8
-14@@ -145,20 +145,24 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,for_each_cpu (cpu, cpus) {struct riscv_isainfo *isainfo = &hart_isa[cpu]; -if (riscv_isa_extension_available (isainfo->isa,ZBA )) - pair->value |=RISCV_HWPROBE_EXT_ZBA ; -else - missing |=RISCV_HWPROBE_EXT_ZBA ; - -if (riscv_isa_extension_available (isainfo->isa,ZBB )) - pair->value |=RISCV_HWPROBE_EXT_ZBB ; -else - missing |=RISCV_HWPROBE_EXT_ZBB ; - -if (riscv_isa_extension_available (isainfo->isa,ZBS )) - pair->value |=RISCV_HWPROBE_EXT_ZBS ; -else - missing |=RISCV_HWPROBE_EXT_ZBS ; +#define CHECK_ISA_EXT (__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) +Quoted 8 lines
arch/riscv/kernel/sys_riscv.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 160
Quoted 5 lines
arch/riscv/kernel/sys_riscv.c +5
-0+/* +* Only use CHECK_ISA_EXT() for extensions which can be exposed +* to userspace, regardless of the kernel's configuration, as no +* other checks, besides presence in the hart_isa bitmap, are +* made. This comment alludes to a dangerous trap, but I'm having trouble understanding what it is.
Quoted 3 lines
You cannot, for example, use this for communicating the presence of F or D, since they require a config option to be set before their use is safe.
Funnily enough, this comment is immediately contradicted by the vector subset extensions, where these
CHECK_ISA_EXT()macros are used wrapped inhas_vector(). The code looks valid to me, sincehas_vector()contains theKconfigcheck, but does fly in the face of this comment.
Quoted 5 lines
Quoted 2 lines
Yes, the KConfig checks are already done by the headers, adding #ifdef would be redundant even if more coherent with the comment
I don't really understand what the first part of this means, or why using avoidable ifdeffery here would be desirable.
Sorry, I was not clear enough. What I meant is that the has_fpu() and has_vector() functions are already ifdef'd in headers based on the KConfig options for their support (CONFIG_FPU/CONFIG_RISCV_ISA_V) So in the end, using ifdef here in hwprobe_isa_ext0() would be redundant.
Quoted 8 lines
Quoted 7 lines
BTW, wouldn't
it make more sense to get rid out of the unsupported extensions directly at ISA string parsing ? ie, if kernel is compiled without V support, then do not set the bits corresponding to these in the riscv_isa_ext[] array ? But the initial intent was probably to be able to report the full string through cpuinfo.
Quoted 7 lines
Yeah, hysterical raisins I guess, it's always been that way. I don't think anyone originally thought about such configurations and that is how the cpuinfo stuff behaves. I strongly dislike the
riscv_isa_extension_available()interface, but one of Drew's patches does at least improve things a bit. Kinda waiting for some of the patches in flight to settle down before deciding if I want to refactor stuff to be less of a potential for shooting oneself in the foot.
Make sense.
Clément
Re: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting
In reply to Conor DooleyQuoted 1 line · Conor Dooley
On Thu, Oct 19, 2023 at 09:26:31AM +0200, Clément Léger wrote:
...
Quoted 7 lines
Quoted 6 lines
BTW, wouldn't
it make more sense to get rid out of the unsupported extensions directly at ISA string parsing ? ie, if kernel is compiled without V support, then do not set the bits corresponding to these in the riscv_isa_ext[] array ? But the initial intent was probably to be able to report the full string through cpuinfo.
Quoted 7 lines
Yeah, hysterical raisins I guess, it's always been that way. I don't think anyone originally thought about such configurations and that is how the cpuinfo stuff behaves. I strongly dislike the
riscv_isa_extension_available()interface, but one of Drew's patches does at least improve things a bit. Kinda waiting for some of the patches in flight to settle down before deciding if I want to refactor stuff to be less of a potential for shooting oneself in the foot.
And I recall promising to try and do something with it too, but that promise got buried under other promises... It's still on the TODO, at least!
drew
PATCH v2 2/19 riscv: add ISA extension parsing for scalar crypto
In reply to Clément LégerFrom: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"
riscv_isa_ext_data grows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension properties
--- arch/riscv/include/asm/hwcap.h | 13 +++++ arch/riscv/kernel/cpufeature.c | 103 ++++++++++++++++++++++++++------- 2 files changed, 96 insertions(+), 20 deletions(-)
arch/riscv/include/asm/hwcap.h +13 -0
@@ -58,6 +58,17 @@#define RISCV_ISA_EXT_ZICSR 40#define RISCV_ISA_EXT_ZIFENCEI 41#define RISCV_ISA_EXT_ZIHPM 42 +#define RISCV_ISA_EXT_ZBC 43 +#define RISCV_ISA_EXT_ZBKB 44 +#define RISCV_ISA_EXT_ZBKC 45 +#define RISCV_ISA_EXT_ZBKX 46 +#define RISCV_ISA_EXT_ZKND 47 +#define RISCV_ISA_EXT_ZKNE 48 +#define RISCV_ISA_EXT_ZKNH 49 +#define RISCV_ISA_EXT_ZKR 50 +#define RISCV_ISA_EXT_ZKSED 51 +#define RISCV_ISA_EXT_ZKSH 52 +#define RISCV_ISA_EXT_ZKT 53#define RISCV_ISA_EXT_MAX 64
@@ -77,6 +88,8 @@ struct riscv_isa_ext_data {const unsigned int id;const char *name;const char *property; +const unsigned int *bundle_ids; +const unsigned int bundle_size; };extern const struct riscv_isa_ext_data riscv_isa_ext[];
arch/riscv/kernel/cpufeature.c +83 -20
144 lines not on this page · raw message
Signature · 1 line
2.42.0
Re: [PATCH v2 02/19] riscv: add ISA extension parsing for scalar crypto
Quoted 14 lines · Clément Léger
From: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "
rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"
Quoted 8 lines
riscv_isa_ext_datagrows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension propertiesCo-developed-by Conor Dooley <[email protected]>Signed-off-by Conor Dooley <[email protected]>Signed-off-by Evan Green <[email protected]>Signed-off-by Clément Léger <[email protected]>
My tree might be out of sync, but in my search for riscv_isa_ext, I also found a use in print_isa() (cpu.c) where we're reaching into riscv_isa_ext[].id and assuming it's always valid. If that's still in there we'll want to fix up that spot too, since now with bundles .id may or may not be valid.
-Evan
Re: [PATCH v2 02/19] riscv: add ISA extension parsing for scalar crypto
Quoted 24 lines · Evan Green
Quoted 14 lines · Clément Léger
From: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "
rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"Quoted 8 lines
riscv_isa_ext_datagrows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension propertiesCo-developed-by Conor Dooley <[email protected]>Signed-off-by Conor Dooley <[email protected]>Signed-off-by Evan Green <[email protected]>Signed-off-by Clément Léger <[email protected]>
Quoted 5 lines
My tree might be out of sync, but in my search for
riscv_isa_ext, I also found a use inprint_isa()(cpu.c) where we're reaching into riscv_isa_ext[].id and assuming it's always valid. If that's still in there we'll want to fix up that spot too, since now with bundles .id may or may not be valid.
Oh indeed, the array is visible outside of this compilation unit :/. I'll check that before sending V3.
Clément
Quoted 2 lines
-Evan
Re: [PATCH v2 02/19] riscv: add ISA extension parsing for scalar crypto
Quoted 27 lines · Clément Léger
Quoted 24 lines · Evan Green
Quoted 22 lines · Clément Léger
From: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "
rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"
riscv_isa_ext_datagrows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension propertiesCo-developed-by Conor Dooley <[email protected]>Signed-off-by Conor Dooley <[email protected]>Signed-off-by Evan Green <[email protected]>Signed-off-by Clément Léger <[email protected]>
Quoted 8 lines
Quoted 5 lines
My tree might be out of sync, but in my search for
riscv_isa_ext, I also found a use inprint_isa()(cpu.c) where we're reaching into riscv_isa_ext[].id and assuming it's always valid. If that's still in there we'll want to fix up that spot too, since now with bundles .id may or may not be valid.Oh indeed, the array is visible outside of this compilation unit :/. I'll check that before sending V3.
After looking a bit more at that, it actually seems that id is used in cpuinfo to determine which extensions are present which means you are right, bundle_size needs to be accounted for.
Looking at it also raises the question (again) of exposing the "bundles" extensions themselves or not in cpuinfo output. With the current setup, the bundles extensions won't be visible in cpuinfo output. For instance if Zk was in the isa string, then it will not be visible in the cpuinfo output, only the child extensions. One solution would be to always have a valid id for each extension. So we would have one for Zk for instance.
We would then have a similar setup for all "bundles" or "subset" extensions, they would have a id for all of them. For instance, Zk would become:
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZK, riscv_zk_bundled_exts)
Same would go for zvbb (riscv_zvbb_subset_exts would only contain Zvkb):
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZVBB, riscv_zvbb_subset_exts)
For the sake of completeness, I feel like it would be good to have all the extensions (bundles or not) visible in the riscv_isa_ext.
Any objection ?
Clément
Quoted 5 lines
Clément
Quoted 2 lines
-Evan
Re: [PATCH v2 02/19] riscv: add ISA extension parsing for scalar crypto
Quoted 57 lines · Clément Léger
Quoted 27 lines · Clément Léger
Quoted 24 lines · Evan Green
Quoted 22 lines · Clément Léger
From: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "
rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"
riscv_isa_ext_datagrows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension propertiesCo-developed-by Conor Dooley <[email protected]>Signed-off-by Conor Dooley <[email protected]>Signed-off-by Evan Green <[email protected]>Signed-off-by Clément Léger <[email protected]>Quoted 8 lines
Quoted 5 lines
My tree might be out of sync, but in my search for
riscv_isa_ext, I also found a use inprint_isa()(cpu.c) where we're reaching into riscv_isa_ext[].id and assuming it's always valid. If that's still in there we'll want to fix up that spot too, since now with bundles .id may or may not be valid.Oh indeed, the array is visible outside of this compilation unit :/. I'll check that before sending V3.
After looking a bit more at that, it actually seems that id is used in cpuinfo to determine which extensions are present which means you are right,
bundle_sizeneeds to be accounted for.Looking at it also raises the question (again) of exposing the "bundles" extensions themselves or not in cpuinfo output. With the current setup, the bundles extensions won't be visible in cpuinfo output. For instance if Zk was in the isa string, then it will not be visible in the cpuinfo output, only the child extensions. One solution would be to always have a valid id for each extension. So we would have one for Zk for instance.
We would then have a similar setup for all "bundles" or "subset" extensions, they would have a id for all of them. For instance, Zk would become:
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZK, riscv_zk_bundled_exts)
Quoted 8 lines
Same would go for zvbb (
riscv_zvbb_subset_extswould only contain Zvkb):
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZVBB, riscv_zvbb_subset_exts)For the sake of completeness, I feel like it would be good to have all the extensions (bundles or not) visible in the
riscv_isa_ext.Any objection ?
I could be persuaded that it's a good idea, but there are arguments to be made for not defining them as separate bits:
1. Having two (sets of) bits that mean the same thing means usermode now has to decide which one to query, or query both. Multiple values that mean the same thing is always something that makes me nervous.
2. To avoid these two sets having different answers, we'd have to solve the reverse problem too: If all of the bundled extensions that make up Zk are on, we'd need to detect that and turn Zk on as well. That code would also need to know the difference between a pure lasso like Zk, where you should flip it on if its components are on, and the loose change variant we were discussing on the other thread (Zvkb?), where you cannot.
Pretending pure lasso extensions didn't exist on their own was a way to sidestep the problem.
-Evan
Re: [PATCH v2 02/19] riscv: add ISA extension parsing for scalar crypto
Quoted 65 lines · Evan Green
Quoted 64 lines · Clément Léger
Quoted 27 lines · Clément Léger
Quoted 24 lines · Evan Green
Quoted 22 lines · Clément Léger
From: Evan Green <[email protected]>
The Scalar Crypto specification defines Zk as a shorthand for the Zkn, Zkr and Zkt extensions. The same follows for both Zkn, Zks and Zbk, which are all shorthands for various other extensions. The detailed breakdown can be found in their dt-binding entries.
Since Zkn also implies the Zbkb, Zbkc and Zbkx extensions, simply passing "zk" through a DT should enable all of Zbkb, Zbkc, Zbkx, Zkn, Zkr and Zkt. For example, setting the "riscv,isa" DT property to "
rv64imafdc_zk" should generate the following cpuinfo output:
"rv64imafdc_zicntr_zicsr_zifencei_zihpm_zbkb_zbkc_zbkx_zknd_zkne_zknh_zkr_zkt"
riscv_isa_ext_datagrows a pair of new members, to permit setting the relevant bits for "bundled" extensions, both while parsing the ISA string and the new dedicated extension propertiesCo-developed-by Conor Dooley <[email protected]>Signed-off-by Conor Dooley <[email protected]>Signed-off-by Evan Green <[email protected]>Signed-off-by Clément Léger <[email protected]>Quoted 8 lines
Quoted 5 lines
My tree might be out of sync, but in my search for
riscv_isa_ext, I also found a use inprint_isa()(cpu.c) where we're reaching into riscv_isa_ext[].id and assuming it's always valid. If that's still in there we'll want to fix up that spot too, since now with bundles .id may or may not be valid.Oh indeed, the array is visible outside of this compilation unit :/. I'll check that before sending V3.
After looking a bit more at that, it actually seems that id is used in cpuinfo to determine which extensions are present which means you are right,
bundle_sizeneeds to be accounted for.Looking at it also raises the question (again) of exposing the "bundles" extensions themselves or not in cpuinfo output. With the current setup, the bundles extensions won't be visible in cpuinfo output. For instance if Zk was in the isa string, then it will not be visible in the cpuinfo output, only the child extensions. One solution would be to always have a valid id for each extension. So we would have one for Zk for instance.
We would then have a similar setup for all "bundles" or "subset" extensions, they would have a id for all of them. For instance, Zk would become:
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZK, riscv_zk_bundled_exts)Same would go for zvbb (
riscv_zvbb_subset_extswould only contain Zvkb):
__RISCV_ISA_EXT_DATA_BUNDLE(zk, RISCV_ISA_EXT_ZVBB, riscv_zvbb_subset_exts)For the sake of completeness, I feel like it would be good to have all the extensions (bundles or not) visible in the
riscv_isa_ext.
Quoted 8 lines
Quoted 1 line
Any objection ?
I could be persuaded that it's a good idea, but there are arguments to be made for not defining them as separate bits:
1. Having two (sets of) bits that mean the same thing means usermode now has to decide which one to query, or query both. Multiple values that mean the same thing is always something that makes me nervous.
That is indeed an acceptable cons.
Quoted 3 lines
2. To avoid these two sets having different answers, we'd have to solve the reverse problem too: If all of the bundled extensions that make up Zk are on, we'd need to detect that and turn Zk on as well.
Oh yes, sorry, already forgot that point :/ Well, I guess things sorted out by themselves. Let's do what you proposed:
- Pure lasso extensions (Zk) will simply result in all the sub extensions being enable, there won't be any .id specified for these ones, simply a bundle of extensions.
- "Superset" extensions (Zvbb for instance) will have their own .id as well as a bundle made of subsets extensions.
Clément
Quoted 8 lines
That code would also need to know the difference between a pure lasso like Zk, where you should flip it on if its components are on, and the loose change variant we were discussing on the other thread (Zvkb?), where you cannot.
Pretending pure lasso extensions didn't exist on their own was a way to sidestep the problem.
-Evan
PATCH v2 3/19 riscv: hwprobe: add support for scalar crypto ISA extensions
In reply to Clément LégerExport the following scalar crypto extensions through hwprobe:
- Zbkb
- Zbkc
- Zbkx
- Zknd
- Zkne
- Zknh
- Zksed
- Zksh
- Zkt
--- Documentation/riscv/hwprobe.rst | 30 +++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 10 +++++++++ arch/riscv/kernel/sys_riscv.c | 10 +++++++++ 3 files changed, 50 insertions(+)
Documentation/riscv/hwprobe.rst +30 -0
@@ -77,6 +77,36 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined in version 1.0 of the Bit-Manipulation ISA extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZBC` The Zbc extension is supported, as defined + in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZBKB` The Zbkb extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZBKC` The Zbkc extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZBKX` The Zbkx extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKND` The Zknd extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKNE` The Zkne extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKNH` The Zknh extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKSED` The Zksed extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKSH` The Zksh extension is supported, as + defined in version 1.0 of the Scalar Crypto ISA extensions. + + * :c:macro:`RISCV_HWPROBE_EXT_ZKT` The Zkt extension is supported, as defined + in version 1.0 of the Scalar Crypto ISA extensions. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +10 -0
@@ -29,6 +29,16 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZBA (1 << 3)#define RISCV_HWPROBE_EXT_ZBB (1 << 4)#define RISCV_HWPROBE_EXT_ZBS (1 << 5) +#define RISCV_HWPROBE_EXT_ZBC (1 << 6) +#define RISCV_HWPROBE_EXT_ZBKB (1 << 7) +#define RISCV_HWPROBE_EXT_ZBKC (1 << 8) +#define RISCV_HWPROBE_EXT_ZBKX (1 << 9) +#define RISCV_HWPROBE_EXT_ZKND (1 << 10) +#define RISCV_HWPROBE_EXT_ZKNE (1 << 11) +#define RISCV_HWPROBE_EXT_ZKNH (1 << 12) +#define RISCV_HWPROBE_EXT_ZKSED (1 << 13) +#define RISCV_HWPROBE_EXT_ZKSH (1 << 14) +#define RISCV_HWPROBE_EXT_ZKT (1 << 15)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +10 -0
@@ -162,6 +162,16 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,CHECK_ISA_EXT (ZBA );CHECK_ISA_EXT (ZBB );CHECK_ISA_EXT (ZBS ); +CHECK_ISA_EXT (ZBC ); +CHECK_ISA_EXT (ZBKB ); +CHECK_ISA_EXT (ZBKC ); +CHECK_ISA_EXT (ZBKX ); +CHECK_ISA_EXT (ZKND ); +CHECK_ISA_EXT (ZKNE ); +CHECK_ISA_EXT (ZKNH ); +CHECK_ISA_EXT (ZKSED ); +CHECK_ISA_EXT (ZKSH ); +CHECK_ISA_EXT (ZKT );#undef CHECK_ISA_EXT }
Signature · 1 line
2.42.0
Re: [PATCH v2 03/19] riscv: hwprobe: add support for scalar crypto ISA extensions
Quoted 25 lines · Clément Léger
Export the following scalar crypto extensions through hwprobe:
- Zbkb
- Zbkc
- Zbkx
- Zknd
- Zkne
- Zknh
- Zksed
- Zksh
- ZktSigned-off-by Clément Léger <[email protected]>--- Documentation/riscv/hwprobe.rst | 30 +++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 10 +++++++++ arch/riscv/kernel/sys_riscv.c | 10 +++++++++ 3 files changed, 50 insertions(+)Documentation/riscv/hwprobe.rst +0
-0
Documentation/riscv/hwprobe.rst The following keys are defined: · line 81
Quoted 5 lines
Documentation/riscv/hwprobe.rst +2
-0@@ -77,6 +77,36 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined in version 1.0 of the Bit-Manipulation ISA extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZBC` The Zbc extension is supported, as defined + in version 1.0 of the Scalar Crypto ISA extensions.
At least in my v1.0.1 version of the crypto scalar spec, I don't see Zbc. That seems to be defined in the bit manipulation extensions.
Re: [PATCH v2 03/19] riscv: hwprobe: add support for scalar crypto ISA extensions
Quoted 29 lines · Evan Green
Quoted 28 lines · Clément Léger
Export the following scalar crypto extensions through hwprobe:
- Zbkb
- Zbkc
- Zbkx
- Zknd
- Zkne
- Zknh
- Zksed
- Zksh
- ZktSigned-off-by Clément Léger <[email protected]>--- Documentation/riscv/hwprobe.rst | 30 +++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 10 +++++++++ arch/riscv/kernel/sys_riscv.c | 10 +++++++++ 3 files changed, 50 insertions(+)Documentation/riscv/hwprobe.rst +0
-0@@ -77,6 +77,36 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined in version 1.0 of the Bit-Manipulation ISA extensions.
Quoted 5 lines
Documentation/riscv/hwprobe.rst The following keys are defined: · line 81
Quoted 2 lines
Documentation/riscv/hwprobe.rst +2
-0+ * :c:macro:`RISCV_HWPROBE_EXT_ZBC` The Zbc extension is supported, as defined + in version 1.0 of the Scalar Crypto ISA extensions.At least in my v1.0.1 version of the crypto scalar spec, I don't see Zbc. That seems to be defined in the bit manipulation extensions.
Thanks for catching this, this should be same than the previous line. I will actually move the ZBC on another patch since it is not scalar crypto.
Clément
PATCH v2 4/19 dt-bindings: riscv: add scalar crypto ISA extensions description
In reply to Clément LégerAdd description for scalar crypto ISA extensions which can now be reported through hwprobe for userspace usage. These extensions are the following:
- Zbkb
- Zbkc
- Zbkx
- Zknd
- Zkne
- Zknh
- Zkr
- Zksed
- Zksh
- Zkt
--- .../devicetree/bindings/riscv/extensions.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +77 -0
@@ -184,12 +184,89 @@ properties: multiplication as ratified at commit 6d33919 ("Merge pull request #158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip. + - const: zbkb + description: + The standard Zbkb bitmanip instructions for cryptography as ratified + in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zbkc + description: + The standard Zbkc carry-less multiply instructions as ratified + in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zbkx + description: + The standard Zbkx crossbar permutation instructions as ratified + in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + - const: zbs description: | The standard Zbs bit-manipulation extension for single-bit instructions as ratified at commit 6d33919 ("Merge pull request #158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip. + - const: zk + description: + The standard Zk Standard Scalar cryptography extension as ratified + in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zkn + description: + The standard Zkn NIST algorithm suite extensions as ratified in + version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zknd + description: | + The standard Zknd for NIST suite: AES decryption instructions as + ratified in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zkne + description: | + The standard Zkne for NIST suite: AES encryption instructions as + ratified in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zknh + description: | + The standard Zknh for NIST suite: hash function instructions as + ratified in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zkr + description: + The standard Zkr entropy source extension as ratified in version + 1.0 of RISC-V Cryptography Extensions Volume I specification. + + - const: zks + description: + The standard Zks ShangMi algorithm suite extensions as ratified in + version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + + - const: zksed + description: | + The standard Zksed for ShangMi suite: SM4 block cipher instructions + as ratified in version 1.0 of RISC-V Cryptography Extensions + Volume I specification. + + - const: zksh + description: | + The standard Zksh for ShangMi suite: SM3 hash function instructions + as ratified in version 1.0 of RISC-V Cryptography Extensions + Volume I specification. + + - const: zkt + description: + The standard Zkt for data independent execution latency as ratified + in version 1.0 of RISC-V Cryptography Extensions Volume I + specification. + - const: zicbom description: The standard Zicbom extension for base cache management operations as
Signature · 1 line
2.42.0
PATCH v2 5/19 riscv: add ISA extension parsing for vector crypto extensions
In reply to Clément LégerAdd parsing of some Zv* vector crypto ISA extensions that are mentioned in "RISC-V Cryptography Extensions Volume II" [1]. These ISA extensions are the following:
- Zvbb: Vector Basic Bit-manipulation
- Zvbc: Vector Carryless Multiplication
- Zvkb: Vector Cryptography Bit-manipulation
- Zvkg: Vector GCM/GMAC.
- Zvkned: NIST Suite: Vector AES Block Cipher
- Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash
- Zvksed: ShangMi Suite: SM4 Block Cipher
- Zvksh: ShangMi Suite: SM3 Secure Hash
- Zvkn: NIST Algorithm Suite
- Zvknc: NIST Algorithm Suite with carryless multiply
- Zvkng: NIST Algorithm Suite with GCM.
- Zvks: ShangMi Algorithm Suite
- Zvksc: ShangMi Algorithm Suite with carryless multiplication
- Zvksg: ShangMi Algorithm Suite with GCM.
- Zvkt: Vector Data-Independent Execution Latency.
--- arch/riscv/include/asm/hwcap.h | 10 ++++++ arch/riscv/kernel/cpufeature.c | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
arch/riscv/include/asm/hwcap.h +10 -0
@@ -69,6 +69,16 @@#define RISCV_ISA_EXT_ZKSED 51#define RISCV_ISA_EXT_ZKSH 52#define RISCV_ISA_EXT_ZKT 53 +#define RISCV_ISA_EXT_ZVBB 54 +#define RISCV_ISA_EXT_ZVBC 55 +#define RISCV_ISA_EXT_ZVKB 56 +#define RISCV_ISA_EXT_ZVKG 57 +#define RISCV_ISA_EXT_ZVKNED 58 +#define RISCV_ISA_EXT_ZVKNHA 59 +#define RISCV_ISA_EXT_ZVKNHB 60 +#define RISCV_ISA_EXT_ZVKSED 61 +#define RISCV_ISA_EXT_ZVKSH 62 +#define RISCV_ISA_EXT_ZVKT 63#define RISCV_ISA_EXT_MAX 64
arch/riscv/kernel/cpufeature.c +56 -0
68 lines not on this page · raw message
Signature · 1 line
2.42.0
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),
The Zvkb is the subset of Zvbb[1]. So, the Zvkb should be bundled with Zvbb.
+ __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVBB),
+ __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVKB),
+ __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),
or
+ __RISCV_ISA_EXT_BUNDLE(zvbb, riscv_zvbb_bundled_exts),
+ __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),
[1]
https://github.com/riscv/riscv-crypto/blob/main/doc/vector/riscv-crypto-vector-zvkb.adoc
-Jerry
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 10 lines · Jerry Shih
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.
Hi Jerry,
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
Clément
Quoted 14 lines
arch/riscv/kernel/cpufeature.c +3
-0+__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVKB ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),or
(quoted diff) +2
-0+ __RISCV_ISA_EXT_BUNDLE(zvbb, riscv_zvbb_bundled_exts), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),[1]
https://github.com/riscv/riscv-crypto/blob/main/doc/vector/riscv-crypto-vector-zvkb.adoc-Jerry
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 15 lines · Clément Léger
Quoted 10 lines · Jerry Shih
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.
Quoted 4 lines
Hi Jerry,
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
-Evan
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 18 lines · Evan Green
Quoted 17 lines · Clément Léger
Quoted 10 lines · Jerry Shih
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};
static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA, RISCV_ISA_EXT_ZVKNHB
};
Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
Quoted 7 lines
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
Agreed but if a system only report ZVBB for instance and the user wants ZVKB, then it is clear that ZVKB should be reported as well I guess. So in the end, it works much like "bundle" extension, just that the bundle is actually a "real" ISA extension by itself.
Clément
Quoted 10 lines
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
-Evan
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 53 lines · Clément Léger
Quoted 18 lines · Evan Green
Quoted 17 lines · Clément Léger
Quoted 10 lines · Jerry Shih
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,RISCV_ISA_EXT_ZVKNHB
};Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
Quoted 7 lines
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
Quoted 15 lines
Agreed but if a system only report ZVBB for instance and the user wants ZVKB, then it is clear that ZVKB should be reported as well I guess. So in the end, it works much like "bundle" extension, just that the bundle is actually a "real" ISA extension by itself.
Clément
Quoted 8 lines
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
I'm not really sure that those are "silly" ISA strings. People are going to do it that way because it is much easier than spelling out 5 dozen sub-components, and it is pretty inevitable that subsets will be introduced in the future for extensions we currently have.
IMO, it's perfectly valid to say you have the supersets and not spell out all the subcomponents.
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 71 lines · Conor Dooley
Quoted 53 lines · Clément Léger
Quoted 18 lines · Evan Green
Quoted 17 lines · Clément Léger
Quoted 10 lines · Jerry Shih
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
arch/riscv/kernel/cpufeature.c +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zkt,RISCV_ISA_EXT_ZKT ),__RISCV_ISA_EXT_DATA (zksed,RISCV_ISA_EXT_ZKSED ),__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ), +__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ), +__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,
RISCV_ISA_EXT_ZVKNHB
};Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
Quoted 7 lines
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
Quoted 15 lines
Agreed but if a system only report ZVBB for instance and the user wants ZVKB, then it is clear that ZVKB should be reported as well I guess. So in the end, it works much like "bundle" extension, just that the bundle is actually a "real" ISA extension by itself.
Clément
Quoted 8 lines
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
Quoted 7 lines
I'm not really sure that those are "silly" ISA strings. People are going to do it that way because it is much easier than spelling out 5 dozen sub-components, and it is pretty inevitable that subsets will be introduced in the future for extensions we currently have.
IMO, it's perfectly valid to say you have the supersets and not spell out all the subcomponents.
Hm, ok. If ISA strings are likely to be written that way, then I agree having the kernel flip on all the contained extensions is a good idea. We can tweak patch 2 to support the parsing of struct riscv_isa_ext_data with both .id and .bundle_size set (instead of only one or the other as it is now). Looking back at that patch, it looks quite doable. Alright!
-Evan
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 80 lines · Evan Green
Quoted 71 lines · Conor Dooley
Quoted 53 lines · Clément Léger
Quoted 18 lines · Evan Green
Quoted 17 lines · Clément Léger
Quoted 10 lines · Jerry Shih
Review const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
(quoted diff) +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), + __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVBB), + __RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,
RISCV_ISA_EXT_ZVKNHB
};Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
Quoted 7 lines
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
Quoted 15 lines
Agreed but if a system only report ZVBB for instance and the user wants ZVKB, then it is clear that ZVKB should be reported as well I guess. So in the end, it works much like "bundle" extension, just that the bundle is actually a "real" ISA extension by itself.
Clément
Quoted 8 lines
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
Quoted 7 lines
I'm not really sure that those are "silly" ISA strings. People are going to do it that way because it is much easier than spelling out 5 dozen sub-components, and it is pretty inevitable that subsets will be introduced in the future for extensions we currently have.
IMO, it's perfectly valid to say you have the supersets and not spell out all the subcomponents.
Quoted 6 lines
Hm, ok. If ISA strings are likely to be written that way, then I agree having the kernel flip on all the contained extensions is a good idea. We can tweak patch 2 to support the parsing of struct
riscv_isa_ext_datawith both .id and .bundle_size set (instead of only one or the other as it is now). Looking back at that patch, it looks quite doable. Alright!
Hey Evan,
do you have anything against using this code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};
...
Then declaring zvbb like that:
__RISCV_ISA_EXT_BUNDLE(zvbb, riscv_zvbb_bundled_exts),
I agree that it is *not* a bundled extension but it actually already works with Conor's code. Not sure that adding more code is needed to handle that case.
Clément
Quoted 2 lines
-Evan
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 102 lines · Clément Léger
Quoted 80 lines · Evan Green
Quoted 71 lines · Conor Dooley
Quoted 53 lines · Clément Léger
Quoted 18 lines · Evan Green
Quoted 17 lines · Clément Léger
Quoted 10 lines · Jerry Shih
Review const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 266
Quoted 7 lines · Clément Léger
(quoted diff) +3
-0@@ -221,6 +261,22 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(zkt, RISCV_ISA_EXT_ZKT), __RISCV_ISA_EXT_DATA(zksed, RISCV_ISA_EXT_ZKSED), __RISCV_ISA_EXT_DATA(zksh, RISCV_ISA_EXT_ZKSH), + __RISCV_ISA_EXT_DATA(zvbb, RISCV_ISA_EXT_ZVBB), + __RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC), + __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,
RISCV_ISA_EXT_ZVKNHB
};Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
Quoted 7 lines
IMO, decomposing "pure" bundles makes sense since otherwise usermode would have to query multiple distinct bitmaps that meant the same thing (eg check the Zk bit, or maybe check the Zkn/Zkr/Zkt bits, or maybe check the Zbkb/Zbkc... bits, and they're all equivalent). But when an extension is a superset that also contains loose change, there really aren't two equivalent bitmasks, each bit adds something new.
Quoted 15 lines
Agreed but if a system only report ZVBB for instance and the user wants ZVKB, then it is clear that ZVKB should be reported as well I guess. So in the end, it works much like "bundle" extension, just that the bundle is actually a "real" ISA extension by itself.
Clément
Quoted 8 lines
There's an argument to be made for still turning on the containing extensions to cover for silly ISA strings (eg ISA strings that advertise the superset but fail to advertise the containing extensions). We can decide if we want to work that hard to cover hypothetical broken ISA strings now, or wait until they show up. Personally I would wait until something broken shows up. But others may feel differently.
Quoted 7 lines
I'm not really sure that those are "silly" ISA strings. People are going to do it that way because it is much easier than spelling out 5 dozen sub-components, and it is pretty inevitable that subsets will be introduced in the future for extensions we currently have.
IMO, it's perfectly valid to say you have the supersets and not spell out all the subcomponents.
Quoted 6 lines
Hm, ok. If ISA strings are likely to be written that way, then I agree having the kernel flip on all the contained extensions is a good idea. We can tweak patch 2 to support the parsing of struct
riscv_isa_ext_datawith both .id and .bundle_size set (instead of only one or the other as it is now). Looking back at that patch, it looks quite doable. Alright!Hey Evan,
do you have anything against using this code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};...
Quoted 7 lines
Then declaring zvbb like that:
__RISCV_ISA_EXT_BUNDLE(zvbb, riscv_zvbb_bundled_exts),I agree that it is *not* a bundled extension but it actually already works with Conor's code. Not sure that adding more code is needed to handle that case.
Ah, I had missed that Zvbb was in Zvbb's own bundle. I see now that it works, but it also feels a bit like we're working around our own code.
An alternate way, which you can decide if you like better, would be a new macro (something like __RISCV_ISA_EXT_DATA_BUNDLE(), but better names welcome) that allows setting both .id and .bundle_size. Then the else-if in match_isa_ext() could just turn into two independent ifs. You'd have to define an "invalid" value for .id, since 0 is 'a', but that should be straightforward. Or maybe jiggle things around a bit so 0 is invalid and 'a' is 1.
-Evan
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
In reply to Clément LégerQuoted 25 lines · Clément Léger
Quoted 8 lines · Evan Green
Quoted 7 lines · Clément Léger
Quoted 2 lines · Jerry Shih
The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};
Quoted 7 lines
static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,RISCV_ISA_EXT_ZVKNHB
};Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
We should not bundle zvknha and zvknhb together. They are exclusive. Please check:
https://github.com/riscv/riscv-crypto/issues/364#issuecomment-1726782096
-Jerry
Re: [PATCH v2 05/19] riscv: add ISA extension parsing for vector crypto extensions
Quoted 31 lines · Jerry Shih
Quoted 30 lines · Clément Léger
Quoted 8 lines · Evan Green
Quoted 7 lines · Clément Léger
Quoted 2 lines · Jerry Shih
The
Zvkbis the subset ofZvbb[1]. So, theZvkbshould be bundled withZvbb.Hi Jerry,
Quoted 8 lines
Quoted 2 lines
Thanks for catching this, I think some other extensions will fall in this category as well then (Zvknha/Zvknhb). I will verify that.
The bundling mechanism works well when an extension is a pure lasso around other extensions. We'd have to tweak that code if we wanted to support cases like this, where the extension is a superset of others, but also contains loose change not present anywhere else (and therefore also needs to stand as a separate bit).
For Zvbb and Zvknhb, I used the following code:
static const unsigned int riscv_zvbb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKB,
RISCV_ISA_EXT_ZVBB
};static const unsigned int riscv_zvknhb_bundled_exts[] = {
RISCV_ISA_EXT_ZVKNHA,RISCV_ISA_EXT_ZVKNHB
};
Quoted 4 lines
Quoted 2 lines
Which correctly results in both extension (superset + base set) being enabled when only one is set. Is there something that I'm missing ?
We should not bundle zvknha and zvknhb together. They are exclusive.
Yes, but for instance, what happens if the user query the zvknha (if it only needs SHA256) but zvknhb is present. If we don't declare zvknha, then it will fail but the support would actually be present due to zvknhb being there.
Clément
Quoted 5 lines
Please check:
https://github.com/riscv/riscv-crypto/issues/364#issuecomment-1726782096-Jerry
PATCH v2 6/19 riscv: hwprobe: export vector crypto ISA extensions
In reply to Clément LégerExport Zv* vector crypto ISA extensions that were added in "RISC-V Cryptography Extensions Volume II" specification[1] through hwprobe. This adds support for the following instructions:
- Zvbb: Vector Basic Bit-manipulation
- Zvbc: Vector Carryless Multiplication
- Zvkb: Vector Cryptography Bit-manipulation
- Zvkg: Vector GCM/GMAC.
- Zvkned: NIST Suite: Vector AES Block Cipher
- Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash
- Zvksed: ShangMi Suite: SM4 Block Cipher
- Zvksh: ShangMi Suite: SM3 Secure Hash
- Zvknc: NIST Algorithm Suite with carryless multiply
- Zvkng: NIST Algorithm Suite with GCM.
- Zvksc: ShangMi Algorithm Suite with carryless multiplication
- Zvksg: ShangMi Algorithm Suite with GCM.
- Zvkt: Vector Data-Independent Execution Latency.
Zvkn and Zvks are ommited since they are a superset of other extensions.
--- Documentation/riscv/hwprobe.rst | 30 +++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 10 +++++++++ arch/riscv/kernel/sys_riscv.c | 13 ++++++++++++ 3 files changed, 53 insertions(+)
Documentation/riscv/hwprobe.rst +30 -0
@@ -107,6 +107,36 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZKT` The Zkt extension is supported, as defined in version 1.0 of the Scalar Crypto ISA extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZVBB`: The Zvbb extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVBC`: The Zvbc extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKB`: The Zvkb extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKG`: The Zvkg extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKNED`: The Zvkned extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHA`: The Zvknha extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKNHB`: The Zvknhb extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKSED`: The Zvksed extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKSH`: The Zvksh extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + + * :c:macro:`RISCV_HWPROBE_EXT_ZVKT`: The Zvkt extension is supported as + defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +10 -0
@@ -39,6 +39,16 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZKSED (1 << 13)#define RISCV_HWPROBE_EXT_ZKSH (1 << 14)#define RISCV_HWPROBE_EXT_ZKT (1 << 15) +#define RISCV_HWPROBE_EXT_ZVBB (1 << 16) +#define RISCV_HWPROBE_EXT_ZVBC (1 << 17) +#define RISCV_HWPROBE_EXT_ZVKB (1 << 18) +#define RISCV_HWPROBE_EXT_ZVKG (1 << 19) +#define RISCV_HWPROBE_EXT_ZVKNED (1 << 20) +#define RISCV_HWPROBE_EXT_ZVKNHA (1 << 21) +#define RISCV_HWPROBE_EXT_ZVKNHB (1 << 22) +#define RISCV_HWPROBE_EXT_ZVKSED (1 << 23) +#define RISCV_HWPROBE_EXT_ZVKSH (1 << 24) +#define RISCV_HWPROBE_EXT_ZVKT (1 << 25)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +13 -0
@@ -172,6 +172,19 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,CHECK_ISA_EXT (ZKSED );CHECK_ISA_EXT (ZKSH );CHECK_ISA_EXT (ZKT ); + +if (has_vector ()) { +CHECK_ISA_EXT (ZVBB ); +CHECK_ISA_EXT (ZVBC ); +CHECK_ISA_EXT (ZVKB ); +CHECK_ISA_EXT (ZVKG ); +CHECK_ISA_EXT (ZVKNED ); +CHECK_ISA_EXT (ZVKNHA ); +CHECK_ISA_EXT (ZVKNHB ); +CHECK_ISA_EXT (ZVKSED ); +CHECK_ISA_EXT (ZVKSH ); +CHECK_ISA_EXT (ZVKT ); + }#undef CHECK_ISA_EXT }
Signature · 1 line
2.42.0
Re: [PATCH v2 06/19] riscv: hwprobe: export vector crypto ISA extensions
Quoted 19 lines · Clément Léger
Export Zv* vector crypto ISA extensions that were added in "RISC-V Cryptography Extensions Volume II" specification[1] through hwprobe. This adds support for the following instructions:
- Zvbb: Vector Basic Bit-manipulation
- Zvbc: Vector Carryless Multiplication
- Zvkb: Vector Cryptography Bit-manipulation
- Zvkg: Vector GCM/GMAC.
- Zvkned: NIST Suite: Vector AES Block Cipher
- Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash
- Zvksed: ShangMi Suite: SM4 Block Cipher
- Zvksh: ShangMi Suite: SM3 Secure Hash
- Zvknc: NIST Algorithm Suite with carryless multiply
- Zvkng: NIST Algorithm Suite with GCM.
- Zvksc: ShangMi Algorithm Suite with carryless multiplication
- Zvksg: ShangMi Algorithm Suite with GCM.
- Zvkt: Vector Data-Independent Execution Latency.
Quoted 1 line
Zvkn and Zvks are ommited since they are a superset of other extensions.
s/ommited/omitted/, other than that:
PATCH v2 7/19 dt-bindings: riscv: add vector crypto ISA extensions description
In reply to Clément LégerAdd Zv* vector crypto extensions that were added in "RISC-V Cryptography Extensions Volume II" specificationi[1]:
- Zvbb: Vector Basic Bit-manipulation
- Zvbc: Vector Carryless Multiplication
- Zvkb: Vector Cryptography Bit-manipulation
- Zvkg: Vector GCM/GMAC.
- Zvkned: NIST Suite: Vector AES Block Cipher
- Zvknh[ab]: NIST Suite: Vector SHA-2 Secure Hash
- Zvksed: ShangMi Suite: SM4 Block Cipher
- Zvksh: ShangMi Suite: SM3 Secure Hash
- Zvkn: NIST Algorithm Suite
- Zvknc: NIST Algorithm Suite with carryless multiply
- Zvkng: NIST Algorithm Suite with GCM.
- Zvks: ShangMi Algorithm Suite
- Zvksc: ShangMi Algorithm Suite with carryless multiplication
- Zvksg: ShangMi Algorithm Suite with GCM.
- Zvkt: Vector Data-Independent Execution Latency.
--- .../devicetree/bindings/riscv/extensions.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +96 -0
@@ -323,5 +323,101 @@ properties: in commit 2e5236 ("Ztso is now ratified.") of the riscv-isa-manual. + - const: zvbb + description: + The standard Zvbb extension for vectored basic bit-manipulation + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvbc + description: + The standard Zvbc extension for vectored carryless multiplication + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvkb + description: + The standard Zvkb extension for vector cryptography bit-manipulation + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvkg + description: + The standard Zvkg extension for vector GCM/GMAC instructions, as + ratified in commit 56ed795 ("Update riscv-crypto-spec-vector.adoc") + of riscv-crypto. + + - const: zvkn + description: + The standard Zvkn extension for NIST algorithm suite instructions, as + ratified in commit 56ed795 ("Update riscv-crypto-spec-vector.adoc") + of riscv-crypto. + + - const: zvknc + description: + The standard Zvknc extension for NIST algorithm suite with carryless + multiply instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvkned + description: + The standard Zvkned extension for Vector AES block cipher + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvkng + description: + The standard Zvkng extension for NIST algorithm suite with GCM + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvknha + description: | + The standard Zvknha extension for NIST suite: vector SHA-2 secure, + hash (SHA-256 only) instructions, as ratified in commit + 56ed795 ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvknhb + description: | + The standard Zvknhb extension for NIST suite: vector SHA-2 secure, + hash (SHA-256 and SHA-512) instructions, as ratified in commit + 56ed795 ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvks + description: + The standard Zvks extension for ShangMi algorithm suite + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvksc + description: + The standard Zvksc extension for ShangMi algorithm suite with + carryless multiplication instructions, as ratified in commit 56ed795 + ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvksed + description: | + The standard Zvksed extension for ShangMi suite: SM4 block cipher + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvksh + description: | + The standard Zvksh extension for ShangMi suite: SM3 secure hash + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvksg + description: + The standard Zvksg extension for ShangMi algorithm suite with GCM + instructions, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + + - const: zvkt + description: + The standard Zvkt extension for vector data-independent execution + latency, as ratified in commit 56ed795 ("Update + riscv-crypto-spec-vector.adoc") of riscv-crypto. + additionalProperties: true ...
Signature · 1 line
2.42.0
PATCH v2 8/19 riscv: add ISA extension parsing for Zfh/Zfhmin
In reply to Clément LégerAdd parsing for Zvfh/Zfhmin ISA extensions[1].
--- arch/riscv/include/asm/hwcap.h | 4 +++- arch/riscv/kernel/cpufeature.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
arch/riscv/include/asm/hwcap.h +3 -1
@@ -79,8 +79,10 @@#define RISCV_ISA_EXT_ZVKSED 61#define RISCV_ISA_EXT_ZVKSH 62#define RISCV_ISA_EXT_ZVKT 63 +#define RISCV_ISA_EXT_ZFH 64 +#define RISCV_ISA_EXT_ZFHMIN 65 -#define RISCV_ISA_EXT_MAX 64 +#define RISCV_ISA_EXT_MAX 128#ifdef CONFIG_RISCV_M_MODE #define RISCV_ISA_EXT_SxAIA RISCV_ISA_EXT_SMAIA
arch/riscv/kernel/cpufeature.c +2 -0
@@ -244,6 +244,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zifencei,RISCV_ISA_EXT_ZIFENCEI ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ),__RISCV_ISA_EXT_DATA (zihpm,RISCV_ISA_EXT_ZIHPM ), +__RISCV_ISA_EXT_DATA (zfh,RISCV_ISA_EXT_ZFH ), +__RISCV_ISA_EXT_DATA (zfhmin,RISCV_ISA_EXT_ZFHMIN ),__RISCV_ISA_EXT_DATA (zba,RISCV_ISA_EXT_ZBA ),__RISCV_ISA_EXT_DATA (zbb,RISCV_ISA_EXT_ZBB ), __RISCV_ISA_EXT_DATA(zbc, RISCV_ISA_EXT_ZBC),
Signature · 1 line
2.42.0
Re: [PATCH v2 08/19] riscv: add ISA extension parsing for Zfh/Zfhmin
Quoted 2 lines · Clément Léger
Add parsing for Zvfh/Zfhmin ISA extensions[1].
Typo: s/Zvfh/Zfh/. Other than that:
PATCH v2 9/19 riscv: hwprobe: export Zfh/Zfhmin ISA extensions
In reply to Clément LégerExport Zfh/Zfhmin ISA extensions[1] through hwprobe only if FPU support is available.
--- Documentation/riscv/hwprobe.rst | 6 ++++++ arch/riscv/include/uapi/asm/hwprobe.h | 2 ++ arch/riscv/kernel/sys_riscv.c | 5 +++++ 3 files changed, 13 insertions(+)
Documentation/riscv/hwprobe.rst +6 -0
@@ -137,6 +137,12 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZVKT`: The Zvkt extension is supported as defined in version 1.0 of the RISC-V Cryptography Extensions Volume II. + * :c:macro:`RISCV_HWPROBE_EXT_ZFH`: The Zfh extension version 1.0 is supported + as defined in the RISC-V ISA manual. + + * :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is + supported as defined in the RISC-V ISA manual. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +2 -0
@@ -49,6 +49,8 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZVKSED (1 << 23)#define RISCV_HWPROBE_EXT_ZVKSH (1 << 24)#define RISCV_HWPROBE_EXT_ZVKT (1 << 25) +#define RISCV_HWPROBE_EXT_ZFH (1 << 26) +#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 27)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +5 -0
@@ -185,6 +185,11 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,CHECK_ISA_EXT (ZVKSH );CHECK_ISA_EXT (ZVKT ); } + +if (has_fpu ()) { +CHECK_ISA_EXT (ZFH ); +CHECK_ISA_EXT (ZFHMIN ); + }#undef CHECK_ISA_EXT }
Signature · 1 line
2.42.0
Re: [PATCH v2 09/19] riscv: hwprobe: export Zfh/Zfhmin ISA extensions
Quoted 6 lines · Clément Léger
Export Zfh/Zfhmin ISA extensions[1] through hwprobe only if FPU support is available.
PATCH v2 10/19 dt-bindings: riscv: add Zfh[min] ISA extensions description
In reply to Clément LégerAdd description of Zfh[min] ISA extensions[1] which can now be reported through hwprobe for userspace usage.
--- .../devicetree/bindings/riscv/extensions.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +13 -0
@@ -208,6 +208,19 @@ properties: instructions as ratified at commit 6d33919 ("Merge pull request #158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip. + - const: zfh + description: + The standard Zfh extension for 16-bit half-precision binary + floating-point instructions, as ratified in commit 64074bc ("Update + version numbers for Zfh/Zfinx") of riscv-isa-manual. + + - const: zfhmin + description: + The standard Zfhmin extension which provides minimal support for + 16-bit half-precision binary floating-point instructions, as ratified + in commit 64074bc ("Update version numbers for Zfh/Zfinx") of + riscv-isa-manual. + - const: zk description: The standard Zk Standard Scalar cryptography extension as ratified
Signature · 1 line
2.42.0
PATCH v2 11/19 riscv: add ISA extension parsing for Zihintntl
In reply to Clément LégerAdd parsing for Zihintntl ISA extension[1] that was ratified in commit 0dc91f5 ("Zihintntl is ratified") of riscv-isa-manual[2].
--- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpufeature.c | 1 + 2 files changed, 2 insertions(+)
arch/riscv/include/asm/hwcap.h +1 -0
@@ -81,6 +81,7 @@#define RISCV_ISA_EXT_ZVKT 63#define RISCV_ISA_EXT_ZFH 64#define RISCV_ISA_EXT_ZFHMIN 65 +#define RISCV_ISA_EXT_ZIHINTNTL 66#define RISCV_ISA_EXT_MAX 128
arch/riscv/kernel/cpufeature.c +1 -0
@@ -242,6 +242,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zicntr,RISCV_ISA_EXT_ZICNTR ),__RISCV_ISA_EXT_DATA (zicsr,RISCV_ISA_EXT_ZICSR ),__RISCV_ISA_EXT_DATA (zifencei,RISCV_ISA_EXT_ZIFENCEI ), +__RISCV_ISA_EXT_DATA (zihintntl,RISCV_ISA_EXT_ZIHINTNTL ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ),__RISCV_ISA_EXT_DATA (zihpm,RISCV_ISA_EXT_ZIHPM ), __RISCV_ISA_EXT_DATA(zfh, RISCV_ISA_EXT_ZFH),
Signature · 1 line
2.42.0
Re: [PATCH v2 11/19] riscv: add ISA extension parsing for Zihintntl
Quoted 7 lines · Clément Léger
Add parsing for Zihintntl ISA extension[1] that was ratified in commit 0dc91f5 ("Zihintntl is ratified") of riscv-isa-manual[2].
PATCH v2 12/19 riscv: hwprobe: export Zhintntl ISA extension
In reply to Clément LégerExport Zihintntl extension[1] through hwprobe.
--- Documentation/riscv/hwprobe.rst | 3 +++ arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/sys_riscv.c | 1 + 3 files changed, 5 insertions(+)
Documentation/riscv/hwprobe.rst +3 -0
@@ -143,6 +143,9 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is supported as defined in the RISC-V ISA manual. + * :c:macro:`RISCV_HWPROBE_EXT_ZIHINTNTL`: The Zihintntl extension version 1.0 + is supported as defined in the RISC-V ISA manual. + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +1 -0
@@ -51,6 +51,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZVKT (1 << 25)#define RISCV_HWPROBE_EXT_ZFH (1 << 26)#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 27) +#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 28)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +1 -0
@@ -172,6 +172,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,CHECK_ISA_EXT (ZKSED );CHECK_ISA_EXT (ZKSH );CHECK_ISA_EXT (ZKT ); +CHECK_ISA_EXT (ZIHINTNTL );if (has_vector ()) {CHECK_ISA_EXT (ZVBB );
Signature · 1 line
2.42.0
Re: [PATCH v2 12/19] riscv: hwprobe: export Zhintntl ISA extension
Quoted 5 lines · Clément Léger
Export Zihintntl extension[1] through hwprobe.
PATCH v2 13/19 dt-bindings: riscv: add Zihintntl ISA extension description
In reply to Clément LégerAdd description for Zihintntl ISA extension[1] which can now be reported through hwprobe for userspace usage.
--- Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -0
@@ -324,6 +324,12 @@ properties: The standard Zihintpause extension for pause hints, as ratified in commit d8ab5c7 ("Zihintpause is ratified") of the riscv-isa-manual. + - const: zihintntl + description: + The standard Zihintntl extension for non-temporal locality hints, as + ratified in commit 0dc91f5 ("Zihintntl is ratified") of the + riscv-isa-manual. + - const: zihpm description: The standard Zihpm extension for hardware performance counters, as
Signature · 1 line
2.42.0
PATCH v2 14/19 riscv: add ISA extension parsing for Zvfh[min]
In reply to Clément LégerAdd parsing for Zvfh[min] ISA extension[1] which were ratified in june 2023 around commit e2ccd0548d6c ("Remove draft warnings from Zvfh[min]") in riscv-v-spec[2].
--- arch/riscv/include/asm/hwcap.h | 2 ++ arch/riscv/kernel/cpufeature.c | 2 ++ 2 files changed, 4 insertions(+)
arch/riscv/include/asm/hwcap.h +2 -0
@@ -82,6 +82,8 @@#define RISCV_ISA_EXT_ZFH 64#define RISCV_ISA_EXT_ZFHMIN 65#define RISCV_ISA_EXT_ZIHINTNTL 66 +#define RISCV_ISA_EXT_ZVFH 67 +#define RISCV_ISA_EXT_ZVFHMIN 68#define RISCV_ISA_EXT_MAX 128
arch/riscv/kernel/cpufeature.c +2 -0
@@ -266,6 +266,8 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zksh,RISCV_ISA_EXT_ZKSH ),__RISCV_ISA_EXT_DATA (zvbb,RISCV_ISA_EXT_ZVBB ),__RISCV_ISA_EXT_DATA (zvbc,RISCV_ISA_EXT_ZVBC ), +__RISCV_ISA_EXT_DATA (zvfh,RISCV_ISA_EXT_ZVFH ), +__RISCV_ISA_EXT_DATA (zvfhmin,RISCV_ISA_EXT_ZVFHMIN ),__RISCV_ISA_EXT_DATA (zvkb,RISCV_ISA_EXT_ZVKB ),__RISCV_ISA_EXT_DATA (zvkg,RISCV_ISA_EXT_ZVKG ), __RISCV_ISA_EXT_BUNDLE(zvkn, riscv_zvkn_bundled_exts),
Signature · 1 line
2.42.0
Re: [PATCH v2 14/19] riscv: add ISA extension parsing for Zvfh[min]
Quoted 8 lines · Clément Léger
Add parsing for Zvfh[min] ISA extension[1] which were ratified in june 2023 around commit
e2ccd0548d6c("Remove draft warnings from Zvfh[min]") in riscv-v-spec[2].
PATCH v2 15/19 riscv: hwprobe: export Zvfh[min] ISA extensions
In reply to Clément LégerExport Zvfh[min] ISA extension[1] through hwprobe.
--- Documentation/riscv/hwprobe.rst | 8 ++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 2 ++ arch/riscv/kernel/sys_riscv.c | 2 ++ 3 files changed, 12 insertions(+)
Documentation/riscv/hwprobe.rst +8 -0
@@ -146,6 +146,14 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_ZIHINTNTL`: The Zihintntl extension version 1.0 is supported as defined in the RISC-V ISA manual. + * :c:macro:`RISCV_HWPROBE_EXT_ZVFH`: The Zvfh extension is supported as + defined in the RISC-V Vector manual starting from commit e2ccd0548d6c + ("Remove draft warnings from Zvfh[min]"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFHMIN`: The Zvfhmin extension is supported as + defined in the RISC-V Vector manual starting from commit e2ccd0548d6c + ("Remove draft warnings from Zvfh[min]"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +2 -0
@@ -52,6 +52,8 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZFH (1 << 26)#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 27)#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 28) +#define RISCV_HWPROBE_EXT_ZVFH (1 << 29) +#define RISCV_HWPROBE_EXT_ZVFHMIN (1 << 30)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +2 -0
@@ -185,6 +185,8 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,CHECK_ISA_EXT (ZVKSED );CHECK_ISA_EXT (ZVKSH );CHECK_ISA_EXT (ZVKT ); +CHECK_ISA_EXT (ZVFH ); +CHECK_ISA_EXT (ZVFHMIN ); }if (has_fpu ()) {
Signature · 1 line
2.42.0
Re: [PATCH v2 15/19] riscv: hwprobe: export Zvfh[min] ISA extensions
Quoted 5 lines · Clément Léger
Export Zvfh[min] ISA extension[1] through hwprobe.
PATCH v2 16/19 dt-bindings: riscv: add Zvfh[min] ISA extension description
In reply to Clément LégerAdd description for Zvfh[min] ISA extension[1] which can now be reported through hwprobe for userspace usage.
--- .../devicetree/bindings/riscv/extensions.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +12 -0
@@ -354,6 +354,18 @@ properties: instructions, as ratified in commit 56ed795 ("Update riscv-crypto-spec-vector.adoc") of riscv-crypto. + - const: zvfh + description: + The standard Zvfh extension for vectored half-precision + floating-point instructions, as ratified in commit e2ccd05 + ("Remove draft warnings from Zvfh[min]") of riscv-v-spec. + + - const: zvfhmin + description: + The standard Zvfhmin extension for vectored minimal half-precision + floating-point instructions, as ratified in commit e2ccd05 + ("Remove draft warnings from Zvfh[min]") of riscv-v-spec. + - const: zvkb description: The standard Zvkb extension for vector cryptography bit-manipulation
Signature · 1 line
2.42.0
PATCH v2 17/19 riscv: add ISA extension parsing for Zfa
In reply to Clément LégerAdd parsing for Zfa ISA extension [1] which were ratified in commit 056b6ff467c7 ("Zfa is ratified") of riscv-isa-manual[2].
--- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpufeature.c | 1 + 2 files changed, 2 insertions(+)
arch/riscv/include/asm/hwcap.h +1 -0
@@ -84,6 +84,7 @@#define RISCV_ISA_EXT_ZIHINTNTL 66#define RISCV_ISA_EXT_ZVFH 67#define RISCV_ISA_EXT_ZVFHMIN 68 +#define RISCV_ISA_EXT_ZFA 69#define RISCV_ISA_EXT_MAX 128
arch/riscv/kernel/cpufeature.c +1 -0
@@ -245,6 +245,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zihintntl,RISCV_ISA_EXT_ZIHINTNTL ),__RISCV_ISA_EXT_DATA (zihintpause,RISCV_ISA_EXT_ZIHINTPAUSE ),__RISCV_ISA_EXT_DATA (zihpm,RISCV_ISA_EXT_ZIHPM ), +__RISCV_ISA_EXT_DATA (zfa,RISCV_ISA_EXT_ZFA ),__RISCV_ISA_EXT_DATA (zfh,RISCV_ISA_EXT_ZFH ),__RISCV_ISA_EXT_DATA (zfhmin,RISCV_ISA_EXT_ZFHMIN ), __RISCV_ISA_EXT_DATA(zba, RISCV_ISA_EXT_ZBA),
Signature · 1 line
2.42.0
Re: [PATCH v2 17/19] riscv: add ISA extension parsing for Zfa
Quoted 7 lines · Clément Léger
Add parsing for Zfa ISA extension [1] which were ratified in commit
056b6ff467c7("Zfa is ratified") of riscv-isa-manual[2].
PATCH v2 18/19 riscv: hwprobe: export Zfa ISA extension
In reply to Clément LégerExport Zfa ISA extension[1] through hwprobe.
--- Documentation/riscv/hwprobe.rst | 4 ++++ arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/sys_riscv.c | 1 + 3 files changed, 6 insertions(+)
Documentation/riscv/hwprobe.rst +4 -0
@@ -154,6 +154,10 @@ The following keys are defined: defined in the RISC-V Vector manual starting from commit e2ccd0548d6c ("Remove draft warnings from Zvfh[min]"). + * :c:macro:`RISCV_HWPROBE_EXT_ZFA`: The Zfa extension is supported as + defined in the RISC-V ISA manual starting from commit 056b6ff467c7 + ("Zfa is ratified"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance information about the selected set of processors.
arch/riscv/include/uapi/asm/hwprobe.h +1 -0
@@ -54,6 +54,7 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 28)#define RISCV_HWPROBE_EXT_ZVFH (1 << 29)#define RISCV_HWPROBE_EXT_ZVFHMIN (1 << 30) +#define RISCV_HWPROBE_EXT_ZFA (1 << 31)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_riscv.c +1 -0
@@ -192,6 +192,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,if (has_fpu ()) {CHECK_ISA_EXT (ZFH );CHECK_ISA_EXT (ZFHMIN ); +CHECK_ISA_EXT (ZFA ); }#undef CHECK_ISA_EXT }
Signature · 1 line
2.42.0
Re: [PATCH v2 18/19] riscv: hwprobe: export Zfa ISA extension
Quoted 5 lines · Clément Léger
Export Zfa ISA extension[1] through hwprobe.
PATCH v2 19/19 dt-bindings: riscv: add Zfa ISA extension description
In reply to Clément LégerAdd description for the Zfa ISA extension[1] which can now be reported through hwprobe for userspace usage.
--- Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -0
@@ -208,6 +208,12 @@ properties: instructions as ratified at commit 6d33919 ("Merge pull request #158 from hirooih/clmul-fix-loop-end-condition") of riscv-bitmanip. + - const: zfa + description: + The standard Zfa extension for additional floating point + instructions, as ratified in commit 056b6ff ("Zfa is ratified") of + riscv-isa-manual. + - const: zfh description: The standard Zfh extension for 16-bit half-precision binary
Signature · 1 line
2.42.0