^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Accelerated CRC32(C) using ARM CRC, NEON and Crypto Extensions instructions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/cpufeature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/crc32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <crypto/internal/simd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/hwcap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/neon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/simd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define PMULL_MIN_LEN 64L /* minimum size of buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * for crc32_pmull_le_16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define SCALE_F 16L /* size of NEON register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) asmlinkage u32 crc32_pmull_le(const u8 buf[], u32 len, u32 init_crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) asmlinkage u32 crc32_armv8_le(u32 init_crc, const u8 buf[], u32 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) asmlinkage u32 crc32c_pmull_le(const u8 buf[], u32 len, u32 init_crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) asmlinkage u32 crc32c_armv8_le(u32 init_crc, const u8 buf[], u32 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static u32 (*fallback_crc32)(u32 init_crc, const u8 buf[], u32 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static u32 (*fallback_crc32c)(u32 init_crc, const u8 buf[], u32 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int crc32_cra_init(struct crypto_tfm *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u32 *key = crypto_tfm_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *key = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static int crc32c_cra_init(struct crypto_tfm *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u32 *key = crypto_tfm_ctx(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *key = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static int crc32_setkey(struct crypto_shash *hash, const u8 *key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned int keylen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u32 *mctx = crypto_shash_ctx(hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (keylen != sizeof(u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) *mctx = le32_to_cpup((__le32 *)key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static int crc32_init(struct shash_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u32 *mctx = crypto_shash_ctx(desc->tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) *crc = *mctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static int crc32_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *crc = crc32_armv8_le(*crc, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static int crc32c_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) unsigned int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *crc = crc32c_armv8_le(*crc, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static int crc32_final(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) put_unaligned_le32(*crc, out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static int crc32c_final(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) put_unaligned_le32(~*crc, out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static int crc32_pmull_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) unsigned int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) unsigned int l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (crypto_simd_usable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if ((u32)data % SCALE_F) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) l = min_t(u32, length, SCALE_F - ((u32)data % SCALE_F));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *crc = fallback_crc32(*crc, data, l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) data += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) length -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (length >= PMULL_MIN_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) l = round_down(length, SCALE_F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) kernel_neon_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *crc = crc32_pmull_le(data, l, *crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) kernel_neon_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) data += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) length -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (length > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) *crc = fallback_crc32(*crc, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static int crc32c_pmull_update(struct shash_desc *desc, const u8 *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) unsigned int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) u32 *crc = shash_desc_ctx(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) unsigned int l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (crypto_simd_usable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if ((u32)data % SCALE_F) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) l = min_t(u32, length, SCALE_F - ((u32)data % SCALE_F));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) *crc = fallback_crc32c(*crc, data, l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) data += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) length -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (length >= PMULL_MIN_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) l = round_down(length, SCALE_F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) kernel_neon_begin();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) *crc = crc32c_pmull_le(data, l, *crc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) kernel_neon_end();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) data += l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) length -= l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (length > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) *crc = fallback_crc32c(*crc, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static struct shash_alg crc32_pmull_algs[] = { {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) .setkey = crc32_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) .init = crc32_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) .update = crc32_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) .final = crc32_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) .descsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .digestsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) .base.cra_ctxsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) .base.cra_init = crc32_cra_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .base.cra_name = "crc32",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) .base.cra_driver_name = "crc32-arm-ce",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) .base.cra_priority = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) .base.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) .base.cra_module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) .setkey = crc32_setkey,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .init = crc32_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) .update = crc32c_update,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .final = crc32c_final,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) .descsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) .digestsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) .base.cra_ctxsize = sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) .base.cra_init = crc32c_cra_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .base.cra_name = "crc32c",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .base.cra_driver_name = "crc32c-arm-ce",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .base.cra_priority = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .base.cra_blocksize = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .base.cra_module = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) } };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static int __init crc32_pmull_mod_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (elf_hwcap2 & HWCAP2_PMULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) crc32_pmull_algs[0].update = crc32_pmull_update;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) crc32_pmull_algs[1].update = crc32c_pmull_update;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (elf_hwcap2 & HWCAP2_CRC32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) fallback_crc32 = crc32_armv8_le;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) fallback_crc32c = crc32c_armv8_le;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) fallback_crc32 = crc32_le;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) fallback_crc32c = __crc32c_le;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) } else if (!(elf_hwcap2 & HWCAP2_CRC32)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return crypto_register_shashes(crc32_pmull_algs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ARRAY_SIZE(crc32_pmull_algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static void __exit crc32_pmull_mod_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) crypto_unregister_shashes(crc32_pmull_algs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ARRAY_SIZE(crc32_pmull_algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static const struct cpu_feature __maybe_unused crc32_cpu_feature[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) { cpu_feature(CRC32) }, { cpu_feature(PMULL) }, { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_DEVICE_TABLE(cpu, crc32_cpu_feature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) module_init(crc32_pmull_mod_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) module_exit(crc32_pmull_mod_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) MODULE_ALIAS_CRYPTO("crc32");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MODULE_ALIAS_CRYPTO("crc32c");