Skip to contentSkip to conversation

fsl_sec : Add hardware accelerated SHA256 and SHA1

PATCH Superseded Ruchika Gupta 2 participants 5 messages Sep 11, 2014 – Sep 29, 2014

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fsl_sec : Add hardware accelerated SHA256 and SHA1

SHA-256 and SHA-1 accelerated using SEC hardware in Freescale SoC's The driver for SEC (CAAM) IP is based on linux drivers/crypto/caam.

---
The patch series is dependent on
https://patchwork.ozlabs.org/patch/387174/
https://patchwork.ozlabs.org/patch/387175/

 arch/powerpc/cpu/mpc85xx/cpu_init.c   |   5 +
 arch/powerpc/include/asm/config.h     |   4 +
 arch/powerpc/include/asm/immap_85xx.h |   5 +
 arch/powerpc/include/asm/types.h      |   4 +
 drivers/crypto/Makefile               |   1 +
 drivers/crypto/fsl/Makefile           |   9 +
 drivers/crypto/fsl/desc.h             | 651 ++++++++++++++++++++++++++++++++++
 drivers/crypto/fsl/desc_constr.h      | 280 +++++++++++++++
 drivers/crypto/fsl/error.c            | 258 ++++++++++++++
 drivers/crypto/fsl/fsl_hash.c         | 119 +++++++
 drivers/crypto/fsl/jobdesc.c          |  45 +++
 drivers/crypto/fsl/jobdesc.h          |  18 +
 drivers/crypto/fsl/jr.c               | 288 +++++++++++++++
 drivers/crypto/fsl/jr.h               | 100 ++++++
 include/fsl_sec.h                     |  45 +++
 15 files changed, 1832 insertions(+)
 create mode 100644 drivers/crypto/fsl/Makefile
 create mode 100644 drivers/crypto/fsl/desc.h
 create mode 100644 drivers/crypto/fsl/desc_constr.h
 create mode 100644 drivers/crypto/fsl/error.c
 create mode 100644 drivers/crypto/fsl/fsl_hash.c
 create mode 100644 drivers/crypto/fsl/jobdesc.c
 create mode 100644 drivers/crypto/fsl/jobdesc.h
 create mode 100644 drivers/crypto/fsl/jr.c
 create mode 100644 drivers/crypto/fsl/jr.h
arch/powerpc/cpu/mpc85xx/cpu_init.c +5 -0
index bf9fbbf..21c3194 100644
@@ -27,6 +27,7 @@
 #include <hwconfig.h>
 #include <linux/compiler.h>
 #include "mp.h"
+#include <fsl_sec.h>
 #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
 #include <nand.h>
 #include <errno.h>
@@ -938,6 +939,10 @@ int cpu_init_r(void)
 	fman_enet_init();
 #endif
 
+#if CONFIG_SYS_FSL_SEC_COMPAT >= 4
+	sec_init();
+#endif
+
 #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001)
 	/*
 	 * For P1022/1013 Rev1.0 silicon, after power on SATA host
arch/powerpc/include/asm/config.h +4 -0
index 423a6fb..e1b2c20 100644
@@ -103,4 +103,8 @@
 /* All PPC boards must swap IDE bytes */
 #define CONFIG_IDE_SWAP_IO
 
+#if CONFIG_SYS_FSL_SEC_COMPAT >= 4
+#define CONFIG_FSL_CAAM
+#endif
+
 #endif /* _ASM_CONFIG_H_ */
arch/powerpc/include/asm/immap_85xx.h +5 -0
index e426314..88c1e08 100644
@@ -2875,6 +2875,7 @@ struct ccsr_sfp_regs {
 #define CONFIG_SYS_MPC85xx_SATA1_OFFSET		0x220000
 #define CONFIG_SYS_MPC85xx_SATA2_OFFSET		0x221000
 #define CONFIG_SYS_FSL_SEC_OFFSET		0x300000
+#define CONFIG_SYS_FSL_JR0_OFFSET		0x301000
 #define CONFIG_SYS_FSL_CORENET_PME_OFFSET	0x316000
 #define CONFIG_SYS_FSL_QMAN_OFFSET		0x318000
 #define CONFIG_SYS_FSL_BMAN_OFFSET		0x31a000
@@ -2935,8 +2936,10 @@ struct ccsr_sfp_regs {
 #define CONFIG_SYS_MPC85xx_ESDHC_OFFSET		0x2e000
 #if defined(CONFIG_PPC_C29X)
 #define CONFIG_SYS_FSL_SEC_OFFSET		0x80000
+#define CONFIG_SYS_FSL_JR0_OFFSET               0x81000
 #else
 #define CONFIG_SYS_FSL_SEC_OFFSET		0x30000
+#define CONFIG_SYS_FSL_JR0_OFFSET               0x31000
 #endif
 #define CONFIG_SYS_MPC85xx_SERDES2_OFFSET	0xE3100
 #define CONFIG_SYS_MPC85xx_SERDES1_OFFSET	0xE3000
@@ -3041,6 +3044,8 @@ struct ccsr_sfp_regs {
 	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_USB2_PHY_OFFSET)
 #define CONFIG_SYS_FSL_SEC_ADDR \
 	(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_SEC_OFFSET)
+#define CONFIG_SYS_FSL_JR0_ADDR \
+	(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_JR0_OFFSET)
 #define CONFIG_SYS_FSL_FM1_ADDR \
 	(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_FM1_OFFSET)
 #define CONFIG_SYS_FSL_FM1_DTSEC1_ADDR \
arch/powerpc/include/asm/types.h +4 -0
index b27a6b7..b29ce79 100644
@@ -41,8 +41,12 @@ typedef unsigned long long u64;
 
 #define BITS_PER_LONG 32
 
+#ifdef CONFIG_PHYS_64BIT
+typedef unsigned long long dma_addr_t;
+#else
 /* DMA addresses are 32-bits wide */
 typedef u32 dma_addr_t;
+#endif
 
 #ifdef CONFIG_PHYS_64BIT
 typedef unsigned long long phys_addr_t;
drivers/crypto/Makefile +1 -0
index b807795..7b79237 100644
@@ -6,3 +6,4 @@
 #
 
 obj-$(CONFIG_EXYNOS_ACE_SHA)	+= ace_sha.o
+obj-y += fsl/
drivers/crypto/fsl/Makefile new file +9 -0
new file mode 100644
index 0000000..59d9651
@@ -0,0 +1,9 @@
+#
+# Copyright 2014 Freescale Semiconductor, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# Version 2 as published by the Free Software Foundation.
+#
+
+obj-$(CONFIG_FSL_CAAM) += jr.o fsl_hash.o jobdesc.o error.o
drivers/crypto/fsl/desc.h new file +651 -0

651 lines not on this page · raw message

drivers/crypto/fsl/desc_constr.h new file +280 -0

280 lines not on this page · raw message

drivers/crypto/fsl/error.c new file +258 -0

258 lines not on this page · raw message

drivers/crypto/fsl/fsl_hash.c new file +119 -0

119 lines not on this page · raw message

drivers/crypto/fsl/jobdesc.c new file +45 -0

45 lines not on this page · raw message

drivers/crypto/fsl/jobdesc.h new file +18 -0
new file mode 100644
index 0000000..ed61579
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __JOBDESC_H
+#define __JOBDESC_H
+
+#include <common.h>
+#include <asm/io.h>
+
+void inline_cnstr_jobdesc_hash(uint32_t *desc,
+			  const uint8_t *msg, uint32_t msgsz, uint8_t *digest,
+			  u32 alg_type, uint32_t alg_size, int sg_tbl);
+
+#endif
drivers/crypto/fsl/jr.c new file +288 -0

288 lines not on this page · raw message

drivers/crypto/fsl/jr.h new file +100 -0

100 lines not on this page · raw message

include/fsl_sec.h +45 -0

51 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 2/2 mpc85xx: configs - Add hash command in freescale platforms

Hardware accelerated support for SHA-1 and SHA-256 has been added. Hash command enabled along with hardware accelerated support for SHA-1 and SHA-256 for platforms which have CAAM block.

---
The patch series is dependent on
https://patchwork.ozlabs.org/patch/387174/
https://patchwork.ozlabs.org/patch/387175/

 include/configs/B4860QDS.h   | 4 ++++
 include/configs/BSC9131RDB.h | 4 ++++
 include/configs/BSC9132QDS.h | 4 ++++
 include/configs/C29XPCIE.h   | 4 ++++
 include/configs/P1010RDB.h   | 4 ++++
 include/configs/P2041RDB.h   | 4 ++++
 include/configs/T1040QDS.h   | 4 ++++
 include/configs/T104xRDB.h   | 4 ++++
 include/configs/T208xQDS.h   | 4 ++++
 include/configs/T208xRDB.h   | 4 ++++
 include/configs/T4240QDS.h   | 4 ++++
 include/configs/T4240RDB.h   | 4 ++++
 include/configs/corenet_ds.h | 4 ++++
 13 files changed, 52 insertions(+)
include/configs/B4860QDS.h +4 -0
index 953d06b..58932ad 100644
@@ -758,6 +758,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_CMD_NET
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
 * USB
 */
include/configs/BSC9131RDB.h +4 -0
index 56a3e94..fb50db0 100644
@@ -382,6 +382,10 @@ extern unsigned long get_sdram_size(void);
 #define CONFIG_KGDB_BAUDRATE	230400	/* speed to run kgdb serial port */
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 #define CONFIG_USB_EHCI
 
 #ifdef CONFIG_USB_EHCI
include/configs/BSC9132QDS.h +4 -0
index aeded6d..922ac00 100644
@@ -598,6 +598,10 @@ combinations. this should be removed later
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/C29XPCIE.h +4 -0
index 715616d..ca1b2f5 100644
@@ -506,6 +506,10 @@
 #define CONFIG_CMD_SETEXPR
 #define CONFIG_CMD_REGINFO
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/P1010RDB.h +4 -0
index a373990..45ef53d 100644
@@ -832,6 +832,10 @@ extern unsigned long get_sdram_size(void);
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/P2041RDB.h +4 -0
index 16f7525..7ff2dd5 100644
@@ -647,6 +647,10 @@ unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/T1040QDS.h +4 -0
index a781ba3..5870a49 100644
@@ -716,6 +716,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_CMD_NET
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/T104xRDB.h +4 -0
index 0ee0ff2..8e43931 100644
@@ -727,6 +727,10 @@
 #define CONFIG_CMD_NET
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/T208xQDS.h +4 -0
index 395472b..9a8a3b6 100644
@@ -777,6 +777,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_CMD_NET
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/T208xRDB.h +4 -0
index e5936c7..4ff31e6 100644
@@ -736,6 +736,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_CMD_NET
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
include/configs/T4240QDS.h +4 -0
index ca97247..d2faf94 100644
@@ -506,6 +506,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_PHY_GIGE		/* Include GbE speed/duplex detection */
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
 * USB
 */
include/configs/T4240RDB.h +4 -0
index 183255d..b3fbbe3 100644
@@ -668,6 +668,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 #define CONFIG_BOOTDELAY	10	/* -1 disables auto-boot */
 
 #define __USB_PHY_TYPE	utmi
include/configs/corenet_ds.h +4 -0
index 12b3296..4fd290e 100644
@@ -648,6 +648,10 @@
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* Hash command with SHA acceleration supported in hardware */
+#define CONFIG_CMD_HASH
+#define CONFIG_SHA_HW_ACCEL
+
 /*
  * Miscellaneous configurable options
  */
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/2 mpc85xx: configs - Add hash command in freescale platforms

Quoted 10 lines · Ruchika Gupta

Hardware accelerated support for SHA-1 and SHA-256 has been added. Hash command enabled along with hardware accelerated support for SHA-1 and SHA-256 for platforms which have CAAM block.

---
The patch series is dependent on
https://patchwork.ozlabs.org/patch/387174/
https://patchwork.ozlabs.org/patch/387175/

Ruchika,

This patch further increases the size of image. This board failed to compile

P1010RDB-PB_SPIFLASH_SECBOOT

York

#3 lore raw

PATCH 2/2 mpc85xx: configs - Add hash command in freescale platforms

Hi York,

The patch caused size issues, because the change for uboot image size to 768 K was missing for this target. I have sent a patch which fixes this issue.

https://patchwork.ozlabs.org/patch/394275/

Can you pick up this patch before the rest of the patches. That would resolve the size problems.

Regards,
Ruchika

Quoted 26 lines

-----Original Message-----
From: Sun York-R58495
Sent: Thursday, September 25, 2014 9:01 PM
To: Gupta Ruchika-R66431; u-boot at lists.denx.de
Subject: Re: [PATCH 2/2] mpc85xx: configs - Add hash command in freescale platforms

Quoted 10 lines · Ruchika Gupta

Hardware accelerated support for SHA-1 and SHA-256 has been added. Hash command enabled along with hardware accelerated support for SHA-1 and SHA-256 for platforms which have CAAM block.

---
The patch series is dependent on
https://patchwork.ozlabs.org/patch/387174/
https://patchwork.ozlabs.org/patch/387175/

Ruchika,

This patch further increases the size of image. This board failed to compile

P1010RDB-PB_SPIFLASH_SECBOOT

York

#4 lore raw

PATCH 1/2 fsl_sec : Add hardware accelerated SHA256 and SHA1

In reply to Ruchika Gupta
Quoted 9 lines · Ruchika Gupta

SHA-256 and SHA-1 accelerated using SEC hardware in Freescale SoC's The driver for SEC (CAAM) IP is based on linux drivers/crypto/caam.

---
The patch series is dependent on
https://patchwork.ozlabs.org/patch/387174/
https://patchwork.ozlabs.org/patch/387175/

Ruchika,

This patch increases the image size and causes a problem for these boards, kmcoge4 kmlion1 P1010RDB-PB_36BIT_SPIFLASH_SECBOOT

Please check.

York