All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/3] crypto: Add EIP-93 crypto engine support
@ 2024-11-12  1:58 Christian Marangi
  2024-11-12  1:58 ` [PATCH v7 1/3] spinlock: extend guard with spinlock_bh variants Christian Marangi
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Christian Marangi @ 2024-11-12  1:58 UTC (permalink / raw)
  To: Christian Marangi, Herbert Xu, David S. Miller, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Antoine Tenart, Peter Zijlstra,
	Ingo Molnar, Will Deacon, Waiman Long, Boqun Feng,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-crypto, devicetree, linux-kernel, llvm, upstream

This small series add support for the Inside Secure EIP-93.
This is a predecessor of the current supported EIP197. It doesn't
require a firmware but instead it's embedded in the SoC.

First patch extend guard for spinlock_bh.

The other actually implement Documentation and Driver.

The Driver pass all the normal selft test for the supported
algo and also pass the EXTRA test with fuzz_iterations set to 10000.

Changes v7:
- Fix copypaste error in __eip93_hash_init
- Rework import/export to actually export the partial hash
  (we actually unmap DMA on export)
- Rename no_finalize variable to better partial_hash
- Rename 3rd commit title and drop Mediatek from title.
- Add Cover Letter
- Add Reviewed-by to DT commit
(cumulative changes from old series that had changelog in each patch)
Changes v6:
- Add SoC specific compatible
- Add now supported entry for compatible with no user
Changes v5:
- Add Ack tag to guard patch
- Comment out compatible with no current user
- Fix smatch warning (reported by Dan Carpenter)
Changes v4:
- Out of RFC
- Add missing bitfield.h
- Drop useless header
Changes v3:
- Mute warning from Clang about C23
- Fix not inizialized err
- Drop unused variable
- Add SoC compatible with generic one
Changes v2:
- Rename all variables from mtk to eip93
- Move to inside-secure directory
- Check DMA map errors
- Use guard API for spinlock
- Minor improvements to code
- Add guard patch
- Change to better compatible
- Add description for EIP93 models

Christian Marangi (3):
  spinlock: extend guard with spinlock_bh variants
  dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine
  crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support

 .../crypto/inside-secure,safexcel-eip93.yaml  |   67 ++
 MAINTAINERS                                   |    7 +
 drivers/crypto/Kconfig                        |    1 +
 drivers/crypto/Makefile                       |    1 +
 drivers/crypto/inside-secure/eip93/Kconfig    |   20 +
 drivers/crypto/inside-secure/eip93/Makefile   |    5 +
 .../crypto/inside-secure/eip93/eip93-aead.c   |  710 ++++++++++++
 .../crypto/inside-secure/eip93/eip93-aead.h   |   38 +
 .../crypto/inside-secure/eip93/eip93-aes.h    |   16 +
 .../crypto/inside-secure/eip93/eip93-cipher.c |  413 +++++++
 .../crypto/inside-secure/eip93/eip93-cipher.h |   60 +
 .../crypto/inside-secure/eip93/eip93-common.c |  823 ++++++++++++++
 .../crypto/inside-secure/eip93/eip93-common.h |   23 +
 .../crypto/inside-secure/eip93/eip93-des.h    |   16 +
 .../crypto/inside-secure/eip93/eip93-hash.c   | 1012 +++++++++++++++++
 .../crypto/inside-secure/eip93/eip93-hash.h   |   78 ++
 .../crypto/inside-secure/eip93/eip93-main.c   |  502 ++++++++
 .../crypto/inside-secure/eip93/eip93-main.h   |  152 +++
 .../crypto/inside-secure/eip93/eip93-regs.h   |  335 ++++++
 include/linux/spinlock.h                      |   13 +
 20 files changed, 4292 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml
 create mode 100644 drivers/crypto/inside-secure/eip93/Kconfig
 create mode 100644 drivers/crypto/inside-secure/eip93/Makefile
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aead.c
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aead.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aes.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-cipher.c
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-cipher.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-common.c
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-common.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-des.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-hash.c
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-hash.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-main.c
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-main.h
 create mode 100644 drivers/crypto/inside-secure/eip93/eip93-regs.h

-- 
2.45.2


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH v7 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support
@ 2024-11-13 23:43 kernel test robot
  0 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2024-11-13 23:43 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20241112015920.22564-4-ansuelsmth@gmail.com>
References: <20241112015920.22564-4-ansuelsmth@gmail.com>
TO: Christian Marangi <ansuelsmth@gmail.com>
TO: Christian Marangi <ansuelsmth@gmail.com>
TO: Herbert Xu <herbert@gondor.apana.org.au>
TO: "David S. Miller" <davem@davemloft.net>
CC: netdev@vger.kernel.org
TO: Rob Herring <robh@kernel.org>
TO: Krzysztof Kozlowski <krzk@kernel.org>
TO: Conor Dooley <conor+dt@kernel.org>
TO: Antoine Tenart <atenart@kernel.org>
TO: Peter Zijlstra <peterz@infradead.org>
TO: Ingo Molnar <mingo@redhat.com>
TO: Will Deacon <will@kernel.org>
TO: Waiman Long <longman@redhat.com>
TO: Boqun Feng <boqun.feng@gmail.com>
TO: Nathan Chancellor <nathan@kernel.org>
TO: Nick Desaulniers <ndesaulniers@google.com>
TO: Bill Wendling <morbo@google.com>
TO: Justin Stitt <justinstitt@google.com>
TO: linux-crypto@vger.kernel.org
TO: devicetree@vger.kernel.org
TO: linux-kernel@vger.kernel.org
TO: llvm@lists.linux.dev
TO: upstream@airoha.com
CC: Richard van Schagen <vschagen@icloud.com>

Hi Christian,

kernel test robot noticed the following build warnings:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master tip/locking/core linus/master v6.12-rc7 next-20241113]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/spinlock-extend-guard-with-spinlock_bh-variants/20241112-100439
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/20241112015920.22564-4-ansuelsmth%40gmail.com
patch subject: [PATCH v7 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: m68k-randconfig-r073-20241114 (https://download.01.org/0day-ci/archive/20241114/202411140735.mQv5EJqy-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202411140735.mQv5EJqy-lkp@intel.com/

New smatch warnings:
drivers/crypto/inside-secure/eip93/eip93-hash.c:197 __eip93_hash_init() error: uninitialized symbol 'sa_record_hmac'.

Old smatch warnings:
drivers/crypto/inside-secure/eip93/eip93-hash.c:330 eip93_send_hash_req() error: uninitialized symbol 'crypto_async_idr'.

vim +/sa_record_hmac +197 drivers/crypto/inside-secure/eip93/eip93-hash.c

7cd8d75e204549 Christian Marangi 2024-11-12  143  
7cd8d75e204549 Christian Marangi 2024-11-12  144  static int __eip93_hash_init(struct ahash_request *req, struct sa_state *sa_state,
7cd8d75e204549 Christian Marangi 2024-11-12  145  			     dma_addr_t sa_state_base)
7cd8d75e204549 Christian Marangi 2024-11-12  146  {
7cd8d75e204549 Christian Marangi 2024-11-12  147  	struct eip93_hash_reqctx *rctx = ahash_request_ctx(req);
7cd8d75e204549 Christian Marangi 2024-11-12  148  	struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
7cd8d75e204549 Christian Marangi 2024-11-12  149  	struct eip93_hash_ctx *ctx = crypto_ahash_ctx(ahash);
7cd8d75e204549 Christian Marangi 2024-11-12  150  	struct sa_record *sa_record, *sa_record_hmac;
7cd8d75e204549 Christian Marangi 2024-11-12  151  	struct eip93_device *mtk = ctx->mtk;
7cd8d75e204549 Christian Marangi 2024-11-12  152  	int digestsize;
7cd8d75e204549 Christian Marangi 2024-11-12  153  	int ret;
7cd8d75e204549 Christian Marangi 2024-11-12  154  
7cd8d75e204549 Christian Marangi 2024-11-12  155  	/* Set sa_state and mtk for rctx to handle error case later */
7cd8d75e204549 Christian Marangi 2024-11-12  156  	rctx->mtk = mtk;
7cd8d75e204549 Christian Marangi 2024-11-12  157  	rctx->sa_state = sa_state;
7cd8d75e204549 Christian Marangi 2024-11-12  158  	rctx->sa_state_base = sa_state_base;
7cd8d75e204549 Christian Marangi 2024-11-12  159  
7cd8d75e204549 Christian Marangi 2024-11-12  160  	sa_record = kzalloc(sizeof(*sa_record), GFP_KERNEL);
7cd8d75e204549 Christian Marangi 2024-11-12  161  	if (!sa_record)
7cd8d75e204549 Christian Marangi 2024-11-12  162  		return -ENOMEM;
7cd8d75e204549 Christian Marangi 2024-11-12  163  
7cd8d75e204549 Christian Marangi 2024-11-12  164  	if (IS_HMAC(ctx->flags)) {
7cd8d75e204549 Christian Marangi 2024-11-12  165  		sa_record_hmac = kzalloc(sizeof(*sa_record_hmac), GFP_KERNEL);
7cd8d75e204549 Christian Marangi 2024-11-12  166  		if (!sa_record_hmac) {
7cd8d75e204549 Christian Marangi 2024-11-12  167  			ret = -ENOMEM;
7cd8d75e204549 Christian Marangi 2024-11-12  168  			goto free_sa_record;
7cd8d75e204549 Christian Marangi 2024-11-12  169  		}
7cd8d75e204549 Christian Marangi 2024-11-12  170  	}
7cd8d75e204549 Christian Marangi 2024-11-12  171  
7cd8d75e204549 Christian Marangi 2024-11-12  172  	digestsize = crypto_ahash_digestsize(ahash);
7cd8d75e204549 Christian Marangi 2024-11-12  173  
7cd8d75e204549 Christian Marangi 2024-11-12  174  	eip93_set_sa_record(sa_record, 0, ctx->flags);
7cd8d75e204549 Christian Marangi 2024-11-12  175  	sa_record->sa_cmd0_word |= EIP93_SA_CMD_HASH_FROM_STATE;
7cd8d75e204549 Christian Marangi 2024-11-12  176  	sa_record->sa_cmd0_word |= EIP93_SA_CMD_SAVE_HASH;
7cd8d75e204549 Christian Marangi 2024-11-12  177  	sa_record->sa_cmd0_word &= ~EIP93_SA_CMD_OPCODE;
7cd8d75e204549 Christian Marangi 2024-11-12  178  	sa_record->sa_cmd0_word |= FIELD_PREP(EIP93_SA_CMD_OPCODE,
7cd8d75e204549 Christian Marangi 2024-11-12  179  					      EIP93_SA_CMD_OPCODE_BASIC_OUT_HASH);
7cd8d75e204549 Christian Marangi 2024-11-12  180  	sa_record->sa_cmd0_word &= ~EIP93_SA_CMD_DIGEST_LENGTH;
7cd8d75e204549 Christian Marangi 2024-11-12  181  	sa_record->sa_cmd0_word |= FIELD_PREP(EIP93_SA_CMD_DIGEST_LENGTH,
7cd8d75e204549 Christian Marangi 2024-11-12  182  					      digestsize / sizeof(u32));
7cd8d75e204549 Christian Marangi 2024-11-12  183  
7cd8d75e204549 Christian Marangi 2024-11-12  184  	/*
7cd8d75e204549 Christian Marangi 2024-11-12  185  	 * HMAC special handling
7cd8d75e204549 Christian Marangi 2024-11-12  186  	 * Enabling CMD_HMAC force the inner hash to be always finalized.
7cd8d75e204549 Christian Marangi 2024-11-12  187  	 * This cause problems on handling message > 64 byte as we
7cd8d75e204549 Christian Marangi 2024-11-12  188  	 * need to produce intermediate inner hash on sending intermediate
7cd8d75e204549 Christian Marangi 2024-11-12  189  	 * 64 bytes blocks.
7cd8d75e204549 Christian Marangi 2024-11-12  190  	 *
7cd8d75e204549 Christian Marangi 2024-11-12  191  	 * To handle this, enable CMD_HMAC only on the last block.
7cd8d75e204549 Christian Marangi 2024-11-12  192  	 * We make a duplicate of sa_record and on the last descriptor,
7cd8d75e204549 Christian Marangi 2024-11-12  193  	 * we pass a dedicated sa_record with CMD_HMAC enabled to make
7cd8d75e204549 Christian Marangi 2024-11-12  194  	 * EIP93 apply the outer hash.
7cd8d75e204549 Christian Marangi 2024-11-12  195  	 */
7cd8d75e204549 Christian Marangi 2024-11-12  196  	if (IS_HMAC(ctx->flags)) {
7cd8d75e204549 Christian Marangi 2024-11-12 @197  		memcpy(sa_record_hmac, sa_record, sizeof(*sa_record));
7cd8d75e204549 Christian Marangi 2024-11-12  198  		/* Copy pre-hashed opad for HMAC */
7cd8d75e204549 Christian Marangi 2024-11-12  199  		memcpy(sa_record_hmac->sa_o_digest, ctx->opad, SHA256_DIGEST_SIZE);
7cd8d75e204549 Christian Marangi 2024-11-12  200  
7cd8d75e204549 Christian Marangi 2024-11-12  201  		/* Disable HMAC for hash normal sa_record */
7cd8d75e204549 Christian Marangi 2024-11-12  202  		sa_record->sa_cmd1_word &= ~EIP93_SA_CMD_HMAC;
7cd8d75e204549 Christian Marangi 2024-11-12  203  	}
7cd8d75e204549 Christian Marangi 2024-11-12  204  
7cd8d75e204549 Christian Marangi 2024-11-12  205  	rctx->sa_record = sa_record;
7cd8d75e204549 Christian Marangi 2024-11-12  206  	rctx->sa_record_base = dma_map_single(mtk->dev, rctx->sa_record,
7cd8d75e204549 Christian Marangi 2024-11-12  207  					      sizeof(*rctx->sa_record),
7cd8d75e204549 Christian Marangi 2024-11-12  208  					      DMA_TO_DEVICE);
7cd8d75e204549 Christian Marangi 2024-11-12  209  	ret = dma_mapping_error(mtk->dev, rctx->sa_record_base);
7cd8d75e204549 Christian Marangi 2024-11-12  210  	if (ret)
7cd8d75e204549 Christian Marangi 2024-11-12  211  		goto free_sa_record;
7cd8d75e204549 Christian Marangi 2024-11-12  212  
7cd8d75e204549 Christian Marangi 2024-11-12  213  	if (IS_HMAC(ctx->flags)) {
7cd8d75e204549 Christian Marangi 2024-11-12  214  		rctx->sa_record_hmac = sa_record_hmac;
7cd8d75e204549 Christian Marangi 2024-11-12  215  		rctx->sa_record_hmac_base = dma_map_single(mtk->dev,
7cd8d75e204549 Christian Marangi 2024-11-12  216  							   rctx->sa_record_hmac,
7cd8d75e204549 Christian Marangi 2024-11-12  217  							   sizeof(*rctx->sa_record_hmac),
7cd8d75e204549 Christian Marangi 2024-11-12  218  							   DMA_TO_DEVICE);
7cd8d75e204549 Christian Marangi 2024-11-12  219  		ret = dma_mapping_error(mtk->dev, rctx->sa_record_hmac_base);
7cd8d75e204549 Christian Marangi 2024-11-12  220  		if (ret)
7cd8d75e204549 Christian Marangi 2024-11-12  221  			goto free_sa_record_base;
7cd8d75e204549 Christian Marangi 2024-11-12  222  	}
7cd8d75e204549 Christian Marangi 2024-11-12  223  
7cd8d75e204549 Christian Marangi 2024-11-12  224  	rctx->len = 0;
7cd8d75e204549 Christian Marangi 2024-11-12  225  	rctx->left_last = 0;
7cd8d75e204549 Christian Marangi 2024-11-12  226  	rctx->partial_hash = false;
7cd8d75e204549 Christian Marangi 2024-11-12  227  	rctx->export_state = false;
7cd8d75e204549 Christian Marangi 2024-11-12  228  	rctx->state = NULL;
7cd8d75e204549 Christian Marangi 2024-11-12  229  	INIT_LIST_HEAD(&rctx->blocks);
7cd8d75e204549 Christian Marangi 2024-11-12  230  
7cd8d75e204549 Christian Marangi 2024-11-12  231  	return 0;
7cd8d75e204549 Christian Marangi 2024-11-12  232  
7cd8d75e204549 Christian Marangi 2024-11-12  233  free_sa_record_base:
7cd8d75e204549 Christian Marangi 2024-11-12  234  	dma_unmap_single(mtk->dev, rctx->sa_record_base, sizeof(*rctx->sa_record),
7cd8d75e204549 Christian Marangi 2024-11-12  235  			 DMA_TO_DEVICE);
7cd8d75e204549 Christian Marangi 2024-11-12  236  free_sa_record:
7cd8d75e204549 Christian Marangi 2024-11-12  237  	kfree(sa_record);
7cd8d75e204549 Christian Marangi 2024-11-12  238  	return ret;
7cd8d75e204549 Christian Marangi 2024-11-12  239  }
7cd8d75e204549 Christian Marangi 2024-11-12  240  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-12-10 20:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12  1:58 [PATCH v7 0/3] crypto: Add EIP-93 crypto engine support Christian Marangi
2024-11-12  1:58 ` [PATCH v7 1/3] spinlock: extend guard with spinlock_bh variants Christian Marangi
2024-11-12  1:58 ` [PATCH v7 2/3] dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine Christian Marangi
2024-11-12  1:59 ` [PATCH v7 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support Christian Marangi
2024-12-09 23:27   ` Christian Marangi
2024-12-10  3:23   ` Herbert Xu
2024-12-10 11:55     ` Christian Marangi
2024-12-10 12:06       ` Herbert Xu
2024-12-10 12:16         ` Christian Marangi
2024-12-10 13:27           ` Herbert Xu
2024-12-10 20:51             ` Christian Marangi
  -- strict thread matches above, loose matches on Subject: below --
2024-11-13 23:43 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.