Skip to contentSkip to conversation

AM65x HS device support

PATCH Superseded Andrew F. Davis 2 participants 16 messages Apr 12, 2019 – Apr 27, 2019

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

v3 cover AM65x HS device support

Hello all,

This series brings up HS device support on the AM65x platform. Support for HS on K3 family devices is a bit different than previous devices but for the most part all that has been abstracted into the SECDEV package, allowing for a rather straight forward implementation here.

Thanks,
Andrew

Changes from v2:
- Rebased on latest master

Changes from v1:
- Commented on use of .data section
- Use ti_sci_msg_hdr header directly when possible
- Rebase and add Reviewed-bys
- Will add makefile cleanup later as it also affects files unrelated to this series

Andrew F. Davis (7):
arm: K3: Avoid use of MCU_PSRAM0 before SYSFW is loaded
firmware: ti_sci: Add support for firewall management
firmware: ti_sci: Modify auth_boot TI-SCI API to match new version
arm: mach-k3: Add secure device support
arm: mach-k3: Add secure device build support
configs: Add configs for AM65x High Security EVM
doc: Update info on using K3 secure devices

 MAINTAINERS                                  |   4 +
 arch/arm/Kconfig                             |   2 +-
 arch/arm/mach-k3/Makefile                    |   1 +
 arch/arm/mach-k3/am6_init.c                  |  13 +-
 arch/arm/mach-k3/config.mk                   |  25 +++
 arch/arm/mach-k3/config_secure.mk            |  44 ++++
 arch/arm/mach-k3/include/mach/am6_hardware.h |   3 -
 arch/arm/mach-k3/security.c                  |  63 ++++++
 configs/am65x_hs_evm_a53_defconfig           |  77 +++++++
 configs/am65x_hs_evm_r5_defconfig            |  90 +++++++++
 doc/README.ti-secure                         |  20 +-
 drivers/firmware/ti_sci.c                    | 202 ++++++++++++++++++-
 drivers/firmware/ti_sci.h                    | 130 +++++++++++-
 include/linux/soc/ti/ti_sci_protocol.h       |  68 ++++++-
 tools/k3_fit_atf.sh                          |   8 +-
 15 files changed, 721 insertions(+), 29 deletions(-)
 create mode 100644 arch/arm/mach-k3/config_secure.mk
 create mode 100644 arch/arm/mach-k3/security.c
 create mode 100644 configs/am65x_hs_evm_a53_defconfig
 create mode 100644 configs/am65x_hs_evm_r5_defconfig
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/7 arm: K3: Avoid use of MCU_PSRAM0 before SYSFW is loaded

On HS devices the 512b region of reset isolated memory called MCU_PSRAM0 is firewalled by default. Until SYSFW is loaded we cannot use this memory. It is only used to store a single value left at the end of SRAM by ROM that will be needed later. Save that value to a global variable stored in the .data section. This section is used as .bss will be cleared between saving this value and using it.

---
 arch/arm/mach-k3/am6_init.c                  | 13 ++++++++-----
 arch/arm/mach-k3/include/mach/am6_hardware.h |  3 ---
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/mach-k3/am6_init.c +8 -5
index 77cd15f388..60a580305d 100644
@@ -49,11 +49,16 @@ static void ctrl_mmr_unlock(void)
 	mmr_unlock(CTRL_MMR0_BASE, 7);
 }
 
+/*
+ * This uninitialized global variable would normal end up in the .bss section,
+ * but the .bss is cleared between writing and reading this variable, so move
+ * it to the .data section.
+ */
+u32 bootindex __attribute__((section(".data")));
+
 static void store_boot_index_from_rom(void)
 {
-	u32 *boot_index = (u32 *)K3_BOOT_PARAM_TABLE_INDEX_VAL;
-
-	*boot_index = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
+	bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
 }
 
 void board_init_f(ulong dummy)
@@ -92,7 +97,6 @@ u32 spl_boot_mode(const u32 boot_device)
 {
 #if defined(CONFIG_SUPPORT_EMMC_BOOT)
 	u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
-	u32 bootindex = readl(K3_BOOT_PARAM_TABLE_INDEX_VAL);
 
 	u32 bootmode = (devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK) >>
 			CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT;
@@ -168,7 +172,6 @@ static u32 __get_primary_bootmedia(u32 devstat)
 u32 spl_boot_device(void)
 {
 	u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
-	u32 bootindex = readl(K3_BOOT_PARAM_TABLE_INDEX_VAL);
 
 	if (bootindex == K3_PRIMARY_BOOTMODE)
 		return __get_primary_bootmedia(devstat);
arch/arm/mach-k3/include/mach/am6_hardware.h +0 -3
index b5244609af..3343233aa3 100644
@@ -44,7 +44,4 @@
 #define CTRLMMR_LOCK_KICK1				0x0100c
 #define CTRLMMR_LOCK_KICK1_UNLOCK_VAL			0xd172bc5a
 
-/* MCU SCRATCHPAD usage */
-#define K3_BOOT_PARAM_TABLE_INDEX_VAL	CONFIG_SYS_K3_MCU_SCRATCHPAD_BASE
-
 #endif /* __ASM_ARCH_AM6_HARDWARE_H */
Signature · 1 line
2.21.0
#2 lore raw

PATCH v3 1/7 arm: K3: Avoid use of MCU_PSRAM0 before SYSFW is loaded

Quoted 11 lines · Andrew F. Davis

On HS devices the 512b region of reset isolated memory called MCU_PSRAM0 is firewalled by default. Until SYSFW is loaded we cannot use this memory. It is only used to store a single value left at the end of SRAM by ROM that will be needed later. Save that value to a global variable stored in the .data section. This section is used as .bss will be cleared between saving this value and using it.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/cb720bba/attachment.sig>
#3 lore raw

PATCH v3 2/7 firmware: ti_sci: Add support for firewall management

In reply to Andrew F. Davis

TI-SCI message protocol provides support for controlling the firewall configurations available in SoC.

Introduce support for the set of TI-SCI message protocol APIs that provide us with this capability of controlling firewalls.

---
 drivers/firmware/ti_sci.c              | 177 +++++++++++++++++++++++++
 drivers/firmware/ti_sci.h              | 121 +++++++++++++++++
 include/linux/soc/ti/ti_sci_protocol.h |  64 +++++++++
 3 files changed, 362 insertions(+)
drivers/firmware/ti_sci.c +177 -0
index d47d22fff3..44bbeb66c2 100644
@@ -2428,6 +2428,178 @@ fail:
 	return ret;
 }
 
+/**
+ * ti_sci_cmd_set_fwl_region() - Request for configuring a firewall region
+ * @handle:    pointer to TI SCI handle
+ * @region:    region configuration parameters
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_set_fwl_region(const struct ti_sci_handle *handle,
+				     const struct ti_sci_msg_fwl_region *region)
+{
+	struct ti_sci_msg_fwl_set_firewall_region_req req;
+	struct ti_sci_msg_hdr *resp;
+	struct ti_sci_info *info;
+	struct ti_sci_xfer *xfer;
+	int ret = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
+
+	xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_SET,
+				     TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+				     (u32 *)&req, sizeof(req), sizeof(*resp));
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+
+	req.fwl_id = region->fwl_id;
+	req.region = region->region;
+	req.n_permission_regs = region->n_permission_regs;
+	req.control = region->control;
+	req.permissions[0] = region->permissions[0];
+	req.permissions[1] = region->permissions[1];
+	req.permissions[2] = region->permissions[2];
+	req.start_address = region->start_address;
+	req.end_address = region->end_address;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret) {
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
+	}
+
+	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
+
+	if (!ti_sci_is_response_ack(resp))
+		return -ENODEV;
+
+	return 0;
+}
+
+/**
+ * ti_sci_cmd_get_fwl_region() - Request for getting a firewall region
+ * @handle:    pointer to TI SCI handle
+ * @region:    region configuration parameters
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_get_fwl_region(const struct ti_sci_handle *handle,
+				     struct ti_sci_msg_fwl_region *region)
+{
+	struct ti_sci_msg_fwl_get_firewall_region_req req;
+	struct ti_sci_msg_fwl_get_firewall_region_resp *resp;
+	struct ti_sci_info *info;
+	struct ti_sci_xfer *xfer;
+	int ret = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
+
+	xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_GET,
+				     TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
+				     (u32 *)&req, sizeof(req), sizeof(*resp));
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+
+	req.fwl_id = region->fwl_id;
+	req.region = region->region;
+	req.n_permission_regs = region->n_permission_regs;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret) {
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
+	}
+
+	resp = (struct ti_sci_msg_fwl_get_firewall_region_resp *)xfer->tx_message.buf;
+
+	if (!ti_sci_is_response_ack(resp))
+		return -ENODEV;
+
+	region->fwl_id = resp->fwl_id;
+	region->region = resp->region;
+	region->n_permission_regs = resp->n_permission_regs;
+	region->control = resp->control;
+	region->permissions[0] = resp->permissions[0];
+	region->permissions[1] = resp->permissions[1];
+	region->permissions[2] = resp->permissions[2];
+	region->start_address = resp->start_address;
+	region->end_address = resp->end_address;
+
+	return 0;
+}
+
+/**
+ * ti_sci_cmd_change_fwl_owner() - Request for changing a firewall owner
+ * @handle:    pointer to TI SCI handle
+ * @region:    region configuration parameters
+ *
+ * Return: 0 if all went well, else returns appropriate error value.
+ */
+static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle,
+				       struct ti_sci_msg_fwl_owner *owner)
+{
+	struct ti_sci_msg_fwl_change_owner_info_req req;
+	struct ti_sci_msg_fwl_change_owner_info_resp *resp;
+	struct ti_sci_info *info;
+	struct ti_sci_xfer *xfer;
+	int ret = 0;
+
+	if (IS_ERR(handle))
+		return PTR_ERR(handle);
+	if (!handle)
+		return -EINVAL;
+
+	info = handle_to_ti_sci_info(handle);
+
+	xfer = ti_sci_setup_one_xfer(info, TISCI_MSG_FWL_GET,
+				     TISCI_MSG_FWL_CHANGE_OWNER,
+				     (u32 *)&req, sizeof(req), sizeof(*resp));
+	if (IS_ERR(xfer)) {
+		ret = PTR_ERR(xfer);
+		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
+		return ret;
+	}
+
+	req.fwl_id = owner->fwl_id;
+	req.region = owner->region;
+	req.owner_index = owner->owner_index;
+
+	ret = ti_sci_do_xfer(info, xfer);
+	if (ret) {
+		dev_err(info->dev, "Mbox send fail %d\n", ret);
+		return ret;
+	}
+
+	resp = (struct ti_sci_msg_fwl_change_owner_info_resp *)xfer->tx_message.buf;
+
+	if (!ti_sci_is_response_ack(resp))
+		return -ENODEV;
+
+	owner->fwl_id = resp->fwl_id;
+	owner->region = resp->region;
+	owner->owner_index = resp->owner_index;
+	owner->owner_privid = resp->owner_privid;
+	owner->owner_permission_bits = resp->owner_permission_bits;
+
+	return ret;
+}
+
 /*
  * ti_sci_setup_ops() - Setup the operations structures
  * @info:	pointer to TISCI pointer
@@ -2444,6 +2616,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
 	struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops;
 	struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops;
 	struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops;
+	struct ti_sci_fwl_ops *fwl_ops = &ops->fwl_ops;
 
 	bops->board_config = ti_sci_cmd_set_board_config;
 	bops->board_config_rm = ti_sci_cmd_set_board_config_rm;
@@ -2501,6 +2674,10 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
 	udmap_ops->tx_ch_cfg = ti_sci_cmd_rm_udmap_tx_ch_cfg;
 	udmap_ops->rx_ch_cfg = ti_sci_cmd_rm_udmap_rx_ch_cfg;
 	udmap_ops->rx_flow_cfg = ti_sci_cmd_rm_udmap_rx_flow_cfg;
+
+	fwl_ops->set_fwl_region = ti_sci_cmd_set_fwl_region;
+	fwl_ops->get_fwl_region = ti_sci_cmd_get_fwl_region;
+	fwl_ops->change_fwl_owner = ti_sci_cmd_change_fwl_owner;
 }
 
 /**
drivers/firmware/ti_sci.h +121 -0

131 lines not on this page · raw message

include/linux/soc/ti/ti_sci_protocol.h +64 -0

82 lines not on this page · raw message

Signature · 1 line
2.21.0
#4 lore raw

PATCH v3 2/7 firmware: ti_sci: Add support for firewall management

Quoted 9 lines · Andrew F. Davis

TI-SCI message protocol provides support for controlling the firewall configurations available in SoC.

Introduce support for the set of TI-SCI message protocol APIs that provide us with this capability of controlling firewalls.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/bcc9f094/attachment.sig>
#5 lore raw

PATCH v3 3/7 firmware: ti_sci: Modify auth_boot TI-SCI API to match new version

In reply to Andrew F. Davis

SYSFW version 2019.01 introduces a slightly modified version of this API, add support for it here.

---
 drivers/firmware/ti_sci.c              | 25 ++++++++++++++++---------
 drivers/firmware/ti_sci.h              |  9 +++++++--
 include/linux/soc/ti/ti_sci_protocol.h |  4 ++--
 3 files changed, 25 insertions(+), 13 deletions(-)
drivers/firmware/ti_sci.c +16 -9
index 44bbeb66c2..1196ce0712 100644
@@ -1915,16 +1915,19 @@ static int ti_sci_cmd_set_proc_boot_ctrl(const struct ti_sci_handle *handle,
  * ti_sci_cmd_proc_auth_boot_image() - Command to authenticate and load the
  *			image and then set the processor configuration flags.
  * @handle:	Pointer to TI SCI handle
- * @proc_id:	Processor ID this request is for
- * @cert_addr:	Memory address at which payload image certificate is located.
+ * @image_addr:	Memory address at which payload image and certificate is
+ *		located in memory, this is updated if the image data is
+ *		moved during authentication.
+ * @image_size: This is updated with the final size of the image after
+ *		authentication.
  *
  * Return: 0 if all went well, else returns appropriate error value.
  */
 static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
-					   u8 proc_id, u64 cert_addr)
+					   u64 *image_addr, u32 *image_size)
 {
 	struct ti_sci_msg_req_proc_auth_boot_image req;
-	struct ti_sci_msg_hdr *resp;
+	struct ti_sci_msg_resp_proc_auth_boot_image *resp;
 	struct ti_sci_info *info;
 	struct ti_sci_xfer *xfer;
 	int ret = 0;
@@ -1944,9 +1947,8 @@ static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
 		dev_err(info->dev, "Message alloc failed(%d)\n", ret);
 		return ret;
 	}
-	req.processor_id = proc_id;
-	req.cert_addr_low = cert_addr & TISCI_ADDR_LOW_MASK;
-	req.cert_addr_high = (cert_addr & TISCI_ADDR_HIGH_MASK) >>
+	req.cert_addr_low = *image_addr & TISCI_ADDR_LOW_MASK;
+	req.cert_addr_high = (*image_addr & TISCI_ADDR_HIGH_MASK) >>
 				TISCI_ADDR_HIGH_SHIFT;
 
 	ret = ti_sci_do_xfer(info, xfer);
@@ -1955,10 +1957,15 @@ static int ti_sci_cmd_proc_auth_boot_image(const struct ti_sci_handle *handle,
 		return ret;
 	}
 
-	resp = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
+	resp = (struct ti_sci_msg_resp_proc_auth_boot_image *)xfer->tx_message.buf;
 
 	if (!ti_sci_is_response_ack(resp))
-		ret = -ENODEV;
+		return -ENODEV;
+
+	*image_addr = (resp->image_addr_low & TISCI_ADDR_LOW_MASK) |
+			(((u64)resp->image_addr_high <<
+			  TISCI_ADDR_HIGH_SHIFT) & TISCI_ADDR_HIGH_MASK);
+	*image_size = resp->image_size;
 
 	return ret;
 }
drivers/firmware/ti_sci.h +7 -2
index 1b601ff01b..a484b1fa40 100644
@@ -708,7 +708,6 @@ struct ti_sci_msg_req_set_proc_boot_ctrl {
 /**
  * struct ti_sci_msg_req_proc_auth_start_image - Authenticate and start image
  * @hdr:		Generic Header
- * @processor_id:	ID of processor
  * @cert_addr_low:	Lower 32bit (Little Endian) of certificate
  * @cert_addr_high:	Higher 32bit (Little Endian) of certificate
  *
@@ -717,11 +716,17 @@ struct ti_sci_msg_req_set_proc_boot_ctrl {
  */
 struct ti_sci_msg_req_proc_auth_boot_image {
 	struct ti_sci_msg_hdr hdr;
-	u8 processor_id;
 	u32 cert_addr_low;
 	u32 cert_addr_high;
 } __packed;
 
+struct ti_sci_msg_resp_proc_auth_boot_image {
+	struct ti_sci_msg_hdr hdr;
+	u32 image_addr_low;
+	u32 image_addr_high;
+	u32 image_size;
+} __packed;
+
 /**
  * struct ti_sci_msg_req_get_proc_boot_status - Get processor boot status
  * @hdr:		Generic Header
include/linux/soc/ti/ti_sci_protocol.h +2 -2
index 895cb1b911..c57802f293 100644
@@ -279,8 +279,8 @@ struct ti_sci_proc_ops {
 				 u64 bv, u32 cfg_set, u32 cfg_clr);
 	int (*set_proc_boot_ctrl)(const struct ti_sci_handle *handle, u8 pid,
 				  u32 ctrl_set, u32 ctrl_clr);
-	int (*proc_auth_boot_image)(const struct ti_sci_handle *handle, u8 pid,
-				    u64 caddr);
+	int (*proc_auth_boot_image)(const struct ti_sci_handle *handle,
+				    u64 *image_addr, u32 *image_size);
 	int (*get_proc_boot_status)(const struct ti_sci_handle *handle, u8 pid,
 				    u64 *bv, u32 *cfg_flags, u32 *ctrl_flags,
 				    u32 *sts_flags);
Signature · 1 line
2.21.0
#6 lore raw

PATCH v3 3/7 firmware: ti_sci: Modify auth_boot TI-SCI API to match new version

Quoted 6 lines · Andrew F. Davis

SYSFW version 2019.01 introduces a slightly modified version of this API, add support for it here.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/855a6e0e/attachment.sig>
#7 lore raw

PATCH v3 4/7 arm: mach-k3: Add secure device support

In reply to Andrew F. Davis

K3 devices have High Security (HS) variants along with the non-HS already supported. Like the previous generation devices (OMAP/Keystone2) K3 supports boot chain-of-trust by authenticating and optionally decrypting images as they are unpacked from FIT images. Add support for this here.

---
 MAINTAINERS                 |  1 +
 arch/arm/Kconfig            |  2 +-
 arch/arm/mach-k3/Makefile   |  1 +
 arch/arm/mach-k3/security.c | 63 +++++++++++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-k3/security.c
MAINTAINERS +1 -0
index f9ee4281d9..de1ea20930 100644
@@ -721,6 +721,7 @@ S:	Supported
 F:	arch/arm/mach-omap2/omap5/sec_entry_cpu1.S
 F:	arch/arm/mach-omap2/sec-common.c
 F:	arch/arm/mach-omap2/config_secure.mk
+F:	arch/arm/mach-k3/security.c
 F:	configs/am335x_hs_evm_defconfig
 F:	configs/am335x_hs_evm_uart_defconfig
 F:	configs/am43xx_hs_evm_defconfig
arch/arm/Kconfig +1 -1
index 398dbef1cb..f89e590464 100644
@@ -1456,7 +1456,7 @@ endchoice
 
 config TI_SECURE_DEVICE
 	bool "HS Device Type Support"
-	depends on ARCH_KEYSTONE || ARCH_OMAP2PLUS
+	depends on ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3
 	help
 	  If a high secure (HS) device type is being used, this config
 	  must be set. This option impacts various aspects of the
arch/arm/mach-k3/Makefile +1 -0
index bd4ab361b2..0c3a4f7db1 100644
@@ -6,4 +6,5 @@
 obj-$(CONFIG_SOC_K3_AM6) += am6_init.o
 obj-$(CONFIG_ARM64) += arm64-mmu.o
 obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o
+obj-$(CONFIG_TI_SECURE_DEVICE) += security.o
 obj-y += common.o
arch/arm/mach-k3/security.c new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.21.0
#8 lore raw

PATCH v3 4/7 arm: mach-k3: Add secure device support

Quoted 8 lines · Andrew F. Davis

K3 devices have High Security (HS) variants along with the non-HS already supported. Like the previous generation devices (OMAP/Keystone2) K3 supports boot chain-of-trust by authenticating and optionally decrypting images as they are unpacked from FIT images. Add support for this here.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/0ffdf1ef/attachment.sig>
#9 lore raw

PATCH v3 5/7 arm: mach-k3: Add secure device build support

In reply to Andrew F. Davis

K3 HS devices require signed binaries for boot, use the SECDEV tools to sign the boot artifacts during build.

---
 MAINTAINERS                       |  1 +
 arch/arm/mach-k3/config.mk        | 25 ++++++++++++++++++
 arch/arm/mach-k3/config_secure.mk | 44 +++++++++++++++++++++++++++++++
 tools/k3_fit_atf.sh               |  8 ++++--
 4 files changed, 76 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-k3/config_secure.mk
MAINTAINERS +1 -0
index de1ea20930..69a6789c04 100644
@@ -722,6 +722,7 @@ F:	arch/arm/mach-omap2/omap5/sec_entry_cpu1.S
 F:	arch/arm/mach-omap2/sec-common.c
 F:	arch/arm/mach-omap2/config_secure.mk
 F:	arch/arm/mach-k3/security.c
+F:	arch/arm/mach-k3/config_secure.mk
 F:	configs/am335x_hs_evm_defconfig
 F:	configs/am335x_hs_evm_uart_defconfig
 F:	configs/am43xx_hs_evm_defconfig
arch/arm/mach-k3/config.mk +25 -0
index be00d79fb0..2d8f61f9db 100644
@@ -36,6 +36,14 @@ cmd_gencert = cat $(srctree)/tools/k3_x509template.txt | sed $(SED_OPTS) > u-boo
 # If external key is not provided, generate key using openssl.
 ifeq ($(CONFIG_SYS_K3_KEY), "")
 KEY=u-boot-spl-eckey.pem
+# On HS use real key or warn if not available
+ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
+ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/keys/custMpk.pem),)
+KEY=$(TI_SECURE_DEV_PKG)/keys/custMpk.pem
+else
+$(warning "WARNING: signing key not found. Random key will NOT work on HS hardware!")
+endif
+endif
 else
 KEY=$(patsubst "%",$(srctree)/%,$(CONFIG_SYS_K3_KEY))
 endif
@@ -65,6 +73,15 @@ ALL-y	+= tiboot3.bin
 endif
 
 ifdef CONFIG_ARM64
+ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
+SPL_ITS := u-boot-spl-k3_HS.its
+$(SPL_ITS): FORCE
+	IS_HS=1 \
+	$(srctree)/tools/k3_fit_atf.sh \
+	$(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) > $@
+
+ALL-y	+= tispl.bin_HS
+else
 SPL_ITS := u-boot-spl-k3.its
 $(SPL_ITS): FORCE
 	$(srctree)/tools/k3_fit_atf.sh \
@@ -72,7 +89,15 @@ $(SPL_ITS): FORCE
 
 ALL-y	+= tispl.bin
 endif
+endif
+
+else
 
+ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
+ALL-y	+= u-boot.img_HS
 else
 ALL-y	+= u-boot.img
 endif
+endif
+
+include $(srctree)/arch/arm/mach-k3/config_secure.mk
arch/arm/mach-k3/config_secure.mk new file +44 -0

44 lines not on this page · raw message

tools/k3_fit_atf.sh +6 -2
index 430b5ca616..4e9f69c087 100755
@@ -21,6 +21,10 @@ if [ ! -f $TEE ]; then
 	TEE=/dev/null
 fi
 
+if [ ! -z "$IS_HS" ]; then
+	HS_APPEND=_HS
+fi
+
 cat << __HEADER_EOF
 /dts-v1/;
 
@@ -51,7 +55,7 @@ cat << __HEADER_EOF
 		};
 		spl {
 			description = "SPL (64-bit)";
-			data = /incbin/("spl/u-boot-spl-nodtb.bin");
+			data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
 			type = "standalone";
 			os = "U-Boot";
 			arch = "arm64";
@@ -66,7 +70,7 @@ do
 	cat << __FDT_IMAGE_EOF
 		$(basename $dtname) {
 			description = "$(basename $dtname .dtb)";
-			data = /incbin/("$dtname");
+			data = /incbin/("$dtname$HS_APPEND");
 			type = "flat_dt";
 			arch = "arm";
 			compression = "none";
Signature · 1 line
2.21.0
#10 lore raw

PATCH v3 5/7 arm: mach-k3: Add secure device build support

Quoted 6 lines · Andrew F. Davis

K3 HS devices require signed binaries for boot, use the SECDEV tools to sign the boot artifacts during build.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/d3cede00/attachment.sig>
#11 lore raw

PATCH v3 6/7 configs: Add configs for AM65x High Security EVM

In reply to Andrew F. Davis

Add new defconfig files for the AM65x High Security EVM.

This defconfigs are the same as for the non-secure part, except for:
CONFIG_TI_SECURE_DEVICE option set to 'y' CONFIG_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_SPL_FIT_IMAGE_POST_PROCESS option set to 'y'

---
 MAINTAINERS                        |  2 +
 configs/am65x_hs_evm_a53_defconfig | 77 +++++++++++++++++++++++++
 configs/am65x_hs_evm_r5_defconfig  | 90 ++++++++++++++++++++++++++++++
 3 files changed, 169 insertions(+)
 create mode 100644 configs/am65x_hs_evm_a53_defconfig
 create mode 100644 configs/am65x_hs_evm_r5_defconfig
MAINTAINERS +2 -0
index 69a6789c04..aae2838f5c 100644
@@ -734,6 +734,8 @@ F:	configs/k2hk_hs_evm_defconfig
 F:	configs/k2e_hs_evm_defconfig
 F:	configs/k2g_hs_evm_defconfig
 F:	configs/k2l_hs_evm_defconfig
+F:	configs/am65x_hs_evm_r5_defconfig
+F:	configs/am65x_hs_evm_a53_defconfig
 
 TQ GROUP
 #M:	Martin Krause <[email protected]>
configs/am65x_hs_evm_a53_defconfig new file +77 -0

77 lines not on this page · raw message

configs/am65x_hs_evm_r5_defconfig new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.21.0
#12 lore raw

PATCH v3 6/7 configs: Add configs for AM65x High Security EVM

Quoted 10 lines · Andrew F. Davis

Add new defconfig files for the AM65x High Security EVM.

This defconfigs are the same as for the non-secure part, except for:
CONFIG_TI_SECURE_DEVICE option set to 'y' CONFIG_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_SPL_FIT_IMAGE_POST_PROCESS option set to 'y'

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/16a36d13/attachment.sig>
#13 lore raw

PATCH v3 7/7 doc: Update info on using K3 secure devices

In reply to Andrew F. Davis
---
 doc/README.ti-secure | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
doc/README.ti-secure +15 -5
index 76950253ac..27c0eaa77f 100644
@@ -138,7 +138,7 @@ Booting of U-Boot SPL
 	<INPUT_FILE>
 
 	Invoking the script for Keystone2 Secure Devices
-	=============================================
+	================================================
 
 	create-boot-image.sh \
 		<UNUSED> <INPUT_FILE> <OUTPUT_FILE> <UNUSED>
@@ -157,6 +157,18 @@ Booting of U-Boot SPL
 		boot from all media. Secure boot from SPI NOR flash is not
 		currently supported.
 
+	Invoking the script for K3 Secure Devices
+	=========================================
+
+	The signing steps required to produce a bootable SPL image on secure
+	K3 TI devices are the same as those performed on non-secure devices.
+	The only difference is the key is not checked on non-secure devices so
+	a dummy key is used when building U-Boot for those devices. For secure
+	K3 TI devices simply use the real hardware key for your device. This
+	real key can be set with the Kconfig option "K3_KEY". The environment
+	variable TI_SECURE_DEV_PKG is also searched for real keys when the
+	build targets secure devices.
+
 Booting of Primary U-Boot (u-boot.img)
 ======================================
 
@@ -181,10 +193,8 @@ Booting of Primary U-Boot (u-boot.img)
 	is enabled through the CONFIG_SPL_FIT_IMAGE_POST_PROCESS option which
 	must be enabled for the secure boot scheme to work. In order to allow
 	verifying proper operation of the secure boot chain in case of successful
-	authentication messages like "Authentication passed: CERT_U-BOOT-NOD" are
-	output by the SPL to the console for each blob that got extracted from the
-	FIT image. Note that the last part of this log message is the (truncated)
-	name of the signing certificate embedded into the blob that got processed.
+	authentication messages like "Authentication passed" are output by the
+	SPL to the console for each blob that got extracted from the FIT image.
 
 	The exact details of the how the images are secured is handled by the
 	SECDEV package. Within the SECDEV package exists a script to process
Signature · 1 line
2.21.0
#14 lore raw

PATCH v3 7/7 doc: Update info on using K3 secure devices

Quoted 3 lines · Andrew F. Davis

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/ff3178aa/attachment.sig>
#15 lore raw

v3 cover AM65x HS device support

In reply to Andrew F. Davis
Quoted 7 lines · Andrew F. Davis

Hello all,

This series brings up HS device support on the AM65x platform. Support for HS on K3 family devices is a bit different than previous devices but for the most part all that has been abstracted into the SECDEV package, allowing for a rather straight forward implementation here.

Quoted 5 lines

Thanks,
Andrew

Changes from v2:
- Rebased on latest master

Ping?

Quoted 38 lines

Changes from v1:
- Commented on use of .data section
- Use ti_sci_msg_hdr header directly when possible
- Rebase and add Reviewed-bys
- Will add makefile cleanup later as it also affects files unrelated to this series

Andrew F. Davis (7):
arm: K3: Avoid use of MCU_PSRAM0 before SYSFW is loaded
firmware: ti_sci: Add support for firewall management
firmware: ti_sci: Modify auth_boot TI-SCI API to match new version
arm: mach-k3: Add secure device support
arm: mach-k3: Add secure device build support
configs: Add configs for AM65x High Security EVM
doc: Update info on using K3 secure devices

 MAINTAINERS                                  |   4 +
 arch/arm/Kconfig                             |   2 +-
 arch/arm/mach-k3/Makefile                    |   1 +
 arch/arm/mach-k3/am6_init.c                  |  13 +-
 arch/arm/mach-k3/config.mk                   |  25 +++
 arch/arm/mach-k3/config_secure.mk            |  44 ++++
 arch/arm/mach-k3/include/mach/am6_hardware.h |   3 -
 arch/arm/mach-k3/security.c                  |  63 ++++++
 configs/am65x_hs_evm_a53_defconfig           |  77 +++++++
 configs/am65x_hs_evm_r5_defconfig            |  90 +++++++++
 doc/README.ti-secure                         |  20 +-
 drivers/firmware/ti_sci.c                    | 202 ++++++++++++++++++-
 drivers/firmware/ti_sci.h                    | 130 +++++++++++-
 include/linux/soc/ti/ti_sci_protocol.h       |  68 ++++++-
 tools/k3_fit_atf.sh                          |   8 +-
 15 files changed, 721 insertions(+), 29 deletions(-)
 create mode 100644 arch/arm/mach-k3/config_secure.mk
 create mode 100644 arch/arm/mach-k3/security.c
 create mode 100644 configs/am65x_hs_evm_a53_defconfig
 create mode 100644 configs/am65x_hs_evm_r5_defconfig