Add support to boot TI K3 HSM M4 core
Subsystems (3)
v7 cover Add support to boot TI K3 HSM M4 core
Some TI K3 SoCs like J721S2, J784S4, and J722S have a HSM (High Security Module) M4F core in the Wakeup Voltage Domain which could be used to run secure services like Authentication. Boot flow for HSM M4 core is different than the general purpose M4F cores, and is as below:
1. Request control of HSM M4F remote processor.
2. Assert Reset on the HSM M4F remote processor.
3. Request Secure Entity to Authenticate and Load HSM firmware into core's internal SRAM memory region. For GP device, load the firmware manually into core's SRAM region.
4. Deassert Reset on the HSM M4F remote processor.
5. Release control of HSM M4F remote processor.
This series adds support to boot HSM M4 core from R5 SPL stage. The HSM firmware is packed inside the tispl.bin fit image. The firmware is unpacked into a temporary DDR address which is then used to load HSM core. The configs to boot HSM M4 core are disabled by default.
Additional documentation on HSM M4 core usage:
https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-j784s4/latest/exports/docs/linux/Foundational_Components/U-Boot/UG-HSM.html
v7: Changelog:
[Udit]:
1. Update docs to include HSM loading section in applicable board specific files.
[Neha]:
1. Post to new U-Boot mailing list.
[General]:
1. Collect R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v6: Changelog:
[Bryan]:
1. Rebase on upstream main branch.
2. Drop [PATCH v5 1/7] as existing fix is already available in main.
3. Add documentation about enabling and booting HSM core in
doc/board/ti/k3.rst.
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
[Simon]:
1. Add 'depends on SOC_K3_J721S2 || SOC_K3_J784S4 || SOC_K3_J722S' for KConfig options.
2. Use hyphens in DT property names and underscores in python code.
3. Add comments to explain DT property values and link to ti-sci documentation
4. Use lower-case hex for DT property values.
5. Use consistent whitespaces.
6. Add property documentation in function docstring.
7. Log missing properties for boot and load extension groups.
8. Update tests to check the load and boot sections contain the expected values from test DTS. Add negative tests to check it raises an error when some of the properties are missing.
9. Driver improvements: Size check before memcpy(), type-casting, and checking device type via get_device_type().
10. Invoke ti_secure_image_post_process() only once for HSM images.
[General]:
1. Explicitly mention the load address of the HSM image in the FIT. Don't rely on U-Boot to assign a fallback load address. Use a Kconfig option to specify the HSM load address.
2. Pick up R/B tags from Neha and Simon.
3. Squash various patches together as they are atomic.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
Re-spinning after Device Tree Syncup happened from Linux to U-Boot. [Andrew]:
1. Reworded commit message on [PATCH v4 03/11].
[Simon]:
1. Add a binman test for the boot & load extensions in certificate in
[PATCH v4 08/11].
General:
1. Drop J722S defconfig changes out of this series. Will be posted/discussed separately.
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
[Andrew]:
1. Added dedicated remoteproc driver for booting HSM core.
2. Added support for signing HSM firmware images in U-Boot. [Anshul]
General:
1. Add support for booting HSM on J722S SoC as well.
Link to v2:
http://lore.kernel.org/all/[email protected]/
v2: Changelog:
[Andrew]:
1. Added support in SPL to load FIT images with no 'load' property.
2. Removed 'default = n' in CONFIG option.
3. Used __maybe_unused to decrease preprocessing.
4. Better error messages with error code.
[Udit]:
1. Added 'HSM' entries in enum at the last.
2. Added error condition in if-elseif-else ladder.
3. Hang System boot when HSM failed to boot properly.
Link to v1:
https://lore.kernel.org/all/[email protected]/
Testing done:
1. Tested HSM boot across GP, HS-FS, HS-SE device types for J721S2, J784S4 and J722S SoCs.
Logs after enabling HSM boot configs:
https://gist.github.com/3V3RYONE/ad33683652c8c49e4fedab49f0493e79
Beleswar Padhi (7):
arm: mach-k3: Add config options for packaging HSM firmware
arm: dts: k3-{j721s2/j722s/j784s4}-binman: Add template for packing
HSM firmware
binman: openssl: Add boot and load extensions to x509 cert
arm: dts: k3-{j721s2/j722s/j784s4}-r5.dtsi: Enable HSM core
remoteproc: k3-hsm: Introduce a remoteproc driver for K3 HSM core
arm: mach-k3: r5: common: Invoke boot of HSM M4 core
doc: board: ti: k3: Add section for HSM M4F core loading
MAINTAINERS | 1 + arch/arm/dts/k3-binman.dtsi | 26 ++ arch/arm/dts/k3-j721s2-binman.dtsi | 12 + arch/arm/dts/k3-j721s2-r5.dtsi | 10 + arch/arm/dts/k3-j722s-binman.dtsi | 12 + arch/arm/dts/k3-j722s-r5.dtsi | 10 + arch/arm/dts/k3-j784s4-binman.dtsi | 12 + arch/arm/dts/k3-j784s4-r5.dtsi | 9 + arch/arm/mach-k3/Kconfig | 16 ++ arch/arm/mach-k3/r5/common.c | 29 +- doc/board/ti/j721s2_evm.rst | 7 + doc/board/ti/j784s4_evm.rst | 7 + doc/board/ti/k3.rst | 136 +++++++++ drivers/remoteproc/Kconfig | 10 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/ti_k3_hsm_rproc.c | 268 ++++++++++++++++++ tools/binman/btool/openssl.py | 49 +++- tools/binman/etype/ti_secure.py | 65 +++++ tools/binman/etype/x509_cert.py | 4 +- tools/binman/ftest.py | 45 +++ .../test/vendor/ti_secure_boot_load_ext.dts | 23 ++ .../ti_secure_boot_load_ext_partial.dts | 20 ++ 22 files changed, 763 insertions(+), 9 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_hsm_rproc.c create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext.dts create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext_partial.dts
Signature · 1 line
2.34.1
PATCH v7 1/7 arm: mach-k3: Add config options for packaging HSM firmware
Some K3 SoCs like J721S2, and J784S4 have a HSM (High Security Module) M4F core in the Wakeup Voltage Domain which could be used to run secure services like Authentication. Add a config option which indicates that the SoC has a HSM core and the firmware for the core is available.
Add another config option (K3_HSM_LOAD_ADDR) to specify the load address for the HSM firmware image. This address is used to build the FIT image header that places the HSM image in memory during boot.
---
v7: Changelog:
1. Carried R/B from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. None
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Add new config option to specify the load address of HSM firmware in memory.
2. Add R/B tags.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. None
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. Updated description of config to match with functionality.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. Removed 'default = n' line from CONFIG.
Link to v1:
https://lore.kernel.org/all/[email protected]/
arch/arm/mach-k3/Kconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/mach-k3/Kconfig +16 -0
@@ -198,6 +198,22 @@ config K3_REMOTEPROC_PRU imply REMOTEPROC_TI_PRU default y if (SOC_K3_AM642 || SOC_K3_AM654) +config K3_HSM_FW + bool "Package firmware for HSM core" + depends on (SOC_K3_J721S2 || SOC_K3_J784S4 || SOC_K3_J722S) + help + Enabling this will indicate that the system has a HSM (High Security + Module) M4 Core and the firmware for the core is available. When + enabled, the firmware for HSM core will be packaged inside tispl.bin. + +config K3_HSM_LOAD_ADDR + hex "Load address of HSM image" + depends on K3_HSM_FW + default 0x82000000 + help + The load address for the HSM image. This value is used to build the + FIT image header that places HSM image in memory. + if CPU_V7R source "arch/arm/mach-k3/r5/Kconfig" endif
Signature · 1 line
2.34.1
PATCH v7 2/7 arm: dts: k3-{j721s2/j722s/j784s4}-binman: Add template for packing HSM firmware
In reply to Beleswar PadhiThe HSM M4 core needs to be booted at R5 SPL stage so that it can be used for further Authentication and security services. Therefore, the firmware for the HSM core needs to be packed in tispl.bin fit image so that it can be used by R5 SPL to boot the HSM core. By default, point to the firmware for HS-SE device type. This needs to be changed to point to appropriate firmware when using a different device type.
Add a template for packing the HSM firmware in tispl.bin. The template also contains necessary fields which will be populated in the boot extension and load extension in the x509 certificate for HSM firmware. This is required as the HSM firmware needs to be signed before invoking TIFS to authenticate and load the blob to HSM core.
Note: The os = "hsm" property is matched against image_os_match[IMAGE_ID_HSM] in arch/arm/mach-k3/r5/common.c during post-processing. This string must be kept consistent between the device tree and code, as changing it will break the image identification logic.
---
v7: Changelog:
1. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. None
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Squash [PATCH v4 05/11] and [PATCH v4 06/11] into [PATCH v5 3/7] for bisectability.
2. Use hyphens in DT property names.
3. Update commit message to call out os = "hsm" matching criteria.
4. Add comments explaining DT property values and add link to ti-sci documentation.
5. Use whitespaces consistently.
6. Add R/B tags.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. Changed phandle from hsm to hsm_fw in 'content' field to match with node label.
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. Added ti-secure node for signing hsm firmware image in U-Boot.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. Got rid of 'load' and 'entry' properties. Rely on U-Boot to set it.
Link to v1:
https://lore.kernel.org/all/[email protected]/
arch/arm/dts/k3-binman.dtsi | 26 ++++++++++++++++++++++++++ arch/arm/dts/k3-j721s2-binman.dtsi | 12 ++++++++++++ arch/arm/dts/k3-j722s-binman.dtsi | 12 ++++++++++++ arch/arm/dts/k3-j784s4-binman.dtsi | 12 ++++++++++++ 4 files changed, 62 insertions(+)
arch/arm/dts/k3-binman.dtsi +26 -0
@@ -297,6 +297,32 @@ }; }; +#ifdef CONFIG_K3_HSM_FW + hsm { + description = "HSM binary"; + type = "standalone"; + compression = "none"; + os = "hsm"; + load = <CONFIG_K3_HSM_LOAD_ADDR>; + + ti-secure { + /* + * HSM (Hardware Security Module) core boot configuration. + * Refer to TIFS Boot Extension format specification: + * https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/security/sec_cert_format.html#sysfw-boot-ext + */ + content = <&hsm_fw>; + keyfile = "custMpk.pem"; + proc-id = <0x80>; /* HSM core processor ID */ + flags-set = <0x04>; /* Bit 2: Release processor from reset */ + flags-clr = <0x00>; /* No flags to clear */ + reset-vector = <0x00>; /* HSM starts execution from address 0x0 */ + dest-addr = <0x43c00000>; /* Load address: HSM SRAM base */ + auth-type = <0xfd00>; /* Upper byte 0xfd: HSM host ID, lower byte 0x00: Copy to dest-addr */ + }; + }; +#endif + dm { description = "DM binary"; type = "firmware";
arch/arm/dts/k3-j721s2-binman.dtsi +12 -0
@@ -268,6 +268,14 @@ }; }; +#ifdef CONFIG_K3_HSM_FW + hsm { + hsm_fw: blob-ext { + filename = "ti-hsm/hsm-demo-firmware-j721s2-hs.bin"; + }; + }; +#endif + dm { ti-secure { content = <&dm>;
@@ -300,7 +308,11 @@ conf-0 { description = "k3-j721s2-common-proc-board"; firmware = "atf"; +#ifdef CONFIG_K3_HSM_FW + loadables = "hsm", "tee", "dm", "spl"; +#else loadables = "tee", "dm", "spl"; +#endif fdt = "fdt-0"; }; };
arch/arm/dts/k3-j722s-binman.dtsi +12 -0
@@ -117,6 +117,14 @@ fit { images { +#ifdef CONFIG_K3_HSM_FW + hsm { + hsm_fw: blob-ext { + filename = "ti-hsm/hsm-demo-firmware-j722s-hs.bin"; + }; + }; +#endif + dm { ti-secure { content = <&dm>;
@@ -153,7 +161,11 @@ conf-0 { description = "k3-j722s-evm"; firmware = "atf"; +#ifdef CONFIG_K3_HSM_FW + loadables = "hsm", "tee", "dm", "spl"; +#else loadables = "tee", "dm", "spl"; +#endif fdt = "fdt-0"; }; };
arch/arm/dts/k3-j784s4-binman.dtsi +12 -0
@@ -154,6 +154,14 @@ fit { images { +#ifdef CONFIG_K3_HSM_FW + hsm { + hsm_fw: blob-ext { + filename = "ti-hsm/hsm-demo-firmware-j784s4-hs.bin"; + }; + }; +#endif + dm { ti-secure { content = <&dm>;
@@ -188,7 +196,11 @@ conf-0 { description = BOARD_DESCRIPTION; firmware = "atf"; +#ifdef CONFIG_K3_HSM_FW + loadables = "hsm", "tee", "dm", "spl"; +#else loadables = "tee", "dm", "spl"; +#endif fdt = "fdt-0"; }; };
Signature · 1 line
2.34.1
PATCH v7 3/7 binman: openssl: Add boot and load extensions to x509 cert
In reply to Beleswar PadhiThe boot and load extensions in the x509 certificate are required for requesting the secure entity (TIFS) to boot a core. These fields are defined in the binman node for each core that must be booted by TIFS and must be included when generating the signed certificate.
Add support to parse the boot and load extension properties from the binman node and populate them into the certificate. If any of the mandatory properties for an extension are missing, that respective extension section is NOT added to the certificate.
Add test coverage for the boot and load extension functionality in ti-secure certificates. The test reads the generated config file and verifies the sysfw_boot_seq and sysfw_image_load sections contain the expected values from the DTS. The negative test verifies that partially specified boot/load extension properties trigger an error.
---
v7: Changelog:
1. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. None
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Log missing properties and raise exception rather than returning silently.
2. Squash [PATCH v4 07/11] and [PATCH v4 08/11] into [PATCH v5 4/7]
3. Document properties in function docstring.
4. Update tests to check the load and boot sections contain the expected values from test DTS. Add negative tests to check it raises an error when some of the properties are missing.
5. Add R/B tags.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. None
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. New patch. Add support to sign HSM firmware here in U-Boot.
tools/binman/btool/openssl.py | 49 ++++++++++++-- tools/binman/etype/ti_secure.py | 65 +++++++++++++++++++ tools/binman/etype/x509_cert.py | 4 +- tools/binman/ftest.py | 45 +++++++++++++ .../test/vendor/ti_secure_boot_load_ext.dts | 23 +++++++ .../ti_secure_boot_load_ext_partial.dts | 20 ++++++ 6 files changed, 201 insertions(+), 5 deletions(-) create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext.dts create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext_partial.dts
tools/binman/btool/openssl.py +45 -4
@@ -82,7 +82,8 @@ imageSize = INTEGER:{len(indata)} return self.run_cmd(*args) def x509_cert_sysfw(self, cert_fname, input_fname, key_fname, sw_rev, - config_fname, req_dist_name_dict, firewall_cert_data): + config_fname, req_dist_name_dict, firewall_cert_data, + boot_ext_data, load_ext_data): """Create a certificate to be booted by system firmware Args:
@@ -101,12 +102,52 @@ imageSize = INTEGER:{len(indata)} extended certificate - certificate (str): Extended firewall certificate with the information for the firewall configurations. + boot_ext_data (dict): + - proc_id (int): The processor ID of core being booted + - flags_set (int): The config flags to set for core being booted + - flags_clr (int): The config flags to clear for core being booted + - reset_vector (int): The location of reset vector for core being + booted + load_ext_data (dict): + - dest_addr (int): The address to which image has to be copied + - auth_type (int): Contains the host ID for core being booted and + how the image is to be copied Returns: str: Tool output """ indata = tools.read_file(input_fname) hashval = hashlib.sha512(indata).hexdigest() + + if boot_ext_data is not None: + boot_ext = f''' +[ sysfw_boot_seq ] +bootCore = INTEGER:{boot_ext_data['proc_id']} +bootCoreOpts_set = INTEGER:{boot_ext_data['flags_set']} +bootCoreOpts_clr = INTEGER:{boot_ext_data['flags_clr']} +resetVec = FORMAT:HEX,OCT:{boot_ext_data['reset_vector']:08x} +# Reserved for future use +flagsValid = FORMAT:HEX,OCT:00000000 +rsvd1 = INTEGER:0x00 +rsvd2 = INTEGER:0x00 +rsvd3 = INTEGER:0x00 +''' + else: + boot_ext = "" + + if load_ext_data is not None: + load_ext = f''' +[ sysfw_image_load ] +destAddr = FORMAT:HEX,OCT:{load_ext_data['dest_addr']:08x} +authInPlace = INTEGER:{load_ext_data['auth_type']} +''' + else: + load_ext = f''' +[ sysfw_image_load ] +destAddr = FORMAT:HEX,OCT:00000000 +authInPlace = INTEGER:{hex(firewall_cert_data['auth_in_place'])} +''' + with open(config_fname, 'w', encoding='utf-8') as outf: print(f'''[ req ] distinguished_name = req_distinguished_name
@@ -138,9 +179,9 @@ shaType = OID:2.16.840.1.101.3.4.2.3 shaValue = FORMAT:HEX,OCT:{hashval} imageSize = INTEGER:{len(indata)} -[ sysfw_image_load ] -destAddr = FORMAT:HEX,OCT:00000000 -authInPlace = INTEGER:{hex(firewall_cert_data['auth_in_place'])} +{boot_ext} + +{load_ext} [ firewall ] numFirewallRegions = INTEGER:{firewall_cert_data['num_firewalls']}
tools/binman/etype/ti_secure.py +65 -0
83 lines not on this page · raw message
tools/binman/etype/x509_cert.py +3 -1
@@ -102,7 +102,9 @@ class Entry_x509_cert(Entry_collection): config_fname=config_fname, sw_rev=self.sw_rev, req_dist_name_dict=self.req_dist_name, - firewall_cert_data=self.firewall_cert_data) + firewall_cert_data=self.firewall_cert_data, + boot_ext_data=self.boot_ext, + load_ext_data=self.load_ext) elif type == 'rom': stdout = self.openssl.x509_cert_rom( cert_fname=output_fname,
tools/binman/ftest.py +45 -0
51 lines not on this page · raw message
tools/binman/test/vendor/ti_secure_boot_load_ext.dts new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + ti-secure { + content = <&unsecure_binary>; + proc-id = <0x20>; + flags-set = <0x00000001>; + flags-clr = <0x00000002>; + reset-vector = <0x70000000>; + dest-addr = <0x80000000>; + auth-type = <0x02>; + }; + unsecure_binary: blob-ext { + filename = "ti_unsecure.bin"; + }; + }; +};
tools/binman/test/vendor/ti_secure_boot_load_ext_partial.dts new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + ti-secure { + content = <&unsecure_binary>; + proc-id = <0x20>; + flags-set = <0x00000001>; + // Missing: flags-clr, reset-vector, dest-addr, auth-type + }; + unsecure_binary: blob-ext { + filename = "ti_unsecure.bin"; + }; + }; +};
Signature · 1 line
2.34.1
Re: [PATCH v7 3/7] binman: openssl: Add boot and load extensions to x509 cert
Quoted 54 lines · Beleswar Padhi
The boot and load extensions in the x509 certificate are required for requesting the secure entity (TIFS) to boot a core. These fields are defined in the binman node for each core that must be booted by TIFS and must be included when generating the signed certificate.
Add support to parse the boot and load extension properties from the binman node and populate them into the certificate. If any of the mandatory properties for an extension are missing, that respective extension section is NOT added to the certificate.
Add test coverage for the boot and load extension functionality in ti-secure certificates. The test reads the generated config file and verifies the
sysfw_boot_seqandsysfw_image_loadsections contain the expected values from the DTS. The negative test verifies that partially specified boot/load extension properties trigger an error.Signed-off-by Beleswar Padhi <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Udit Kumar <[email protected]>---
v7: Changelog:
1. Carried R/B tag from Udit.Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/v6: Changelog:
1. NoneLink to v5:
https://lore.kernel.org/all/[email protected]/v5: Changelog:
1. Log missing properties and raise exception rather than returning silently.
2. Squash [PATCH v4 07/11] and [PATCH v4 08/11] into [PATCH v5 4/7]
3. Document properties in function docstring.
4. Update tests to check the load and boot sections contain the expected values from test DTS. Add negative tests to check it raises an error when some of the properties are missing.
5. Add R/B tags.Link to v4:
https://lore.kernel.org/all/[email protected]/v4: Changelog:
1. NoneLink to v3:
https://lore.kernel.org/all/[email protected]/v3: Changelog:
1. New patch. Add support to sign HSM firmware here in U-Boot.
Quoted 9 lines
tools/binman/btool/openssl.py | 49 ++++++++++++-- tools/binman/etype/ti_secure.py | 65 +++++++++++++++++++ tools/binman/etype/x509_cert.py | 4 +- tools/binman/ftest.py | 45 +++++++++++++ .../test/vendor/ti_secure_boot_load_ext.dts | 23 +++++++ .../ti_secure_boot_load_ext_partial.dts | 20 ++++++ 6 files changed, 201 insertions(+), 5 deletions(-) create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext.dts create mode 100644 tools/binman/test/vendor/ti_secure_boot_load_ext_partial.dts
This leads to CI failures:
https://git.u-boot-project.org/u-boot/u-boot/-/jobs/105234
and:tools/binman/etype/x509_cert.py:106:30: E1101: Instance of 'Entry_x509_cert' has no 'boot_ext' member (no-member) tools/binman/etype/x509_cert.py:107:30: E1101: Instance of 'Entry_x509_cert' has no 'load_ext' member (no-member)
Signature · 1 line
Tom
PATCH v7 4/7 arm: dts: k3-{j721s2/j722s/j784s4}-r5.dtsi: Enable HSM core
In reply to Beleswar PadhiThe HSM M4F node is disabled by default in the device tree. Enable the node here as we have to load and boot the core in R5 SPL stage. Assign the alias of 'remoteproc2' to the hsm node. This assigns the sequence number '2' to HSM core which can be used during rproc_load() and rproc_start() calls.
---
v7: Changelog:
1. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. None
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Add a comment calling out the usage of alias indexes in code.
2. Add R/B tags.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. Changed node labels from 'hsm_m4fss' to 'hsm' to match with device tree definition.
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. New patch. Enable HSM nodes from DT.
arch/arm/dts/k3-j721s2-r5.dtsi | 10 ++++++++++ arch/arm/dts/k3-j722s-r5.dtsi | 10 ++++++++++ arch/arm/dts/k3-j784s4-r5.dtsi | 9 +++++++++ 3 files changed, 29 insertions(+)
arch/arm/dts/k3-j721s2-r5.dtsi +10 -0
@@ -8,9 +8,15 @@ tick-timer = &mcu_timer0; }; + /* + * The remoteproc sequence numbers defined here are used as literal indices + * in arch/arm/mach-k3/r5/common.c (e.g., rproc_load(1, ...), rproc_load(2, ...)). + * Adding, removing, or reordering these aliases will break the code. + */ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &hsm; }; a72_0: a72@0 {
@@ -102,3 +108,7 @@ ranges = <0x0 0x47000000 0x0 0x47000000 0x0 0x00068400>, <0x0 0x50000000 0x0 0x50000000 0x0 0x08000000>; }; + +&hsm { + status = "okay"; +};
arch/arm/dts/k3-j722s-r5.dtsi +10 -0
@@ -4,9 +4,15 @@ */ / { + /* + * The remoteproc sequence numbers defined here are used as literal indices + * in arch/arm/mach-k3/r5/common.c (e.g., rproc_load(1, ...), rproc_load(2, ...)). + * Adding, removing, or reordering these aliases will break the code. + */ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a53_0; + remoteproc2 = &hsm; serial0 = &wkup_uart0; serial2 = &main_uart0; };
@@ -82,3 +88,7 @@ reg = <0x00 0x0fc40000 0x00 0x100>, <0x00 0x60000000 0x00 0x08000000>; }; + +&hsm { + status = "okay"; +};
arch/arm/dts/k3-j784s4-r5.dtsi +9 -0
@@ -8,9 +8,15 @@ tick-timer = &mcu_timer0; }; + /* + * The remoteproc sequence numbers defined here are used as literal indices + * in arch/arm/mach-k3/r5/common.c (e.g., rproc_load(1, ...), rproc_load(2, ...)). + * Adding, removing, or reordering these aliases will break the code. + */ aliases { remoteproc0 = &sysctrler; remoteproc1 = &a72_0; + remoteproc2 = &hsm; }; a72_0: a72@0 {
@@ -113,3 +119,6 @@ vdd-supply-2 = <&tps62873a>; }; +&hsm { + status = "okay"; +};
Signature · 1 line
2.34.1
PATCH v7 5/7 remoteproc: k3-hsm: Introduce a remoteproc driver for K3 HSM core
In reply to Beleswar PadhiSome K3 SoCs like J721S2, J784S4, J722S, AM62X and AM62PX have a HSM (High Security Module) M4F core in the Wakeup Voltage Domain which could be used to run secure services like Authentication. Boot flow for HSM M4 core is different than the general purpose M4F cores, and is as below:
1. Request control of HSM M4F remote processor.
2. Assert Reset on the HSM M4F remote processor.
3. For HS devices, Request Secure Entity to Authenticate and Load HSM firmware into core's internal SRAM memory region. For GP devices, load the unsigned firmware manually.
4. Deassert Reset on the HSM M4F remote processor.
5. Release control of HSM M4F remote processor.
Add a new remoteproc driver to support this boot flow for HSM M4F core.
---
v7: Changelog:
1. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. Add a call to ti_secure_image_check_binary() to strip off the certificate for GP firmware. (needed after rebasing to main)
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Use get_device_type() to detect device type (GP, HS-FS, HS-SE).
2. Avoid typecasting at certain places.
3. Check buffer size before doing memcpy() for overruns.
4. Add R/B tag.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. None
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. New patch. Add a dedicated remoteproc driver to boot HSM core.
MAINTAINERS | 1 + drivers/remoteproc/Kconfig | 10 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/ti_k3_hsm_rproc.c | 268 +++++++++++++++++++++++++++ 4 files changed, 280 insertions(+) create mode 100644 drivers/remoteproc/ti_k3_hsm_rproc.c
MAINTAINERS +1 -0
@@ -755,6 +755,7 @@ F: drivers/phy/ti-pipe3-phy.c F: drivers/ram/k3* F: drivers/ram/k3*/ F: drivers/remoteproc/ipu_rproc.c +F: drivers/remoteproc/ti_k3_hsm_rproc.c F: drivers/remoteproc/k3_system_controller.c F: drivers/remoteproc/pruc_rpoc.c F: drivers/remoteproc/ti*
drivers/remoteproc/Kconfig +10 -0
@@ -108,6 +108,16 @@ config REMOTEPROC_TI_K3_M4F on various TI K3 family of SoCs through the remote processor framework. +config REMOTEPROC_TI_K3_HSM_M4F + bool "TI K3 HSM M4F remoteproc support" + select REMOTEPROC + depends on ARCH_K3 + depends on TI_SCI_PROTOCOL + help + Say y here to support TI's HSM M4F remote processor subsystems + on various TI K3 family of SoCs through the remote processor + framework. + config REMOTEPROC_TI_K3_R5F bool "TI K3 R5F remoteproc support" select REMOTEPROC
drivers/remoteproc/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_REMOTEPROC_STM32_COPRO) += stm32_copro.o obj-$(CONFIG_REMOTEPROC_TI_K3_ARM64) += ti_k3_arm64_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_M4F) += ti_k3_m4_rproc.o +obj-$(CONFIG_REMOTEPROC_TI_K3_HSM_M4F) += ti_k3_hsm_rproc.o obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o
drivers/remoteproc/ti_k3_hsm_rproc.c new file +268 -0
268 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 6/7 arm: mach-k3: r5: common: Invoke boot of HSM M4 core
In reply to Beleswar PadhiThe tispl.bin fit image is packed with the HSM firmware image. Add support to load and boot the HSM M4F core during R5 SPL stage using the remoteprocessor framework.
Add IMAGE_ID_HSM enum and "hsm" OS type to detect HSM firmware in the FIT image. Track the load address for all FIT images. Load HSM firmware to remoteproc device 2 and start the core using the remoteprocessor framework when CONFIG_REMOTEPROC_TI_K3_HSM_M4F is enabled.
Skip HSM firmware from R5 secure image authentication as TIFS will authenticate it during the remoteproc load operation.
---
v7: Changelog:
1. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. None
Link to v5:
https://lore.kernel.org/all/[email protected]/
v5: Changelog:
1. Optimize if-else ladder for logging.
2. Call ti_secure_image_post_process() only once for HSM image (during rproc load).
3. Add R/B tag.
Link to v4:
https://lore.kernel.org/all/[email protected]/
v4: Changelog:
1. None
Link to v3:
https://lore.kernel.org/all/[email protected]/
v3: Changelog:
1. Use remoteproc framework to boot HSM core.
Link to v2:
https://lore.kernel.org/all/[email protected]/
v2: Changelog:
1. Hang system boot if HSM firmware failed to boot.
2. __maybe_unused to decrease preprocessor usage.
3. Better error messages with return code.
4. Added Error case in if-elseif-else ladder.
Note:
#define PROC_ID_HSM_M4F seems to have extra tab in the diff/patch. But when patch gets applied in file, all of them have consistent tabs.
Link to v1:
https://lore.kernel.org/all/[email protected]
arch/arm/mach-k3/r5/common.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
arch/arm/mach-k3/r5/common.c +25 -4
@@ -28,6 +28,7 @@ enum {IMAGE_ID_TIFSSTUB_HS ,IMAGE_ID_TIFSSTUB_FS ,IMAGE_ID_TIFSSTUB_GP , +IMAGE_ID_HSM , IMAGE_AMT, };
@@ -40,6 +41,7 @@ static const char *image_os_match[IMAGE_AMT] = {"tifsstub-hs" ,"tifsstub-fs" ,"tifsstub-gp" , + "hsm", };#endif
@@ -158,6 +160,23 @@ void __noreturn jump_to_image(struct spl_image_info *spl_image) &loadaddr); } +/* +* It is assumed that remoteproc device 2 is the corresponding +* Cortex-M4F HSM core. Make sure DT reflects the same. +*/ +if (IS_ENABLED (CONFIG_REMOTEPROC_TI_K3_HSM_M4F )) { + ret =rproc_load (2 , fit_image_info[IMAGE_ID_HSM ].load, + fit_image_info[IMAGE_ID_HSM ].image_len); +if (ret) +panic ("Error while loading HSM firmware, ret = %d\n" , ret); + + ret =rproc_start (2 ); +if (ret) +panic ("Error while starting HSM core\n" ); + +printf ("Successfully loaded and started HSM core\n" ); + } +/* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same.
@@ -330,17 +349,19 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,int len;int i;const char *os; -u32 addr; +u32 addr, load_addr; os =fdt_getprop (fit, node,"os" , &len); addr =fdt_getprop_u32_default_node (fit, node,0 ,"entry" ,-1 ); + load_addr =fdt_getprop_u32_default_node (fit, node,0 ,"load" ,0 ); -debug ("%s: processing image: addr=%x, size=%d, os=%s\n" , __func__, - addr, *p_size, os); +debug ("%s: processing image: addr=%x, load=%x, size=%d, os=%s\n" , __func__, + addr, load_addr, *p_size, os);for (i =0 ; i <IMAGE_AMT ; i++) {if (!strcmp (os, image_os_match[i])) { fit_image_info[i].image_start = addr; + fit_image_info[i].load = load_addr; fit_image_info[i].image_len = *p_size;debug ("%s: matched image for ID %d\n" , __func__, i);break ;
@@ -356,7 +377,7 @@ void board_fit_image_post_process(const void *fit, int node, void **p_image,* Only DM and the DTBs are being authenticated here, * rest will be authenticated when A72 cluster is up */ -if ((i !=IMAGE_ID_ATF ) && (i !=IMAGE_ID_OPTEE )) { +if ((i !=IMAGE_ID_ATF ) && (i !=IMAGE_ID_OPTEE ) && (i !=IMAGE_ID_HSM )) {ti_secure_image_check_binary (p_image, p_size);ti_secure_image_post_process (p_image, p_size); }else {
Signature · 1 line
2.34.1
PATCH v7 7/7 doc: board: ti: k3: Add section for HSM M4F core loading
In reply to Beleswar PadhiAdd a concise section for loading and booting the HSM M4F core in TI K3 SoCs like J721S2, J742S2 and J784S4.
---
v7: Changelog:
1. Included the HSM doc in the applicable board specific files.
2. Carried R/B tag from Udit.
Link to v6:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
v6: Changelog:
1. New patch. Adds documentation for loading and booting the TI K3 HSM M4F remote processor.
doc/board/ti/j721s2_evm.rst | 7 ++ doc/board/ti/j784s4_evm.rst | 7 ++ doc/board/ti/k3.rst | 136 ++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+)
doc/board/ti/j721s2_evm.rst +7 -0
@@ -281,6 +281,13 @@ https://www.ti.com/lit/pdf/spruj68 under the `Bootmode Settings` section. For SW1, the switch state in the "ON" position = 1. +HSM M4F Loading +---------------- + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_hsm_m4f_loading + :end-before: .. k3_rst_include_end_hsm_m4f_loading + Debugging U-Boot ----------------
doc/board/ti/j784s4_evm.rst +7 -0
@@ -637,6 +637,13 @@ to the J784S4 endpoint: This program copies the boot image to the PCIe endpoint's memory region and writes the necessary control words to signal image transfer completion. +HSM M4F Loading +---------------- + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_hsm_m4f_loading + :end-before: .. k3_rst_include_end_hsm_m4f_loading + Debugging U-Boot ----------------
doc/board/ti/k3.rst +136 -0
142 lines not on this page · raw message
Signature · 1 line
2.34.1