efi_loader: add missing EFI_CALL around tcg2 read_blocks calls
PATCH 1/1 efi_loader: add missing EFI_CALL around tcg2 read_blocks calls
The read_blocks() function from the Block IO protocol is a UEFI function; make sure to call it from within U-Boot using the EFI_CALL() macro.
To demonstrate the issue on an AArch64 machine, define the DEBUG macro in include/efi_loader.h and build u-boot with sandbox_defconfig, then download and uncompress the ACS-DT image [1], and finally execute the following command:
$ ./u-boot -T -c " \
host bind 0 systemready-dt_acs_live_image.wic; \
setenv loadaddr 0x10000; \
load host 0 \${loadaddr} EFI/BOOT/Shell.efi; \
bootefi \${loadaddr} \${fdtcontroladdr}"The following assertion should fail:
lib/efi_loader/efi_net.c:858: efi_network_timer_notify: Assertion `__efi_entry_check()' failed.
This happens due to the following EFIAPI functions call chain:
efi_start_image()
efi_disk_read_blocks()
(due to the missing EFI_CALL, entry_count == 2)
efi_network_timer_notify()--- lib/efi_loader/efi_tcg2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
lib/efi_loader/efi_tcg2.c +8 -5
@@ -1213,8 +1213,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id,1 , - block_io->media->block_size, gpt_h); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id,1 , + block_io->media->block_size, + gpt_h));if (ret !=EFI_SUCCESS ) goto out2;
@@ -1227,9 +1229,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id, - gpt_h->partition_entry_lba, - total_gpt_entry_size, entry); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id, + gpt_h->partition_entry_lba, + total_gpt_entry_size, entry));if (ret !=EFI_SUCCESS ) goto out2;
Signature · 1 line
2.51.0
Hi Vincent,
Quoted 62 lines
Subject: [PATCH]
efi_loader: add missingEFI_CALLaround tcg2read_blockscallsThe
read_blocks()function from the Block IO protocol is a UEFI function; make sure to call it from within U-Boot using theEFI_CALL()macro.To demonstrate the issue on an AArch64 machine, define the DEBUG macro in
include/efi_loader.hand build u-boot withsandbox_defconfig, then download and uncompress the ACS-DT image [1], and finally execute the following command:$ ./u-boot -T -c " \ host bind 0 systemready-dt_acs_live_image.wic; \ setenv loadaddr 0x10000; \ load host 0 \${loadaddr} EFI/BOOT/Shell.efi; \ bootefi \${loadaddr} \${fdtcontroladdr}"The following assertion should fail:
lib/efi_loader/efi_net.c:858:efi_network_timer_notify: Assertion
`__efi_entry_check()' failed.This happens due to the following EFIAPI functions call chain:
efi_start_image()efi_disk_read_blocks() (due to the missing EFI_CALL, entry_count == 2) efi_network_timer_notify()Link:
https://github.com/ARM-software/arm-systemready/releases/download/v25
.12_DT_3.1.1/systemready-dt_acs_live_image.wic.xz [1]Fixes ce3dbc5d080d ("efi_loader: add UEFI GPT measurement")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Tom Rini <[email protected]>Cc Masahisa Kojima <[email protected]>--- lib/efi_loader/efi_tcg2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)lib/efi_loader/efi_tcg2.c +4
-2@@ -1213,8 +1213,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id,1 , - block_io->media->block_size, gpt_h); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id,1 , + block_io->media->block_size, + gpt_h));if (ret !=EFI_SUCCESS )lib/efi_loader/efi_tcg2.c +0
-0goto out2;
lib/efi_loader/efi_tcg2.c tcg2_measure_gpt_data(struct udevice *dev, · line 1235
Quoted 10 lines
lib/efi_loader/efi_tcg2.c +4
-3@@ -1227,9 +1229,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id, - gpt_h->partition_entry_lba, - total_gpt_entry_size, entry); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id, + gpt_h->partition_entry_lba, + total_gpt_entry_size, entry));
Thank you again for the fix.
Best regards,
Masahisa Kojima
Quoted 5 lines
lib/efi_loader/efi_tcg2.c +0
-1if (ret !=EFI_SUCCESS ) goto out2; --2.51.0
Merci Vincent
Quoted 26 lines · Vincent Stehlé
The
read_blocks()function from the Block IO protocol is a UEFI function; make sure to call it from within U-Boot using theEFI_CALL()macro.To demonstrate the issue on an AArch64 machine, define the DEBUG macro in
include/efi_loader.hand build u-boot withsandbox_defconfig, then download and uncompress the ACS-DT image [1], and finally execute the following command:$ ./u-boot -T -c " \ host bind 0 systemready-dt_acs_live_image.wic; \ setenv loadaddr 0x10000; \ load host 0 \${loadaddr} EFI/BOOT/Shell.efi; \ bootefi \${loadaddr} \${fdtcontroladdr}"The following assertion should fail:
lib/efi_loader/efi_net.c:858:efi_network_timer_notify: Assertion `__efi_entry_check()' failed.This happens due to the following EFIAPI functions call chain:
efi_start_image()efi_disk_read_blocks() (due to the missing EFI_CALL, entry_count == 2) efi_network_timer_notify()
Quoted 8 lines
Fixes ce3dbc5d080d ("efi_loader: add UEFI GPT measurement")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Tom Rini <[email protected]>Cc Masahisa Kojima <[email protected]>---
Quoted 37 lines
lib/efi_loader/efi_tcg2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)lib/efi_loader/efi_tcg2.c +8
-6@@ -1213,8 +1213,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id,1 , - block_io->media->block_size, gpt_h); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id,1 , + block_io->media->block_size, + gpt_h));if (ret !=EFI_SUCCESS ) goto out2;@@ -1227,9 +1229,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id, - gpt_h->partition_entry_lba, - total_gpt_entry_size, entry); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id, + gpt_h->partition_entry_lba, + total_gpt_entry_size, entry));if (ret !=EFI_SUCCESS ) goto out2; --2.51.0
Quoted 25 lines · Vincent Stehlé
The
read_blocks()function from the Block IO protocol is a UEFI function; make sure to call it from within U-Boot using theEFI_CALL()macro.To demonstrate the issue on an AArch64 machine, define the DEBUG macro in
include/efi_loader.hand build u-boot withsandbox_defconfig, then download and uncompress the ACS-DT image [1], and finally execute the following command:$ ./u-boot -T -c " \ host bind 0 systemready-dt_acs_live_image.wic; \ setenv loadaddr 0x10000; \ load host 0 \${loadaddr} EFI/BOOT/Shell.efi; \ bootefi \${loadaddr} \${fdtcontroladdr}"The following assertion should fail:
lib/efi_loader/efi_net.c:858:efi_network_timer_notify: Assertion `__efi_entry_check()' failed.This happens due to the following EFIAPI functions call chain:
efi_start_image() efi_disk_read_blocks() (due to the missing EFI_CALL, entry_count == 2) efi_network_timer_notify()
Quoted 7 lines
Fixes ce3dbc5d080d ("efi_loader: add UEFI GPT measurement")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Tom Rini <[email protected]>Cc Masahisa Kojima <[email protected]>
Quoted 35 lines
--- lib/efi_loader/efi_tcg2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)lib/efi_loader/efi_tcg2.c +8
-5@@ -1213,8 +1213,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id,1 , - block_io->media->block_size, gpt_h); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id,1 , + block_io->media->block_size, + gpt_h));if (ret !=EFI_SUCCESS ) goto out2;@@ -1227,9 +1229,10 @@ tcg2_measure_gpt_data(struct udevice *dev, goto out2; } - ret = block_io->read_blocks (block_io, block_io->media->media_id, - gpt_h->partition_entry_lba, - total_gpt_entry_size, entry); + ret =EFI_CALL (block_io->read_blocks (block_io, + block_io->media->media_id, + gpt_h->partition_entry_lba, + total_gpt_entry_size, entry));if (ret !=EFI_SUCCESS ) goto out2;