From f3b12ead835a0e3bcaa1ce257ed17cba9a29fab9 Mon Sep 17 00:00:00 2001 From: Bitan Biswas Date: Tue, 10 Oct 2023 01:45:29 +0000 Subject: [PATCH] crypto: fix crypto_engine_ctx build error struct crypto_engine_ctx removed in k6.6 hence use conftest helper based macro to select updated data types Bug 4346767 Signed-off-by: Bitan Biswas Change-Id: Iaf565c4ef74fdd87ea0020b369bc3d882d32326e Signed-off-by: Akhil R Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3176823 Reviewed-by: svcacv GVS: buildbot_gerritrpt Reviewed-by: Laxman Dewangan (cherry picked from commit cba663d0dbd0d55b3e37bd418d06d54ae8e29105) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3196067 --- drivers/crypto/tegra/tegra-se-aes.c | 177 ++++++++++++++++++++++++--- drivers/crypto/tegra/tegra-se-hash.c | 117 +++++++++++++++++- drivers/crypto/tegra/tegra-se.h | 22 ++++ 3 files changed, 295 insertions(+), 21 deletions(-) diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c index 9fcd7c11..155754e2 100644 --- a/drivers/crypto/tegra/tegra-se-aes.c +++ b/drivers/crypto/tegra/tegra-se-aes.c @@ -4,6 +4,8 @@ * Crypto driver to handle block cipher algorithms using NVIDIA Security Engine. */ +#include + #include #include #include @@ -23,7 +25,9 @@ #include "tegra-se.h" struct tegra_aes_ctx { +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX struct crypto_engine_ctx enginectx; +#endif struct tegra_se *se; u32 alg; u32 ivsize; @@ -41,7 +45,9 @@ struct tegra_aes_reqctx { }; struct tegra_aead_ctx { +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX struct crypto_engine_ctx enginectx; +#endif struct tegra_se *se; unsigned int authsize; u32 alg; @@ -66,7 +72,9 @@ struct tegra_aead_reqctx { }; struct tegra_cmac_ctx { +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX struct crypto_engine_ctx enginectx; +#endif struct tegra_se *se; unsigned int alg; u32 key_id; @@ -307,7 +315,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm) const char *algname; int ret; +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher.base); +#else se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher); +#endif crypto_skcipher_set_reqsize(tfm, sizeof(struct tegra_aes_reqctx)); @@ -325,9 +337,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm) ctx->alg = ret; +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_aes_do_one_req; +#endif return 0; } @@ -469,6 +483,9 @@ 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 + .base = { +#endif .init = tegra_aes_cra_init, .exit = tegra_aes_cra_exit, .setkey = tegra_aes_setkey, @@ -487,9 +504,16 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_aes_do_one_req, +#endif } }, { .alg.skcipher = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_aes_cra_init, .exit = tegra_aes_cra_exit, .setkey = tegra_aes_setkey, @@ -507,9 +531,16 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_aes_do_one_req, +#endif } }, { .alg.skcipher = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_aes_cra_init, .exit = tegra_aes_cra_exit, .setkey = tegra_aes_setkey, @@ -528,9 +559,16 @@ static struct tegra_se_alg tegra_aes_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_aes_do_one_req, +#endif } }, { .alg.skcipher = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_aes_cra_init, .exit = tegra_aes_cra_exit, .setkey = tegra_xts_setkey, @@ -548,6 +586,10 @@ 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 + }, + .op.do_one_request = tegra_aes_do_one_req, +#endif } }, }; @@ -1277,7 +1319,11 @@ 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 + se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base); +#else se_alg = container_of(alg, struct tegra_se_alg, alg.aead); +#endif crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx)); @@ -1292,9 +1338,11 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm) ctx->alg = ret; +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_ccm_do_one_req; +#endif return 0; } @@ -1309,7 +1357,11 @@ 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 + se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base); +#else se_alg = container_of(alg, struct tegra_se_alg, alg.aead); +#endif crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx)); @@ -1324,10 +1376,11 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm) ctx->alg = ret; +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_gcm_do_one_req; - +#endif return 0; } @@ -1647,7 +1700,11 @@ 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 + se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base); +#else se_alg = container_of(alg, struct tegra_se_alg, alg.ahash); +#endif crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_cmac_reqctx)); @@ -1662,9 +1719,11 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm) ctx->alg = ret; +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_cmac_do_one_req; +#endif tegra_cmac_init_fallback(ahash_tfm, ctx, algname); @@ -1804,6 +1863,9 @@ 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 + .base = { +#endif .init = tegra_gcm_cra_init, .exit = tegra_aead_cra_exit, .setkey = tegra_aead_setkey, @@ -1821,9 +1883,16 @@ static struct tegra_se_alg tegra_aead_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_gcm_do_one_req, +#endif } }, { .alg.aead = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_ccm_cra_init, .exit = tegra_aead_cra_exit, .setkey = tegra_aead_setkey, @@ -1842,6 +1911,10 @@ static struct tegra_se_alg tegra_aead_algs[] = { .cra_alignmask = 0xf, .cra_module = THIS_MODULE, }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_ccm_do_one_req, +#endif } } }; @@ -1849,6 +1922,9 @@ 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 + .base = { +#endif .init = tegra_cmac_init, .setkey = tegra_cmac_setkey, .update = tegra_cmac_update, @@ -1870,11 +1946,79 @@ static struct tegra_se_alg tegra_cmac_algs[] = { .cra_module = THIS_MODULE, .cra_init = tegra_cmac_cra_init, .cra_exit = tegra_cmac_cra_exit, - } + }, +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + }, + .op.do_one_request = tegra_cmac_do_one_req, +#endif } } }; +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +int tegra_init_aes(struct tegra_se *se) +{ + struct aead_engine_alg *aead_alg; + struct ahash_engine_alg *ahash_alg; + struct skcipher_engine_alg *sk_alg; + int i, ret; + + se->manifest = tegra_aes_kac_manifest; + + for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) { + sk_alg = &tegra_aes_algs[i].alg.skcipher; + tegra_aes_algs[i].se_dev = se; + ret = CRYPTO_REGISTER(skcipher, sk_alg); + if (ret) { + dev_err(se->dev, "failed to register %s\n", + sk_alg->base.base.cra_name); + goto err_aes; + } + } + + for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) { + aead_alg = &tegra_aead_algs[i].alg.aead; + tegra_aead_algs[i].se_dev = se; + ret = CRYPTO_REGISTER(aead, aead_alg); + if (ret) { + dev_err(se->dev, "failed to register %s\n", + aead_alg->base.base.cra_name); + goto err_aead; + } + } + + for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) { + ahash_alg = &tegra_cmac_algs[i].alg.ahash; + tegra_cmac_algs[i].se_dev = se; + ret = CRYPTO_REGISTER(ahash, ahash_alg); + if (ret) { + dev_err(se->dev, "failed to register %s\n", + ahash_alg->base.halg.base.cra_name); + goto err_cmac; + } + } + + return 0; + +err_cmac: + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash); + + i = ARRAY_SIZE(tegra_aead_algs); +err_aead: + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead); + + i = ARRAY_SIZE(tegra_aes_algs); +err_aes: + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher); + + return ret; +} + +#else + int tegra_init_aes(struct tegra_se *se) { struct aead_alg *aead_alg; @@ -1887,8 +2031,7 @@ int tegra_init_aes(struct tegra_se *se) for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) { sk_alg = &tegra_aes_algs[i].alg.skcipher; tegra_aes_algs[i].se_dev = se; - - ret = crypto_register_skcipher(sk_alg); + ret = CRYPTO_REGISTER(skcipher, sk_alg); if (ret) { dev_err(se->dev, "failed to register %s\n", sk_alg->base.cra_name); @@ -1899,8 +2042,7 @@ int tegra_init_aes(struct tegra_se *se) for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) { aead_alg = &tegra_aead_algs[i].alg.aead; tegra_aead_algs[i].se_dev = se; - - ret = crypto_register_aead(aead_alg); + ret = CRYPTO_REGISTER(aead, aead_alg); if (ret) { dev_err(se->dev, "failed to register %s\n", aead_alg->base.cra_name); @@ -1911,8 +2053,7 @@ int tegra_init_aes(struct tegra_se *se) for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) { ahash_alg = &tegra_cmac_algs[i].alg.ahash; tegra_cmac_algs[i].se_dev = se; - - ret = crypto_register_ahash(ahash_alg); + ret = CRYPTO_REGISTER(ahash, ahash_alg); if (ret) { dev_err(se->dev, "failed to register %s\n", ahash_alg->halg.base.cra_name); @@ -1923,32 +2064,34 @@ int tegra_init_aes(struct tegra_se *se) return 0; err_cmac: - while (i--) - crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash); + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash); i = ARRAY_SIZE(tegra_aead_algs); err_aead: - while (i--) - crypto_unregister_aead(&tegra_aead_algs[i].alg.aead); + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead); i = ARRAY_SIZE(tegra_aes_algs); err_aes: - while (i--) - crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher); + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher); return ret; } +#endif void tegra_deinit_aes(struct tegra_se *se) { int i; for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) - crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher); + CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher); for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) - crypto_unregister_aead(&tegra_aead_algs[i].alg.aead); + CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead); for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) - crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash); + CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash); + } diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c index e5c3533b..f86b65b6 100644 --- a/drivers/crypto/tegra/tegra-se-hash.c +++ b/drivers/crypto/tegra/tegra-se-hash.c @@ -4,6 +4,7 @@ * Crypto driver to handle HASH algorithms using NVIDIA Security Engine. */ +#include #include #include #include @@ -22,7 +23,9 @@ #include "tegra-se.h" struct tegra_sha_ctx { +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX struct crypto_engine_ctx enginectx; +#endif struct tegra_se *se; unsigned int alg; bool fallback; @@ -466,7 +469,11 @@ 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 + se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base); +#else se_alg = container_of(alg, struct tegra_se_alg, alg.ahash); +#endif crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_sha_reqctx)); @@ -485,9 +492,11 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm) ctx->alg = ret; +#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX ctx->enginectx.op.prepare_request = NULL; ctx->enginectx.op.unprepare_request = NULL; ctx->enginectx.op.do_one_request = tegra_sha_do_one_req; +#endif return 0; } @@ -661,6 +670,9 @@ 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 + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -682,9 +694,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -706,9 +725,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -730,9 +756,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -754,9 +787,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -778,9 +818,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -802,9 +849,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -826,9 +880,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -850,9 +911,16 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -874,10 +942,17 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg_base = "sha224", .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -900,10 +975,17 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg_base = "sha256", .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -926,10 +1008,17 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg_base = "sha384", .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -952,10 +1041,17 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } }, { .alg_base = "sha512", .alg.ahash = { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + .base = { +#endif .init = tegra_sha_init, .update = tegra_sha_update, .final = tegra_sha_final, @@ -978,6 +1074,10 @@ 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 + }, + .op.do_one_request = tegra_sha_do_one_req, +#endif } } }; @@ -1017,7 +1117,11 @@ 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 + struct ahash_engine_alg *alg; +#else struct ahash_alg *alg; +#endif int i, ret; se->manifest = tegra_hash_kac_manifest; @@ -1026,10 +1130,15 @@ int tegra_init_hash(struct tegra_se *se) tegra_hash_algs[i].se_dev = se; alg = &tegra_hash_algs[i].alg.ahash; - ret = crypto_register_ahash(alg); + ret = CRYPTO_REGISTER(ahash, alg); if (ret) { +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX + dev_err(se->dev, "failed to register %s\n", + alg->base.halg.base.cra_name); +#else dev_err(se->dev, "failed to register %s\n", alg->halg.base.cra_name); +#endif goto sha_err; } } @@ -1037,8 +1146,8 @@ int tegra_init_hash(struct tegra_se *se) return 0; sha_err: - while (i--) - crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash); + for (--i; i >= 0; i--) + CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash); return ret; } @@ -1048,5 +1157,5 @@ void tegra_deinit_hash(struct tegra_se *se) int i; for (i = 0; i < ARRAY_SIZE(tegra_hash_algs); i++) - crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash); + CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash); } diff --git a/drivers/crypto/tegra/tegra-se.h b/drivers/crypto/tegra/tegra-se.h index 3cefc4e5..ec5768fb 100644 --- a/drivers/crypto/tegra/tegra-se.h +++ b/drivers/crypto/tegra/tegra-se.h @@ -348,6 +348,22 @@ #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) +#endif + +#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX +#define CRYPTO_UNREGISTER(alg, x) \ + crypto_engine_unregister_##alg(x) +#else +#define CRYPTO_UNREGISTER(alg, x) \ + crypto_unregister_##alg(x) +#endif + /* Security Engine operation modes */ enum se_aes_alg { SE_ALG_CBC, /* Cipher Block Chaining (CBC) mode */ @@ -385,9 +401,15 @@ 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 + struct skcipher_engine_alg skcipher; + struct aead_engine_alg aead; + struct ahash_engine_alg ahash; +#endif } alg; };