Skip to contentSkip to conversation

Use HACE to accelerate sha512

PATCH In review Joel Stanley 3 participants 17 messages Apr 20, 2021 – Apr 23, 2021 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Joel Stanley

author maintainer
#0 lore raw

v2 cover Use HACE to accelerate sha512

This series adds support to u-boot to using the HACE hardware in the AST2600 to perform SHA hashing during boot, and enable the SPL features to load u-boot as a signed FIT.

This is only applicable for MMC booting, as the HACE cannot be used to hash directly from the memory mapped SPI NOR.

These have been tested with Cédric's aspeed-6.0 Qemu tree. You can reproduce using the script in this repository:

https://github.com/shenki/qemu-boot-test

Joel Stanley (10):
configs/ast2600: Make early malloc pool larger
crypto: Add driver for Aspeed HACE
ast2600: Enable HACE probing in SPL
ast2600: Add HACE to device tree
ast2600: spl: Remove SECBOOT BL2 kconfig option
ast2600: spl: Add ASPEED_LOADERS option
ast2600: spl: Support common boot loader features
config: ast2600: Configure common MMC SPL loader
configs: ast2600: Enable FIT SHA512 support
config: ast2600: Disable SPL raw image support

 arch/arm/dts/ast2600-rainier.dts           |   5 +
 arch/arm/dts/ast2600-tacoma.dts            |   5 +
 arch/arm/dts/ast2600.dtsi                  |   9 +
 arch/arm/dts/ast2600a1-evb.dts             |   4 +
 arch/arm/mach-aspeed/Kconfig               |  15 ++
 arch/arm/mach-aspeed/ast2600/Kconfig       |  12 -
 arch/arm/mach-aspeed/ast2600/Makefile      |   6 +-
 arch/arm/mach-aspeed/ast2600/spl.c         |  30 +++
 arch/arm/mach-aspeed/ast2600/spl_boot.c    |  17 +-
 configs/ast2600_openbmc_spl_emmc_defconfig |  24 +-
 drivers/crypto/Kconfig                     |  19 ++
 drivers/crypto/Makefile                    |   1 +
 drivers/crypto/aspeed_hace.c               | 266 +++++++++++++++++++++
 13 files changed, 375 insertions(+), 38 deletions(-)
 create mode 100644 drivers/crypto/aspeed_hace.c
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH v2 1/10 configs/ast2600: Make early malloc pool larger

The size of the early (pre-DRAM) SRAM heap in u-boot proper is extended to 8KB.

Testing found that the DRAM driver would perform an allocation that exceeded the limits, due to the probing of the HACE driver increasing memory presssure. As SRAM is unused when u-boot proper is running, it can all be allocated.

(In theory the entire 88KB of SRAM is free, but testing showed more than 60KB would break booting. Finding out why is TODO).

The SPL early heap is fixed to 0x800, the default before this change. Testing shows that:

SPL malloc() before relocation used 0x794 bytes (1 KB)

So 2KB should be enough.

---
 configs/ast2600_openbmc_spl_emmc_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
configs/ast2600_openbmc_spl_emmc_defconfig +2 -1
index 6daf6343478b..5a4d66da1cea 100644
@@ -24,12 +24,13 @@ CONFIG_ASPEED_KERNEL_FIT_DRAM_BASE=0x83000000
 CONFIG_TARGET_EVB_AST2600A1=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0x5000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x800
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R_ADDR=0x90300000
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc v2 01/10] configs/ast2600: Make early malloc pool larger

Hello,

Quoted 10 lines · Joel Stanley

The size of the early (pre-DRAM) SRAM heap in u-boot proper is extended to 8KB.

Testing found that the DRAM driver would perform an allocation that exceeded the limits, due to the probing of the HACE driver increasing memory presssure. As SRAM is unused when u-boot proper is running, it can all be allocated.

(In theory the entire 88KB of SRAM is free, but testing showed more than 60KB would break booting. Finding out why is TODO).

Could it be a HW problem ?

C.

Quoted 33 lines

The SPL early heap is fixed to 0x800, the default before this change. Testing shows that:

SPL malloc() before relocation used 0x794 bytes (1 KB)

So 2KB should be enough.

---
 configs/ast2600_openbmc_spl_emmc_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
configs/ast2600_openbmc_spl_emmc_defconfig +2 -1
index 6daf6343478b..5a4d66da1cea 100644
@@ -24,12 +24,13 @@ CONFIG_ASPEED_KERNEL_FIT_DRAM_BASE=0x83000000
 CONFIG_TARGET_EVB_AST2600A1=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_ENV_SIZE=0x10000
 CONFIG_ENV_OFFSET=0x5000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x800
 CONFIG_SPL=y
 CONFIG_SPL_STACK_R_ADDR=0x90300000
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
author maintainer
#3 lore raw

Re: [PATCH u-boot v2019.04-aspeed-openbmc v2 01/10] configs/ast2600: Make early malloc pool larger

Quoted 12 lines · Cédric Le Goater

Hello,

Quoted 8 lines · Joel Stanley

The size of the early (pre-DRAM) SRAM heap in u-boot proper is extended to 8KB.

Testing found that the DRAM driver would perform an allocation that exceeded the limits, due to the probing of the HACE driver increasing memory presssure. As SRAM is unused when u-boot proper is running, it can all be allocated.

Quoted 4 lines
Quoted 2 lines

(In theory the entire 88KB of SRAM is free, but testing showed more than 60KB would break booting. Finding out why is TODO).

Could it be a HW problem ?

This was testing in Qemu, so probably not. We model the full 88KB in Qemu.

author maintainer
#4 lore raw

PATCH v2 2/10 crypto: Add driver for Aspeed HACE

In reply to Joel Stanley

The HACE supports MD5, SHA1 and SHA2 family hash functions. This driver uses it in a polling mode to perform hash calculations over buffers placed in DRAM.

---
 configs/ast2600_openbmc_spl_emmc_defconfig |   1 +
 drivers/crypto/Kconfig                     |  19 ++
 drivers/crypto/Makefile                    |   1 +
 drivers/crypto/aspeed_hace.c               | 266 +++++++++++++++++++++
 4 files changed, 287 insertions(+)
 create mode 100644 drivers/crypto/aspeed_hace.c
configs/ast2600_openbmc_spl_emmc_defconfig +1 -0
index 5a4d66da1cea..f58a677f1914 100644
@@ -97,6 +97,7 @@ CONFIG_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_ASPEED_HACE=y
 CONFIG_DM_GPIO=y
 CONFIG_ASPEED_GPIO=y
 CONFIG_DM_I2C=y
drivers/crypto/Kconfig +19 -0
index 1ea116be7503..e92037d88906 100644
@@ -2,4 +2,23 @@ menu "Hardware crypto devices"
 
 source drivers/crypto/fsl/Kconfig
 
+config ASPEED_HACE
+	bool "ASPEED Hash and Crypto Engine"
+	depends on ASPEED_AST2600
+	imply SHA_HW_ACCEL
+	imply SHA_PROG_HW_ACCEL
+	imply SHA512
+	imply SHA512_ALGO
+	imply CMD_HASH
+	help
+	 Select this option to enable a driver for using the SHA engine in
+	 the ASPEED BMC SoCs.
+
+	 Enabling this allows the use of SHA operations in hardware without requiring the
+	 SHA software implementations, saving code size.
+
+	 Due to hardware limitations it cannot be used with a FIT placed in SPI
+	 FLASH. Data can only be hashed if it is in SDRAM, making this relevant
+	 for MMC and network boot only.
+
 endmenu
drivers/crypto/Makefile +1 -0
index efbd1d3fca05..ac93b1295954 100644
@@ -4,5 +4,6 @@
 # 	http://www.samsung.com
 
 obj-$(CONFIG_EXYNOS_ACE_SHA)	+= ace_sha.o
+obj-$(CONFIG_ASPEED_HACE)	+= aspeed_hace.o
 obj-y += rsa_mod_exp/
 obj-y += fsl/
drivers/crypto/aspeed_hace.c new file +266 -0

266 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#5 lore raw

PATCH v2 3/10 ast2600: Enable HACE probing in SPL

In reply to Joel Stanley

Look up the driver by name so we don't cause a link failure when building without the HACE driver built in.

---
 arch/arm/mach-aspeed/ast2600/spl.c         | 13 +++++++++++++
 configs/ast2600_openbmc_spl_emmc_defconfig |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
arch/arm/mach-aspeed/ast2600/spl.c +13 -0
index 54f89b0e8431..e1eef121d5c6 100644
@@ -32,6 +32,19 @@ void board_init_f(ulong dummy)
 #endif
 }
 
+#ifdef CONFIG_SPL_BOARD_INIT
+void spl_board_init(void)
+{
+	struct udevice *dev;
+
+	if (uclass_get_device_by_driver(UCLASS_MISC,
+				DM_GET_DRIVER(aspeed_hace),
+				&dev)) {
+		debug("Warning: HACE initialization failure\n");
+	}
+}
+#endif
+
 u32 spl_boot_device(void)
 {
 	switch (aspeed_bootmode()) {
configs/ast2600_openbmc_spl_emmc_defconfig +1 -1
index f58a677f1914..ed0233379fe9 100644
@@ -48,7 +48,7 @@ CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_BOARD_EARLY_INIT_F=y
-# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_BOARD_INIT=y
 # CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

PATCH v2 4/10 ast2600: Add HACE to device tree

In reply to Joel Stanley

HACE is the Hash and Crypto Egine in the AST2600.

---
 arch/arm/dts/ast2600-rainier.dts | 5 +++++
 arch/arm/dts/ast2600-tacoma.dts  | 5 +++++
 arch/arm/dts/ast2600.dtsi        | 9 +++++++++
 arch/arm/dts/ast2600a1-evb.dts   | 4 ++++
 4 files changed, 23 insertions(+)
arch/arm/dts/ast2600-rainier.dts +5 -0
index 67e177baf1bd..aae507b4c23d 100755
@@ -103,3 +103,8 @@
 	pinctrl-0 = <&pinctrl_emmc_default>;
 	sdhci-drive-type = <1>;
 };
+
+&hace {
+	u-boot,dm-pre-reloc;
+	status = "okay";
+};
arch/arm/dts/ast2600-tacoma.dts +5 -0
index 85d1e3902b11..c8ed5e35a74c 100755
@@ -94,3 +94,8 @@
 	pinctrl-0 = <&pinctrl_emmc_default>;
 	sdhci-drive-type = <1>;
 };
+
+&hace {
+	u-boot,dm-pre-reloc;
+	status = "okay";
+};
arch/arm/dts/ast2600.dtsi +9 -0
index e619f7118886..57ea98a47b67 100644
@@ -304,6 +304,15 @@
 
 			};
 
+			hace: hace@1e6d0000 {
+				compatible = "aspeed,ast2600-hace";
+				reg = <0x1e6d0000 0x200>;
+				interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&scu ASPEED_CLK_GATE_YCLK>;
+				clock-names = "yclk";
+				status = "disabled";
+			};
+
 			smp-memram@0 {
 				compatible = "aspeed,ast2600-smpmem", "syscon";
 				reg = <0x1e6e2180 0x40>;
arch/arm/dts/ast2600a1-evb.dts +4 -0
index 2827e00c0eb4..2ae6e3bdf192 100644
@@ -301,3 +301,7 @@
 &display_port {
 	status = "okay";
 };
+
+&hace {
+	status = "okay";
+};
Signature · 1 line
2.30.2
author maintainer
#7 lore raw

PATCH v2 5/10 ast2600: spl: Remove SECBOOT BL2 kconfig option

In reply to Joel Stanley

THis option was added in "ast2600: Allow selection of SPL boot devices" to allow disabling the secboot BL2 loaders. Instead of adding the new symbol the patch could have used the existing ASPEED_SECURE_BOOT option.

Change to use the existing option.

---
 arch/arm/mach-aspeed/ast2600/Kconfig    | 12 ------------
 arch/arm/mach-aspeed/ast2600/spl_boot.c | 17 +++++++----------
 2 files changed, 7 insertions(+), 22 deletions(-)
arch/arm/mach-aspeed/ast2600/Kconfig +0 -12
index 518f41b558d3..dd991e87c795 100644
@@ -53,18 +53,6 @@ config TARGET_SLT_AST2600
 
 endchoice
 
-config ASPEED_SECBOOT_BL2
-	bool "ASPEED secure boot BL2 support"
-	depends on ASPEED_AST2600
-	help
-	  Enable ASPEED's "secboot" secure boot support for verifying
-	  the SPL's playload ("BL2").
-
-	  Enable this is if you're using secure boot support in the AST2600 (or similar)
-	  to verify your u-boot proper.
-
-	  Disable this is if you are using u-boot's vboot to verify u-boot.
-
 source "board/aspeed/evb_ast2600a0/Kconfig"
 source "board/aspeed/evb_ast2600a1/Kconfig"
 source "board/aspeed/ncsi_ast2600a0/Kconfig"
arch/arm/mach-aspeed/ast2600/spl_boot.c +7 -10
index 06800940109e..517f3a767c82 100644
@@ -23,7 +23,7 @@ static int aspeed_spl_ram_load_image(struct spl_image_info *spl_image,
 }
 SPL_LOAD_IMAGE_METHOD("RAM", 0, ASPEED_BOOT_DEVICE_RAM, aspeed_spl_ram_load_image);
 
-#if IS_ENABLED(ASPEED_SECBOOT_BL2)
+#if IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT)
 static int aspeed_secboot_spl_ram_load_image(struct spl_image_info *spl_image,
 				      struct spl_boot_device *bootdev)
 {
@@ -42,9 +42,8 @@ static int aspeed_secboot_spl_ram_load_image(struct spl_image_info *spl_image,
 	return 0;
 }
 SPL_LOAD_IMAGE_METHOD("RAM with Aspeed Secure Boot", 0, ASPEED_SECBOOT_DEVICE_RAM, aspeed_secboot_spl_ram_load_image);
-#endif /* ASPEED_SECBOOT_BL2 */
+#endif /* IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT) */
 
-#if IS_ENABLED(CONFIG_SPL_MMC_SUPPORT)
 static int aspeed_spl_mmc_load_image(struct spl_image_info *spl_image,
 				      struct spl_boot_device *bootdev)
 {
@@ -104,7 +103,7 @@ static int aspeed_spl_mmc_load_image(struct spl_image_info *spl_image,
 }
 SPL_LOAD_IMAGE_METHOD("MMC", 0, ASPEED_BOOT_DEVICE_MMC, aspeed_spl_mmc_load_image);
 
-#if IS_ENABLED(ASPEED_SECBOOT_BL2)
+#if IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT)
 static int aspeed_secboot_spl_mmc_load_image(struct spl_image_info *spl_image,
 				      struct spl_boot_device *bootdev)
 {
@@ -165,8 +164,7 @@ static int aspeed_secboot_spl_mmc_load_image(struct spl_image_info *spl_image,
 	return 0;
 }
 SPL_LOAD_IMAGE_METHOD("MMC with Aspeed Secure Boot", 0, ASPEED_SECBOOT_DEVICE_MMC, aspeed_secboot_spl_mmc_load_image);
-#endif /* ASPEED_SECBOOT_BL2 */
-#endif
+#endif /* IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT) */
 
 #if IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT)
 static int getcymodem(void)
@@ -211,8 +209,7 @@ end_stream:
 }
 SPL_LOAD_IMAGE_METHOD("UART", 0, ASPEED_BOOT_DEVICE_UART, aspeed_spl_ymodem_load_image);
 
-
-#if IS_ENABLED(ASPEED_SECBOOT_BL2)
+#if IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT)
 static int aspeed_secboot_spl_ymodem_load_image(struct spl_image_info *spl_image,
 		struct spl_boot_device *bootdev)
 {
@@ -254,5 +251,5 @@ end_stream:
 	return ret;
 }
 SPL_LOAD_IMAGE_METHOD("UART with Aspeed Secure Boot", 0, ASPEED_SECBOOT_DEVICE_UART, aspeed_secboot_spl_ymodem_load_image);
-#endif /* ASPEED_SECBOOT_BL2 */
-#endif
+#endif /* IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT) */
+#endif /* IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) */
Signature · 1 line
2.30.2
author maintainer
#8 lore raw

PATCH v2 6/10 ast2600: spl: Add ASPEED_LOADERS option

In reply to Joel Stanley

This places the ASPEED loaders behind configuration option that can be disabled to instead use the common code. This option is enabled by default so existing configurations do not need to change.

---
 arch/arm/mach-aspeed/Kconfig          | 15 +++++++++++++++
 arch/arm/mach-aspeed/ast2600/Makefile |  6 ++++--
 arch/arm/mach-aspeed/ast2600/spl.c    |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)
arch/arm/mach-aspeed/Kconfig +15 -0
index 44d392a70610..bccb63a99e54 100644
@@ -54,6 +54,19 @@ config ASPEED_PALLADIUM
 	  This is mainly for internal verification and investigation
 	  on HW design. If not sure, say N.
 
+config ASPEED_LOADERS
+       bool "ASPEED custom loaders"
+       depends on SPL
+       default y
+       help
+        Enable the custom payload loading methods used by ASPEED. This is requited to
+        use ASPEED's proprietary secure boot feature.
+
+        Disable this is if you are using u-boot's common loader functionally
+        to eg. load u-boot as a FIT and use vboot.
+
+if ASPEED_LOADERS
+
 config ASPEED_SECURE_BOOT
 	bool "Support Aspeed secure boot feature"
 	depends on SPL && ASPEED_AST2600
@@ -154,6 +167,8 @@ config ASPEED_KERNEL_FIT_DRAM_BASE
 	  The DRAM address where the Kernel FIT image
 	  will be loaded if XIP is not supported
 
+endif
+
 source "arch/arm/mach-aspeed/ast2400/Kconfig"
 source "arch/arm/mach-aspeed/ast2500/Kconfig"
 source "arch/arm/mach-aspeed/ast2600/Kconfig"
arch/arm/mach-aspeed/ast2600/Makefile +4 -2
index 0abac4c233e4..d07e8c737cfe 100644
@@ -1,2 +1,4 @@
-obj-y   += platform.o board_common.o scu_info.o utils.o cache.o crypto.o aspeed_verify.o
-obj-$(CONFIG_SPL_BUILD) += spl.o spl_boot.o
+obj-y   += platform.o board_common.o scu_info.o utils.o cache.o
+obj-$(CONFIG_ASPEED_SECURE_BOOT) += crypto.o aspeed_verify.o
+obj-$(CONFIG_ASPEED_LOADERS) += spl_boot.o
+obj-$(CONFIG_SPL_BUILD) += spl.o
arch/arm/mach-aspeed/ast2600/spl.c +2 -0
index e1eef121d5c6..40eabca683c2 100644
@@ -47,6 +47,7 @@ void spl_board_init(void)
 
 u32 spl_boot_device(void)
 {
+#if IS_ENABLED(CONFIG_ASPEED_LOADERS)
 	switch (aspeed_bootmode()) {
 	case AST_BOOTMODE_EMMC:
 		return (IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT))?
@@ -60,6 +61,7 @@ u32 spl_boot_device(void)
 	default:
 		break;
 	}
+#endif
 
 	return BOOT_DEVICE_NONE;
 }
Signature · 1 line
2.30.2
author maintainer
#9 lore raw

PATCH v2 7/10 ast2600: spl: Support common boot loader features

In reply to Joel Stanley

Enable the common SPL code for loading boot images from various devices that the system can be configured to use. These loaders are used when not using the custom ASPEED loaders.

The system will try to boot from the strapped device, but fall back to the UART.

---
 arch/arm/mach-aspeed/ast2600/spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-aspeed/ast2600/spl.c +15 -0
index 40eabca683c2..778b326755ba 100644
@@ -61,11 +61,26 @@ u32 spl_boot_device(void)
 	default:
 		break;
 	}
+#else
+	switch (aspeed_bootmode()) {
+	case AST_BOOTMODE_EMMC:
+		return BOOT_DEVICE_MMC1;
+	case AST_BOOTMODE_SPI:
+		return BOOT_DEVICE_SPI;
+	case AST_BOOTMODE_UART:
+		return BOOT_DEVICE_UART;
+	}
 #endif
 
 	return BOOT_DEVICE_NONE;
 }
 
+void board_boot_order(u32 *spl_boot_list)
+{
+	spl_boot_list[0] = spl_boot_device();
+	spl_boot_list[1] = ASPEED_BOOT_DEVICE_UART;
+}
+
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
Signature · 1 line
2.30.2
author maintainer
#10 lore raw

PATCH v2 8/10 config: ast2600: Configure common MMC SPL loader

In reply to Joel Stanley

The SPL will load u-boot proper from sector 0x80 (128), which is 64KB into the device.

The link address changes as this is used as the load address by the loader. Given the Aspeed loaders are linking u-boot at 0x10000 but running it from RAM, the u-boot relocation code must be fine with this setup.

The custom Aspeed loaders are disabled, and so the related configuration options are removed from the defconfig.

---
 configs/ast2600_openbmc_spl_emmc_defconfig | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
configs/ast2600_openbmc_spl_emmc_defconfig +4 -13
index ed0233379fe9..b9190c70baa5 100644
@@ -7,20 +7,9 @@ CONFIG_SYS_THUMB_BUILD=y
 # CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/mach-aspeed/ast2600/u-boot-spl.lds"
 CONFIG_ARCH_ASPEED=y
-CONFIG_SYS_TEXT_BASE=0x10000
+CONFIG_SYS_TEXT_BASE=0x81000000
 CONFIG_ASPEED_AST2600=y
-CONFIG_ASPEED_UBOOT_SPI_BASE=0x10000
-CONFIG_ASPEED_UBOOT_SPI_SIZE=0xd0000
-CONFIG_ASPEED_UBOOT_MMC_BASE=0x80
-CONFIG_ASPEED_UBOOT_MMC_PART=1
-CONFIG_ASPEED_UBOOT_MMC_SIZE=0x680
-CONFIG_ASPEED_UBOOT_UART_SIZE=0xe0000
-CONFIG_ASPEED_UBOOT_DRAM_BASE=0x81000000
-CONFIG_ASPEED_KERNEL_FIT_SPI_BASE=0x20100000
-CONFIG_ASPEED_KERNEL_FIT_SPI_SIZE=0x1000000
-CONFIG_ASPEED_KERNEL_FIT_MMC_BASE=0x800
-CONFIG_ASPEED_KERNEL_FIT_MMC_SIZE=0x8000
-CONFIG_ASPEED_KERNEL_FIT_DRAM_BASE=0x83000000
+# CONFIG_ASPEED_LOADERS is not set
 CONFIG_TARGET_EVB_AST2600A1=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
@@ -53,6 +42,8 @@ CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
 CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_RAM_SUPPORT=y
Signature · 1 line
2.30.2
author maintainer
#11 lore raw

PATCH v2 9/10 configs: ast2600: Enable FIT SHA512 support

In reply to Joel Stanley

OpenBMC systems intend to use SHA512 in the FIT images.

---
 configs/ast2600_openbmc_spl_emmc_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/ast2600_openbmc_spl_emmc_defconfig +2 -0
index b9190c70baa5..195c03d274f9 100644
@@ -26,6 +26,7 @@ CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_ARMV7_PSCI_NR_CPUS=2
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA512_SUPPORT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
@@ -44,6 +45,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x80
+CONFIG_SPL_SHA512_SUPPORT=y
 CONFIG_SPL_FIT_IMAGE_TINY=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_RAM_SUPPORT=y
Signature · 1 line
2.30.2
author maintainer
#12 lore raw

PATCH v2 10/10 config: ast2600: Disable SPL raw image support

In reply to Joel Stanley

The only way to load u-boot will be as part FIT, so secure boot cannot be bypassed.

---
 configs/ast2600_openbmc_spl_emmc_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/ast2600_openbmc_spl_emmc_defconfig +1 -0
index 195c03d274f9..f72c77cd7541 100644
@@ -39,6 +39,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_BOARD_INIT=y
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 # CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): OF2C524D29.DA2BBB20-ON002586BD.00695579-002586BD.006F66D8@notes.na.collabserv.com

author maintainer
#14 lore raw
Quoted 6 lines · Sandhya Koteshwara

Hi Joel,

I am looking at the patches and confused by this: This is only applicable for MMC booting, as the HACE cannot be used to hash directly from the memory mapped SPI NOR.

From my understanding, when secure boot is enabled in AST2600, the secure boot microprocessor & ROM code copy the RoT image (either from SPI or eMMC) to SRAM before integrity check is performed. Subsequent CoT images are copied to DRAM before integrity check. Why is the same process not applicable here and why is there a need to hash directly from SPI?

Your understanding is correct, for Aspeed's secure boot solution. However we are not using that in this case (except for the initial image; the SPL). Once we have the SPL loaded we instead use the verification features in u-boot. This means we use the generic FIT loader code in common/.

If someone has a use case where they want to use the u-boot boot infrastructure to boot from NOR, then they could submit patches to modify the infrastructure to first copy the FIT to DRAM, and then perform verification.

Cheers,

Joel

Quoted 59 lines

Thanks,
Sandhya

----- Original message -----
From: Joel Stanley <[email protected]>
Sent by: "openbmc" <[email protected]>
To: [email protected], Klaus Heinrich Kiwi <[email protected]>, Andrew Jeffery <[email protected]>
Cc: "Cédric Le Goater" <[email protected]>
Subject: [EXTERNAL] [PATCH u-boot v2019.04-aspeed-openbmc v2 00/10] Use HACE to accelerate sha512
Date: Tue, Apr 20, 2021 2:47 AM

This series adds support to u-boot to using the HACE hardware in the AST2600 to perform SHA hashing during boot, and enable the SPL features to load u-boot as a signed FIT.

This is only applicable for MMC booting, as the HACE cannot be used to hash directly from the memory mapped SPI NOR.

These have been tested with Cédric's aspeed-6.0 Qemu tree. You can reproduce using the script in this repository:

https://github.com/shenki/qemu-boot-test

Joel Stanley (10):
configs/ast2600: Make early malloc pool larger
crypto: Add driver for Aspeed HACE
ast2600: Enable HACE probing in SPL
ast2600: Add HACE to device tree
ast2600: spl: Remove SECBOOT BL2 kconfig option
ast2600: spl: Add ASPEED_LOADERS option
ast2600: spl: Support common boot loader features
config: ast2600: Configure common MMC SPL loader
configs: ast2600: Enable FIT SHA512 support
config: ast2600: Disable SPL raw image support

 arch/arm/dts/ast2600-rainier.dts           |   5 +
 arch/arm/dts/ast2600-tacoma.dts            |   5 +
 arch/arm/dts/ast2600.dtsi                  |   9 +
 arch/arm/dts/ast2600a1-evb.dts             |   4 +
 arch/arm/mach-aspeed/Kconfig               |  15 ++
 arch/arm/mach-aspeed/ast2600/Kconfig       |  12 -
 arch/arm/mach-aspeed/ast2600/Makefile      |   6 +-
 arch/arm/mach-aspeed/ast2600/spl.c         |  30 +++
 arch/arm/mach-aspeed/ast2600/spl_boot.c    |  17 +-
 configs/ast2600_openbmc_spl_emmc_defconfig |  24 +-
 drivers/crypto/Kconfig                     |  19 ++
 drivers/crypto/Makefile                    |   1 +
 drivers/crypto/aspeed_hace.c               | 266 +++++++++++++++++++++
 13 files changed, 375 insertions(+), 38 deletions(-)
 create mode 100644 drivers/crypto/aspeed_hace.c

--
2.30.2

#15 lore raw
In reply to Joel Stanley
Quoted 11 lines · Joel Stanley

Joel Stanley (10):
configs/ast2600: Make early malloc pool larger
crypto: Add driver for Aspeed HACE
ast2600: Enable HACE probing in SPL
ast2600: Add HACE to device tree
ast2600: spl: Remove SECBOOT BL2 kconfig option
ast2600: spl: Add ASPEED_LOADERS option
ast2600: spl: Support common boot loader features
config: ast2600: Configure common MMC SPL loader
configs: ast2600: Enable FIT SHA512 support
config: ast2600: Disable SPL raw image support

Looks like you forgot to include 'clk: aspeed: Add HACE yclk to ast2600'

It fails pretty instantly even in Qemu without it.

Additionally, looks like the spl binary size grew significantly to 59696 bytes (around 10KB larger than before). The final SPL size when added to the Device-tree blob with the 4096bits public key is 65058 bytes, which is just a tad over the maximum limit we have of 65024 bytes.

-Klaus

Signature · 1 line
Klaus Heinrich Kiwi <[email protected]>
author maintainer
#16 lore raw
Quoted 16 lines · Klaus Heinrich Kiwi
Quoted 11 lines · Joel Stanley

Joel Stanley (10):
configs/ast2600: Make early malloc pool larger
crypto: Add driver for Aspeed HACE
ast2600: Enable HACE probing in SPL
ast2600: Add HACE to device tree
ast2600: spl: Remove SECBOOT BL2 kconfig option
ast2600: spl: Add ASPEED_LOADERS option
ast2600: spl: Support common boot loader features
config: ast2600: Configure common MMC SPL loader
configs: ast2600: Enable FIT SHA512 support
config: ast2600: Disable SPL raw image support

Quoted 1 line

Looks like you forgot to include 'clk: aspeed: Add HACE yclk to ast2600'

That patch was already applied to the u-boot tree.

I've since applied this series to the top of v2019.04-aspeed-openbmc.

Quoted 7 lines

It fails pretty instantly even in Qemu without it.

Additionally, looks like the spl binary size grew significantly to 59696 bytes (around 10KB larger than before). The final SPL size when added to the Device-tree blob with the 4096bits public key is 65058 bytes, which is just a tad over the maximum limit we have of 65024 bytes.

That's a surprise. Were you able to work out where the size increase came from?

Here's the size I see with HEAD:

44a8c618c1215e0faac0f335f0afd56ed4240e76 49986

I'm using arm-linux-gnueabi-gcc (Debian 10.2.1-6) 10.2.1 20210110.

Cheers,

Joel

#17 lore raw
Quoted 9 lines
Quoted 5 lines

Looks like you forgot to include 'clk: aspeed: Add HACE yclk to ast2600'

That patch was already applied to the u-boot tree.

I've since applied this series to the top of v2019.04-aspeed-openbmc.

Yeah I missed that you merged some of the patches

Quoted 8 lines
Quoted 7 lines

It fails pretty instantly even in Qemu without it.

Additionally, looks like the spl binary size grew significantly to 59696 bytes (around 10KB larger than before). The final SPL size when added to the Device-tree blob with the 4096bits public key is 65058 bytes, which is just a tad over the maximum limit we have of 65024 bytes.

Quoted 7 lines

That's a surprise. Were you able to work out where the size increase came from?

Here's the size I see with HEAD:

44a8c618c1215e0faac0f335f0afd56ed4240e76 49986

I'm using arm-linux-gnueabi-gcc (Debian 10.2.1-6) 10.2.1 20210110.

Looks like I was also missing some of the patches #ifdef'ing out the sha512/sha256 implementations when hw sha was available.

I was able to test the tree '44a8c618c1 configs: ast2600: Use non-a1 config for openbmc spl emmc' both on Qemu and hardware and it works fine, thanks!

-Klaus

Signature · 1 line
Klaus Heinrich Kiwi <[email protected]>