From: Lennart Poettering Date: Tue, 21 Sep 2021 13:39:47 +0000 (+0200) Subject: boot: move TPM conditionalization into measure.h header X-Git-Tag: v250-rc1~629^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61b6249552ed7d0ce858f2a413aaf7f65b301769;p=thirdparty%2Fsystemd.git boot: move TPM conditionalization into measure.h header Let's move conditionalization of tpm_log_load_options() into the measure.h to encapsulate the ifdeffery a bit more. --- diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 386ee678ea6..9efd157a8ee 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -2314,10 +2314,8 @@ static EFI_STATUS image_start( loaded_image->LoadOptions = options; loaded_image->LoadOptionsSize = StrSize(loaded_image->LoadOptions); -#if ENABLE_TPM /* Try to log any options to the TPM, especially to catch manually edited options */ (VOID) tpm_log_load_options(options); -#endif } efivar_set_time_usec(LOADER_GUID, L"LoaderTimeExecUSec", 0); diff --git a/src/boot/efi/measure.h b/src/boot/efi/measure.h index 69eb682a2ec..b92d0574c9d 100644 --- a/src/boot/efi/measure.h +++ b/src/boot/efi/measure.h @@ -3,6 +3,18 @@ #include -EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description); +#if ENABLE_TPM +EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description); EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline); + +#else + +static inline EFI_STATUS tpm_log_event(UINT32 pcrindex, const EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) { + return EFI_SUCCESS; +} +static inline EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline) { + return EFI_SUCCESS; +} + +#endif diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 3bbb25321e3..ad01ab138b6 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -193,13 +193,11 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { line[i] = options[i]; cmdline = line; -#if ENABLE_TPM /* Let's measure the passed kernel command line into the TPM. Note that this possibly * duplicates what we already did in the boot menu, if that was already used. However, since * we want the boot menu to support an EFI binary, and want to this stub to be usable from * any boot menu, let's measure things anyway. */ (VOID) tpm_log_load_options(loaded_image->LoadOptions); -#endif } export_variables(loaded_image);