diff options
author | Daniel Kestrel <kestrel1974@t-online.de> | 2021-06-05 21:37:53 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2022-01-06 00:22:48 +0100 |
commit | 87a19c9345db7554441dbd10f8c4460f6629c10a (patch) | |
tree | 748cf30a44b5ad8261ba3bc1c7ec9d1f89ecc53e /package/kernel | |
parent | 536dc6f16467f7f029ddf30fb8d47770b3010190 (diff) | |
download | upstream-87a19c9345db7554441dbd10f8c4460f6629c10a.tar.gz upstream-87a19c9345db7554441dbd10f8c4460f6629c10a.tar.bz2 upstream-87a19c9345db7554441dbd10f8c4460f6629c10a.zip |
ltq-deu: make deu hash lock global and remove md5_hmac_ exports
All hash algorithms use the same base IFX_HASH_CON to access the hash unit.
Parallel threads should not be able to call different hash algorithms and
therefor a global lock is required.
Fixed linker warning, that md5_hmac_init, md5_hmac_update and
md5_hmac_final are static export symbols. The export symbols are not
required, because the functions are exposed using shash_alg structure.
Signed-off-by: Daniel Kestrel <kestrel1974@t-online.de>
Diffstat (limited to 'package/kernel')
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c | 3 | ||||
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h | 4 | ||||
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c | 15 | ||||
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 19 | ||||
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 15 | ||||
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 15 |
6 files changed, 23 insertions, 48 deletions
diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c index 3947b31a40..a102568f97 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c @@ -69,6 +69,8 @@ #endif /* CONFIG_xxxx */ int disable_deudma = 1; +spinlock_t ltq_deu_hash_lock; +EXPORT_SYMBOL_GPL(ltq_deu_hash_lock); void chip_version(void); @@ -84,6 +86,7 @@ static int ltq_deu_probe(struct platform_device *pdev) START_DEU_POWER; + CRTCL_SECT_HASH_INIT; #define IFX_DEU_DRV_VERSION "2.0.0" printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h index 8045c2081a..3c994cb346 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h @@ -131,6 +131,10 @@ void __exit lqdeu_fini_async_des(void); void __exit deu_fini (void); int deu_dma_init (void); +extern spinlock_t ltq_deu_hash_lock; +#define CRTCL_SECT_HASH_INIT spin_lock_init(<q_deu_hash_lock) +#define CRTCL_SECT_HASH_START spin_lock_irqsave(<q_deu_hash_lock, flag) +#define CRTCL_SECT_HASH_END spin_unlock_irqrestore(<q_deu_hash_lock, flag) #define DEU_WAKELIST_INIT(queue) \ diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index 14967c30d6..f7dbee4fdc 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -64,11 +64,6 @@ #define MD5_HASH_WORDS 4 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -110,7 +105,7 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; if (mctx->started) { hashs->D1R = endian_swap(*((u32 *) hash + 0)); @@ -136,7 +131,7 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) mctx->started = 1; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; } /*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx) @@ -242,14 +237,14 @@ static int md5_final(struct shash_desc *desc, u8 *out) md5_transform(mctx, mctx->hash, mctx->block); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; *((u32 *) out + 0) = endian_swap (hashs->D1R); *((u32 *) out + 1) = endian_swap (hashs->D2R); *((u32 *) out + 2) = endian_swap (hashs->D3R); *((u32 *) out + 3) = endian_swap (hashs->D4R); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; // Wipe context memset(mctx, 0, sizeof(*mctx)); @@ -288,8 +283,6 @@ int ifxdeu_init_md5 (void) if ((ret = crypto_register_shash(&ifxdeu_md5_alg))) goto md5_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index b6e65c8b22..9cc6eb7a55 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -63,11 +63,6 @@ #define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -167,7 +162,7 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) //printk("\nsetkey keylen: %d\n key: ", keylen); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; j = 0; for (i = 0; i < keylen; i+=4) { @@ -177,7 +172,7 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) asm("sync"); j++; } - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } @@ -198,7 +193,6 @@ static int md5_hmac_init(struct shash_desc *desc) return 0; } -EXPORT_SYMBOL(md5_hmac_init); /*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -237,7 +231,6 @@ static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int memcpy(mctx->block, data, len); return 0; } -EXPORT_SYMBOL(md5_hmac_update); /*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -272,7 +265,7 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) md5_hmac_transform(desc, mctx->block); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; //printk("\ndbn = %d\n", mctx->dbn); hashs->DBN = mctx->dbn; @@ -322,14 +315,12 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } -EXPORT_SYMBOL(md5_hmac_final); - /* * \brief MD5_HMAC function mappings */ @@ -365,8 +356,6 @@ int ifxdeu_init_md5_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg))) goto md5_hmac_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index 362fe89c92..70271b2dd0 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -65,11 +65,6 @@ #define SHA1_HMAC_BLOCK_SIZE 64 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -104,7 +99,7 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; /* For context switching purposes, the previous hash output * is loaded back into the output register @@ -137,7 +132,7 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) sctx->started = 1; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; } /*! \fn static void sha1_init1(struct crypto_tfm *tfm) @@ -229,7 +224,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_update (desc, bits, sizeof bits); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; *((u32 *) out + 0) = hashs->D1R; *((u32 *) out + 1) = hashs->D2R; @@ -237,7 +232,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 3) = hashs->D4R; *((u32 *) out + 4) = hashs->D5R; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; // Wipe context memset (sctx, 0, sizeof *sctx); @@ -278,8 +273,6 @@ int ifxdeu_init_sha1 (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 09496c509b..a1461e6e5b 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -66,11 +66,6 @@ #define SHA1_HMAC_MAX_KEYLEN 64 -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - #ifdef CRYPTO_DEBUG extern char debug_level; #define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args); @@ -158,7 +153,7 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j = 0; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; for (i = 0; i < keylen; i+=4) { hash->KIDX = j; @@ -167,7 +162,7 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j++; } - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } @@ -265,7 +260,7 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_hmac_update (desc, bits, sizeof bits); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; hashs->DBN = sctx->dbn; @@ -312,7 +307,7 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) sctx->count = 0; //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; @@ -355,8 +350,6 @@ int ifxdeu_init_sha1_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; |