aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/ccree
AgeCommit message (Collapse)Author
2020-05-15crypto: ccree - constify struct debugfs_reg32Rikard Falkeborn
pid_cd_regs and debug_regs are never changed and can therefore be made const. This allows the compiler to put it in the text section instead of the data section. Before: text data bss dec hex filename 2871 2320 64 5255 1487 drivers/crypto/ccree/cc_debugfs.o After: text data bss dec hex filename 3255 1936 64 5255 1487 drivers/crypto/ccree/cc_debugfs.o Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-05-08crypto: ccree - use crypto_shash_tfm_digest()Eric Biggers
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us. Cc: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-30crypto: ccree - remove duplicated include from cc_aead.cYueHaibing
Remove duplicated include. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - refactor AEAD IV in AAD handlingGilad Ben-Yossef
Our handling of ciphers with IV trailing the AAD was correct but overly complicated. Refactor to simplify and possibly save one DMA burst. This has the added bonus of behaving the same as the generic rfc4543 implementation for none compliants inputs where the IV in the iv field was not the same as the IV in the AAD. There should be no change in behaviour with correct inputs. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - use crypto_ipsec_check_assoclen()Gilad Ben-Yossef
Use crypto_ipsec_check_assoclen() instead of home grown functions. Clean up some unneeded code as a result. Delete stale comments while we're at it. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - only check condition if neededGilad Ben-Yossef
Move testing of condition to after the point we decide if we need it or not. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - remove ancient TODO remarksGilad Ben-Yossef
Remove left over ancient and now misleading TODO remarks. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - remove pointless commentHadar Gat
removed pointless comment Signed-off-by: Hadar Gat <hadar.gat@arm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-12crypto: ccree - update register handling macrosHadar Gat
Changed CC_GENMASK macro so it can be used for all HW registers. Signed-off-by: Hadar Gat <hadar.gat@arm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use devm_kzalloc() for hash dataGeert Uytterhoeven
As the lifetime of the hash data matches the lifetime of the driver, hash data can be allocated using the managed allocators. While at it, simplify cc_hash_free() by removing an unneeded check (hash_handle is always valid here). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use devm_k[mz]alloc() for cipher dataGeert Uytterhoeven
As the lifetime of the cipher data matches the lifetime of the driver, cipher data can be allocated using the managed allocators. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use devm_k[mz]alloc() for AEAD dataGeert Uytterhoeven
As the lifetime of the AEAD data matches the lifetime of the driver, AEAD data can be allocated using the managed allocators. While at it, simplify cc_aead_free() by removing an unneeded cast, and an unneeded check (aead_handle is always valid here). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use existing dev helper in init_cc_resources()Geert Uytterhoeven
Use the existing dev helper variable instead of plat_dev->dev. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - grammar s/not room/no room/Geert Uytterhoeven
Fix grammar in a comment. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - spelling s/Crytpcell/Cryptocell/Geert Uytterhoeven
Fix a typo in a comment. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - improve kerneldoc in cc_sram_mgr.[ch]Geert Uytterhoeven
Miscellaneous improvements: - Start comment blocks with "/**" to enable kerneldoc, - Mark parameters using "@" instead of "\param", - Fix typos in parameter names, - Add missing function names to kerneldoc headers, - Add missing parameter and return value descriptions. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - improve kerneldoc in cc_request_mgr.[ch]Geert Uytterhoeven
Miscellaneous improvements: - Start comment blocks with "/**" to enable kerneldoc, - Mark parameters using "@" instead of "\param", - Fix copied is_dout parameter of cc_send_request(), - Add missing function names to kerneldoc headers, - Add missing parameter descriptions. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - improve kerneldoc in cc_hash.[ch]Geert Uytterhoeven
Miscellaneous improvements: - Start comment blocks with "/**" to enable kerneldoc, - Mark parameters using "@" instead of "\param", - Add missing function names to kerneldoc headers, - Add missing parameter descriptions. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - improve kerneldoc in cc_buffer_mgr.cGeert Uytterhoeven
Miscellaneous improvements: - Add missing parameter and return value descriptions. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - improve kerneldoc in cc_hw_queue_defs.hGeert Uytterhoeven
Miscellaneous improvements: - Start comment blocks with "/**" to enable kerneldoc, - Fix descriptor type of set_dout_mlli(), - Fix copied config parameter of set_cipher_config1(), - Fix copied config parameter of set_bytes_swap(), - Add missing function names to kerneldoc headers, - Add missing parameter descriptions, - Remove descriptions for nonexistent parameters, - Add missing colons, - Remove references to obsolete camelcase parameter names, - Sort according to actual parameter order, - Fix grammar and spelling. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove bogus kerneldoc markersGeert Uytterhoeven
Normal comments should start with "/*". "/**" is reserver for kerneldoc. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - extract cc_init_copy_sram()Geert Uytterhoeven
Extract the copy to SRAM of the initial values for a hash algorithm into its own function, to improve readability and ease maintenance. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove struct cc_cipher_handleGeert Uytterhoeven
The cc_cipher_handle structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove struct buff_mgr_handleGeert Uytterhoeven
The buff_mgr_handle structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove struct cc_debugfs_ctxGeert Uytterhoeven
The cc_debugfs_ctx structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove struct cc_sram_ctxGeert Uytterhoeven
The cc_sram_ctx structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - make cc_pm_{suspend,resume}() staticGeert Uytterhoeven
cc_pm_suspend() and cc_pm_resume() are not used outside drivers/crypto/ccree/cc_pm.c. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove cc_pm_is_dev_suspended() wrapperGeert Uytterhoeven
If CONFIG_PM=y, cc_pm_is_dev_suspended() is just a wrapper around pm_runtime_suspended(). If CONFIG_PM=n, cc_pm_is_dev_suspended() a dummy that behaves exactly the same as the dummy for pm_runtime_suspended(). Hence remove cc_pm_is_dev_suspended(), and call pm_runtime_suspended() directly. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use of_device_get_match_data()Geert Uytterhoeven
If the driver is probed, it means a match was found in arm_ccree_dev_of_match[]. Hence we can just use the of_device_get_match_data() helper. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - simplify Runtime PM handlingGeert Uytterhoeven
Currently, a large part of the probe function runs before Runtime PM is enabled. As the driver manages the device's clock manually, this may work fine on some systems, but may break on platforms with a more complex power hierarchy. Fix this by moving the initialization of Runtime PM before the first register access (in cc_wait_for_reset_completion()), and putting the device to sleep only after the last access (in cc_set_ree_fips_status()). This allows to remove the pm_on flag, which was used to track manually if Runtime PM had been enabled or not. Remove the cc_pm_{init,go,fini}() wrappers, as they are called only once, and obscure operation. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use u32 for SRAM addressesGeert Uytterhoeven
SRAM addresses are small integer offsets into local SRAM. Currently they are stored using a mixture of cc_sram_addr_t (u64), u32, and dma_addr_t types. Settle on u32, and remove the cc_sram_addr_t typedefs. This allows to drop several casts. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove bogus paragraph about freeing SRAMGeert Uytterhoeven
The SRAM allocator does not support deallocating memory. Hence remove all references to freeing SRAM. Fix grammar while at it. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - defer larval_digest_addr init until neededGeert Uytterhoeven
While the larval digest addresses are not always used in cc_get_plain_hmac_key() and cc_hash_digest(), they are always calculated. Defer their calculations to the points where needed. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - use existing helpers to split 64-bit addressesGeert Uytterhoeven
Use the existing lower_32_bits() and upper_32_bits() macros instead of explicit casts and shifts to split a 64-bit address in its two 32-bit parts. Drop the superfluous cast to "u16", as the FIELD_PREP() macro already masks it to the specified field width. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - make mlli_params.mlli_virt_addr void *Geert Uytterhoeven
mlli_params.mlli_virt_addr is just a buffer of memory. This allows to drop a cast. No change in generated code. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - clean up clock handlingGeert Uytterhoeven
Use devm_clk_get_optional() instead of devm_clk_get() and explicit optional clock handling. As clk_prepare_enable() and clk_disable_unprepare() handle optional clocks fine, the cc_clk_on() and cc_clk_off() wrappers can be removed. While at it, use the new "%pe" format specifier to print error codes. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove empty cc_sram_mgr_fini()Geert Uytterhoeven
cc_sram_mgr_fini() doesn't do anything, so it can just be removed. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - drop duplicated error message on SRAM exhaustionGeert Uytterhoeven
When no SRAM can be allocated, cc_sram_alloc() already prints an error message. Hence there is no need to duplicate this in all callers. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - swap SHA384 and SHA512 larval hashes at build timeGeert Uytterhoeven
Due to the way the hardware works, every double word in the SHA384 and SHA512 larval hashes must be swapped. Currently this is done at run time, during driver initialization. However, this swapping can easily be done at build time. Treating each double word as two words has the benefit of changing the larval hashes' types from u64[] to u32[], like for all other hashes, and allows dropping the casts and size doublings when calling cc_set_sram_desc(). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - remove unneeded castsGeert Uytterhoeven
Unneeded casts prevent the compiler from performing valuable checks. This is especially true for function pointers. Remove these casts, to prevent silently introducing bugs when a variable's type might be changed in the future. No change in generated code. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - fix retry handling in cc_send_sync_request()Geert Uytterhoeven
If cc_queues_status() indicates that the queue is full, cc_send_sync_request() should loop and retry. However, cc_queues_status() returns either 0 (for success), or -ENOSPC (for queue full), while cc_send_sync_request() checks for real errors by comparing with -EAGAIN. Hence -ENOSPC is always considered a real error, and the code never retries the operation. Fix this by just removing the check, as cc_queues_status() never returns any other error value than -ENOSPC. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-22crypto: ccree - fix debugfs register access while suspendedGeert Uytterhoeven
Reading the debugfs files under /sys/kernel/debug/ccree/ can be done by the user at any time. On R-Car SoCs, the CCREE device is power-managed using a moduile clock, and if this clock is not running, bogus register values may be read. Fix this by filling in the debugfs_regset32.dev field, so debugfs will make sure the device is resumed while its registers are being read. This fixes the bogus values (0x00000260) in the register dumps on R-Car H3 ES1.0: -e6601000.crypto/regs:HOST_IRR = 0x00000260 -e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000260 +e6601000.crypto/regs:HOST_IRR = 0x00000038 +e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000038 e6601000.crypto/regs:AXIM_MON_ERR = 0x00000000 e6601000.crypto/regs:DSCRPTR_QUEUE_CONTENT = 0x000002aa -e6601000.crypto/regs:HOST_IMR = 0x00000260 +e6601000.crypto/regs:HOST_IMR = 0x017ffeff e6601000.crypto/regs:AXIM_CFG = 0x001f0007 e6601000.crypto/regs:AXIM_CACHE_PARAMS = 0x00000000 -e6601000.crypto/regs:GPR_HOST = 0x00000260 +e6601000.crypto/regs:GPR_HOST = 0x017ffeff e6601000.crypto/regs:AXIM_MON_COMP = 0x00000000 -e6601000.crypto/version:SIGNATURE = 0x00000260 -e6601000.crypto/version:VERSION = 0x00000260 +e6601000.crypto/version:SIGNATURE = 0xdcc63000 +e6601000.crypto/version:VERSION = 0xaf400001 Note that this behavior is system-dependent, and the issue does not show up on all R-Car Gen3 SoCs and boards. Even when the device is suspended, the module clock may be left enabled, if configured by the firmware for Secure Mode, or when controlled by the Real-Time Core. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - remove set but not used variable 'du_size'YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning: drivers/crypto/ccree/cc_cipher.c: In function 'cc_setup_state_desc': drivers/crypto/ccree/cc_cipher.c:536:15: warning: variable 'du_size' set but not used [-Wunused-but-set-variable] commit 5c83e8ec4d51 ("crypto: ccree - fix FDE descriptor sequence") involved this unused variable, so remove it. Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - dec auth tag size from cryptlen mapGilad Ben-Yossef
Remove the auth tag size from cryptlen before mapping the destination in out-of-place AEAD decryption thus resolving a crash with extended testmgr tests. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Cc: stable@vger.kernel.org # v4.19+ Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - fix AEAD blocksize registrationGilad Ben-Yossef
Fix an error causing no block sizes to be reported during all AEAD registrations. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - fix some reported cipher block sizesGilad Ben-Yossef
OFB and CTR modes block sizes were wrongfully reported as the underlying block sizes. Fix it to 1 bytes as they turn the block ciphers into stream ciphers. Also document why our XTS differes from the generic implementation. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - only try to map auth tag if neededGilad Ben-Yossef
Make sure to only add the size of the auth tag to the source mapping for encryption if it is an in-place operation. Failing to do this previously caused us to try and map auth size len bytes from a NULL mapping and crashing if both the cryptlen and assoclen are zero. Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-02-13crypto: ccree - protect against empty or NULL scatterlistsGilad Ben-Yossef
Deal gracefully with a NULL or empty scatterlist which can happen if both cryptlen and assoclen are zero and we're doing in-place AEAD encryption. This fixes a crash when this causes us to try and map a NULL page, at least with some platforms / DMA mapping configs. Cc: stable@vger.kernel.org # v4.19+ Reported-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-01-22crypto: ccree - erase unneeded inline funcsGilad Ben-Yossef
These inline versions of PM function for the case of CONFIG_PM is not set are never used. Erase them. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-01-22crypto: ccree - make cc_pm_put_suspend() voidGilad Ben-Yossef
cc_pm_put_suspend() return value was never checked and is not useful. Turn it into a void functions. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>