History log of /kvm-unit-tests/lib/efi.c (Results 1 – 21 of 21)
Revision Date Author Comments
# 7b0147ea 10-Apr-2024 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'efi/queue' into 'master'

efi: Another x86 fix the fdt_check_header addition

See merge request kvm-unit-tests/kvm-unit-tests!56


# fc35f6cc 10-Apr-2024 Vasant Karasulli <vkarasulli@suse.de>

efi: include libfdt header only for aarch64 and riscv

For x86, preprocessor fails to locate headers included by lib/libfdt.h
as they are missing from the include path.

Fixes: 9632ce446b8f ("arm64:

efi: include libfdt header only for aarch64 and riscv

For x86, preprocessor fails to locate headers included by lib/libfdt.h
as they are missing from the include path.

Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery")
Signed-off-by: Vasant Karasulli <vkarasulli@suse.de>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 9f993e21 03-Apr-2024 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'efi/queue' into 'master'

A couple EFI fixes

See merge request kvm-unit-tests/kvm-unit-tests!55


# b365a5b0 29-Mar-2024 Pavan Kumar Paluri <papaluri@amd.com>

lib/efi: Retry call to efi exit boot services

In some cases, KUT guest might fail to exit boot services due to a
possible memory map update that might have taken place between
efi_get_memory_map() a

lib/efi: Retry call to efi exit boot services

In some cases, KUT guest might fail to exit boot services due to a
possible memory map update that might have taken place between
efi_get_memory_map() and efi_exit_boot_services() calls. As per UEFI
spec 2.10 (Section 7.4.6 EFI_BOOT_SERVICES.ExitBootServices()), we need
to keep trying to update the memory map and calls to exit boot
services as long as case status is EFI_INVALID_PARAMETER. Keep freeing
the old memory map before obtaining new memory map via
efi_get_memory_map() in case of exit boot services failure.

Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
[Dropped x86 reference from summary.]
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# bb294dfd 29-Mar-2024 Pavan Kumar Paluri <papaluri@amd.com>

x86 EFI: Bypass call to fdt_check_header()

Issuing a call to fdt_check_header() prevents running any of x86 UEFI
enabled tests. Bypass this call for x86 and also calls to
efi_load_image(), efi_grow_

x86 EFI: Bypass call to fdt_check_header()

Issuing a call to fdt_check_header() prevents running any of x86 UEFI
enabled tests. Bypass this call for x86 and also calls to
efi_load_image(), efi_grow_buffer(), efi_get_var() in order to enable
UEFI supported tests for KUT x86 arch.

Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery")
Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 6444ae20 18-Mar-2024 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'riscv/queue' into 'master'

riscv: Add EFI support and SBI base ext tests

See merge request kvm-unit-tests/kvm-unit-tests!54


# ba0a6fd4 05-Mar-2024 Andrew Jones <andrew.jones@linux.dev>

efi: Add support for obtaining the boot hartid

riscv needs to use an EFI protocol to get the boot hartid.

Signed-off-by: Andrew Jones <andrew.jones@linux.dev>


# 611fe6de 18-Mar-2024 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'arm/queue' into 'master'

arm/arm64: EFI improvements and no more MAX_SMP probing

See merge request kvm-unit-tests/kvm-unit-tests!53


# b9f8ff7c 05-Mar-2024 Andrew Jones <andrew.jones@linux.dev>

lib/efi: Add support for loading the initrd

When loading non-efi tests with QEMU's '-kernel' option we also load
an environ with the '-initrd' option. Now that efi tests can also be
loaded with the

lib/efi: Add support for loading the initrd

When loading non-efi tests with QEMU's '-kernel' option we also load
an environ with the '-initrd' option. Now that efi tests can also be
loaded with the '-kernel' option also provide the '-initrd' environ.
For EFI, we use the EFI_LOAD_FILE2_PROTOCOL_GUID protocol to load
LINUX_EFI_INITRD_MEDIA_GUID. Each architecture which wants to use the
initrd for the environ will need to call setup_env() on the initrd
data. As usual, the new efi function is heavily influenced by Linux's
implementation.

Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 9632ce44 05-Mar-2024 Andrew Jones <andrew.jones@linux.dev>

arm64: efi: Improve device tree discovery

Check the device tree GUID when the environment variable is missing,
which allows directly loading the unit test with QEMU's '-kernel'
command line paramete

arm64: efi: Improve device tree discovery

Check the device tree GUID when the environment variable is missing,
which allows directly loading the unit test with QEMU's '-kernel'
command line parameter, which is much faster than putting the test
in the EFI file system and then running it from the UEFI shell.

Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# e526bc78 01-Jul-2023 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'arm/queue' into 'master'

arm/arm64: EFI support, arm64 backtrace support, PMU test improvements, and more

See merge request kvm-unit-tests/kvm-unit-tests!43


# 25ef5154 28-Jun-2023 Nadav Amit <namit@vmware.com>

efi: print address of image

Using gdb to debug tests that are run from efi is very hard without
knowing the base address in which the image was loaded. Print the
address so it can be used while debu

efi: print address of image

Using gdb to debug tests that are run from efi is very hard without
knowing the base address in which the image was loaded. Print the
address so it can be used while debugging.

Signed-off-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 529ab889 30-May-2023 Nikos Nikoleris <nikos.nikoleris@arm.com>

lib/efi: Add support for reading an FDT

This change adds support for reading environment variables. To do so it
introduces a new GUID: 97ef3e03-7329-4a6a-b9ba-6c1fdcc5f823 that the
user needs to pro

lib/efi: Add support for reading an FDT

This change adds support for reading environment variables. To do so it
introduces a new GUID: 97ef3e03-7329-4a6a-b9ba-6c1fdcc5f823 that the
user needs to provide when setting environment variables. For example,
to set the path to the fdt a user can execute:

In addition, this change add support for reading the fdt into memory
and providing a pointer to the test through efi_bootinfo_t.

Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
[Ensure DTB pathname is nul-terminated.]
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 85c3c524 30-May-2023 Nikos Nikoleris <nikos.nikoleris@arm.com>

lib/efi: Add support for getting the cmdline

This change adds support for discovering the command line arguments,
as a string. Then, we parse this string to populate __argc and __argv
for EFI tests.

lib/efi: Add support for getting the cmdline

This change adds support for discovering the command line arguments,
as a string. Then, we parse this string to populate __argc and __argv
for EFI tests.

Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...


# 92a6c9b9 18-Jan-2022 Paolo Bonzini <pbonzini@redhat.com>

Merge remote-tracking branch 'upstream/uefi' into master

Merge UEFI test support into the master branch.


# 2f47d025 16-Nov-2021 Zixuan Wang <zxwang42@gmail.com>

x86 UEFI: introduce efi_exit

The combination of exit() + efi_rs_call() appears twice in the code,
unify them.

Signed-off-by: Zixuan Wang <zxwang42@gmail.com>
Message-Id: <20211116204053.220523-7-zx

x86 UEFI: introduce efi_exit

The combination of exit() + efi_rs_call() appears twice in the code,
unify them.

Signed-off-by: Zixuan Wang <zxwang42@gmail.com>
Message-Id: <20211116204053.220523-7-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# b4e8c300 31-Oct-2021 Zixuan Wang <zxwang42@gmail.com>

x86 UEFI: Refactor set up process

Refactor the EFI set up process. The previous set up process calls
multiple arch-specific functions, now it's simplified to call
only one arch-specific function:

1

x86 UEFI: Refactor set up process

Refactor the EFI set up process. The previous set up process calls
multiple arch-specific functions, now it's simplified to call
only one arch-specific function:

1. (Arch neutral ) Extract EFI data structures, e.g., memory maps
2. (Arch neutral ) Exit EFI boot services
3. (Arch specific) Parse EFI data structures and set up arch-specific
resources
4. (Arch neutral ) Run test cases' main functions

Signed-off-by: Zixuan Wang <zxwang42@gmail.com>
Message-Id: <20211031055634.894263-3-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# f20589d6 04-Oct-2021 Zixuan Wang <zixuanwang@google.com>

x86 UEFI: Set up RSDP after UEFI boot up

Root system description pointer (RSDP) is a data structure used in the
ACPI programming interface. In BIOS, RSDP is located within a
predefined memory area,

x86 UEFI: Set up RSDP after UEFI boot up

Root system description pointer (RSDP) is a data structure used in the
ACPI programming interface. In BIOS, RSDP is located within a
predefined memory area, so a program can scan the memory area and find
RSDP. But in UEFI, RSDP may not appear in that memory area, instead, a
program should find it in the EFI system table.

This commit provides RSDP set up code in UEFI:
1. Read RSDP from EFI system table
2. Pass RSDP pointer to find_acpi_table_attr() function

From this commit, the `x86/s3.c` test can run in UEFI and generates
similar output as in Seabios, note that:
1. In its output, memory addresses are different than Seabios's, this
is because EFI application starts from a dynamic runtime address,
not a fixed predefined memory address
2. There is a short delay (~5 secs) after the test case prints "PM1a
event registers" line. This test case sleeps for a few seconds
and then wakes up, so give it a few seconds to run.

Signed-off-by: Zixuan Wang <zixuanwang@google.com>
Message-Id: <20211004204931.1537823-10-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 1ae9072e 04-Oct-2021 Zixuan Wang <zixuanwang@google.com>

x86 UEFI: Set up memory allocator

KVM-Unit-Tests library implements a memory allocator which requires
two arguments to set up (See `lib/alloc_phys.c:phys_alloc_init()` for
more details):
1. A bas

x86 UEFI: Set up memory allocator

KVM-Unit-Tests library implements a memory allocator which requires
two arguments to set up (See `lib/alloc_phys.c:phys_alloc_init()` for
more details):
1. A base (start) physical address
2. Size of available memory for allocation

To get this memory info, we scan all the memory regions returned by
`LibMemoryMap()`, find out the largest free memory region and use it for
memory allocation.

After retrieving this memory info, we call `ExitBootServices` so that
KVM-Unit-Tests has full control of the machine, and UEFI will not touch
the memory after this point.

Starting from this commit, `x86/hypercall.c` test case can run in UEFI
and generates the same output as in Seabios.

Co-developed-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Zixuan Wang <zixuanwang@google.com>
Message-Id: <20211004204931.1537823-9-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# ad5fb883 04-Oct-2021 Zixuan Wang <zixuanwang@google.com>

x86 UEFI: Boot from UEFI

This commit provides initial support for x86 test cases to boot from
UEFI:

1. UEFI compiler flags are added to Makefile
2. A new TARGET_EFI macro is added to turn on/

x86 UEFI: Boot from UEFI

This commit provides initial support for x86 test cases to boot from
UEFI:

1. UEFI compiler flags are added to Makefile
2. A new TARGET_EFI macro is added to turn on/off UEFI startup code
3. Previous Multiboot setup code is refactored and updated for
supporting UEFI, including the following changes:
1. x86/efi/crt0-efi-x86_64.S: provides entry point and jumps to
setup code in lib/efi.c.
2. lib/efi.c: performs UEFI setup, calls arch-related setup
functions, then jumps to test case main() function
3. lib/x86/setup.c: provides arch-related setup under UEFI

To build test cases for UEFI, please first install the GNU-EFI library.
Check x86/efi/README.md for more details.

This commit is tested by a simple test calling report() and
report_summayr(). This commit does not include such a test to avoid
unnecessary files added into git history. To build and run this test in
UEFI (assuming file name is x86/dummy.c):

./configure --target-efi
make x86/dummy.efi
./x86/efi/run ./x86/dummy.efi

To use the default Multiboot instead of UEFI:

./configure
make x86/dummy.flat
./x86/run ./x86/dummy.flat

Some x86 test cases require additional fixes to work in UEFI, e.g.,
converting to position independent code (PIC), setting up page tables,
etc. This commit does not provide these fixes, so compiling and running
UEFI test cases other than x86/dummy.c may trigger compiler errors or
QEMU crashes. These test cases will be fixed by the follow-up commits in
this series.

The following code is ported from github.com/rhdrjones/kvm-unit-tests
- ./configure: 'target-efi'-related code

See original code:
- Repo: https://github.com/rhdrjones/kvm-unit-tests
- Branch: target-efi

Co-developed-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Zixuan Wang <zixuanwang@google.com>
Message-Id: <20211004204931.1537823-6-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 0eaa5176 04-Oct-2021 Varad Gautam <varad.gautam@suse.com>

x86 UEFI: Implement UEFI function calls

This commit implements helper functions that call UEFI services and
assist the boot up process.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Reviewed-

x86 UEFI: Implement UEFI function calls

This commit implements helper functions that call UEFI services and
assist the boot up process.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Message-Id: <20211004204931.1537823-4-zxwang42@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...