Re: [PATCH 11/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes

2016-12-22 Thread kbuild test robot
Hi Cyrille,

[auto build test ERROR on cryptodev/master]
[also build test ERROR on next-20161222]
[cannot apply to v4.9]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Cyrille-Pitchen/crypto-atmel-authenc-add-support-to-authenc-hmac-shaX-Y-aes-modes/20161223-012130
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

warning: (CRYPTO_DEV_ATMEL_AUTHENC) selects CRYPTO_DEV_ATMEL_SHA which has 
unmet direct dependencies (CRYPTO && CRYPTO_HW && ARCH_AT91)
>> drivers/crypto/atmel-aes.c:44:27: fatal error: atmel-authenc.h: No such file 
>> or directory
#include "atmel-authenc.h"
  ^
   compilation terminated.
--
>> drivers/crypto/atmel-sha.c:44:27: fatal error: atmel-authenc.h: No such file 
>> or directory
#include "atmel-authenc.h"
  ^
   compilation terminated.

vim +44 drivers/crypto/atmel-aes.c

38  #include 
39  #include 
40  #include 
41  #include 
42  #include 
43  #include "atmel-aes-regs.h"
  > 44  #include "atmel-authenc.h"
45  
46  #define ATMEL_AES_PRIORITY  300
47  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 11/12] crypto: atmel-authenc: add support to authenc(hmac(shaX),Y(aes)) modes

2016-12-22 Thread Cyrille Pitchen
This patchs allows to combine the AES and SHA hardware accelerators on
some Atmel SoCs. Doing so, AES blocks are only written to/read from the
AES hardware. Those blocks are also transferred from the AES to the SHA
accelerator internally, without additionnal accesses to the system busses.

Hence, the AES and SHA accelerators work in parallel to process all the
data blocks, instead of serializing the process by (de)crypting those
blocks first then authenticating them after like the generic
crypto/authenc.c driver does.

Of course, both the AES and SHA hardware accelerators need to be available
before we can start to process the data blocks. Hence we use their crypto
request queue to synchronize both drivers.

Signed-off-by: Cyrille Pitchen 
---
 drivers/crypto/Kconfig  |  12 +
 drivers/crypto/atmel-aes-regs.h |  16 ++
 drivers/crypto/atmel-aes.c  | 471 +++-
 drivers/crypto/atmel-sha-regs.h |  14 ++
 drivers/crypto/atmel-sha.c  | 344 +++--
 5 files changed, 842 insertions(+), 15 deletions(-)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 79564785ae30..719a868d8ea1 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -415,6 +415,18 @@ config CRYPTO_DEV_BFIN_CRC
  Newer Blackfin processors have CRC hardware. Select this if you
  want to use the Blackfin CRC module.
 
+config CRYPTO_DEV_ATMEL_AUTHENC
+   tristate "Support for Atmel IPSEC/SSL hw accelerator"
+   depends on (ARCH_AT91 && HAS_DMA) || COMPILE_TEST
+   select CRYPTO_AUTHENC
+   select CRYPTO_DEV_ATMEL_AES
+   select CRYPTO_DEV_ATMEL_SHA
+   help
+ Some Atmel processors can combine the AES and SHA hw accelerators
+ to enhance support of IPSEC/SSL.
+ Select this if you want to use the Atmel modules for
+ authenc(hmac(shaX),Y(cbc)) algorithms.
+
 config CRYPTO_DEV_ATMEL_AES
tristate "Support for Atmel AES hw accelerator"
depends on HAS_DMA
diff --git a/drivers/crypto/atmel-aes-regs.h b/drivers/crypto/atmel-aes-regs.h
index 0ec04407b533..7694679802b3 100644
--- a/drivers/crypto/atmel-aes-regs.h
+++ b/drivers/crypto/atmel-aes-regs.h
@@ -68,6 +68,22 @@
 #define AES_CTRR   0x98
 #define AES_GCMHR(x)   (0x9c + ((x) * 0x04))
 
+#define AES_EMR0xb0
+#define AES_EMR_APEN   BIT(0)  /* Auto Padding Enable */
+#define AES_EMR_APMBIT(1)  /* Auto Padding Mode */
+#define AES_EMR_APM_IPSEC  0x0
+#define AES_EMR_APM_SSLBIT(1)
+#define AES_EMR_PLIPEN BIT(4)  /* PLIP Enable */
+#define AES_EMR_PLIPD  BIT(5)  /* PLIP Decipher */
+#define AES_EMR_PADLEN_MASK(0xFu << 8)
+#define AES_EMR_PADLEN_OFFSET  8
+#define AES_EMR_PADLEN(padlen) (((padlen) << AES_EMR_PADLEN_OFFSET) &\
+AES_EMR_PADLEN_MASK)
+#define AES_EMR_NHEAD_MASK (0xFu << 16)
+#define AES_EMR_NHEAD_OFFSET   16
+#define AES_EMR_NHEAD(nhead)   (((nhead) << AES_EMR_NHEAD_OFFSET) &\
+AES_EMR_NHEAD_MASK)
+
 #define AES_TWR(x) (0xc0 + ((x) * 0x04))
 #define AES_ALPHAR(x)  (0xd0 + ((x) * 0x04))
 
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c
index 9fd2f63b8bc0..3c651e0c3113 100644
--- a/drivers/crypto/atmel-aes.c
+++ b/drivers/crypto/atmel-aes.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include "atmel-aes-regs.h"
+#include "atmel-authenc.h"
 
 #define ATMEL_AES_PRIORITY 300
 
@@ -78,6 +79,7 @@
 #define AES_FLAGS_INIT BIT(2)
 #define AES_FLAGS_BUSY BIT(3)
 #define AES_FLAGS_DUMP_REG BIT(4)
+#define AES_FLAGS_OWN_SHA  BIT(5)
 
 #define AES_FLAGS_PERSISTENT   (AES_FLAGS_INIT | AES_FLAGS_BUSY)
 
@@ -92,6 +94,7 @@ struct atmel_aes_caps {
boolhas_ctr32;
boolhas_gcm;
boolhas_xts;
+   boolhas_authenc;
u32 max_burst_size;
 };
 
@@ -144,10 +147,31 @@ struct atmel_aes_xts_ctx {
u32 key2[AES_KEYSIZE_256 / sizeof(u32)];
 };
 
+#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
+struct atmel_aes_authenc_ctx {
+   struct atmel_aes_base_ctx   base;
+   struct atmel_sha_authenc_ctx*auth;
+};
+#endif
+
 struct atmel_aes_reqctx {
unsigned long   mode;
 };
 
+#ifdef CONFIG_CRYPTO_DEV_ATMEL_AUTHENC
+struct atmel_aes_authenc_reqctx {
+   struct atmel_aes_reqctx base;
+
+   struct scatterlist  src[2];
+   struct scatterlist  dst[2];
+   size_t  textlen;
+   u32 digest[SHA512_DIGEST_SIZE / sizeof(u32)];
+
+   /* auth_req MUST be place last. */
+   struct ahash_requestauth_req;
+};
+#endif
+
 struct atmel_aes_dma {
struct dma_chan *chan;
struct scatterlist  *sg;
@@ -291,6 +315,9 @@ static const char *atmel_aes_reg_name(u32 offset, char 
*tmp, size_t sz)