tpm: Support boot measurements
v5 cover tpm: Support boot measurements
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/
Changes since v4:
- Remove tcg2_measure_event function and check for NULL data in tcg2_measure_data
- Use tpm_auto_startup
- Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentation
Changes since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efi measure_event function
Changes since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measured
Changes since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driver
Eddie James (6):
tpm: Fix spelling for tpmu_ha union
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentation
arch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-) create mode 100644 doc/usage/measured_boot.rst create mode 100644 test/boot/measurement.c
Signature · 1 line
2.31.1
PATCH v5 1/6 tpm: Fix spelling for tpmu_ha union
tmpu -> tpmu
--- include/tpm-v2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/tpm-v2.h +2 -2
@@ -167,7 +167,7 @@ struct tcg_pcr_event {/** * Definition of TPMU_HA Union */ -union tmpu_ha { +union tpmu_ha {u8 sha1[TPM2_SHA1_DIGEST_SIZE ];u8 sha256[TPM2_SHA256_DIGEST_SIZE ];u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE ];
@@ -183,7 +183,7 @@ union tmpu_ha {*/ struct tpmt_ha {u16 hash_alg; -union tmpu_ha digest; +union tpmu_ha digest; } __packed;/**
Signature · 1 line
2.31.1
PATCH v5 2/6 tpm: Support boot measurements
In reply to Eddie JamesAdd TPM2 functions to support boot measurement. This includes starting up the TPM, initializing/appending the event log, and measuring the U-Boot version. Much of the code was used in the EFI subsystem, so remove it there and use the common functions.
---
Changes since v4:
- Remove tcg2_measure_event function and check for NULL data in tcg2_measure_data
- Use tpm_auto_startup
- Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
Changes since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efi measure_event function
Changes since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
include/efi_tcg2.h | 44 -- include/tpm-v2.h | 242 +++++++++ lib/efi_loader/efi_tcg2.c | 1010 +++---------------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++++++ 4 files changed, 1087 insertions(+), 980 deletions(-)
include/efi_tcg2.h +0 -44
@@ -129,50 +129,6 @@ struct efi_tcg2_boot_service_capability {#define BOOT_SERVICE_CAPABILITY_MIN \ offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks) -#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03" -#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2 -#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0 -#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2 - -/** -* struct TCG_EfiSpecIdEventAlgorithmSize - hashing algorithm information -* -* @algorithm_id: algorithm defined in enum tpm2_algorithms -* @digest_size: size of the algorithm -*/ -struct tcg_efi_spec_id_event_algorithm_size { -u16 algorithm_id; -u16 digest_size; -} __packed; - -/** -* struct TCG_EfiSpecIDEventStruct - content of the event log header -* -* @signature: signature, set to Spec ID Event03 -* @platform_class: class defined in TCG ACPI Specification -* Client Common Header. -* @spec_version_minor: minor version -* @spec_version_major: major version -* @spec_version_errata: major version -* @uintn_size: size of the efi_uintn_t fields used in various -* data structures used in this specification. -* 0x01 indicates u32 and 0x02 indicates u64 -* @number_of_algorithms: hashing algorithms used in this event log -* @digest_sizes: array of number_of_algorithms pairs -* 1st member defines the algorithm id -* 2nd member defines the algorithm size -*/ -struct tcg_efi_spec_id_event { -u8 signature[16 ]; -u32 platform_class; -u8 spec_version_minor; -u8 spec_version_major; -u8 spec_errata; -u8 uintn_size; -u32 number_of_algorithms; -struct tcg_efi_spec_id_event_algorithm_size digest_sizes[]; -} __packed; -/** * struct tdEFI_TCG2_FINAL_EVENTS_TABLE - log entries after Get Event Log * @version: version number for this structure
include/tpm-v2.h +242 -0
266 lines not on this page · raw message
lib/efi_loader/efi_tcg2.c +74 -936
1,264 lines not on this page · raw message
lib/tpm-v2.c +771 -0
788 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v5 3/6 bootm: Support boot measurement
In reply to Eddie JamesAdd a configuration option to measure the boot through the bootm function. Add the measurement state to the booti and bootz paths as well.
---
Changes since v4:
- Change PCR indexes for initrd and dtb
Changes since v2:
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measured
Changes since v1:
- Drop #ifdefs for bootm
boot/Kconfig | 23 ++++++++++++++++ boot/bootm.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ cmd/booti.c | 1 + cmd/bootm.c | 2 ++ cmd/bootz.c | 1 + include/bootm.h | 2 ++ include/image.h | 1 + 7 files changed, 100 insertions(+)
boot/Kconfig +23 -0
@@ -601,6 +601,29 @@ config LEGACY_IMAGE_FORMAT loaded. If a board needs the legacy image format support in this case, enable it here. +config MEASURED_BOOT + bool "Measure boot images and configuration to TPM and event log" + depends on HASH && TPM_V2 + help + This option enables measurement of the boot process. Measurement + involves creating cryptographic hashes of the binary images that + are booting and storing them in the TPM. In addition, a log of + these hashes is stored in memory for the OS to verify the booted + images and configuration. Enable this if the OS has configured + some memory area for the event log and you intend to use some + attestation tools on your system. + +if MEASURED_BOOT + config MEASURE_DEVICETREE + bool "Measure the devicetree image" + default y if MEASURED_BOOT + help + On some platforms, the devicetree is not static as it may contain + random MAC addresses or other such data that changes each boot. + Therefore, it should not be measured into the TPM. In that case, + disable the measurement here. +endif # MEASURED_BOOT + config SUPPORT_RAW_INITRD bool "Enable raw initrd images" help
boot/bootm.c +70 -0
88 lines not on this page · raw message
cmd/booti.c +1 -0
@@ -127,6 +127,7 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH BOOTM_STATE_RAMDISK | #endif +BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO , &images, 1);
cmd/bootm.c +2 -0
@@ -161,6 +161,8 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; +if (IS_ENABLED (CONFIG_MEASURED_BOOT )) + states |=BOOTM_STATE_MEASURE ;if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) states |=BOOTM_STATE_OS_CMDLINE ; ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 );
cmd/bootz.c +1 -0
@@ -81,6 +81,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH BOOTM_STATE_RAMDISK | #endif +BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO , &images, 1);
include/bootm.h +2 -0
@@ -55,6 +55,8 @@ ulong bootm_disable_interrupts(void);int bootm_find_images (int flag,int argc,char *const argv[],ulong start,ulong size); +int bootm_measure (struct bootm_headers *images); +int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[],int states,struct bootm_headers *images,int boot_progress);
include/image.h +1 -0
@@ -407,6 +407,7 @@ struct bootm_headers {#define BOOTM_STATE_OS_FAKE_GO 0x00000200/* 'Almost' run the OS */ #define BOOTM_STATE_OS_GO 0x00000400#define BOOTM_STATE_PRE_LOAD 0x00000800 +#define BOOTM_STATE_MEASURE 0x00001000int state;#if defined(CONFIG_LMB ) && !defined(USE_HOSTCC )
Signature · 1 line
2.31.1
PATCH v5 4/6 tpm: sandbox: Update for needed TPM2 capabilities
In reply to Eddie JamesThe driver needs to support getting the PCRs in the capabilities command. Fix various other things and support the max number of PCRs for TPM2.
--- drivers/tpm/tpm2_tis_sandbox.c | 100 ++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 28 deletions(-)
drivers/tpm/tpm2_tis_sandbox.c +72 -28
@@ -22,11 +22,6 @@ enum tpm2_hierarchy { TPM2_HIERARCHY_NB, }; -/* Subset of supported capabilities */ -enum tpm2_capability { -TPM_CAP_TPM_PROPERTIES =0x6 , -}; -/* Subset of supported properties */ #define TPM2_PROPERTIES_OFFSET 0x0000020E
@@ -38,7 +33,8 @@ enum tpm2_cap_tpm_property { TPM2_PROPERTY_NB, }; -#define SANDBOX_TPM_PCR_NB 1 +#define SANDBOX_TPM_PCR_NB TPM2_MAX_PCRS +#define SANDBOX_TPM_PCR_SELECT_MAX ((SANDBOX_TPM_PCR_NB + 7) / 8)/* * Information about our TPM emulation. This is preserved in the sandbox
@@ -433,7 +429,7 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf,int i, j;/* TPM2_GetProperty */ -u32 capability, property, property_count; +u32 capability, property, property_count, val;/* TPM2_PCR_Read/Extend variables */ int pcr_index =0 ;
@@ -542,19 +538,32 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf,case TPM2_CC_GET_CAPABILITY : capability =get_unaligned_be32 (sent); sent +=sizeof (capability); -if (capability !=TPM_CAP_TPM_PROPERTIES ) { -printf ("Sandbox TPM only support TPM_CAPABILITIES\n" ); -return TPM2_RC_HANDLE ; - } - property =get_unaligned_be32 (sent); sent +=sizeof (property); - property -=TPM2_PROPERTIES_OFFSET ; - property_count =get_unaligned_be32 (sent); sent +=sizeof (property_count); -if (!property_count || - property + property_count >TPM2_PROPERTY_NB ) { + +switch (capability) { +case TPM2_CAP_PCRS : +break ; +case TPM2_CAP_TPM_PROPERTIES : +if (!property_count) { + rc =TPM2_RC_HANDLE ; +return sandbox_tpm2_fill_buf (recv, recv_len, + tag, rc); + } + +if (property >TPM2_PROPERTIES_OFFSET && + ((property -TPM2_PROPERTIES_OFFSET ) + + property_count >TPM2_PROPERTY_NB )) { + rc =TPM2_RC_HANDLE ; +return sandbox_tpm2_fill_buf (recv, recv_len, + tag, rc); + } +break ; +default : +printf ("Sandbox TPM2 only supports TPM2_CAP_PCRS or " +"TPM2_CAP_TPM_PROPERTIES\n" ); rc =TPM2_RC_HANDLE ;return sandbox_tpm2_fill_buf (recv, recv_len, tag, rc); }
@@ -578,18 +587,53 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf,put_unaligned_be32 (capability, recv); recv +=sizeof (capability); -/* Give the number of properties that follow */ -put_unaligned_be32 (property_count, recv); - recv +=sizeof (property_count); - -/* Fill with the properties */ -for (i =0 ; i < property_count; i++) { -put_unaligned_be32 (TPM2_PROPERTIES_OFFSET + property + - i, recv); - recv +=sizeof (property); -put_unaligned_be32 (tpm->properties[property + i], - recv); - recv +=sizeof (property); +switch (capability) { +case TPM2_CAP_PCRS : +/* Give the number of algorithms supported - just SHA256 */ +put_unaligned_be32 (1 , recv); + recv +=sizeof (u32); + +/* Give SHA256 algorithm */ +put_unaligned_be16 (TPM2_ALG_SHA256 , recv); + recv +=sizeof (u16); + +/* Select the PCRs supported */ + *recv =SANDBOX_TPM_PCR_SELECT_MAX ; + recv++; + +/* Activate all the PCR bits */ +for (i =0 ; i <SANDBOX_TPM_PCR_SELECT_MAX ; ++i) { + *recv =0xff ; + recv++; + } +break ; +case TPM2_CAP_TPM_PROPERTIES : +/* Give the number of properties that follow */ +put_unaligned_be32 (property_count, recv); + recv +=sizeof (property_count); + +/* Fill with the properties */ +for (i =0 ; i < property_count; i++) { +put_unaligned_be32 (property + i, recv); + recv +=sizeof (property); +if (property >TPM2_PROPERTIES_OFFSET ) { + val = tpm->properties[(property - +TPM2_PROPERTIES_OFFSET ) + i]; + }else { +switch (property) { +case TPM2_PT_PCR_COUNT : + val =SANDBOX_TPM_PCR_NB ; +break ; +default : + val =0xffffffff ; +break ; + } + } + +put_unaligned_be32 (val, recv); + recv +=sizeof (property); + } +break ; }/* Add trailing \0 */
Signature · 1 line
2.31.1
PATCH v5 5/6 test: Add sandbox TPM boot measurement
In reply to Eddie JamesUse the sandbox TPM driver to measure some boot images in a unit test case.
---
Changes since v4:
- Drop u8 casting in measurement test
Changes since v2:
- Changed reserved memory address to the top of the RAM for sandbox dts.
arch/sandbox/dts/sandbox.dtsi | 14 ++++++++ arch/sandbox/dts/test.dts | 13 +++++++ configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++ 7 files changed, 98 insertions(+) create mode 100644 test/boot/measurement.c
arch/sandbox/dts/sandbox.dtsi +14 -0
@@ -4,9 +4,22 @@ * and sandbox64 builds. */ +#include <config.h> + #define USB_CLASS_HUB 9 / { + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log { + no-map; + reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>; + }; + }; + binman { };
@@ -332,6 +345,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; triangle {
arch/sandbox/dts/test.dts +13 -0
@@ -9,6 +9,7 @@ /dts-v1/; +#include <config.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/sandbox-gpio.h> #include <dt-bindings/input/input.h>
@@ -66,6 +67,17 @@ osd0 = "/osd"; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log { + no-map; + reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>; + }; + }; + binman: binman { };
@@ -1345,6 +1357,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; uart0: serial {
configs/sandbox_defconfig +1 -0
@@ -337,3 +337,4 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_MEASURED_BOOT=y
include/test/suites.h +1 -0
@@ -44,6 +44,7 @@ int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);int do_ut_lib (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_loadm (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_log (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_ut_measurement (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_mem (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_optee (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
test/boot/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o obj-$(CONFIG_FIT) += image.o +obj-$(CONFIG_MEASURED_BOOT) += measurement.o obj-$(CONFIG_EXPO) += expo.o
test/boot/measurement.c new file +66 -0
66 lines not on this page · raw message
test/cmd_ut.c +2 -0
@@ -101,6 +101,8 @@ static struct cmd_tbl cmd_ut_sub[] = { "", ""),U_BOOT_CMD_MKENT (bloblist,CONFIG_SYS_MAXARGS ,1 , do_ut_bloblist,"" ,"" ), +U_BOOT_CMD_MKENT (measurement,CONFIG_SYS_MAXARGS ,1 , do_ut_measurement, +"" ,"" ),U_BOOT_CMD_MKENT (bootm,CONFIG_SYS_MAXARGS ,1 , do_ut_bootm,"" ,"" ), #endif U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
Signature · 1 line
2.31.1
PATCH v5 6/6 doc: Add measured boot documentation
In reply to Eddie JamesBriefly describe the feature and specify the requirements.
---
Changes since v4:
- Use bullets for the requirements list
doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 doc/usage/measured_boot.rst
doc/usage/index.rst +1 -0
@@ -12,6 +12,7 @@ Use U-Boot partitions cmdline semihosting + measured_boot Shell commands --------------
doc/usage/measured_boot.rst new file +23 -0
@@ -0,0 +1,23 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Measured Boot +===================== + +U-Boot can perform a measured boot, the process of hashing various components +of the boot process, extending the results in the TPM and logging the +component's measurement in memory for the operating system to consume. + +Requirements +--------------------- + +* A hardware TPM 2.0 supported by the U-Boot drivers +* CONFIG_TPM=y +* CONFIG_MEASURED_BOOT=y +* Device-tree configuration of the TPM device to specify the memory area + for event logging. The TPM device node must either contain a phandle to + a reserved memory region or "linux,sml-base" and "linux,sml-size" + indicating the address and size of the memory region. An example can be + found in arch/sandbox/dts/test.dts +* The operating system must also be configured to use the memory regions + specified in the U-Boot device-tree in order to make use of the event + log.
Signature · 1 line
2.31.1
Thanks Eddie,
I quickly tested this but the EFI subsystem fails to initialize the TCG protocol properly now. Unfortunately I am on a business trip and I won't be able to take a look into why till next week
Cheers
/Ilias
Quoted 80 lines · Eddie James
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-) create mode 100644 doc/usage/measured_boot.rst create mode 100644 test/boot/measurement.cSignature · 1 line
2.31.1
Quoted 5 lines · Ilias Apalodimas
Thanks Eddie,
I quickly tested this but the EFI subsystem fails to initialize the TCG protocol properly now. Unfortunately I am on a business trip and I won't be able to take a look into why till next week
Hi Ilias,
I haven't had the opportunity to test this, have you?
Thanks,
Eddie
Quoted 85 lines
Cheers
/IliasQuoted 80 lines · Eddie James
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-)create mode 100644
doc/usage/measured_boot.rst
create mode 100644test/boot/measurement.cSignature · 1 line
2.31.1
Hi Eddie,
Quoted 9 lines · Eddie James
Quoted 5 lines · Ilias Apalodimas
Thanks Eddie,
I quickly tested this but the EFI subsystem fails to initialize the TCG protocol properly now. Unfortunately I am on a business trip and I won't be able to take a look into why till next week
Quoted 4 lines
Hi Ilias,
I haven't had the opportunity to test this, have you?
Not yet, apologies. I'll try looking into it this week.
Thanks
/Ilias
Quoted 92 lines
Thanks,
Eddie
Quoted 85 lines
Cheers
/IliasQuoted 80 lines · Eddie James
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-)create mode 100644
doc/usage/measured_boot.rst
create mode 100644test/boot/measurement.c--
2.31.1
Hi Eddie,
Quoted 12 lines · Eddie James
Quoted 5 lines · Ilias Apalodimas
Thanks Eddie,
I quickly tested this but the EFI subsystem fails to initialize the TCG protocol properly now. Unfortunately I am on a business trip and I won't be able to take a look into why till next week
Hi Ilias,
Quoted 12 lines
I haven't had the opportunity to test this, have you?
Thanks,
Eddie
Quoted 4 lines
Cheers
/Ilias
Still going through the code so bear with me.
It seems that the EFI failure is coming from tcg2_platform_get_log() specifically if none of linux,sml-base nor tpm_event_log_addr if present in the dtb.
One thing we should change here is look for tpm_event_log_addr first. The reason is that this is a very 'special' case in which TF-A fills in an eventlog for us, while linux,sml-base is more generic so I'd rather explicitly prefer TF-A id it prepared an eventlog for us.
On the failure now, if none of the nodes is present we are looking for 'memory-region' within the TPM node? Looking at the DT specs the tpm should only support "compatible, label, linux,sml-base/size' am I missing something?
I also had to apply [0] for this to compile. You can 'easily' test the EFI changes by doing a 'printenv -e'. This will at least initialize the efi subsystem and install the needed EFI tables (you need CMD_NVEDIT_EFI=y)
Hope this helps a bit. Let me know if I can help in any other way. Don't bother *testing* the eventlog for EFI on a full linux boot. I'll run that on v6
/Ilias
Quoted 81 lines
Quoted 81 lines · Eddie James
Quoted 80 lines
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-)create mode 100644
doc/usage/measured_boot.rst
create mode 100644test/boot/measurement.c--
2.31.1
Quoted 24 lines · Ilias Apalodimas
Hi Eddie,
Quoted 10 lines · Eddie James
Quoted 5 lines · Ilias Apalodimas
Thanks Eddie,
I quickly tested this but the EFI subsystem fails to initialize the TCG protocol properly now. Unfortunately I am on a business trip and I won't be able to take a look into why till next week
Hi Ilias,
Quoted 11 lines
I haven't had the opportunity to test this, have you?
Thanks,
Eddie
Quoted 3 lines
Cheers
/Ilias
Quoted 8 lines
Still going through the code so bear with me.
It seems that the EFI failure is coming fromtcg2_platform_get_log()specifically if none of linux,sml-base nortpm_event_log_addrif present in the dtb.
One thing we should change here is look fortpm_event_log_addrfirst. The reason is that this is a very 'special' case in which TF-A fills in an eventlog for us, while linux,sml-base is more generic so I'd rather explicitly prefer TF-A id it prepared an eventlog for us.
OK, thanks, this is helpful, I'll have a look.
Quoted 5 lines
On the failure now, if none of the nodes is present we are looking for 'memory-region' within the TPM node? Looking at the DT specs the tpm should only support "compatible, label, linux,sml-base/size' am I missing something?
I just had a commit merged for the reserved memory region: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/char/tpm/eventlog/of.c?id=1e2714bb83fc783d58701967391bea242c65eaff
It isn't documented anywhere so far...
Thanks,
Eddie
Quoted 96 lines
I also had to apply [0] for this to compile. You can 'easily' test the EFI changes by doing a 'printenv -e'. This will at least initialize the efi subsystem and install the needed EFI tables (you need CMD_NVEDIT_EFI=y)
Hope this helps a bit. Let me know if I can help in any other way. Don't bother *testing* the eventlog for EFI on a full linux boot. I'll run that on v6
/Ilias
Quoted 81 lines
Quoted 81 lines · Eddie James
Quoted 80 lines
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-)create mode 100644
doc/usage/measured_boot.rst
create mode 100644test/boot/measurement.c--
2.31.1
Quoted 10 lines · Eddie James
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/
Nice work Eddie. It looks like you're closing in on the issues Ilias and Simon have.
I did some testing and found some missing dependencies from running 'make check':
sandbox_spl: +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s sandbox_spl_defconfig
+make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s -j8 /usr/bin/ld: warning: test/overlay/test-fdt-overlay-stacked.dtb.o:
missing .note.GNU-stack section implies executable stack /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker/usr/bin/ld: /tmp/cc8cNroX.ltrans22.ltrans.o:(.data.rel+0x440):
undefined reference to `do_ut_measurement'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/joel/dev/u-boot/upstream/Makefile:1752: u-boot] Error 1
There's a few variants of the sandbox defconfig. I'm not sure if we want to exclude the measurement code from those configs, or add it to the configs.
When fixing them up to add CONFIG_MEASURED_BOOT=y we still fail to link:
sandbox_spl: +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s sandbox_spl_defconfig
+make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s -j8 /usr/bin/ld: warning: test/overlay/test-fdt-overlay-stacked.dtb.o:
missing .note.GNU-stack section implies executable stack/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker/usr/bin/ld: /tmp/ccRuOSFi.ltrans17.ltrans.o: in function `tcg2_create_digest':/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:112:
undefined reference to `sha512_starts'/usr/bin/ld: /home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:113:
undefined reference to `sha512_update'/usr/bin/ld: /home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:114:
undefined reference to `sha512_finish'/usr/bin/ld: /home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:106:
undefined reference to `sha384_starts'/usr/bin/ld: /home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:107:
undefined reference to `sha384_update'/usr/bin/ld: /home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:108:
undefined reference to `sha384_finish'
collect2: error: ld returned 1 exit status
This sorted that out for me:
lib/Kconfig +2 -0
@@ -411,6 +411,8 @@ config TPM bool "Trusted Platform Module (TPM) Support" depends on DM imply DM_RNG + select SHA512 + select SHA384
The tree I tested with is here:
https://github.com/shenki/u-boot/commits/measured-boot
Cheers,
Joel
Quoted 71 lines
Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-) create mode 100644 doc/usage/measured_boot.rst create mode 100644 test/boot/measurement.c--
2.31.1
Quoted 28 lines · Joel Stanley
Quoted 9 lines · Eddie James
This series adds support for measuring the boot images more generically than the existing EFI support. Several EFI functions have been moved to the TPM layer. The series includes optional measurement from the bootm command.
A new test case has been added for the bootm measurement to test the new path, and the sandbox TPM2 driver has been updated to support this use case.
This series is based on Ilias' auto-startup series:
https://lore.kernel.org/u-boot/[email protected]/Nice work Eddie. It looks like you're closing in on the issues Ilias and Simon have.
I did some testing and found some missing dependencies from running 'make check':
sandbox_spl: +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl(quoted diff) +1
-1-s sandbox_spl_defconfig +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s -j8
/usr/bin/ld: warning:test/overlay/test-fdt-overlay-stacked.dtb.o:
missing .note.GNU-stack section implies executable stack/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker/usr/bin/ld: /tmp/cc8cNroX.ltrans22.ltrans.o:(.data.rel+0x440):
undefined reference to `do_ut_measurement'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/joel/dev/u-boot/upstream/Makefile:1752: u-boot] Error 1
Quoted 3 lines
There's a few variants of the sandbox defconfig. I'm not sure if we want to exclude the measurement code from those configs, or add it to the configs.
Thanks Joel. I feel the right thing here would be to only build the measurement test when CONFIG_MEASURED_BOOT is enabled, so I'll make that change.
Quoted 36 lines
When fixing them up to add
CONFIG_MEASURED_BOOT=ywe still fail to link:
sandbox_spl: +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl(quoted diff) +1
-1-s sandbox_spl_defconfig +make O=/home/joel/dev/u-boot/upstream/build-sandbox_spl -s -j8
/usr/bin/ld: warning:test/overlay/test-fdt-overlay-stacked.dtb.o:
missing .note.GNU-stack section implies executable stack/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker/usr/bin/ld:/tmp/ccRuOSFi.ltrans17.ltrans.o: in function `tcg2_create_digest':/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:112:
undefined reference to `sha512_starts'/usr/bin/ld:/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:113:
undefined reference to `sha512_update'/usr/bin/ld:/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:114:
undefined reference to `sha512_finish'/usr/bin/ld:/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:106:
undefined reference to `sha384_starts'/usr/bin/ld:/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:107:
undefined reference to `sha384_update'/usr/bin/ld:/home/joel/dev/u-boot/upstream/build-sandbox_spl/../lib/tpm-v2.c:108:
undefined reference to `sha384_finish'
collect2: error: ld returned 1 exit statusThis sorted that out for me:
lib/Kconfig +2
-0@@ -411,6 +411,8 @@ config TPM bool "Trusted Platform Module (TPM) Support" depends on DM imply DM_RNG + select SHA512 + select SHA384
Quoted 2 lines
The tree I tested with is here:
https://github.com/shenki/u-boot/commits/measured-boot
Thanks, I'll select those.
Eddie
Quoted 75 lines
Cheers,
Joel
Quoted 70 lines
Changes since v4:
- Removetcg2_measure_eventfunction and check for NULL data intcg2_measure_data
- Usetpm_auto_startup
- Fixefi_tcg2.ccompilation for removingtcg2_pcr_readfunction
- Change PCR indexes for initrd and dtb
- Drop u8 casting in measurement test
- Use bullets in documentationChanges since v3:
- Reordered headers
- Refactored more of EFI code into common code
Removeddigest_infostructure and instead used the commonalg_to_mask
andalg_to_len
Improved event log parsing in common code to get it equivalent to EFI
Common code now extends PCR if previous bootloader stage couldn't No need to allocate memory in the common code, so EFI copies the discovered buffer like it did before
Rename efimeasure_eventfunctionChanges since v2:
- Add documentation.
- Changed reserved memory address to the top of the RAM for sandbox dts.
- Add measure state to booti and bootz.
- Skip measurement for EFI images that should be measuredChanges since v1:
- Refactor TPM layer functions to allow EFI system to use them, and remove duplicate EFI functions.
- Add test case
- Drop #ifdefs for bootm
- Add devicetree measurement config option
- Update sandbox TPM driverEddie James (6):
tpm: Fix spelling fortpmu_haunion
tpm: Support boot measurements
bootm: Support boot measurement
tpm: sandbox: Update for needed TPM2 capabilities
test: Add sandbox TPM boot measurement
doc: Add measured boot documentationarch/sandbox/dts/sandbox.dtsi | 14 + arch/sandbox/dts/test.dts | 13 + boot/Kconfig | 23 + boot/bootm.c | 70 +++ cmd/booti.c | 1 + cmd/bootm.c | 2 + cmd/bootz.c | 1 + configs/sandbox_defconfig | 1 + doc/usage/index.rst | 1 + doc/usage/measured_boot.rst | 23 + drivers/tpm/tpm2_tis_sandbox.c | 100 +++- include/bootm.h | 2 + include/efi_tcg2.h | 44 -- include/image.h | 1 + include/test/suites.h | 1 + include/tpm-v2.h | 246 +++++++- lib/efi_loader/efi_tcg2.c | 1010 +++----------------------------- lib/tpm-v2.c | 771 ++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 21 files changed, 1383 insertions(+), 1010 deletions(-)create mode 100644
doc/usage/measured_boot.rst
create mode 100644test/boot/measurement.c--
2.31.1