-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
riscv: use hwprobe syscall for capability detection #24172
riscv: use hwprobe syscall for capability detection #24172
Conversation
a3fbc7b
to
07e6aa5
Compare
Cherry-picked #24069 on this branch and ran openssl on Canaan Kendryte K230 where kernel=6.8.0 to test whether hwprobe works, the results matched $ unset OPENSSL_riscvcap
$ ./openssl speed -evp chacha20-poly1305
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
ChaCha20-Poly1305 33989.34k 52381.21k 75642.11k 79155.54k 90438.59k 90581.67k
$ export OPENSSL_riscvcap="rv64gc"
$ ./openssl speed -evp chacha20-poly1305
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
ChaCha20-Poly1305 34001.63k 53398.65k 59937.11k 62083.66k 63053.82k 63018.33k
$ export OPENSSL_riscvcap="rv64gc_v_zbb"
$ ./openssl speed -evp chacha20-poly1305
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
ChaCha20-Poly1305 33614.25k 52176.50k 76595.11k 79170.56k 90750.98k 90608.98k
|
Now cpuinfo can be displayed. Benchmark result using #24069 $ ./openssl info -cpusettings
OPENSSL_riscvcap=ZBA_ZBB_ZBC_ZBS_V
$ ./openssl speed -evp chacha20-poly1305
CPUINFO: OPENSSL_riscvcap=ZBA_ZBB_ZBC_ZBS_V
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
ChaCha20-Poly1305 33657.82k 52458.13k 75558.49k 78885.42k 90753.71k 90570.75k
$ export OPENSSL_riscvcap="rv64gc_zba_zbb_zbc_zbs"
$ ./openssl info -cpusettings
OPENSSL_riscvcap=ZBA_ZBB_ZBC_ZBS env:rv64gc_zba_zbb_zbc_zbs
$ ./openssl speed -evp chacha20-poly1305
CPUINFO: OPENSSL_riscvcap=ZBA_ZBB_ZBC_ZBS env:rv64gc_zba_zbb_zbc_zbs
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
ChaCha20-Poly1305 33741.30k 52294.55k 59968.85k 62311.77k 62792.63k 62941.87k |
Documentation for The limitation of the environment variable parser, as documented, would be fixed in another PR. |
bdbcbc1
to
403a17a
Compare
fe7ef98
to
b4e7fe6
Compare
Wonder if anything should be done for this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My approval stands
@openssl/committers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits
b4e7fe6
to
49d3189
Compare
Requested changes addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulidale please reconfirm
This pull request is ready to merge |
Merged to the master branch. Thank you for your contribution. |
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #24172)
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #24172)
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #24172)
*/ | ||
# define OSSL_RISCV_HWPROBE_PAIR_COUNT 1 | ||
# define OSSL_RISCV_HWPROBE_PAIR_CONTENT \ | ||
{ 4, 0 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to replace 4
here with RISCV_HWPROBE_KEY_IMA_EXT_0
with #define RISCV_HWPROBE_KEY_IMA_EXT_0 4
somewhere.
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#24172)
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#24172)
Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from openssl#24172)
This originates from #24069 (comment)
hwprobe is a linux syscall specific to riscv architecture where key/value pairs can be queried to detect whether an extension exists. This corresponds to the capability defined in openssl.
hwprobe syscall is added in Linux 6.4 and
<asm/hwprobe.h>
is still updating (check lkml). To workaround the compile time/runtime linux version problem, examples are<asm/hwprobe.h>
is does not corresponds to the hwprobe.h openssl requiredAs for non-existing syscall,
__has_include(<asm/hwprobe.h>)
can be used at compile time and-ENOSYS
can be used at runtimeAs for unknown key/value query, the syscall would clear it, see
The only problem is the possible unknown macros from
<asm/hwprobe.h>
(undefined macro when compiling in old system) so directly coping value is the workaround.As the original thread discussed,
OPENSSL_riscvcap
, when provided, should override hwprobe interface.Documentation for
OPENSSL_riscvcap
together with hwprobe would be added in another PR.Checklist