From 255dac6de5845fd8373faa9e214088ce8014a66d Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Thu, 13 Nov 2025 18:28:18 +0000 Subject: [PATCH] crypto: tegra: Update crypto_engine_ctx handling In Linux v6.6, the crypto_engine_ctx structure was removed and the crypto_engine_ops was moved from this structure to the crypto_alg structure. The Tegra Security Engine driver was updated accordingly to populate the crypto_engine_ops in the appropriate structure depending on whether the crypto_engine_ctx structure is present or not. Currently conftest is using the presence of the crypto_engine_ctx structure to decide where to populate the crypto_engine_ops. While this works, it is possible that a kernel older than v6.6 also includes a backport of commit e5e7eb023f24 ("crypto: engine - Move crypto_engine_ops from request into crypto_alg") that moves the ops to the crypto_alg structure. Although backporting this commit alone should not cause any problems, it is better to detect if this commit is present rather than relying on the presence of crypto_engine_ctx structure. To detect the presence of commit e5e7eb023f24 we can simply detect if one of the functions added and exported by this commit is present. For example, the function crypto_engine_register_aead() was added and exported by this commit. Therefore, update conftest to detect if commit e5e7eb023f24 is present and then update the Tegra Security Engine accordingly. Bug 5564561 Change-Id: I3f7688e6e954a158094a9a2fdf73354f765ed680 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3499816 (cherry picked from commit c1631d32f8d80cd31f54e7297c542f308a281d25) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3494992 Reviewed-by: mobile promotions Reviewed-by: Hiteshkumar Patel Tested-by: mobile promotions Tested-by: Brad Griffis GVS: buildbot_gerritrpt Reviewed-by: Brad Griffis --- drivers/crypto/tegra/tegra-se-aes.c | 52 +++++++++++------------ drivers/crypto/tegra/tegra-se-hash.c | 62 ++++++++++++++-------------- drivers/crypto/tegra/tegra-se.h | 24 +++++------ scripts/conftest/Makefile | 3 +- scripts/conftest/conftest.sh | 17 -------- 5 files changed, 70 insertions(+), 88 deletions(-) diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c index 0cd38454..ff1c58c0 100644 --- a/drivers/crypto/tegra/tegra-se-aes.c +++ b/drivers/crypto/tegra/tegra-se-aes.c @@ -25,7 +25,7 @@ #include "tegra-se.h" struct tegra_aes_ctx { -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT struct crypto_engine_ctx enginectx; #endif struct tegra_se *se; @@ -50,7 +50,7 @@ struct tegra_aes_reqctx { }; struct tegra_aead_ctx { -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT struct crypto_engine_ctx enginectx; #endif struct tegra_se *se; @@ -78,7 +78,7 @@ struct tegra_aead_reqctx { }; struct tegra_cmac_ctx { -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT struct crypto_engine_ctx enginectx; #endif struct tegra_se *se; @@ -357,7 +357,7 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm) const char *algname; int ret; -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher.base); #else se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher); @@ -380,7 +380,7 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm) ctx->alg = ret; -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_aes_do_one_req; @@ -533,7 +533,7 @@ static int tegra_aes_decrypt(struct skcipher_request *req) static struct tegra_se_alg tegra_aes_algs[] = { { .alg.skcipher = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_aes_cra_init, @@ -554,14 +554,14 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_aes_do_one_req, #endif } }, { .alg.skcipher = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_aes_cra_init, @@ -581,14 +581,14 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_aes_do_one_req, #endif } }, { .alg.skcipher = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_aes_cra_init, @@ -609,14 +609,14 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_aes_do_one_req, #endif } }, { .alg.skcipher = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_aes_cra_init, @@ -636,7 +636,7 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = (__alignof__(u64) - 1), .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_aes_do_one_req, #endif @@ -1390,7 +1390,7 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm) algname = crypto_tfm_alg_name(&tfm->base); -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base); #else se_alg = container_of(alg, struct tegra_se_alg, alg.aead); @@ -1410,7 +1410,7 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm) ctx->alg = ret; -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_ccm_do_one_req; @@ -1429,7 +1429,7 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm) algname = crypto_tfm_alg_name(&tfm->base); -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base); #else se_alg = container_of(alg, struct tegra_se_alg, alg.aead); @@ -1449,7 +1449,7 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm) ctx->alg = ret; -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_gcm_do_one_req; @@ -1809,7 +1809,7 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm) int ret; algname = crypto_tfm_alg_name(tfm); -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base); #else se_alg = container_of(alg, struct tegra_se_alg, alg.ahash); @@ -1829,7 +1829,7 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm) ctx->alg = ret; -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_cmac_do_one_req; @@ -1969,7 +1969,7 @@ static int tegra_cmac_import(struct ahash_request *req, const void *in) static struct tegra_se_alg tegra_aead_algs[] = { { .alg.aead = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_gcm_cra_init, @@ -1989,14 +1989,14 @@ static struct tegra_se_alg tegra_aead_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_gcm_do_one_req, #endif } }, { .alg.aead = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_ccm_cra_init, @@ -2017,7 +2017,7 @@ static struct tegra_se_alg tegra_aead_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_ccm_do_one_req, #endif @@ -2028,7 +2028,7 @@ static struct tegra_se_alg tegra_aead_algs[] = { static struct tegra_se_alg tegra_cmac_algs[] = { { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_cmac_init, @@ -2053,7 +2053,7 @@ static struct tegra_se_alg tegra_cmac_algs[] = { .cra_init = tegra_cmac_cra_init, .cra_exit = tegra_cmac_cra_exit, }, -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_cmac_do_one_req, #endif @@ -2061,7 +2061,7 @@ static struct tegra_se_alg tegra_cmac_algs[] = { } }; -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT int tegra_init_aes(struct tegra_se *se) { struct aead_engine_alg *aead_alg; diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c index a012c1aa..71e3a72b 100644 --- a/drivers/crypto/tegra/tegra-se-hash.c +++ b/drivers/crypto/tegra/tegra-se-hash.c @@ -23,7 +23,7 @@ #include "tegra-se.h" struct tegra_sha_ctx { -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT struct crypto_engine_ctx enginectx; #endif struct tegra_se *se; @@ -488,7 +488,7 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm) int ret; algname = crypto_tfm_alg_name(tfm); -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base); #else se_alg = container_of(alg, struct tegra_se_alg, alg.ahash); @@ -511,7 +511,7 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm) ctx->alg = ret; -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifndef NV_CRYPTO_ENGINE_OPS_PRESENT ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_sha_do_one_req; @@ -686,7 +686,7 @@ static int tegra_sha_import(struct ahash_request *req, const void *in) static struct tegra_se_alg tegra_hash_algs[] = { { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -710,14 +710,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -741,14 +741,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -772,14 +772,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -803,14 +803,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -834,14 +834,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -865,14 +865,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -896,14 +896,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -927,14 +927,14 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif } }, { .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -958,7 +958,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif @@ -966,7 +966,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { }, { .alg_base = "sha224", .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -991,7 +991,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif @@ -999,7 +999,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { }, { .alg_base = "sha256", .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -1024,7 +1024,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif @@ -1032,7 +1032,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { }, { .alg_base = "sha384", .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -1057,7 +1057,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif @@ -1065,7 +1065,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { }, { .alg_base = "sha512", .alg.ahash = { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT .base = { #endif .init = tegra_sha_init, @@ -1090,7 +1090,7 @@ static struct tegra_se_alg tegra_hash_algs[] = { .cra_init = tegra_sha_cra_init, .cra_exit = tegra_sha_cra_exit, } -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT }, .op.do_one_request = tegra_sha_do_one_req, #endif @@ -1133,7 +1133,7 @@ static int tegra_hash_kac_manifest(u32 user, u32 alg, u32 keylen) int tegra_init_hash(struct tegra_se *se) { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT struct ahash_engine_alg *alg; #else struct ahash_alg *alg; @@ -1148,7 +1148,7 @@ int tegra_init_hash(struct tegra_se *se) ret = CRYPTO_REGISTER(ahash, alg); if (ret) { -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT dev_err(se->dev, "failed to register %s\n", alg->base.halg.base.cra_name); #else diff --git a/drivers/crypto/tegra/tegra-se.h b/drivers/crypto/tegra/tegra-se.h index 888fcd25..f6a267b9 100644 --- a/drivers/crypto/tegra/tegra-se.h +++ b/drivers/crypto/tegra/tegra-se.h @@ -350,18 +350,18 @@ #define SHA_UPDATE BIT(1) #define SHA_FINAL BIT(2) -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX -#define CRYPTO_REGISTER(alg, x) \ - crypto_engine_register_##alg(x) -#else -#define CRYPTO_REGISTER(alg, x) \ - crypto_register_##alg(x) +#if NV_IS_EXPORT_SYMBOL_PRESENT_crypto_engine_register_aead /* Linux v6.6 */ +#define NV_CRYPTO_ENGINE_OPS_PRESENT #endif -#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT +#define CRYPTO_REGISTER(alg, x) \ + crypto_engine_register_##alg(x) #define CRYPTO_UNREGISTER(alg, x) \ crypto_engine_unregister_##alg(x) #else +#define CRYPTO_REGISTER(alg, x) \ + crypto_register_##alg(x) #define CRYPTO_UNREGISTER(alg, x) \ crypto_unregister_##alg(x) #endif @@ -403,14 +403,14 @@ struct tegra_se_alg { const char *alg_base; union { -#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX - struct skcipher_alg skcipher; - struct aead_alg aead; - struct ahash_alg ahash; -#else +#ifdef NV_CRYPTO_ENGINE_OPS_PRESENT struct skcipher_engine_alg skcipher; struct aead_engine_alg aead; struct ahash_engine_alg ahash; +#else + struct skcipher_alg skcipher; + struct aead_alg aead; + struct ahash_alg ahash; #endif } alg; }; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 072a7c2a..cca65697 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -215,10 +215,9 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_subdev_pad_ops_struct_has_dv_timings NV_CONFTEST_FUNCTION_COMPILE_TESTS += vm_area_struct_has_const_vm_flags NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_present_drm_gem_prime_fd_to_handle NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_present_drm_gem_prime_handle_to_fd -NV_CONFTEST_FUNCTION_COMPILE_TESTS += crypto_engine_ctx_struct_removed_test NV_CONFTEST_MACRO_COMPILE_TESTS ?= -NV_CONFTEST_SYMBOL_COMPILE_TESTS ?= NV_CONFTEST_TYPE_COMPILE_TESTS += request_struct_has_completion_data_arg +NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_crypto_engine_register_aead $(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,functions,$(NV_CONFTEST_FUNCTION_COMPILE_TESTS))) $(eval $(call NV_GENERATE_COMPILE_TEST_HEADER,generic,$(NV_CONFTEST_GENERIC_COMPILE_TESTS))) diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 97a9e4d5..7deb4068 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -8638,23 +8638,6 @@ compile_test() { compile_check_conftest "$CODE" \ "NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_DV_TIMINGS" "" "types" ;; - crypto_engine_ctx_struct_removed_test) - # - # Determine if struct 'crypto_engine_ctx' is removed in linux kernel. - # - # Commit 5ce0bc68e0ee ("crypto: engine - Remove crypto_engine_ctx") - # Linux v6.6 removed struct crypto_engine_ctx - # - CODE=" - #include - void conftest_crypto_engine_ctx_struct_removed_test(void) { - struct crypto_engine_ctx *ptr = NULL; - struct crypto_engine_ctx enginectx; - ptr = &enginectx; - }" - - compile_check_conftest "$CODE" "NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX" "" "functions" - ;; # When adding a new conftest entry, please use the correct format for # specifying the relevant upstream Linux kernel commit.