Commit Graph

1412062 Commits

Author SHA1 Message Date
Alexander Bendezu
fcce6bcb14 crypto: blowfish - fix typo in comment
Fix spelling mistake in comment: endianess -> endianness

Signed-off-by: Alexander Bendezu <alexanderbendezu10@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:44 +08:00
Thomas Weißschuh
c1b12cd933 padata: Constify padata_sysfs_entry structs
These structs are never modified.

To prevent malicious or accidental modifications due to bugs,
mark them as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:44 +08:00
Thorsten Blum
a3f8e00991 crypto: api - remove unnecessary forward declarations
Add the __maybe_unused attribute to the function definitions and remove
the now-unnecessary forward declarations.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Thorsten Blum
b4f275b92d crypto: simd - Simplify request size calculation in simd_aead_init
Fold both assignments into a single max() call to simplify the code.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
280bfc3eb5 crypto: xilinx - Add gcm(aes) support for AMD/Xilinx Versal device
Add gcm(aes) algorithm support for AMD/Xilinx Versal devices.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
856f061925 crypto: xilinx - Remove un-necessary typecast operation
Return type of crypto_tfm_ctx() is void *. Remove explicit type cast.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
e9f6870bb7 firmware: xilinx: Add firmware API's to support aes-gcm in Versal device
Add aes-gcm crypto API's for AMD/Xilinx Versal device.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
c315cb0005 crypto: xilinx - Change coherent DMA to streaming DMA API
Update the driver to use streaming DMA API.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
56934489a8 crypto: xilinx - Replace zynqmp prefix with xilinx
Replace zynqmp with xilinx to have more generic name.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
43f0478672 crypto: xilinx - Register H/W key support with paes
Register gcm(paes) for hardware supported keys.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
0d120a39b9 crypto: xilinx - Avoid submitting fallback requests to engine
Don't enqueue requests which are supposed to fallback to s/w crypto.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
f939b88c7c crypto: xilinx - Avoid Encrypt request to fallback for authsize < 16
Encrypt requests can be handled by driver when authsize is less than 16.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
349f0d326d crypto: xilinx - Return linux error code instead of firmware error code
Convert FW error code to linux error code and remove dmesg error print for
authentication tag mismatch failure.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
75578e5c20 crypto: xilinx - Update probe to self discover the device
Update driver to self discover the device.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
2de468529f dt-bindings: crypto: Mark zynqmp-aes as Deprecated
zynqmp-aes-gcm updated to self discover, corresponding dt binding
can be mark deprecated.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
465d783126 firmware: zynqmp: Add helper API to self discovery the device
Add API to get SoC version and family info.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
c7a768f57d crypto: xilinx - Remove union from zynqmp_aead_drv_ctx
"alg" in zynqmp_aead_drv_ctx is single field union variable.
Remove unnecessary alg union from structure.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Harsh Jain
c15291e227 firmware: zynqmp: Move crypto API's to separate file
For better maintainability move crypto related API's to
new zynqmp-crypto.c file.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:43 +08:00
Thorsten Blum
1ccc00d71e crypto: engine - Use unregister_* in register_{aeads,ahashes,skciphers}
Replace the for loops with calls to unregister_aeads(),
unregister_ahashes(), and unregister_skciphers(), respectively. Return
'ret' immediately and remove the goto statements to simplify the error
handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Thorsten Blum
32adff68c7 crypto: lskcipher - Use unregister_lskciphers in register_lskciphers
Replace the for loop with a call to crypto_unregister_lskciphers().
Return 'ret' immediately and remove the goto statement to simplify the
error handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Thorsten Blum
5a22716ebe crypto: skcipher - Use unregister_skciphers in register_skciphers
Replace the for loop with a call to crypto_unregister_skciphers().
Return 'ret' immediately and remove the goto statement to simplify the
error handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Thorsten Blum
c29fcecaf8 crypto: shash - Use unregister_shashes in register_shashes
Replace the for loop with a call to crypto_unregister_shashes(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Thorsten Blum
bcc3b3c8ae crypto: ahash - Use unregister_ahashes in register_ahashes
Replace the for loop with a call to crypto_unregister_ahashes(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Thorsten Blum
fbbc944b59 crypto: acomp - Use unregister_acomps in register_acomps
Replace the for loop with a call to crypto_unregister_acomps(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-23 13:48:42 +08:00
Chenghai Huang
4154f7d3b1 crypto: hisilicon/sgl - fix inconsistent map/unmap direction issue
Ensure that the direction for dma_map_sg and dma_unmap_sg is
consistent.

Fixes: 2566de3e06 ("crypto: hisilicon - Use fine grained DMA mapping direction")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Qi Tao
e750743962 crypto: hisilicon/sec2 - support skcipher/aead fallback for hardware queue unavailable
When all hardware queues are busy and no shareable queue,
new processes fail to apply for queues. To avoid affecting
tasks, support fallback mechanism when hardware queues are
unavailable.

Fixes: c16a70c1f2 ("crypto: hisilicon/sec - add new algorithm mode for AEAD")
Signed-off-by: Qi Tao <taoqi10@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Weili Qian
6aff4d977e crypto: hisilicon/hpre - support the hpre algorithm fallback
When all hardware queues are busy and no shareable queue,
new processes fail to apply for queues. To avoid affecting
tasks, support fallback mechanism when hardware queues are
unavailable.

HPRE driver supports DH algorithm, limited to prime numbers up to 4K.
It supports prime numbers larger than 4K via fallback mechanism.

Fixes: 05e7b906aa ("crypto: hisilicon/hpre - add 'ECDH' algorithm")
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
73398f85a4 crypto: hisilicon/zip - support fallback for zip
When the hardware queue resource busy(no shareable queue)
or memery alloc fail in initialization of acomp_alg, use
soft algorithm to complete the work.

Fixes: 1a9e6f59ca ("crypto: hisilicon/zip - remove zlib and gzip")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
2a75decec1 crypto: hisilicon/qm - optimize device selection priority based on queue ref count and NUMA distance
Add device sorting criteria to prioritize devices with fewer
references and closer NUMA distances. Devices that are fully
occupied will not be prioritized for use.

Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
4705489742 crypto: hisilicon/qm - add reference counting to queues for tfm kernel reuse
Add reference counting to queues. When all queues are occupied, tfm
will reuse queues with the same algorithm type that have already
been allocated in the kernel. The corresponding queue will be
released when the reference count reaches 1.

Reviewed-by: Longfang Liu <liulongfang@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
72f3bbebff crypto: hisilicon - consolidate qp creation and start in hisi_qm_alloc_qps_node
Consolidate the creation and start of qp into the function
hisi_qm_alloc_qps_node. This change eliminates the need for
each module to perform these steps in two separate phases
(creation and start).

Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
8cd9b608ee crypto: hisilicon/qm - centralize the sending locks of each module into qm
When a single queue used by multiple tfms, the protection of shared
resources by individual module driver programs is no longer
sufficient. The hisi_qp_send needs to be ensured by the lock in qp.

Fixes: 5fdb4b345c ("crypto: hisilicon - add a lock for the qp send operation")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
21452eaa06 crypto: hisilicon/qm - enhance the configuration of req_type in queue attributes
Originally, when a queue was requested, it could only be configured
with the default algorithm type of 0. Now, when multiple tfms use
the same queue, the queue must be selected based on its attributes
to meet the requirements of tfm tasks. So the algorithm type
attribute of queue need to be distinguished. Just like a queue used
for compression in ZIP cannot be used for decompression tasks.

Fixes: 3f1ec97aac ("crypto: hisilicon/qm - Put device finding logic into QM")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
lizhi
3a19847581 crypto: hisilicon/hpre: extend tag field to 64 bits for better performance
This commit expands the tag field in hpre_sqe structure from 16-bit
to 64-bit. The change enables storing request addresses directly
in the tag field, allowing callback functions to access request messages
without the previous indirection mechanism.

By eliminating the need for lookup tables, this modification reduces lock
contention and associated overhead, leading to improved efficiency and
simplified code.

Fixes: c8b4b47707 ("crypto: hisilicon - add HiSilicon HPRE accelerator")
Signed-off-by: lizhi <lizhi206@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
08eb67d23e crypto: hisilicon/sec - move backlog management to qp and store sqe in qp for callback
When multiple tfm use a same qp, the backlog data should be managed
centrally by the qp, rather than in the qp_ctx of each req.

Additionally, since SEC_BD_TYPE1 and SEC_BD_TYPE2 cannot use the
tag of the sqe to carry the virtual address of the req, the sent
sqe is stored in the qp. This allows the callback function to get
the req address. To handle the differences between hardware types,
the callback functions are split into two separate implementations.

Fixes: f0ae287c50 ("crypto: hisilicon/sec2 - implement full backlog mode for sec")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Chenghai Huang
19c2475ce1 crypto: hisilicon/zip - adjust the way to obtain the req in the callback function
In the shared queue design, multiple tfms use same qp, and one qp
need to corresponds to multiple qp_ctx. So use tag to obtain the
req virtual address. Build a one-to-one relationship between tfm
and qp_ctx. finaly remove the old get_tag operation.

Fixes: 2bcf36348c ("crypto: hisilicon/zip - initialize operations about 'sqe' in 'acomp_alg.init'")
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Thomas Fourier
624a6760bf crypto: octeontx - fix dma_free_coherent() size
The size of the buffer in alloc_command_queues() is
curr->size + OTX_CPT_NEXT_CHUNK_PTR_SIZE, so used that length for
dma_free_coherent().

Fixes: 10b4f09491 ("crypto: marvell - add the Virtual Function driver for CPT")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Thomas Fourier
941676c30b crypto: cavium - fix dma_free_coherent() size
The size of the buffer in alloc_command_queues() is
curr->size + CPT_NEXT_CHUNK_PTR_SIZE, so used that length for
dma_free_coherent().

Fixes: c694b23329 ("crypto: cavium - Add the Virtual Function driver for CPT")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-01-16 14:02:06 +08:00
Sergey Shtylyov
c904e459cf crypto: drbg - make drbg_get_random_bytes() return *void*
Now that drbg_get_random_bytes() always returns 0, checking its result at
the call sites stopped to make sense -- make this function return *void*
instead of *int*...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Sergey Shtylyov
6acd394367 crypto: drbg - make drbg_fips_continuous_test() return bool
Currently, drbg_fips_continuous_test() only returns 0 and -EAGAIN, so an
early return from the *do*/*while* loop in drbg_get_random_bytes() just
isn't possible. Make drbg_fips_continuous_test() return bool instead of
*int* (using true instead of 0 and false instead of -EAGAIN). This way,
we can further simplify drbg_get_random_bytes()...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Sergey Shtylyov
eb6449aa7b crypto: drbg - kill useless variable in drbg_fips_continuous_test()
In drbg_fips_continuous_test(), not only the initializer of the ret local
variable is useless, the variable itself does not seem needed as it only
stores the result of memcmp() until it's checked on the next line -- get
rid of the variable...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Thorsten Blum
b6aa86c8a5 crypto: khazad - simplify return statement in khazad_mod_init
Return the result of calling crypto_register_alg() directly and remove
the local return variable.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Thorsten Blum
37b03cb378 crypto: octeontx2 - Use sysfs_emit in sysfs show functions
Replace sprintf() with sysfs_emit() in sso_pf_func_ovrd_show() and
kvf_limits_show(). sysfs_emit() is preferred for formatting sysfs output
as it performs proper bounds checking.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Thorsten Blum
bce4678f02 crypto: iaa - Replace sprintf with sysfs_emit in sysfs show functions
Replace sprintf() with sysfs_emit() in verify_compress_show() and
sync_mode_show(). sysfs_emit() is preferred to format sysfs output as it
provides better bounds checking.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-29 08:48:35 +08:00
Thorsten Blum
32c539884d crypto: algapi - Use crypto_unregister_algs in crypto_register_algs
Replace the for loop with a call to crypto_unregister_algs(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.

In crypto_unregister_algs(), unregister the algorithms in reverse order.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00
Thorsten Blum
0e602c5f04 crypto: scompress - Use crypto_unregister_scomps in crypto_register_scomps
Replace the for loop with a call to crypto_unregister_scomps(). Return
'ret' immediately and remove the goto statement to simplify the error
handling code.  No functional changes.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00
Harshal Dev
bb571875f7 dt-bindings: crypto: qcom,prng: document x1e80100
Document x1e80100 compatible for the True Random Number Generator.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Harshal Dev <harshal.dev@oss.qualcomm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00
Thorsten Blum
3e8541f98d crypto: scompress - Remove forward declaration of crypto_scomp_show
Add the __maybe_unused attribute to the crypto_scomp_show() definition
and remove the now-unnecessary forward declaration.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00
Can Peng
97282e2cde crypto: fips - annotate fips_enable() with __init to free init memory after boot
The fips_enable() function is only invoked early during kernel boot via the
__setup() macro ("fips=" command line parameter), and is never used again
after initialization completes.

Annotating it with __init places the function in the .init.text section,
allowing the kernel to free its memory after init (when freeing_initmem()
runs), reducing runtime memory footprint.

This is a standard practice for setup/early-parse functions and has no
functional impact — the parsing logic, return values, and fips mode
setting behavior remain unchanged.

Signed-off-by: Can Peng <pengcan@kylinos.cn>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00
Thorsten Blum
e6bba60966 crypto: iaa - Remove unreachable pr_debug from iaa_crypto_cleanup_module
iaa_unregister_compression_device() always returns 0, making the debug
log message unreachable. Remove the log statement and convert
iaa_unregister_compression_device() to a void function.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-12-19 14:47:47 +08:00