Skip to contentSkip to conversation

Add ACE HW support for SHA256 and SHA1

PATCH New Akshay Saraswat 2 participants 6 messages Mar 21, 2013 – Mar 29, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v8 cover Add ACE HW support for SHA256 and SHA1

This patch set adds hardware acceleration for SHA 256 with the help of ACE.

Changes since v1:
- Patch-1: Fixed few nits.
- Patch-2: Removed not required config.
- Patch-3: Added sha256 to hash command instead of new sha256 command.

Changes since v2:
- Patch-1:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in the patch.
- Removed space after a cast at line 506 in the patch.
- Removed blank line at line 561 in the patch.
- Removed space before semicolon at line 576 in the patch.
- Patch-2:
- Added "SHA1" in the comment for config.
- Patch-3:
- Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled.
- Added new declaration for function pointer hash_func_ws with different return type.
- Patch-4:
- New patch to enable config for hash command.

Changes since v3:
- Patch-1:
- Removed buffer limit since there are 2 regs for address hash_msg_size_high and low.
That means buffer length could go upto 2^64 bits which is practically
- Removed falling back to software sha256 because there is no buffer limit.
- Removed "/ 4" to sha1 and sha256 lengths and added increment to 4 in for loop at line 573.
- Timed out still kept to be 100 ms since this is enough for hardware to switch status to idle from busy.
In case it couldn't that means h/w is faulty.
- Patch-2:
- Added "Acked-by: Simon Glass <[email protected]>".
- Patch-3:
- New patch.
- Patch-4:
- Changed command names to lower case in algo struct.
- Added generic ace_sha config.
- Patch-5: Added acked-by Simon Glass
- Added new generic config for ace_sha to enable ace support in hash.c.

Changes since v4:
- Patch-1:
- Added include for clk.h.
- Added define for MAX_FREQ.
- Added timeout calculation as per frequency.
- Changed "i+=4" to "i++" and "len" to "len/4" in for loop at line 591 in this patch.
- Added two new functions ace_sha256 and ace_sha1.
- Patch-2: None.
- Patch-3:
- Changed function names in struct algo.
- Replaced ACE_SHA_TYPE to CHUNSZ in struct algo.
- Patch-4: Added "Acked-by: Simon Glass <[email protected]>".

Changes since v5:
- Patch-1:
- Removed ace_sha.h.
- Renamed ace_sfr.h as ace_sha.h.
- Removed timeout and checking for PRNG_ERROR bit in HASH_STATUS register. PRNG_ERROR bit high means setup was not done properly. Since there is no way to detect faulty h/w, we consider the possible fact that h/w should not be able to setup feed properly if it's faulty.
- Renamed function name ace_sha256 to hw_sha256 and ace_sha1 to hw_sha1.
- Patch-2: None.
- Patch-3:
- Added file hw_sha.h.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.
- Renamed function names ace_sha1 and ace_sha256 to hw_sha1 and hw_sha256 respectively.
- Patch-4:
- Removed "Acked-by: Simon Glass <[email protected]>" because of a change.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.

Changes since v6:
- Patch-1: Added "Acked-by: Simon Glass <[email protected]>".
- Patch-2: None.
- Patch-3:
- Changed position of "hw_sha.h" among includes (alpha order).
- Rebased patch.
- Patch-4: Added "Acked-by: Simon Glass <[email protected]>".

Changes since v7:
- Patch-1:
- Moved ace_sha.h to drivers/crypto.
- Removed parantheses where not required in ace_sha.h.
- Removed leftover time limit comment in ace_sha.c.
- Replaced "break" with "return -EBUSY" in PRNGERROR check.
- Patch-2: None.
- Patch-3: Added "Acked-by: Simon Glass <[email protected]>".
- Patch-4: None.

Akshay Saraswat (4):
Exynos: Add hardware accelerated SHA256 and SHA1
Exynos: config: Enable ACE HW for SHA 256 for Exynos
gen: Add sha h/w acceleration to hash
Exynos: config: Enable hash command

 Makefile                               |   1 +
 arch/arm/include/asm/arch-exynos/cpu.h |   4 +
 common/hash.c                          |  18 ++
 drivers/crypto/Makefile                |  47 +++++
 drivers/crypto/ace_sha.c               | 126 +++++++++++++
 drivers/crypto/ace_sha.h               | 325 +++++++++++++++++++++++++++++++++
 include/configs/exynos5250-dt.h        |   5 +
 include/hw_sha.h                       |  50 +++++
 8 files changed, 576 insertions(+)
 create mode 100644 drivers/crypto/Makefile
 create mode 100644 drivers/crypto/ace_sha.c
 create mode 100644 drivers/crypto/ace_sha.h
 create mode 100644 include/hw_sha.h
Signature · 1 line
1.8.0
#1 lore raw

PATCH v8 1/4 Exynos: Add hardware accelerated SHA256 and SHA1

SHA-256 and SHA-1 accelerated using ACE hardware.

---
Changes since v1:
- Moved code to drivers/crypto.
- Fixed few other nits.

Changes since v2:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in this patch.
- Removed space after a cast at line 506 in this patch.
- Removed blank line at line 561 in this patch.
- Removed space before semicolon at line 576 in this patch.

Changes since v3:
- Removed buffer limit since there are 2 regs for address hash_msg_size_high and low. That means buffer length could go upto 2^64 bits which is practically
- Removed falling back to software sha256 because there is no buffer limit.
- Removed "/ 4" to sha1 and sha256 lengths and added increment to 4 in for loop at line 573.
- Timed out still kept to be 100 ms since this is enough for hardware to switch status to idle from busy.
In case it couldn't that means h/w is faulty.

Changes since v4:
- Added include for clk.h.
- Added define for MAX_FREQ.
- Added timeout calculation as per frequency.
- Changed "i+=4" to "i++" and "len" to "len/4" in for loop at line 591 in this patch.
- Added two new functions ace_sha256 and ace_sha1.

Changes since v5:
- Removed ace_sha.h.
- Renamed ace_sfr.h as ace_sha.h.
- Removed timeout and checking for PRNG_ERROR bit in HASH_STATUS register. PRNG_ERROR bit high means setup was not done properly. Since there is no way to detect faulty h/w, we consider the possible fact that h/w should not be able to setup feed properly if it's faulty.
- Renamed function name ace_sha256 to hw_sha256 and ace_sha1 to hw_sha1.

Changes since v6:
- Added "Acked-by: Simon Glass <[email protected]>".

Changes since v7:
- Moved ace_sha.h to drivers/crypto.
- Removed parantheses where not required in ace_sha.h.
- Removed leftover time limit comment in ace_sha.c.
- Replaced "break" with "return -EBUSY" in PRNGERROR check.

 Makefile                               |   1 +
 arch/arm/include/asm/arch-exynos/cpu.h |   4 +
 drivers/crypto/Makefile                |  47 +++++
 drivers/crypto/ace_sha.c               | 126 +++++++++++++
 drivers/crypto/ace_sha.h               | 325 +++++++++++++++++++++++++++++++++
 5 files changed, 503 insertions(+)
 create mode 100644 drivers/crypto/Makefile
 create mode 100644 drivers/crypto/ace_sha.c
 create mode 100644 drivers/crypto/ace_sha.h
Makefile +1 -0
index 12763ce..2583f7f 100644
@@ -273,6 +273,7 @@ LIBS-y += disk/libdisk.o
 LIBS-y += drivers/bios_emulator/libatibiosemu.o
 LIBS-y += drivers/block/libblock.o
 LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o
+LIBS-y += drivers/crypto/libcrypto.o
 LIBS-y += drivers/dma/libdma.o
 LIBS-y += drivers/fpga/libfpga.o
 LIBS-y += drivers/gpio/libgpio.o
arch/arm/include/asm/arch-exynos/cpu.h +4 -0
index eb34422..2a20558 100644
@@ -62,6 +62,7 @@
 #define EXYNOS4_GPIO_PART4_BASE		DEVICE_NOT_AVAILABLE
 #define EXYNOS4_DP_BASE			DEVICE_NOT_AVAILABLE
 #define EXYNOS4_SPI_ISP_BASE		DEVICE_NOT_AVAILABLE
+#define EXYNOS4_ACE_SFR_BASE		DEVICE_NOT_AVAILABLE
 
 /* EXYNOS4X12 */
 #define EXYNOS4X12_GPIO_PART3_BASE	0x03860000
@@ -95,6 +96,7 @@
 #define EXYNOS4X12_I2S_BASE            DEVICE_NOT_AVAILABLE
 #define EXYNOS4X12_SPI_BASE            DEVICE_NOT_AVAILABLE
 #define EXYNOS4X12_SPI_ISP_BASE                DEVICE_NOT_AVAILABLE
+#define EXYNOS4X12_ACE_SFR_BASE		DEVICE_NOT_AVAILABLE
 
 /* EXYNOS5 Common*/
 #define EXYNOS5_I2C_SPACING		0x10000
@@ -106,6 +108,7 @@
 #define EXYNOS5_SWRESET			0x10040400
 #define EXYNOS5_SYSREG_BASE		0x10050000
 #define EXYNOS5_WATCHDOG_BASE		0x101D0000
+#define EXYNOS5_ACE_SFR_BASE            0x10830000
 #define EXYNOS5_DMC_PHY0_BASE		0x10C00000
 #define EXYNOS5_DMC_PHY1_BASE		0x10C10000
 #define EXYNOS5_GPIO_PART3_BASE		0x10D10000
@@ -205,6 +208,7 @@ static inline unsigned int samsung_get_base_##device(void)	\
 
 SAMSUNG_BASE(adc, ADC_BASE)
 SAMSUNG_BASE(clock, CLOCK_BASE)
+SAMSUNG_BASE(ace_sfr, ACE_SFR_BASE)
 SAMSUNG_BASE(dp, DP_BASE)
 SAMSUNG_BASE(sysreg, SYSREG_BASE)
 SAMSUNG_BASE(fimd, FIMD_BASE)
drivers/crypto/Makefile new file +47 -0

47 lines not on this page · raw message

drivers/crypto/ace_sha.c new file +126 -0

126 lines not on this page · raw message

drivers/crypto/ace_sha.h new file +325 -0

325 lines not on this page · raw message

Signature · 1 line
1.8.0
#2 lore raw

PATCH v8 2/4 Exynos: config: Enable ACE HW for SHA 256 for Exynos

In reply to Akshay Saraswat

This enables SHA 256 for exynos.

---
Changes since v1:
- Removed not required config.

Changes sice v2:
- Added "SHA1" in the comment for config.

Changes sice v3:
- Added "Acked-by: Simon Glass <[email protected]>".

Changes sice v4:
- None.

Changes sice v5:
- None.

Changes sice v6:
- None.

Changes since v7:
- None.

 include/configs/exynos5250-dt.h | 3 +++
 1 file changed, 3 insertions(+)
include/configs/exynos5250-dt.h +3 -0
index 1c624d4..1fb47a0 100644
@@ -46,6 +46,9 @@
 /* Keep L2 Cache Disabled */
 #define CONFIG_SYS_DCACHE_OFF
 
+/* Enable ACE acceleration for SHA1 and SHA256 */
+#define CONFIG_EXYNOS_ACE_SHA
+
 #define CONFIG_SYS_SDRAM_BASE		0x40000000
 #define CONFIG_SYS_TEXT_BASE		0x43E00000
 
Signature · 1 line
1.8.0
#3 lore raw

PATCH v8 3/4 gen: Add sha h/w acceleration to hash

In reply to Akshay Saraswat

Adding H/W acceleration support to hash which can be used to test SHA 256 hash algorithm.

---
Changes since v1:
- Added sha256 support to "hash" command instead of new sha256 command.

Changes sice v2:
- Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled.
- Added new declaration for function pointer hash_func_ws with different return type.

Changes sice v3:
- Changed command names to lower case in algo struct.
- Added generic ace_sha config.

Changes sice v4:
- Changed function names in struct algo.
- Replaced ACE_SHA_TYPE to CHUNSZ in struct algo.

Changes sice v5:
- Added file hw_sha.h.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.
- Renamed function names ace_sha1 and ace_sha256 to hw_sha1 and hw_sha256 respectively.

Changes sice v6:
- Changed position of "hw_sha.h" among includes (alpha order).
- Rebased patch.

Changes sice v7:
- Added "Acked-by: Simon Glass <[email protected]>".

 common/hash.c    | 18 ++++++++++++++++++
 include/hw_sha.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)
 create mode 100644 include/hw_sha.h
common/hash.c +18 -0
index f5badcb..c9ac33e 100644
@@ -25,6 +25,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <hw_sha.h>
 #include <hash.h>
 #include <sha1.h>
 #include <sha256.h>
@@ -37,6 +38,23 @@
  */
 static struct hash_algo hash_algo[] = {
 	/*
+	 * CONFIG_SHA_HW_ACCEL is defined if hardware acceleration is
+	 * available.
+	 */
+#ifdef CONFIG_SHA_HW_ACCEL
+	{
+		"sha1",
+		SHA1_SUM_LEN,
+		hw_sha1,
+		CHUNKSZ_SHA1,
+	}, {
+		"sha256",
+		SHA256_SUM_LEN,
+		hw_sha256,
+		CHUNKSZ_SHA256,
+	},
+#endif
+	/*
 	 * This is CONFIG_CMD_SHA1SUM instead of CONFIG_SHA1 since otherwise
 	 * it bloats the code for boards which use SHA1 but not the 'hash'
 	 * or 'sha1sum' commands.
include/hw_sha.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.8.0
#4 lore raw

PATCH v8 4/4 Exynos: config: Enable hash command

In reply to Akshay Saraswat

This enables hash command.

Tested with command "hash sha256 0x40008000 0x2B 0x40009000". Used mm and md to write a standard string to memory location 0x40008000 and ran the above command to verify the output.

---
Changes since v2:
- New patch to enable config for hash command.

Changes since v3:
- Added new generic config for ace_sha to enable ace support in hash.c.

Changes since v4:
- Added "Acked-by: Simon Glass <[email protected]>".

Changes since v5:
- Removed "Acked-by: Simon Glass <[email protected]>" because of a change.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.

Changes since v6:
- Added "Acked-by: Simon Glass <[email protected]>".

Changes since v7:
- None.

 include/configs/exynos5250-dt.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/exynos5250-dt.h +2 -0
index 1fb47a0..9680b9d 100644
@@ -48,6 +48,7 @@
 
 /* Enable ACE acceleration for SHA1 and SHA256 */
 #define CONFIG_EXYNOS_ACE_SHA
+#define CONFIG_SHA_HW_ACCEL
 
 #define CONFIG_SYS_SDRAM_BASE		0x40000000
 #define CONFIG_SYS_TEXT_BASE		0x43E00000
@@ -117,6 +118,7 @@
 #define CONFIG_CMD_EXT2
 #define CONFIG_CMD_FAT
 #define CONFIG_CMD_NET
+#define CONFIG_CMD_HASH
 
 #define CONFIG_BOOTDELAY		3
 #define CONFIG_ZERO_BOOTDELAY_CHECK
Signature · 1 line
1.8.0
#5 lore raw

v8 cover Add ACE HW support for SHA256 and SHA1

In reply to Akshay Saraswat
Quoted 103 lines · Akshay Saraswat

This patch set adds hardware acceleration for SHA 256 with the help of ACE.

Changes since v1:
- Patch-1: Fixed few nits.
- Patch-2: Removed not required config.
- Patch-3: Added sha256 to hash command instead of new sha256 command.

Changes since v2:
- Patch-1:
- Added falling back to software sha256 in case length exceeds buffer limit.
- Reduced one tab at lines 533, 559 and 571 in the patch.
- Removed space after a cast at line 506 in the patch.
- Removed blank line at line 561 in the patch.
- Removed space before semicolon at line 576 in the patch.
- Patch-2:
- Added "SHA1" in the comment for config.
- Patch-3:
- Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled.
- Added new declaration for function pointer hash_func_ws with different return type.
- Patch-4:
- New patch to enable config for hash command.

Changes since v3:
- Patch-1:
- Removed buffer limit since there are 2 regs for address hash_msg_size_high and low.
That means buffer length could go upto 2^64 bits which is practically
- Removed falling back to software sha256 because there is no buffer limit.
- Removed "/ 4" to sha1 and sha256 lengths and added increment to 4 in for loop at line 573.
- Timed out still kept to be 100 ms since this is enough for hardware to switch status to idle from busy.
In case it couldn't that means h/w is faulty.
- Patch-2:
- Added "Acked-by: Simon Glass <[email protected]>".
- Patch-3:
- New patch.
- Patch-4:
- Changed command names to lower case in algo struct.
- Added generic ace_sha config.
- Patch-5: Added acked-by Simon Glass
- Added new generic config for ace_sha to enable ace support in hash.c.

Changes since v4:
- Patch-1:
- Added include for clk.h.
- Added define for MAX_FREQ.
- Added timeout calculation as per frequency.
- Changed "i+=4" to "i++" and "len" to "len/4" in for loop at line 591 in this patch.
- Added two new functions ace_sha256 and ace_sha1.
- Patch-2: None.
- Patch-3:
- Changed function names in struct algo.
- Replaced ACE_SHA_TYPE to CHUNSZ in struct algo.
- Patch-4: Added "Acked-by: Simon Glass <[email protected]>".

Changes since v5:
- Patch-1:
- Removed ace_sha.h.
- Renamed ace_sfr.h as ace_sha.h.
- Removed timeout and checking for PRNG_ERROR bit in HASH_STATUS register. PRNG_ERROR bit high means setup was not done properly. Since there is no way to detect faulty h/w, we consider the possible fact that h/w should not be able to setup feed properly if it's faulty.
- Renamed function name ace_sha256 to hw_sha256 and ace_sha1 to hw_sha1.
- Patch-2: None.
- Patch-3:
- Added file hw_sha.h.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.
- Renamed function names ace_sha1 and ace_sha256 to hw_sha1 and hw_sha256 respectively.
- Patch-4:
- Removed "Acked-by: Simon Glass <[email protected]>" because of a change.
- Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.

Changes since v6:
- Patch-1: Added "Acked-by: Simon Glass <[email protected]>".
- Patch-2: None.
- Patch-3:
- Changed position of "hw_sha.h" among includes (alpha order).
- Rebased patch.
- Patch-4: Added "Acked-by: Simon Glass <[email protected]>".

Changes since v7:
- Patch-1:
- Moved ace_sha.h to drivers/crypto.
- Removed parantheses where not required in ace_sha.h.
- Removed leftover time limit comment in ace_sha.c.
- Replaced "break" with "return -EBUSY" in PRNGERROR check.
- Patch-2: None.
- Patch-3: Added "Acked-by: Simon Glass <[email protected]>".
- Patch-4: None.

Akshay Saraswat (4):
Exynos: Add hardware accelerated SHA256 and SHA1
Exynos: config: Enable ACE HW for SHA 256 for Exynos
gen: Add sha h/w acceleration to hash
Exynos: config: Enable hash command

Quoted 14 lines
 Makefile                               |   1 +
 arch/arm/include/asm/arch-exynos/cpu.h |   4 +
 common/hash.c                          |  18 ++
 drivers/crypto/Makefile                |  47 +++++
 drivers/crypto/ace_sha.c               | 126 +++++++++++++
 drivers/crypto/ace_sha.h               | 325 +++++++++++++++++++++++++++++++++
 include/configs/exynos5250-dt.h        |   5 +
 include/hw_sha.h                       |  50 +++++
 8 files changed, 576 insertions(+)
 create mode 100644 drivers/crypto/Makefile
 create mode 100644 drivers/crypto/ace_sha.c
 create mode 100644 drivers/crypto/ace_sha.h
 create mode 100644 include/hw_sha.h

applied to u-boot-samsung.

Thanks,
Minkyu Kang.