This dir provides code to build kvm-unit-tests test cases and run them under QEMU and UEFI.
The following dependencies should be installed:
- UEFI firmware: to run test cases in QEMU
To build:
./configure --enable-efi
make
To run a test case with UEFI:
./x86/efi/run ./x86/msr.efi
By default the runner script loads the UEFI firmware /usr/share/ovmf/OVMF.fd
;
please install UEFI firmware to this path, or specify the correct path through
the env variable EFI_UEFI
:
EFI_UEFI=/path/to/OVMF.fd ./x86/efi/run ./x86/msr.efi
This dir contains source code and linker script copied from GNU-EFI:
- crt0-efi-x86_64.S: startup code of an EFI application
- elf_x86_64_efi.lds: linker script to build an EFI application
- reloc_x86_64.c: position independent x86_64 ELF shared object relocator
EFI application binaries should be relocatable as UEFI loads binaries to dynamic runtime addresses. To build such relocatable binaries, GNU-EFI utilizes the above-mentioned files in its build process:
- build an ELF shared object and link it using linker script
elf_x86_64_efi.lds
to organize the sections in a way UEFI recognizes - link the shared object with self-relocator
reloc_x86_64.c
that applies dynamic relocations that may be present in the shared object - link the entry point code
crt0-efi-x86_64.S
that invokes self-relocator and then jumps to EFI application'sefi_main()
function - convert the shared object to an EFI binary
More details can be found in GNU-EFI/README.gnuefi
, section "Building
Relocatable Binaries".
kvm-unit-tests follows a similar build process, but does not link with GNU-EFI library.
This dir also contains kvm-unit-tests startup code in UEFI:
- efistart64.S: startup code for kvm-unit-tests in UEFI