Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: inside-secure - remove crc32 support

The crc32 acceleration in the inside-secure driver is accessible only as
an asynchronous hash. However, there seems to be no corresponding user
of crc32 in the kernel that supports asynchronous hashes. Therefore,
this code seems to be unused.

The patch that added this code provided no justification for its
inclusion. All devicetree bindings for this accelerator are for arm64;
arm64 CPUs often have CRC or PMULL instructions, which already
accelerate crc32 very well. And these actually work with the crc32
users in the kernel, unlike this driver which doesn't.

Remove this unnecessary code.

Cc: Antoine Tenart <atenart@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250531204244.24648-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+2 -92
-1
drivers/crypto/inside-secure/safexcel.c
··· 1218 1218 &safexcel_alg_xts_aes, 1219 1219 &safexcel_alg_gcm, 1220 1220 &safexcel_alg_ccm, 1221 - &safexcel_alg_crc32, 1222 1221 &safexcel_alg_cbcmac, 1223 1222 &safexcel_alg_xcbcmac, 1224 1223 &safexcel_alg_cmac,
-1
drivers/crypto/inside-secure/safexcel.h
··· 959 959 extern struct safexcel_alg_template safexcel_alg_xts_aes; 960 960 extern struct safexcel_alg_template safexcel_alg_gcm; 961 961 extern struct safexcel_alg_template safexcel_alg_ccm; 962 - extern struct safexcel_alg_template safexcel_alg_crc32; 963 962 extern struct safexcel_alg_template safexcel_alg_cbcmac; 964 963 extern struct safexcel_alg_template safexcel_alg_xcbcmac; 965 964 extern struct safexcel_alg_template safexcel_alg_cmac;
+2 -90
drivers/crypto/inside-secure/safexcel_hash.c
··· 289 289 return 1; 290 290 } 291 291 292 - if (unlikely(sreq->digest == CONTEXT_CONTROL_DIGEST_XCM && 293 - ctx->alg == CONTEXT_CONTROL_CRYPTO_ALG_CRC32)) { 294 - /* Undo final XOR with 0xffffffff ...*/ 295 - *(__le32 *)areq->result = ~sreq->state[0]; 296 - } else { 297 - memcpy(areq->result, sreq->state, 298 - crypto_ahash_digestsize(ahash)); 299 - } 292 + memcpy(areq->result, sreq->state, 293 + crypto_ahash_digestsize(ahash)); 300 294 } 301 295 302 296 cache_len = safexcel_queued_len(sreq); ··· 1868 1874 .cra_blocksize = MD5_HMAC_BLOCK_SIZE, 1869 1875 .cra_ctxsize = sizeof(struct safexcel_ahash_ctx), 1870 1876 .cra_init = safexcel_ahash_cra_init, 1871 - .cra_exit = safexcel_ahash_cra_exit, 1872 - .cra_module = THIS_MODULE, 1873 - }, 1874 - }, 1875 - }, 1876 - }; 1877 - 1878 - static int safexcel_crc32_cra_init(struct crypto_tfm *tfm) 1879 - { 1880 - struct safexcel_ahash_ctx *ctx = crypto_tfm_ctx(tfm); 1881 - int ret = safexcel_ahash_cra_init(tfm); 1882 - 1883 - /* Default 'key' is all zeroes */ 1884 - memset(&ctx->base.ipad, 0, sizeof(u32)); 1885 - return ret; 1886 - } 1887 - 1888 - static int safexcel_crc32_init(struct ahash_request *areq) 1889 - { 1890 - struct safexcel_ahash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(areq)); 1891 - struct safexcel_ahash_req *req = ahash_request_ctx_dma(areq); 1892 - 1893 - memset(req, 0, sizeof(*req)); 1894 - 1895 - /* Start from loaded key */ 1896 - req->state[0] = cpu_to_le32(~ctx->base.ipad.word[0]); 1897 - /* Set processed to non-zero to enable invalidation detection */ 1898 - req->len = sizeof(u32); 1899 - req->processed = sizeof(u32); 1900 - 1901 - ctx->alg = CONTEXT_CONTROL_CRYPTO_ALG_CRC32; 1902 - req->digest = CONTEXT_CONTROL_DIGEST_XCM; 1903 - req->state_sz = sizeof(u32); 1904 - req->digest_sz = sizeof(u32); 1905 - req->block_sz = sizeof(u32); 1906 - 1907 - return 0; 1908 - } 1909 - 1910 - static int safexcel_crc32_setkey(struct crypto_ahash *tfm, const u8 *key, 1911 - unsigned int keylen) 1912 - { 1913 - struct safexcel_ahash_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); 1914 - 1915 - if (keylen != sizeof(u32)) 1916 - return -EINVAL; 1917 - 1918 - memcpy(&ctx->base.ipad, key, sizeof(u32)); 1919 - return 0; 1920 - } 1921 - 1922 - static int safexcel_crc32_digest(struct ahash_request *areq) 1923 - { 1924 - return safexcel_crc32_init(areq) ?: safexcel_ahash_finup(areq); 1925 - } 1926 - 1927 - struct safexcel_alg_template safexcel_alg_crc32 = { 1928 - .type = SAFEXCEL_ALG_TYPE_AHASH, 1929 - .algo_mask = 0, 1930 - .alg.ahash = { 1931 - .init = safexcel_crc32_init, 1932 - .update = safexcel_ahash_update, 1933 - .final = safexcel_ahash_final, 1934 - .finup = safexcel_ahash_finup, 1935 - .digest = safexcel_crc32_digest, 1936 - .setkey = safexcel_crc32_setkey, 1937 - .export = safexcel_ahash_export, 1938 - .import = safexcel_ahash_import, 1939 - .halg = { 1940 - .digestsize = sizeof(u32), 1941 - .statesize = sizeof(struct safexcel_ahash_export_state), 1942 - .base = { 1943 - .cra_name = "crc32", 1944 - .cra_driver_name = "safexcel-crc32", 1945 - .cra_priority = SAFEXCEL_CRA_PRIORITY, 1946 - .cra_flags = CRYPTO_ALG_OPTIONAL_KEY | 1947 - CRYPTO_ALG_ASYNC | 1948 - CRYPTO_ALG_ALLOCATES_MEMORY | 1949 - CRYPTO_ALG_KERN_DRIVER_ONLY, 1950 - .cra_blocksize = 1, 1951 - .cra_ctxsize = sizeof(struct safexcel_ahash_ctx), 1952 - .cra_init = safexcel_crc32_cra_init, 1953 1877 .cra_exit = safexcel_ahash_cra_exit, 1954 1878 .cra_module = THIS_MODULE, 1955 1879 },