
On 05/16/2018 05:42 PM, Simon Glass wrote:
A limitation of the EFI loader at present is that it does not build with sandbox. This makes it hard to write tests, since sandbox is used for most testing in U-Boot.
This series enables the EFI loader feature. It allows sandbox to build and run a trivial function which calls the EFI API to output a message.
This series is at u-boot-dm/efi-working
I applied you patch series
make sandbox_defconfig CONFIG_CMD_BOOTEFI_SELFTEST=y make -j6
results in:
ld.bfd: read in flex scanner failed scripts/Makefile.lib:407: recipe for target 'lib/efi_selftest/efi_selftest_miniapp_exit_efi.so' failed make[2]: *** [lib/efi_selftest/efi_selftest_miniapp_exit_efi.so] Error 1 rm lib/efi_selftest/efi_selftest_miniapp_exit.o lib/efi_selftest/efi_selftest_miniapp_return.o scripts/Makefile.build:423: recipe for target 'lib/efi_selftest' failed make[1]: *** [lib/efi_selftest] Error 2 make[1]: *** Waiting for unfinished jobs....
Please, change /lib/efi_selftest/Makefile -ifeq ($(CONFIG_X86_64),) +ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),)
Now running ./u-boot
bootefi selftest Found 0 disks WARNING: booting without device tree
Testing EFI API implementation
Number of tests to execute: 17
Setting up 'block device' Setting up 'block device' succeeded
Executing 'block device' lib/efi_selftest/efi_selftest_block_device.c(378): TODO: Wrong volume label 'xxa1', expected 'U-BOOT TEST' FAT: Misaligned buffer address (00007ff70aafe658) Segmentation fault
Please, fix the alignment fault. You have to ensure that the memory that Sandbox has retrieved via malloc is reduced to 4k aligned pages before being published to the EFI implementation in lib/efi_loader/efi_memory.c
Best regards
Heinrich
Changes in v4:
- Fix up the sizeof() operations on jmp_buf
- Move the fix to query_console_serial()
- Rebase to master
- Remove code already applied
- Update SPDX tags
- Update subject
Changes in v3:
- Add comments on aligment
- Add new patch to init the 'rows' and 'cols' variables
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
- Add new patch to split out test init/uninit into functions
- Add patch to create a function to set up for running EFI code
- Drop incorrect map_sysmem() in write_smbios_table()
- Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)
- Rebase to master
- Return error value of efi_allocate_pages()
- Update function comment for write_smbios_table()
Changes in v2:
- Rebase to master
- Update return type of efi_smbios_register() to efi_status_t
- Update to use mapmem instead of a cast
- Use return value of efi_install_configuration_table
Simon Glass (16): efi: Init the 'rows' and 'cols' variables efi: Update some comments related to smbios tables efi: sandbox: Adjust memory usage for sandbox sandbox: smbios: Update to support sandbox sandbox: Add a setjmp() implementation efi: sandbox: Add required linker sections efi: sandbox: Add distroboot support Define board_quiesce_devices() in a shared location Add a comment for board_quiesce_devices() efi: sandbox: Add relocation constants efi: Add a comment about duplicated ELF constants efi: sandbox: Enable EFI loader builder for sandbox efi: Split out test init/uninit into functions efi: sandbox: Add a simple 'bootefi test' command efi: Create a function to set up for running EFI code efi: Rename bootefi_test_finish() to bootefi_run_finish()
arch/arm/include/asm/u-boot-arm.h | 1 - arch/sandbox/cpu/cpu.c | 13 +++ arch/sandbox/cpu/os.c | 23 +++++ arch/sandbox/cpu/u-boot.lds | 29 ++++++ arch/sandbox/include/asm/setjmp.h | 30 ++++++ arch/sandbox/lib/Makefile | 2 +- arch/sandbox/lib/sections.c | 12 +++ arch/x86/include/asm/u-boot-x86.h | 1 - arch/x86/lib/bootm.c | 4 - cmd/bootefi.c | 158 +++++++++++++++++++++--------- common/bootm.c | 4 + include/bootm.h | 8 ++ include/config_distro_bootcmd.h | 2 +- include/efi_loader.h | 10 ++ include/os.h | 21 ++++ include/smbios.h | 5 +- lib/efi_loader/Kconfig | 12 ++- lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_console.c | 5 +- lib/efi_loader/efi_memory.c | 31 +++--- lib/efi_loader/efi_runtime.c | 7 ++ lib/efi_loader/efi_smbios.c | 7 +- lib/efi_loader/efi_test.c | 16 +++ lib/smbios.c | 32 ++++-- 24 files changed, 351 insertions(+), 83 deletions(-) create mode 100644 arch/sandbox/include/asm/setjmp.h create mode 100644 arch/sandbox/lib/sections.c create mode 100644 lib/efi_loader/efi_test.c