tpm: Support boot measurements
v2 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.
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 (5):
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
arch/sandbox/dts/test.dts | 12 + boot/Kconfig | 23 ++ boot/bootm.c | 64 +++ cmd/bootm.c | 2 + configs/sandbox_defconfig | 1 + 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 | 215 +++++++++- lib/efi_loader/efi_tcg2.c | 362 +---------------- lib/tpm-v2.c | 708 +++++++++++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 16 files changed, 1187 insertions(+), 417 deletions(-) create mode 100644 test/boot/measurement.c
Signature · 1 line
2.31.1
PATCH v2 1/5 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 v2 2/5 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.
--- include/efi_tcg2.h | 44 --- include/tpm-v2.h | 211 ++++++++++++ lib/efi_loader/efi_tcg2.c | 362 +------------------ lib/tpm-v2.c | 708 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 938 insertions(+), 387 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 +211 -0
235 lines not on this page · raw message
lib/efi_loader/efi_tcg2.c +19 -343
506 lines not on this page · raw message
lib/tpm-v2.c +708 -0
727 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v2 3/5 bootm: Support boot measurement
In reply to Eddie JamesAdd a configuration option to measure the boot through the bootm function.
--- boot/Kconfig | 23 ++++++++++++++++++ boot/bootm.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ cmd/bootm.c | 2 ++ include/bootm.h | 2 ++ include/image.h | 1 + 5 files changed, 92 insertions(+)
boot/Kconfig +23 -0
@@ -587,6 +587,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 +64 -0
82 lines not on this page · raw message
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 );
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 v2 4/5 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
Re: [PATCH v2 4/5] tpm: sandbox: Update for needed TPM2 capabilities
Quoted 9 lines · Eddie James
The driver needs to support getting the PCRs in the capabilities command. Fix various other things and support the max number of PCRs for TPM2.
Signed-off-by Eddie James <[email protected]>--- drivers/tpm/tpm2_tis_sandbox.c | 100 ++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 28 deletions(-)
PATCH v2 5/5 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.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0
--- arch/sandbox/dts/test.dts | 12 +++++++ configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++ 6 files changed, 83 insertions(+) create mode 100644 test/boot/measurement.c
arch/sandbox/dts/test.dts +12 -0
@@ -66,6 +66,17 @@ osd0 = "/osd"; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>; + }; + }; + binman: binman { };
@@ -1332,6 +1343,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; uart0: serial {
configs/sandbox_defconfig +1 -0
@@ -335,3 +335,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
@@ -43,6 +43,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 ifdef CONFIG_OF_LIVE obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o
test/boot/measurement.c new file +66 -0
66 lines not on this page · raw message
test/cmd_ut.c +2 -0
@@ -100,6 +100,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
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 25 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>--- arch/sandbox/dts/test.dts | 12 +++++++ configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++ 6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd";
arch/sandbox/dts/test.dts line 76
Quoted 10 lines
arch/sandbox/dts/test.dts +8
-0}; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>;
This would limit the file loaded at $loadaddr = 0x0 to 13 MiB. Please, choose a much higher address. Or change $loadaddr, e.g. use loadaddr = kernel_addr_r = 0x1000000. I would prefer raising loadaddr.
Best regards
Heinrich
Quoted 132 lines
arch/sandbox/dts/test.dts +4
-0+ }; + }; + binman: binman { };@@ -1332,6 +1343,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; uart0: serial {configs/sandbox_defconfig +1
-0@@ -335,3 +335,4 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_MEASURED_BOOT=yinclude/test/suites.h +1
-0@@ -43,6 +43,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 ifdef CONFIG_OF_LIVE obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.otest/boot/measurement.c new file +66
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Test for measured boot functions +* +* Copyright 2023 IBM Corp. +* Written by Eddie James <[email protected]> +*/ + +#include <common.h> +#include <bootm.h> +#include <malloc.h> +#include <test/suites.h> +#include <test/test.h> +#include <test/ut.h> +#include <asm/io.h> + +#define MEASUREMENT_TEST (_name, _flags) \ + UNIT_TEST(_name, _flags, measurement_test) + +static int measure (struct unit_test_state *uts) +{ +struct bootm_headers images; +const size_t size =1024 ; +u8 *kernel; +u8 *initrd; +size_t i; + + kernel =malloc (size); + initrd =malloc (size); + + images.os.image_start =map_to_sysmem (kernel); + images.os.image_len = size; + + images.rd_start =map_to_sysmem (initrd); + images.rd_end = images.rd_start + size; + + images.ft_addr =malloc (size); + images.ft_len = size; + +env_set ("bootargs" ,"measurement testing" ); + +for (i =0 ; i < size; ++i) { + kernel[i] = (u8)(0xf0 | (i &0xf )); + initrd[i] = (u8)((i &0xf0 ) |0xf ); + ((u8 *)images.ft_addr)[i] = (u8)(i &0xff ); + } + +ut_assertok (bootm_measure (&images)); + +free (images.ft_addr); +free (initrd); +free (kernel); + +return 0 ; +} +MEASUREMENT_TEST (measure,0 ); + +int do_ut_measurement (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct unit_test *tests =UNIT_TEST_SUITE_START (measurement_test); +const int n_ents =UNIT_TEST_SUITE_COUNT (measurement_test); + +return cmd_ut_category ("measurement" ,"measurement_test_" , tests, + n_ents, argc, argv); +}test/cmd_ut.c +2
-0@@ -100,6 +100,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, "", ""),
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 28 lines · Heinrich Schuchardt
Quoted 27 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++ configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };
Quoted 8 lines
arch/sandbox/dts/test.dts line 76
Quoted 8 lines
arch/sandbox/dts/test.dts +8
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>;
How should this work if you don't define linux,sml-base and linux,sml-size?
Best regards
Heinrich
Quoted 152 lines
This would limit the file loaded at $loadaddr =
0x0to 13 MiB. Please, choose a much higher address. Or change $loadaddr, e.g. use loadaddr =kernel_addr_r=0x1000000. I would prefer raising loadaddr.Best regards
Heinrich
Quoted 142 lines
arch/sandbox/dts/test.dts +4
-0+ }; + }; + binman: binman { };@@ -1332,6 +1343,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; uart0: serial {configs/sandbox_defconfig +0
-0@@ -335,3 +335,4 @@ CONFIG_TEST_FDTDEC=y
CONFIG_UNIT_TEST=y
CONFIG_UT_TIME=y
CONFIG_UT_DM=yconfigs/sandbox_defconfig +1
-0+CONFIG_MEASURED_BOOT=yinclude/test/suites.h +0
-0@@ -43,6 +43,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[]);
intdo_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
intdo_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_measurement(structcmd_tbl*cmdtp, int flag, int argc, char
* const argv[]);
intdo_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
intdo_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(structcmd_tbl*cmdtp, int flag, int argc,test/boot/Makefile +0
-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.oifdef
CONFIG_OF_LIVEobj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.otest/boot/measurement.c new file +66
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Test for measured boot functions +* +* Copyright 2023 IBM Corp. +* Written by Eddie James <[email protected]> +*/ + +#include <common.h> +#include <bootm.h> +#include <malloc.h> +#include <test/suites.h> +#include <test/test.h> +#include <test/ut.h> +#include <asm/io.h> + +#define MEASUREMENT_TEST (_name, _flags) \ + UNIT_TEST(_name, _flags, measurement_test) + +static int measure (struct unit_test_state *uts) +{ + struct bootm_headers images; + const size_t size = 1024; + u8 *kernel; + u8 *initrd; + size_t i; + + kernel = malloc(size); + initrd = malloc(size); + + images.os.image_start = map_to_sysmem(kernel); + images.os.image_len = size; + + images.rd_start = map_to_sysmem(initrd); + images.rd_end = images.rd_start + size; + + images.ft_addr = malloc(size); + images.ft_len = size; + + env_set("bootargs", "measurement testing"); + + for (i = 0; i < size; ++i) { + kernel[i] = (u8)(0xf0 | (i & 0xf)); + initrd[i] = (u8)((i & 0xf0) | 0xf); + ((u8 *)images.ft_addr)[i] = (u8)(i & 0xff); + } + + ut_assertok(bootm_measure(&images)); + + free(images.ft_addr); + free(initrd); + free(kernel); + + return 0; +} +MEASUREMENT_TEST (measure,0 ); + +int do_ut_measurement (struct cmd_tbl *cmdtp,int flag,int argc, + char *const argv[]) +{ + struct unit_test *tests = UNIT_TEST_SUITE_START(measurement_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(measurement_test); + + return cmd_ut_category("measurement", "measurement_test_", tests, + n_ents, argc, argv); +}test/cmd_ut.c +2
-0@@ -100,6 +100,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, "", ""),
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 30 lines · Heinrich Schuchardt
Quoted 29 lines · Heinrich Schuchardt
Quoted 28 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++
configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66
+++++++++++++++++++++++++++++++++++++++
test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };
Quoted 10 lines
Quoted 8 lines
arch/sandbox/dts/test.dts line 76
Quoted 8 lines
arch/sandbox/dts/test.dts +8
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>;How should this work if you don't define linux,sml-base and linux,sml-size?
I have sent a patch to the linux list for using a reserved memory region, as I have also added in the u-boot TPM layer for the event log.
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/
Thanks,
Eddie
Quoted 159 lines
Best regards
Heinrich
Quoted 152 lines
This would limit the file loaded at $loadaddr =
0x0to 13 MiB. Please, choose a much higher address. Or change $loadaddr, e.g. use loadaddr =kernel_addr_r=0x1000000. I would prefer raising loadaddr.Best regards
Heinrich
Quoted 142 lines
arch/sandbox/dts/test.dts +4
-0+ }; + }; + binman: binman { };@@ -1332,6 +1343,7 @@ tpm2 { compatible = "sandbox,tpm2"; + memory-region = <&event_log>; }; uart0: serial {configs/sandbox_defconfig +0
-0@@ -335,3 +335,4 @@ CONFIG_TEST_FDTDEC=y
CONFIG_UNIT_TEST=y
CONFIG_UT_TIME=y
CONFIG_UT_DM=yconfigs/sandbox_defconfig +1
-0+CONFIG_MEASURED_BOOT=yinclude/test/suites.h +0
-0@@ -43,6 +43,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[]);
intdo_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
intdo_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_measurement(structcmd_tbl*cmdtp, int flag, int argc, char
* const argv[]);
intdo_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
intdo_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(structcmd_tbl*cmdtp, int flag, int argc,test/boot/Makefile +0
-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.oifdef
CONFIG_OF_LIVEobj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.otest/boot/measurement.c new file +66
-0@@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Test for measured boot functions +* +* Copyright 2023 IBM Corp. +* Written by Eddie James <[email protected]> +*/ + +#include <common.h> +#include <bootm.h> +#include <malloc.h> +#include <test/suites.h> +#include <test/test.h> +#include <test/ut.h> +#include <asm/io.h> + +#define MEASUREMENT_TEST (_name, _flags) \ + UNIT_TEST(_name, _flags, measurement_test) + +static int measure (struct unit_test_state *uts) +{ + struct bootm_headers images; + const size_t size = 1024; + u8 *kernel; + u8 *initrd; + size_t i; + + kernel = malloc(size); + initrd = malloc(size); + + images.os.image_start = map_to_sysmem(kernel); + images.os.image_len = size; + + images.rd_start = map_to_sysmem(initrd); + images.rd_end = images.rd_start + size; + + images.ft_addr = malloc(size); + images.ft_len = size; + + env_set("bootargs", "measurement testing"); + + for (i = 0; i < size; ++i) { + kernel[i] = (u8)(0xf0 | (i & 0xf)); + initrd[i] = (u8)((i & 0xf0) | 0xf); + ((u8 *)images.ft_addr)[i] = (u8)(i & 0xff); + } + + ut_assertok(bootm_measure(&images)); + + free(images.ft_addr); + free(initrd); + free(kernel); + + return 0; +} +MEASUREMENT_TEST (measure,0 ); + +int do_ut_measurement (struct cmd_tbl *cmdtp,int flag,int argc, + char *const argv[]) +{ + struct unit_test *tests = UNIT_TEST_SUITE_START(measurement_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(measurement_test); + + return cmd_ut_category("measurement", "measurement_test_", tests, + n_ents, argc, argv); +}test/cmd_ut.c +2
-0@@ -100,6 +100,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, "", ""),
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 45 lines · Eddie James
Quoted 30 lines · Heinrich Schuchardt
Quoted 29 lines · Heinrich Schuchardt
Quoted 28 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++
configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66
+++++++++++++++++++++++++++++++++++++++
test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };Quoted 11 lines
Quoted 8 lines
arch/sandbox/dts/test.dts line 76
Quoted 8 lines
arch/sandbox/dts/test.dts +8
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>;How should this work if you don't define linux,sml-base and linux,sml-size?
Quoted 4 lines
I have sent a patch to the linux list for using a reserved memory region, as I have also added in the u-boot TPM layer for the event log.
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/
Thank you for the clarification.
The kernel patch seems to need rework:
https://lore.kernel.org/all/[email protected]/
Shouldn't the sandbox device-tree support these properties? This will allow us to write a test application that the sandbox can run via booti/bootz (depending on bitness) and bootm. This test application can retrieve the event log and print it via Linux system calls.
Best regards
Heinrich
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 49 lines · Heinrich Schuchardt
Quoted 48 lines · Eddie James
Quoted 30 lines · Heinrich Schuchardt
Quoted 29 lines · Heinrich Schuchardt
Quoted 28 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++
configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66
+++++++++++++++++++++++++++++++++++++++
test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };Quoted 11 lines
Quoted 8 lines
arch/sandbox/dts/test.dts line 76
Quoted 8 lines
arch/sandbox/dts/test.dts +8
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map; + reg = <0x00d0e000 0x2000>;How should this work if you don't define linux,sml-base and linux,sml-size?
I have sent a patch to the linux list for using a reserved memory region, as I have also added in the u-boot TPM layer for the event log.
Quoted 7 lines
Thank you for the clarification.
The kernel patch seems to need rework:
https://lore.kernel.org/all/[email protected]/
Yes I'll address that.
Quoted 5 lines
Shouldn't the sandbox device-tree support these properties? This will allow us to write a test application that the sandbox can run via booti/bootz (depending on bitness) and bootm. This test application can retrieve the event log and print it via Linux system calls.
OK, I can add it to the main sandbox device-tree as well then. It is added to the sandbox test device-tree, used by the unit test case I added.
Thanks,
Eddie
Quoted 4 lines
Best regards
Heinrich
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
In reply to Eddie JamesQuoted 24 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>--- arch/sandbox/dts/test.dts | 12 +++++++ configs/sandbox_defconfig | 1 + include/test/suites.h | 1 + test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++ 6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0
arch/sandbox/dts/test.dts line 75
Quoted 10 lines
arch/sandbox/dts/test.dts +7
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; }; + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map;
Isn't no-map misplaced? Shouldn't it be a reserved-memory property?
If the memory region is not mapped, Linux can never access it as described in Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml.
Please, document all changes to the device-tree semantics via patches for the Linux kernels documentation and provide a full example.
Best regards
Heinrich
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 28 lines · Heinrich Schuchardt
Quoted 27 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++ configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };
Quoted 9 lines
arch/sandbox/dts/test.dts line 75
Quoted 7 lines
arch/sandbox/dts/test.dts +7
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map;Isn't no-map misplaced? Shouldn't it be a reserved-memory property?
The placement is correct. But I still wonder why we should have this area as no-map.
Quoted 11 lines
If the memory region is not mapped, Linux can never access it as described in
Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml.Please, document all changes to the device-tree semantics via patches for the Linux kernels documentation and provide a full example.
Best regards
Heinrich
Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement
Quoted 40 lines · Heinrich Schuchardt
Quoted 29 lines · Heinrich Schuchardt
Quoted 28 lines · Eddie James
Use the sandbox TPM driver to measure some boot images in a unit test case.
$ ./u-boot -T -c "ut measurement" Running 1 measurement tests Test: measure: measurement.c Failures: 0Signed-off-by Eddie James <[email protected]>---
arch/sandbox/dts/test.dts| 12 +++++++
configs/sandbox_defconfig | 1 +
include/test/suites.h | 1 +
test/boot/Makefile | 1 +
test/boot/measurement.c | 66
+++++++++++++++++++++++++++++++++++++++
test/cmd_ut.c | 2 ++6 files changed, 83 insertions(+)create mode 100644
test/boot/measurement.carch/sandbox/dts/test.dts +0
-0@@ -66,6 +66,17 @@ osd0 = "/osd"; };Quoted 9 lines
arch/sandbox/dts/test.dts line 75
Quoted 7 lines
arch/sandbox/dts/test.dts +7
-0+ reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + event_log: tcg_event_log@d0e000 { + no-map;Isn't no-map misplaced? Shouldn't it be a reserved-memory property?
Quoted 7 lines
The placement is correct. But I still wonder why we should have this area as no-map.
Quoted 4 lines
If the memory region is not mapped, Linux can never access it as described in
Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml.
I read the documentation as meaning that Linux won't map it as part of it's standard mappings. It's still available for a device driver (TPM driver in this case). I believe no-map is appropriate here since we don't want anything except the TPM driver to access that memory.
Thanks,
Eddie
Quoted 8 lines
Quoted 7 lines
Please, document all changes to the device-tree semantics via patches for the Linux kernels documentation and provide a full example.
Best regards
Heinrich
Quoted 8 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.
Quoted 7 lines
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
This looks like a useful feature to me. Some questions remain:
How about the booti and bootz commands. Are they covered by the change?
What are the consequences of your changes for UEFI FIT images (cf. CONFIG_BOOTM_EFI)?
Quoted 7 lines
Eddie James (5):
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
I am missing the documentation changes. These should describe which changes in the device-tree and in the configuration are needed to enable measurements. This should be in doc/usage/
@Ilias:
Could you contribute the UEFI part for the document, please.
Best regards
Heinrich
Quoted 20 lines
arch/sandbox/dts/test.dts | 12 + boot/Kconfig | 23 ++ boot/bootm.c | 64 +++ cmd/bootm.c | 2 + configs/sandbox_defconfig | 1 + 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 | 215 +++++++++- lib/efi_loader/efi_tcg2.c | 362 +---------------- lib/tpm-v2.c | 708 +++++++++++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++ test/cmd_ut.c | 2 + 16 files changed, 1187 insertions(+), 417 deletions(-)create mode 100644
test/boot/measurement.c
Quoted 17 lines · Heinrich Schuchardt
Quoted 8 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.Quoted 7 lines
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
Quoted 3 lines
This looks like a useful feature to me. Some questions remain:
How about the booti and bootz commands. Are they covered by the change?
No, not yet.
Quoted 3 lines
What are the consequences of your changes for UEFI FIT images (cf.
CONFIG_BOOTM_EFI)?
I suppose the image would be measured twice, but only if the user selected both of the relevant config options.
Quoted 9 lines
Quoted 8 lines
Eddie James (5):
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
Quoted 3 lines
I am missing the documentation changes. These should describe which changes in the device-tree and in the configuration are needed to enable measurements. This should be in doc/usage/
Sure.
Thanks,
Eddie
Quoted 29 lines
@Ilias:
Could you contribute the UEFI part for the document, please.Best regards
Heinrich
Quoted 20 lines
arch/sandbox/dts/test.dts | 12 +
boot/Kconfig | 23 ++
boot/bootm.c | 64 +++
cmd/bootm.c | 2 + configs/sandbox_defconfig | 1 +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 | 215 +++++++++- lib/efi_loader/efi_tcg2.c | 362 +---------------- lib/tpm-v2.c | 708 +++++++++++++++++++++++++++++++++ test/boot/Makefile | 1 + test/boot/measurement.c | 66 +++
test/cmd_ut.c | 2 +16 files changed, 1187 insertions(+), 417 deletions(-)create mode 100644
test/boot/measurement.c
Quoted 19 lines · Eddie James
Quoted 17 lines · Heinrich Schuchardt
Quoted 15 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.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
Quoted 6 lines
Quoted 3 lines
This looks like a useful feature to me. Some questions remain:
How about the booti and bootz commands. Are they covered by the change?
No, not yet.
Please, add the measurements in common code for all boot commands (except bootefi).
Quoted 9 lines
Quoted 5 lines
What are the consequences of your changes for UEFI FIT images (cf.
CONFIG_BOOTM_EFI)?I suppose the image would be measured twice, but only if the user selected both of the relevant config options.
We should have a test case for this.
Best regards
Heinrich