efi: Add a test for EFI bootmeth
Subsystems (3)
v6 cover efi: Add a test for EFI bootmeth
The test coverage for the EFI bootmeth is incomplete since it does not actually boot the application.
This series creates a simple test for this purpose. It includes a few patches to make this work:
- ANSI output from the EFI loader confusing the unit-testing checker
- Hang in sandbox virtio due to EFI probing all block devices
Other necessary fixes have been split out into two other series.
Changes in v6:
- Expand the debug messages to be more descriptive
- Drop the patch to disable sandbox virtio blk with EFI
- Add new patch to disable the sandbox virtio blk device
- Deal with sandbox CONFIG_LOGF_FUNC
- Rebase on -next
- Drop patches previously applied
- Drop mention of helloworld since it is no-longer used by this test
Changes in v5:
- Drop the Fixes tag
Changes in v4:
- Add efi_loader tag to some patches
- Split out non-EFI patches into a different series
Changes in v3:
- Drop the extra- rules since scripts/Makefile.lib takes care of it
- Add new patch to drop crt0/relocal extra- rules
- Put back the Linaro copyright accidentally removed
Changes in v2:
- Reword commit message
- Use 'Firmware vendor' instead of just 'Vendor'
- Add many new patches to resolve all the outstanding test issues
Simon Glass (12):
efi_loader: Rename and move CMD_BOOTEFI_HELLO_COMPILE
efi: arm: x86: riscv: Drop crt0/relocal extra- rules
efi_loader: Shorten the app rules
efi_loader: Shorten the app rules further
efi_loader: Show the vendor in helloworld
efi: Use the same filename for all sandbox builds
bootstd: Add debugging for efi bootmeth
efi_loader: Disable ANSI output for tests
efi_loader: Add a test app
sandbox: virtio: Disable the sandbox virtio blk device
test: efi: boot: Set up an image suitable for EFI testing
test: efi: boot: Add a test for the efi bootmeth
arch/Kconfig | 3 +- arch/arm/lib/Makefile | 8 ---- arch/riscv/lib/Makefile | 4 -- arch/sandbox/dts/test.dts | 2 +- arch/x86/lib/Makefile | 16 ------- boot/bootmeth_efi.c | 11 ++++- cmd/Kconfig | 14 +----- configs/octeontx2_95xx_defconfig | 2 +- configs/octeontx2_96xx_defconfig | 2 +- configs/octeontx_81xx_defconfig | 2 +- configs/octeontx_83xx_defconfig | 2 +- doc/develop/uefi/uefi.rst | 2 +- include/efi_default_filename.h | 24 +--------- include/efi_loader.h | 21 ++++++++- lib/efi_loader/Kconfig | 22 +++++++++ lib/efi_loader/Makefile | 47 ++++++------------- lib/efi_loader/efi_console.c | 26 +++++++---- lib/efi_loader/helloworld.c | 3 ++ lib/efi_loader/testapp.c | 68 ++++++++++++++++++++++++++++ test/boot/bootdev.c | 18 +++++++- test/boot/bootflow.c | 65 +++++++++++++++++++++++++- test/py/tests/bootstd/flash1.img.xz | Bin 0 -> 5016 bytes test/py/tests/test_efi_fit.py | 2 +- test/py/tests/test_efi_loader.py | 2 +- test/py/tests/test_ut.py | 52 ++++++++++++++++++--- 25 files changed, 294 insertions(+), 124 deletions(-) create mode 100644 lib/efi_loader/testapp.c create mode 100644 test/py/tests/bootstd/flash1.img.xz
Signature · 1 line
2.43.0
PATCH v6 1/12 efi_loader: Rename and move CMD_BOOTEFI_HELLO_COMPILE
This is not actually a command so the name is confusing. Use BOOTEFI_HELLO_COMPILE instead. Put it in the efi_loader directory with the other such config options.
The link rule (for $(obj)/%_efi.so) in scripts/Makefile.lib handles pulling in efi_crt0.o and efi_reloc.o so drop the 'extra' rules.
---
(no changes since v3)
Changes in v3:
- Drop the extra- rules since scripts/Makefile.lib takes care of it
arch/arm/lib/Makefile | 1 - arch/riscv/lib/Makefile | 1 - arch/x86/lib/Makefile | 2 +- cmd/Kconfig | 14 +------------- configs/octeontx2_95xx_defconfig | 2 +- configs/octeontx2_96xx_defconfig | 2 +- configs/octeontx_81xx_defconfig | 2 +- configs/octeontx_83xx_defconfig | 2 +- doc/develop/uefi/uefi.rst | 2 +- lib/efi_loader/Kconfig | 12 ++++++++++++ lib/efi_loader/Makefile | 2 +- test/py/tests/test_efi_fit.py | 2 +- test/py/tests/test_efi_loader.py | 2 +- 13 files changed, 22 insertions(+), 24 deletions(-)
arch/arm/lib/Makefile +0 -1
@@ -130,7 +130,6 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) -extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC) # TODO: As of v2019.01 the relocation code for the EFI application cannot # be built on ARMv7-M. ifndef CONFIG_CPU_V7M
arch/riscv/lib/Makefile +0 -1
@@ -36,7 +36,6 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) -extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC) extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)
arch/x86/lib/Makefile +1 -1
@@ -97,7 +97,7 @@ endif else ifndef CONFIG_SPL_BUILD -ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) +ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),) extra-y += $(EFI_CRT0) $(EFI_RELOC) endif endif
cmd/Kconfig +1 -13
@@ -438,21 +438,9 @@ config CMD_BOOTEFI_BOOTMGR This subcommand will allow you to select the UEFI binary to be booted via UEFI variables Boot####, BootOrder, and BootNext. -config CMD_BOOTEFI_HELLO_COMPILE - bool "Compile a standard EFI hello world binary for testing" - default y - help - This compiles a standard EFI hello world application with U-Boot so - that it can be used with the test/py testing framework. This is useful - for testing that EFI is working at a basic level, and for bringing - up EFI support on a new architecture. - - No additional space will be required in the resulting U-Boot binary - when this option is enabled. - config CMD_BOOTEFI_HELLO bool "Allow booting a standard EFI hello world for testing" - depends on CMD_BOOTEFI_BINARY && CMD_BOOTEFI_HELLO_COMPILE + depends on CMD_BOOTEFI_BINARY && BOOTEFI_HELLO_COMPILE default y if CMD_BOOTEFI_SELFTEST help This adds a standard EFI hello world application to U-Boot so that
configs/octeontx2_95xx_defconfig +1 -1
@@ -38,7 +38,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y
configs/octeontx2_96xx_defconfig +1 -1
@@ -38,7 +38,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y
configs/octeontx_81xx_defconfig +1 -1
@@ -39,7 +39,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y
configs/octeontx_83xx_defconfig +1 -1
@@ -37,7 +37,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y
doc/develop/uefi/uefi.rst +1 -1
@@ -720,7 +720,7 @@ Executing the built in hello world application A hello world UEFI application can be built with:: - CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y + CONFIG_BOOTEFI_HELLO_COMPILE=y It can be embedded into the U-Boot binary with::
lib/efi_loader/Kconfig +12 -0
@@ -552,6 +552,18 @@ config EFI_HTTP_BOOT directly boot from network. endmenu +config BOOTEFI_HELLO_COMPILE + bool "Compile a standard EFI hello world binary for testing" + default y + help + This compiles a standard EFI hello world application with U-Boot so + that it can be used with the test/py testing framework. This is useful + for testing that EFI is working at a basic level, and for bringing + up EFI support on a new architecture. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig"
lib/efi_loader/Makefile +1 -1
@@ -27,7 +27,7 @@ always += boothart.efi targets += boothart.o endif -ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) +ifneq ($(CONFIG_BOOTEFI_HELLO_COMPILE),) always += helloworld.efi targets += helloworld.o endif
test/py/tests/test_efi_fit.py +1 -1
@@ -119,7 +119,7 @@ FDT_DATA = ''' ''' @pytest.mark.buildconfigspec('bootm_efi') [email protected]('cmd_bootefi_hello_compile') [email protected]('BOOTEFI_HELLO_COMPILE') @pytest.mark.buildconfigspec('fit') @pytest.mark.notbuildconfigspec('generate_acpi_table') @pytest.mark.requiredtool('dtc')
test/py/tests/test_efi_loader.py +1 -1
@@ -170,7 +170,7 @@ def do_test_efi_helloworld_net(u_boot_console, proto): assert expected_text not in output @pytest.mark.buildconfigspec('of_control') [email protected]('cmd_bootefi_hello_compile') [email protected]('bootefi_hello_compile') @pytest.mark.buildconfigspec('cmd_tftpboot') def test_efi_helloworld_net_tftp(u_boot_console): """Run the helloworld.efi binary via TFTP.
Signature · 1 line
2.43.0
PATCH v6 2/12 efi: arm: x86: riscv: Drop crt0/relocal extra- rules
In reply to Simon GlassThe link rule (for $(obj)/%_efi.so) in scripts/Makefile.lib handles pulling in efi_crt0.o and efi_reloc.o so drop the 'extra' rules.
---
(no changes since v3)
Changes in v3:
- Add new patch to drop crt0/relocal extra- rules
arch/arm/lib/Makefile | 7 ------- arch/riscv/lib/Makefile | 3 --- arch/x86/lib/Makefile | 16 ---------------- 3 files changed, 26 deletions(-)
arch/arm/lib/Makefile +0 -7
@@ -129,10 +129,3 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) - -# TODO: As of v2019.01 the relocation code for the EFI application cannot -# be built on ARMv7-M. -ifndef CONFIG_CPU_V7M -#extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) -endif -extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)
arch/riscv/lib/Makefile +0 -3
@@ -36,9 +36,6 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) -extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) -extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) - obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o
arch/x86/lib/Makefile +0 -16
@@ -87,19 +87,3 @@ extra-$(CONFIG_EFI_STUB_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o extra-$(CONFIG_EFI_STUB_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o endif - -ifdef CONFIG_EFI_STUB - -ifeq ($(CONFIG_$(SPL_)X86_64),) -extra-y += $(EFI_CRT0) $(EFI_RELOC) -endif - -else - -ifndef CONFIG_SPL_BUILD -ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),) -extra-y += $(EFI_CRT0) $(EFI_RELOC) -endif -endif - -endif
Signature · 1 line
2.43.0
PATCH v6 3/12 efi_loader: Shorten the app rules
In reply to Simon GlassWe have quite a few apps now, so create a way to specify them as a list rather than repeating the same rules again and again.
---
(no changes since v1)
lib/efi_loader/Makefile | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
lib/efi_loader/Makefile +9 -22
@@ -22,29 +22,13 @@ CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI) CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) -ifdef CONFIG_RISCV -always += boothart.efi -targets += boothart.o -endif - -ifneq ($(CONFIG_BOOTEFI_HELLO_COMPILE),) -always += helloworld.efi -targets += helloworld.o -endif - -ifneq ($(CONFIG_GENERATE_SMBIOS_TABLE),) -always += smbiosdump.efi -targets += smbiosdump.o -endif - +# These are the apps that are built +apps-$(CONFIG_RISCV) += boothart +apps-$(CONFIG_BOOTEFI_HELLO_COMPILE) += helloworld +apps-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbiosdump +apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) -always += dtbdump.efi -targets += dtbdump.o -endif - -ifdef CONFIG_EFI_LOAD_FILE2_INITRD -always += initrddump.efi -targets += initrddump.o +apps-y += dtbdump endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
@@ -95,3 +79,6 @@ obj-$(CONFIG_EFI_ECPT) += efi_conformance.o EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE)) $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE) + +always += $(foreach f,$(apps-y),$(f).efi) +targets += $(foreach f,$(apps-y),$(f).o)
Signature · 1 line
2.43.0
PATCH v6 4/12 efi_loader: Shorten the app rules further
In reply to Simon GlassAdd a way to factor out the CFLAGS changes for each app, since they are all the same.
---
(no changes since v1)
lib/efi_loader/Makefile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
lib/efi_loader/Makefile +5 -10
@@ -11,16 +11,6 @@ asflags-y += -I. CFLAGS_efi_boottime.o += \ -DFW_VERSION="0x$(VERSION)" \ -DFW_PATCHLEVEL="0x$(PATCHLEVEL)" -CFLAGS_boothart.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_boothart.o := $(CFLAGS_NON_EFI) -CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) -CFLAGS_smbiosdump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_smbiosdump.o := $(CFLAGS_NON_EFI) -CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI) -CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) # These are the apps that are built apps-$(CONFIG_RISCV) += boothart
@@ -80,5 +70,10 @@ obj-$(CONFIG_EFI_ECPT) += efi_conformance.o EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE)) $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE) +# Set the C flags to add and remove for each app +$(foreach f,$(apps-y),\ + $(eval CFLAGS_$(f).o := $(CFLAGS_EFI) -Os -ffreestanding)\ + $(eval CFLAGS_REMOVE_$(f).o := $(CFLAGS_NON_EFI))) + always += $(foreach f,$(apps-y),$(f).efi) targets += $(foreach f,$(apps-y),$(f).o)
Signature · 1 line
2.43.0
PATCH v6 5/12 efi_loader: Show the vendor in helloworld
In reply to Simon GlassShow the vendor name so it is clear which firmware is being used, e.g. whether U-Boot is providing the boot services.
---
(no changes since v2)
Changes in v2:
- Reword commit message
- Use 'Firmware vendor' instead of just 'Vendor'
lib/efi_loader/helloworld.c | 3 +++ 1 file changed, 3 insertions(+)
lib/efi_loader/helloworld.c +3 -0
@@ -237,6 +237,9 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, (con_out,u"Missing device path for device handle\r\n" ); goto out; } + con_out->output_string (con_out,u"Firmware vendor: " ); + con_out->output_string (con_out, systab->fw_vendor); + con_out->output_string (con_out,u"\n" ); con_out->output_string (con_out,u"Boot device: " ); ret =print_device_path (device_path, device_path_to_text);if (ret !=EFI_SUCCESS )
Signature · 1 line
2.43.0
Re: [PATCH v6 05/12] efi_loader: Show the vendor in helloworld
Hi Simon
Quoted 5 lines · Simon Glass
Show the vendor name so it is clear which firmware is being used, e.g. whether U-Boot is providing the boot services.
Signed-off-by Simon Glass <[email protected]>
I already sent my r-b for this. [0]. I am not sure Heinrich remarks were covered
Quoted 26 lines
---
(no changes since v2)
Changes in v2:
- Reword commit message
- Use 'Firmware vendor' instead of just 'Vendor'lib/efi_loader/helloworld.c | 3 +++ 1 file changed, 3 insertions(+)lib/efi_loader/helloworld.c +3
-1@@ -237,6 +237,9 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, (con_out,u"Missing device path for device handle\r\n" ); goto out; } + con_out->output_string (con_out,u"Firmware vendor: " ); + con_out->output_string (con_out, systab->fw_vendor); + con_out->output_string (con_out,u"\n" ); con_out->output_string (con_out,u"Boot device: " ); ret =print_device_path (device_path, device_path_to_text);if (ret !=EFI_SUCCESS ) --
Quoted 2 lines
2.43.0
[0] https://lore.kernel.org/u-boot/CAC_iWj+DtHbghAqJWiwm8ZVCXf3mCOOm13YpLSQGGBPcpgnWiQ@mail.gmail.com/
Re: [PATCH v6 05/12] efi_loader: Show the vendor in helloworld
Hi Ilias,
Quoted 4 lines · Ilias Apalodimas
Hi Simon
Quoted 8 lines
Quoted 5 lines · Simon Glass
Show the vendor name so it is clear which firmware is being used, e.g. whether U-Boot is providing the boot services.
Signed-off-by Simon Glass <[email protected]>I already sent my r-b for this. [0]. I am not sure Heinrich remarks were covered
Heinrich basically didn't see the point of this patch, but then suggested printing out FirmwareRevision too. I did reply but didn't hear back.
So I suggest we just go with this and we can expand it later. Or just drop the patch.
Quoted 23 lines
Quoted 23 lines
---
(no changes since v2)
Changes in v2:
- Reword commit message
- Use 'Firmware vendor' instead of just 'Vendor'lib/efi_loader/helloworld.c | 3 +++ 1 file changed, 3 insertions(+)lib/efi_loader/helloworld.c +3
-0@@ -237,6 +237,9 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, (con_out,u"Missing device path for device handle\r\n" ); goto out; } + con_out->output_string (con_out,u"Firmware vendor: " ); + con_out->output_string (con_out, systab->fw_vendor); + con_out->output_string (con_out,u"\n" );
Quoted 8 lines
Quoted 6 lines
lib/efi_loader/helloworld.c +0
-1con_out->output_string (con_out,u"Boot device: " ); ret =print_device_path (device_path, device_path_to_text);if (ret !=EFI_SUCCESS ) --2.43.0
[0] https://lore.kernel.org/u-boot/CAC_iWj+DtHbghAqJWiwm8ZVCXf3mCOOm13YpLSQGGBPcpgnWiQ@mail.gmail.com/
Regards,
Simon
PATCH v6 6/12 efi: Use the same filename for all sandbox builds
In reply to Simon GlassSandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Drop the confusing use of host architecture and just let sandbox be sandbox.
---
(no changes since v5)
Changes in v5:
- Drop the Fixes tag
Changes in v3:
- Put back the Linaro copyright accidentally removed
include/efi_default_filename.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
include/efi_default_filename.h +2 -22
@@ -16,26 +16,8 @@#undef BOOTEFI_NAME#ifdef CONFIG_SANDBOX - -#if HOST_ARCH ==HOST_ARCH_X86_64 -#define BOOTEFI_NAME "BOOTX64.EFI" -#elif HOST_ARCH ==HOST_ARCH_X86 -#define BOOTEFI_NAME "BOOTIA32.EFI" -#elif HOST_ARCH ==HOST_ARCH_AARCH64 -#define BOOTEFI_NAME "BOOTAA64.EFI" -#elif HOST_ARCH ==HOST_ARCH_ARM -#define BOOTEFI_NAME "BOOTARM.EFI" -#elif HOST_ARCH ==HOST_ARCH_RISCV32 -#define BOOTEFI_NAME "BOOTRISCV32.EFI" -#elif HOST_ARCH ==HOST_ARCH_RISCV64 -#define BOOTEFI_NAME "BOOTRISCV64.EFI" -#else -#error Unsupported UEFI architecture -#endif - -#else - -#if defined(CONFIG_ARM64 ) +#define BOOTEFI_NAME "BOOTSBOX.EFI" +#elif defined(CONFIG_ARM64 )#define BOOTEFI_NAME "BOOTAA64.EFI"#elif defined(CONFIG_ARM )#define BOOTEFI_NAME "BOOTARM.EFI"
@@ -52,5 +34,3 @@#endif #endif - -#endif
Signature · 1 line
2.43.0
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Quoted 9 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.
bootsbx.efi does not exist in the UEFI specification.
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Best regards
Heinrich
Quoted 55 lines
Signed-off-by Simon Glass <[email protected]>Reviewed-by Ilias Apalodimas <[email protected]>---
(no changes since v5)
Changes in v5:
- Drop the Fixes tagChanges in v3:
- Put back the Linaro copyright accidentally removedinclude/efi_default_filename.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)include/efi_default_filename.h +2
-22@@ -16,26 +16,8 @@#undef BOOTEFI_NAME#ifdef CONFIG_SANDBOX - -#if HOST_ARCH ==HOST_ARCH_X86_64 -#define BOOTEFI_NAME "BOOTX64.EFI" -#elif HOST_ARCH ==HOST_ARCH_X86 -#define BOOTEFI_NAME "BOOTIA32.EFI" -#elif HOST_ARCH ==HOST_ARCH_AARCH64 -#define BOOTEFI_NAME "BOOTAA64.EFI" -#elif HOST_ARCH ==HOST_ARCH_ARM -#define BOOTEFI_NAME "BOOTARM.EFI" -#elif HOST_ARCH ==HOST_ARCH_RISCV32 -#define BOOTEFI_NAME "BOOTRISCV32.EFI" -#elif HOST_ARCH ==HOST_ARCH_RISCV64 -#define BOOTEFI_NAME "BOOTRISCV64.EFI" -#else -#error Unsupported UEFI architecture -#endif - -#else - -#if defined(CONFIG_ARM64 ) +#define BOOTEFI_NAME "BOOTSBOX.EFI" +#elif defined(CONFIG_ARM64 )#define BOOTEFI_NAME "BOOTAA64.EFI"#elif defined(CONFIG_ARM )#define BOOTEFI_NAME "BOOTARM.EFI"@@ -52,5 +34,3 @@#endif #endif - -#endif
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0d efi_loader: correctly identify binary name
Let me know if you would like a selection mechanism and I'll see what I can do.
Regards,
Simon
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Quoted 29 lines · Simon Glass
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
Quoted 7 lines
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0defi_loader: correctly identify binary nameLet me know if you would like a selection mechanism and I'll see what I can do.
I'm confused. It sounds like Heinrich is using sandbox to test on various hosts, how U-Boot behaves, without relying on "just test in QEMU". I don't see how this disconnects from your usual request on how to use sandbox for further testing. What is breaking for you, Simon, by us saying that the host instruction set determines what we load and run (and so, is portable whereas saying "sandbox" is not, between x86 hosts, arm64 hosts and riscv64 hosts).
Quoted 3 lines
Regards,
Simon
Signature · 1 line
Tom
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Hi Tom,
Quoted 39 lines · Tom Rini
Quoted 29 lines · Simon Glass
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
Quoted 7 lines
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0defi_loader: correctly identify binary nameLet me know if you would like a selection mechanism and I'll see what I can do.
Quoted 7 lines
I'm confused. It sounds like Heinrich is using sandbox to test on various hosts, how U-Boot behaves, without relying on "just test in QEMU". I don't see how this disconnects from your usual request on how to use sandbox for further testing. What is breaking for you, Simon, by us saying that the host instruction set determines what we load and run (and so, is portable whereas saying "sandbox" is not, between x86 hosts, arm64 hosts and riscv64 hosts).
This:
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
The idea of using sandbox to run native EFI apps is new to me, but it sounds great, if it will get us more tests in this area.
But sandbox is sandbox. It is not (x86, arm, riscv). It is a fake architecture that we use in U-Boot. I've offered to create a way to get the behaviour that Heinrich wants, so let's see what he says.
Regards,
Simon
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Am 18. Oktober 2024 05:05:08 MESZ schrieb Simon Glass <[email protected]>:
Quoted 50 lines
Hi Tom,
Quoted 39 lines · Tom Rini
Quoted 29 lines · Simon Glass
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
Quoted 7 lines
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0defi_loader: correctly identify binary nameLet me know if you would like a selection mechanism and I'll see what I can do.
Quoted 7 lines
I'm confused. It sounds like Heinrich is using sandbox to test on various hosts, how U-Boot behaves, without relying on "just test in QEMU". I don't see how this disconnects from your usual request on how to use sandbox for further testing. What is breaking for you, Simon, by us saying that the host instruction set determines what we load and run (and so, is portable whereas saying "sandbox" is not, between x86 hosts, arm64 hosts and riscv64 hosts).
Quoted 5 lines
This:
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
As I wrote before:
The UEFI specification prescribes the naming of the default boot binary. Deviating from the specification should be avoided.
Anyway you need different images per host architecture. Writing a single switch statement to derive the default EFI binary name from the OS architecture does not look like an undue burden.
The sandbox should remain able to start GRUB from a distro image for the host architecture.
The sandbox is not a fake architecture but can be considered a valid testbed for host native EFI binaries including GRUB, the kernel stub, the stubs of UKI images, and the EFI SCT.
Best regards
Heinrich
Quoted 10 lines
The idea of using sandbox to run native EFI apps is new to me, but it sounds great, if it will get us more tests in this area.
But sandbox is sandbox. It is not (x86, arm, riscv). It is a fake architecture that we use in U-Boot. I've offered to create a way to get the behaviour that Heinrich wants, so let's see what he says.
Regards,
Simon
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Hi Heinrich,
Quoted 56 lines · Heinrich Schuchardt
Am 18. Oktober 2024 05:05:08 MESZ schrieb Simon Glass <[email protected]>:
Quoted 52 lines
Hi Tom,
Quoted 39 lines · Tom Rini
Quoted 29 lines · Simon Glass
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
Quoted 7 lines
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0defi_loader: correctly identify binary nameLet me know if you would like a selection mechanism and I'll see what I can do.
Quoted 7 lines
I'm confused. It sounds like Heinrich is using sandbox to test on various hosts, how U-Boot behaves, without relying on "just test in QEMU". I don't see how this disconnects from your usual request on how to use sandbox for further testing. What is breaking for you, Simon, by us saying that the host instruction set determines what we load and run (and so, is portable whereas saying "sandbox" is not, between x86 hosts, arm64 hosts and riscv64 hosts).
This:
Quoted 7 lines
Quoted 3 lines
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
As I wrote before:
The UEFI specification prescribes the naming of the default boot binary. Deviating from the specification should be avoided.
As I said before, I'm happy to get this added to the spec, if it helps. It is a real use case.
Quoted 2 lines
Anyway you need different images per host architecture. Writing a single switch statement to derive the default EFI binary name from the OS architecture does not look like an undue burden.
Yes, it is easy, but it is taking sandbox in a strange direction. It becomes a hybrid of a host architecture and a U-Boot architecture, which is then going to lead to all sorts of strange conversations. At present it is pretty clear. So I want to head this off at the pass.
I did not get a chance to review the original patch, of which this is essentially a revert. It has actually bitten me in a few areas.
Quoted 4 lines
The sandbox should remain able to start GRUB from a distro image for the host architecture.
The sandbox is not a fake architecture but can be considered a valid testbed for host native EFI binaries including GRUB, the kernel stub, the stubs of UKI images, and the EFI SCT.
I have to say that I wrote sandbox and I know what it is for. It wasn't designed to run binaries built outside of U-Boot, or anything of the sort. That said, as I mentioned, I should be able to make something work here.
To help me come up with a solution, can you please send your workflow / commands for the testing you do? Also, what architectures do you do this with?
My approach to U-Boot is that code needs to land, one way or another, perhaps with some changes for the use case that is thrown up, or perhaps done another way. But please try to consider this approach to Open Source too.
Regards,
Simon
Quoted 13 lines
Best regards
Heinrich
Quoted 7 lines
The idea of using sandbox to run native EFI apps is new to me, but it sounds great, if it will get us more tests in this area.
But sandbox is sandbox. It is not (x86, arm, riscv). It is a fake architecture that we use in U-Boot. I've offered to create a way to get the behaviour that Heinrich wants, so let's see what he says.
Regards,
SImon
Re: [PATCH v6 06/12] efi: Use the same filename for all sandbox builds
Am 18. Oktober 2024 17:02:47 MESZ schrieb Simon Glass <[email protected]>:
Quoted 63 lines
Hi Heinrich,
Quoted 60 lines · Heinrich Schuchardt
Am 18. Oktober 2024 05:05:08 MESZ schrieb Simon Glass <[email protected]>:
Quoted 55 lines
Hi Tom,
Quoted 39 lines · Tom Rini
Quoted 29 lines · Simon Glass
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 7 lines · Simon Glass
Sandbox is not a real architecture, but within U-Boot it is real enough. We should not need to pretend it is x86 or ARM anywhere in the code.
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 8 lines
Quoted 2 lines
Drop the confusing use of host architecture and just let sandbox be sandbox.
As I already wrote in
https://lore.kernel.org/u-boot/[email protected]/
this patch should not be merged.bootsbx.efi does not exist in the UEFI specification.
If that is of concern I can get it added. Let me know.
Quoted 3 lines
Without this patch I can test that shim work and grub are correctly loaded from a distro image. This patch makes the sandbox misbehave.
Why don't you do that with QEMU?
Quoted 7 lines
If we want sandbox to do this, I could add a way for sandbox to select its architecture. But this patch is correct, sorry. It is basically a revert of your patch:
3a0654ecd0defi_loader: correctly identify binary nameLet me know if you would like a selection mechanism and I'll see what I can do.
Quoted 7 lines
I'm confused. It sounds like Heinrich is using sandbox to test on various hosts, how U-Boot behaves, without relying on "just test in QEMU". I don't see how this disconnects from your usual request on how to use sandbox for further testing. What is breaking for you, Simon, by us saying that the host instruction set determines what we load and run (and so, is portable whereas saying "sandbox" is not, between x86 hosts, arm64 hosts and riscv64 hosts).
This:
Also we want to be able to locate the sandbox app using a single filename, 'bootsbox.efi', to avoid needing tests to produce different files on each host architecture.
Quoted 6 lines
Quoted 3 lines
As I wrote before:
The UEFI specification prescribes the naming of the default boot binary. Deviating from the specification should be avoided.
As I said before, I'm happy to get this added to the spec, if it helps. It is a real use case.
Do you really think that the UEFI organization should care about your test preference? This is just absurd.
As tests should run on all devices including but not restricted to the sandbox we have to support different names for the default file anyway.
This patch has no virtue in this context.
Best regards
Heinrich
Quoted 51 lines
Quoted 3 lines
Anyway you need different images per host architecture. Writing a single switch statement to derive the default EFI binary name from the OS architecture does not look like an undue burden.
Yes, it is easy, but it is taking sandbox in a strange direction. It becomes a hybrid of a host architecture and a U-Boot architecture, which is then going to lead to all sorts of strange conversations. At present it is pretty clear. So I want to head this off at the pass.
I did not get a chance to review the original patch, of which this is essentially a revert. It has actually bitten me in a few areas.
Quoted 4 lines
The sandbox should remain able to start GRUB from a distro image for the host architecture.
The sandbox is not a fake architecture but can be considered a valid testbed for host native EFI binaries including GRUB, the kernel stub, the stubs of UKI images, and the EFI SCT.
I have to say that I wrote sandbox and I know what it is for. It wasn't designed to run binaries built outside of U-Boot, or anything of the sort. That said, as I mentioned, I should be able to make something work here.
To help me come up with a solution, can you please send your workflow / commands for the testing you do? Also, what architectures do you do this with?
My approach to U-Boot is that code needs to land, one way or another, perhaps with some changes for the use case that is thrown up, or perhaps done another way. But please try to consider this approach to Open Source too.
Regards,
SimonQuoted 13 lines
Best regards
Heinrich
Quoted 7 lines
The idea of using sandbox to run native EFI apps is new to me, but it sounds great, if it will get us more tests in this area.
But sandbox is sandbox. It is not (x86, arm, riscv). It is a fake architecture that we use in U-Boot. I've offered to create a way to get the behaviour that Heinrich wants, so let's see what he says.
Regards,
SImon
PATCH v6 7/12 bootstd: Add debugging for efi bootmeth
In reply to Simon GlassAdd a little debugging so we can see what is happening.
---
Changes in v6:
- Expand the debug messages to be more descriptive
boot/bootmeth_efi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
boot/bootmeth_efi.c +9 -2
@@ -162,8 +162,10 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,int ret, seq;/* We require a partition table */ -if (!bflow->part) +if (!bflow->part) { +log_debug ("no partitions\n" );return -ENOENT ; + }strcpy (fname,EFI_DIRNAME );strcat (fname,BOOTEFI_NAME );
@@ -171,8 +173,10 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,if (bflow->blk) desc =dev_get_uclass_plat (bflow->blk); ret =bootmeth_try_file (bflow, desc,NULL , fname); -if (ret) +if (ret) { +log_debug ("File '%s' not found\n" , fname);return log_msg_ret ("try" , ret); + }/* Since we can access the file, let's call it ready */ bflow->state =BOOTFLOWST_READY ;
@@ -307,6 +311,8 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) {int ret; +log_debug ("dev='%s', part=%d\n" , bflow->dev->name, bflow->part); +/* * bootmeth_efi doesn't allocate any buffer neither for blk nor net device * set flag to avoid freeing static buffer.
@@ -332,6 +338,7 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)ulong kernel, fdt;int ret; +log_debug ("distro EFI boot\n" ); kernel =env_get_hex ("kernel_addr_r" ,0 );if (!bootmeth_uses_network (bflow)) { ret =efiload_read_file (bflow, kernel);
Signature · 1 line
2.43.0
PATCH v6 8/12 efi_loader: Disable ANSI output for tests
In reply to Simon GlassWe don't want ANSI characters written in tests since it is a pain to check the output with ut_assert_nextline() et al.
Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
---
(no changes since v1)
include/efi_loader.h | 21 ++++++++++++++++++++- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-)
include/efi_loader.h +20 -1
@@ -531,8 +531,27 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index);efi_status_t efi_bootmgr_run (void *fdt);/* search the boot option index in BootOrder */ bool efi_search_bootorder (u16 *bootorder,efi_uintn_t num,u32 target,u32 *index); -/* Set up console modes */ + +/** +* efi_setup_console_size() - update the mode table. +* +* By default the only mode available is 80x25. If the console has at least 50 +* lines, enable mode 80x50. If we can query the console size and it is neither +* 80x25 nor 80x50, set it as an additional mode. +*/ void efi_setup_console_size (void ); + +/** +* efi_console_set_ansi() - Set whether ANSI characters should be emitted +* +* These characters mess up tests which use ut_assert_nextline(). Call this +* function to tell efi_loader not to emit these characters when starting up the +* terminal +* +* @allow_ansi: Allow emitting ANSI characters +*/ +void efi_console_set_ansi (bool allow_ansi); +/* Set up load options from environment variable */ efi_status_t efi_env_set_load_options (efi_handle_t handle,const char *env_var,u16 **load_options);
lib/efi_loader/efi_console.c +17 -9
@@ -30,6 +30,17 @@ struct cout_mode {__maybe_unused static struct efi_object uart_obj; +/* +* suppress emission of ANSI codes for use by unit tests. Leave it as 0 for the +* default behaviour +*/ +static bool no_ansi; + +void efi_console_set_ansi (bool allow_ansi) +{ + no_ansi = !allow_ansi; +} +static struct cout_mode efi_cout_modes[] = {/* EFI Mode 0 is 80x25 and always present */ {
@@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)return 0 ; } -/** -* efi_setup_console_size() - update the mode table. -* -* By default the only mode available is 80x25. If the console has at least 50 -* lines, enable mode 80x50. If we can query the console size and it is neither -* 80x25 nor 80x50, set it as an additional mode. -*/ void efi_setup_console_size (void ) {int rows =25 , cols =80 ;
@@ -362,8 +366,12 @@ void efi_setup_console_size(void)if (IS_ENABLED (CONFIG_VIDEO )) ret =query_vidconsole (&rows, &cols); -if (ret) - ret =query_console_serial (&rows, &cols); +if (ret) { +if (no_ansi) + ret =0 ; +else + ret =query_console_serial (&rows, &cols); + }if (ret)return ;
Signature · 1 line
2.43.0
Re: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests
Quoted 8 lines · Simon Glass
We don't want ANSI characters written in tests since it is a pain to check the output with
ut_assert_nextline()et al.Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
Signed-off-by Simon Glass <[email protected]>
Please, consider prior review before resubmitting patches.
As responded to all prior submissions:
We want to test the code running on actual machines. We don't want to have sandbox code everywhere.
I cannot see any test that is not passing due to the current behavior.
The size serial console is just requested once in the live-time of the U-Boot session.
You have bunches of options in your upcoming tests. Neither of these requires the suggested patch:
* You can set stdout=vidconsole,serial and let the vidconsole provide a screen size.
* You can add the ANSI sequence to your ut_assert_nextline() statement.
* You can filter out ANSI codes in the test framework.
* You can run an EFI command like 'printenv -e' before the command that you actually want to test.
Best regards
Heinrich
Quoted 92 lines
---
(no changes since v1)
include/efi_loader.h | 21 ++++++++++++++++++++- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-)include/efi_loader.h +20
-1@@ -531,8 +531,27 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index);efi_status_t efi_bootmgr_run (void *fdt);/* search the boot option index in BootOrder */ bool efi_search_bootorder (u16 *bootorder,efi_uintn_t num,u32 target,u32 *index); -/* Set up console modes */ + +/** +* efi_setup_console_size() - update the mode table. +* +* By default the only mode available is 80x25. If the console has at least 50 +* lines, enable mode 80x50. If we can query the console size and it is neither +* 80x25 nor 80x50, set it as an additional mode. +*/ void efi_setup_console_size (void ); + +/** +* efi_console_set_ansi() - Set whether ANSI characters should be emitted +* +* These characters mess up tests which use ut_assert_nextline(). Call this +* function to tell efi_loader not to emit these characters when starting up the +* terminal +* +* @allow_ansi: Allow emitting ANSI characters +*/ +void efi_console_set_ansi (bool allow_ansi); +/* Set up load options from environment variable */ efi_status_t efi_env_set_load_options (efi_handle_t handle,const char *env_var,u16 **load_options);lib/efi_loader/efi_console.c +17
-9@@ -30,6 +30,17 @@ struct cout_mode {__maybe_unused static struct efi_object uart_obj; +/* +* suppress emission of ANSI codes for use by unit tests. Leave it as 0 for the +* default behaviour +*/ +static bool no_ansi; + +void efi_console_set_ansi (bool allow_ansi) +{ + no_ansi = !allow_ansi; +} +static struct cout_mode efi_cout_modes[] = {/* EFI Mode 0 is 80x25 and always present */ {@@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)return 0 ; } -/** -* efi_setup_console_size() - update the mode table. -* -* By default the only mode available is 80x25. If the console has at least 50 -* lines, enable mode 80x50. If we can query the console size and it is neither -* 80x25 nor 80x50, set it as an additional mode. -*/ void efi_setup_console_size (void ) {int rows =25 , cols =80 ;@@ -362,8 +366,12 @@ void efi_setup_console_size(void)if (IS_ENABLED (CONFIG_VIDEO )) ret =query_vidconsole (&rows, &cols); -if (ret) - ret =query_console_serial (&rows, &cols); +if (ret) { +if (no_ansi) + ret =0 ; +else + ret =query_console_serial (&rows, &cols); + }if (ret)return ;
Re: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests
Quoted 10 lines · Heinrich Schuchardt
Quoted 8 lines · Simon Glass
We don't want ANSI characters written in tests since it is a pain to check the output with
ut_assert_nextline()et al.Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
Signed-off-by Simon Glass <[email protected]>
Quoted 8 lines
Please, consider prior review before resubmitting patches.
As responded to all prior submissions:
We want to test the code running on actual machines. We don't want to have sandbox code everywhere.
I cannot see any test that is not passing due to the current behavior.
The pytests for the EFI selftests are unreliable for me, on Raspberry Pi 3, more often in 32bit mode than 64bit mode, but I feel like I see it there too. And when they fail, the console log is full of ANSI escape sequences. Is this specific test a test you run regularly on real hardware?
Signature · 1 line
Tom
Re: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests
Quoted 18 lines · Tom Rini
Quoted 17 lines · Heinrich Schuchardt
Quoted 8 lines · Simon Glass
We don't want ANSI characters written in tests since it is a pain to check the output with
ut_assert_nextline()et al.Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
Signed-off-by Simon Glass <[email protected]>Please, consider prior review before resubmitting patches.
As responded to all prior submissions:
We want to test the code running on actual machines. We don't want to have sandbox code everywhere.
Quoted 8 lines
Quoted 1 line
I cannot see any test that is not passing due to the current behavior.
The pytests for the EFI selftests are unreliable for me, on Raspberry Pi 3, more often in 32bit mode than 64bit mode, but I feel like I see it there too. And when they fail, the console log is full of ANSI escape sequences. Is this specific test a test you run regularly on real hardware?
It is not only the EFI test but also pytest adding color to the console output.
When I download a raw LOG and display it with
wget
https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/904222/raw
less -r raw
I see the correct colored output. Same when I run
cat raw
If you want to strip ANSI codes from a file, you can use ansi2txt from Ubuntu package colorized logs.
ansi2txt < raw > flat.log
I typically run UEFI tests interactively on the sandbox, virtual machines, and on actual hardware.
lib/efi_selftest/efi_selftest_textoutput.c is specifically used to print out all combinations of fore- and background colors.
Furthermore color is used in /lib/efi_selftest/ for:
* start of test
* success, warning, error
This coloring is not functionally necessary but for my taste makes the output easier to read.
test/py/tests/test_efi_selftest.py just has no problems with the color output when running:
if u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']):
While color output in UEFI unit tests as said is not functionally necessary in most tests, the current patch tries to suppress ANSI output which is functionally necessary and which probably should be tested for.
Best regards
Heinrich
Re: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests
Quoted 28 lines · Heinrich Schuchardt
Quoted 18 lines · Tom Rini
Quoted 17 lines · Heinrich Schuchardt
Quoted 8 lines · Simon Glass
We don't want ANSI characters written in tests since it is a pain to check the output with
ut_assert_nextline()et al.Provide a way to tests to request that ANSI characters not be sent.
Add a proper function comment while we are here, to encourage others.
Signed-off-by Simon Glass <[email protected]>Please, consider prior review before resubmitting patches.
As responded to all prior submissions:
We want to test the code running on actual machines. We don't want to have sandbox code everywhere.
Quoted 8 lines
Quoted 1 line
I cannot see any test that is not passing due to the current behavior.
The pytests for the EFI selftests are unreliable for me, on Raspberry Pi 3, more often in 32bit mode than 64bit mode, but I feel like I see it there too. And when they fail, the console log is full of ANSI escape sequences. Is this specific test a test you run regularly on real hardware?
Quoted 2 lines
It is not only the EFI test but also pytest adding color to the console output.
Alright, so at least for the problems I have _today_, I've figured it out, and the problem is that the watchdog test fails too quickly:
[snip]test/py/tests/test_efi_selftest.py ..F
=================================== FAILURES =================================== ______________________ test_efi_selftest_watchdog_reboot _______________________ test/py/tests/test_efi_selftest.py:61: in test_efi_selftest_watchdog_reboot
u_boot_console.restart_uboot()test/py/u_boot_console_base.py:478: in restart_uboot
self.ensure_spawned(expect_reset)test/py/u_boot_console_base.py:442: in ensure_spawned
self.wait_for_boot_prompt(loop_num = loop_num)test/py/u_boot_console_base.py:195: in wait_for_boot_prompt
raise Exception('Bad pattern found on console: ' +
E Exception: Bad pattern found on console: spl_signon
----------------------------- Captured stdout call ----------------------------- => setenv efi_selftest list
=> => bootefi selftest
7[r[999;999H[6n8No EFI system partition
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
Available tests:
'block image transfer' - on request
'block device'
'configuration tables'
'controllers'
'crc32'
'device path'
'device path utilities protocol'
'conformance profile table'
'event groups'
'event services'
'exception' - on request
'ExitBootServices'
'device tree'
'graphical output'
'HII database protocols'
'load file protocol'
'loaded image'
'load image from file'
'mem'
'memory'
'open protocol'
'manage protocols'
'register protocol notify'
'reset system' - on request
'reset system runtime' - on request
'real time clock'
'simple network protocol'
'start image return'
'start image exit'
'text input' - on request
'extended text input' - on request
'text output'
'task priority levels'
'unicode collation'
'variables'
'variables at runtime'
'virtual address map'
'watchdog timer'
'watchdog reboot' - on request
=> => setenv efi_selftest watchdog reboot
=> => bootefi selftest
[1;37;40m
Testing EFI API implementation
[0;37;40m[1;37;40m
Selected test: 'watchdog reboot'
[0;37;40m[1;34;40m
Setting up 'watchdog reboot'
[0;37;40m[1;32;40mSetting up 'watchdog reboot' succeeded
[0;37;40m[1;34;40m
Executing 'watchdog reboot'
[0;37;40m
EFI: Watchdog timeout
resetting ...
+u-boot-test-reset am64x_evm_a53 na
Selected role am64-sk from configuration file
Selected role am64-sk from configuration file
connecting to NetworkSerialPort(target=Target(name='am64-sk', env=Environment(config_file='/home/trini/u-boot/lg_env.yaml')), name='USBSerialPort', state=<BindingState.bound: 1>, avail=True, host='ti-lab-host', port=57479, speed=115200, protocol='rfc2217') calling microcom -s 115200 -t ti-lab-host:57479 connected to 192.168.116.10 (port 57479)
Escape character: Ctrl-\
Type the escape character to get to the prompt.
U-Boot SPL 2024.10-rc5-00022-g17da9795c115 (Oct 01 2024 - 14:29:10 +0000) SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)') EEPROM not available at 0x50, trying to read at 0x51
SPL initial stack usage: 13368 bytes
Trying to boot from MMC2
Loading Environment from MMC... MMC Device 0 not found
*** Warning - No MMC card found, using default environment
Starting ATF on ARM64 core...
NOTICE: BL31: v2.10.0(release):v2.10.0-729-gc8be7c08c NOTICE: BL31: Built : 13:50:07, Apr 24 2024
I/TC:
I/TC: OP-TEE version: 4.2.0-22-g16fbd46d2 (gcc version 13.2.0 (GCC)) #2 Wed Apr 24 19:50:23 UTC 2024 aarch64 I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: GIC redistributor base address not provided
I/TC: Assuming default GIC group status and modifier
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
I/TC: Fixing SA2UL firewall owner for GP device
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot
U-Boot SPL 2024.10-rc5-00022-g17da9795c115 (Oct 01 2024 - 14:31:31 +0000) SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)') Trying to boot from MMC2