diff options
| author | Eric Biggers <ebiggers@google.com> | 2024-12-02 04:08:28 +0300 |
|---|---|---|
| committer | Eric Biggers <ebiggers@google.com> | 2024-12-02 04:23:01 +0300 |
| commit | b5ae12e0ee099e4c458f7814f0317f4e2cbf105e (patch) | |
| tree | 2971f631ae4a609aafc5c4e5c932bcd8a6117ab9 /arch/arm64/lib | |
| parent | d36cebe03c3ae4ea1fde20cfc797fab8729c3ab5 (diff) | |
| download | linux-b5ae12e0ee099e4c458f7814f0317f4e2cbf105e.tar.xz | |
lib/crc32: expose whether the lib is really optimized at runtime
Make the CRC32 library export a function crc32_optimizations() which
returns flags that indicate which CRC32 functions are actually executing
optimized code at runtime.
This will be used to determine whether the crc32[c]-$arch shash
algorithms should be registered in the crypto API. btrfs could also
start using these flags instead of the hack that it currently uses where
it parses the crypto_shash_driver_name.
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20241202010844.144356-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Diffstat (limited to 'arch/arm64/lib')
| -rw-r--r-- | arch/arm64/lib/crc32-glue.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm64/lib/crc32-glue.c b/arch/arm64/lib/crc32-glue.c index d7f6e1cbf0d2..15c4c9db573e 100644 --- a/arch/arm64/lib/crc32-glue.c +++ b/arch/arm64/lib/crc32-glue.c @@ -85,5 +85,15 @@ u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len) } EXPORT_SYMBOL(crc32_be_arch); +u32 crc32_optimizations(void) +{ + if (alternative_has_cap_likely(ARM64_HAS_CRC32)) + return CRC32_LE_OPTIMIZATION | + CRC32_BE_OPTIMIZATION | + CRC32C_OPTIMIZATION; + return 0; +} +EXPORT_SYMBOL(crc32_optimizations); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("arm64-optimized CRC32 functions"); |
