0cc3a351 | 22-Feb-2025 |
Sean Christopherson <seanjc@google.com> |
lib: Use __ASSEMBLER__ instead of __ASSEMBLY__
Convert all non-x86 #ifdefs from __ASSEMBLY__ to __ASSEMBLER__, and remove all manual __ASSEMBLY__ #defines. __ASSEMBLY_ was inherited blindly from th
lib: Use __ASSEMBLER__ instead of __ASSEMBLY__
Convert all non-x86 #ifdefs from __ASSEMBLY__ to __ASSEMBLER__, and remove all manual __ASSEMBLY__ #defines. __ASSEMBLY_ was inherited blindly from the Linux kernel, and must be manually defined, e.g. through build rules or with the aforementioned explicit #defines in assembly code.
__ASSEMBLER__ on the other hand is automatically defined by the compiler when preprocessing assembly, i.e. doesn't require manually #defines for the code to function correctly.
Ignore x86, as x86 doesn't actually rely on __ASSEMBLY__ at the moment, and is undergoing a parallel cleanup.
Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Andrew Jones <andrew.jones@linux.dev> Message-ID: <20250222014526.2302653-1-seanjc@google.com> [thuth: Fix three more occurances in libfdt.h and sbi-tests.h] Signed-off-by: Thomas Huth <thuth@redhat.com>
show more ...
|
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 ...
|
22f287f4 | 24-Sep-2023 |
Andrew Jones <andrew.jones@linux.dev> |
riscv: Add DT parsing
Start building setup() by copying code from Arm and adding dependencies along the way like bitops and a few more barriers. We now parse the DT for the UART base address to be s
riscv: Add DT parsing
Start building setup() by copying code from Arm and adding dependencies along the way like bitops and a few more barriers. We now parse the DT for the UART base address to be sure we find what we expect with the early base. We also parse the CPU nodes to get the hartids, even though we don't yet support booting secondaries. Finally, add parsing of bootargs to get the command line and parsing of the environ to set the environment variables, and then extend the selftest to ensure it all works.
We don't do proper memory setup yet, only just enough to allocate memory for the environment variables and any another small mallocs that may be necessary.
Note, we've added a banner, which Arm doesn't have, because we need to separate the test output from OpenSBI output.
Run with qemu-system-riscv64 -nographic -M virt \ -kernel riscv/selftest.flat \ -append 'foo bar baz' \ -initrd test-env \ -smp 16
where test-env is a text file with the environment, i.e. $ cat test-env FOO=foo BAR=bar BAZ=baz
Signed-off-by: Andrew Jones <andrew.jones@linux.dev> Acked-by: Thomas Huth <thuth@redhat.com>
show more ...
|
23e17626 | 30-May-2023 |
Nikos Nikoleris <nikos.nikoleris@arm.com> |
arm64: Add a setup sequence for systems that boot through EFI
This change implements an alternative setup sequence for the system when we are booting through EFI. The memory map is discovered throug
arm64: Add a setup sequence for systems that boot through EFI
This change implements an alternative setup sequence for the system when we are booting through EFI. The memory map is discovered through EFI boot services and devices through ACPI.
This change is based on a change initially proposed by Andrew Jones <drjones@redhat.com>
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Shaoqin Huang <shahuang@redhat.com> [Changed __ALIGN to ALIGN as pointed out by Nadav Amit.] Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
show more ...
|
f49151be | 30-May-2023 |
Nikos Nikoleris <nikos.nikoleris@arm.com> |
lib: Avoid ms_abi for calls related to EFI on arm64
x86_64 requires that EFI calls use the ms_abi calling convention. For arm64 this is unnecessary.
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@
lib: Avoid ms_abi for calls related to EFI on arm64
x86_64 requires that EFI calls use the ms_abi calling convention. For arm64 this is unnecessary.
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Andrew Jones <drjones@redhat.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 ...
|
f56f21cd | 07-Mar-2023 |
Marc Hartmayer <mhartmay@linux.ibm.com> |
lib/linux/const.h: test for `__ASSEMBLER__` as well
On s390x we're using the preprocessor for generating our linker scripts out of assembly files. The macro `__ASSEMBLER__` is defined with value 1 w
lib/linux/const.h: test for `__ASSEMBLER__` as well
On s390x we're using the preprocessor for generating our linker scripts out of assembly files. The macro `__ASSEMBLER__` is defined with value 1 when preprocessing assembly language using gcc. [1] Therefore, let's check for the macro `__ASSEMBLER__` in `lib/linux/const.h` as well. Thus we can use macros that makes use of the `_AC` or `_AT` macro in the "linker scripts".
[1] https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Link: https://lore.kernel.org/r/20230307091051.13945-8-mhartmay@linux.ibm.com Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
show more ...
|
b0fcca88 | 27-Mar-2023 |
Nicholas Piggin <npiggin@gmail.com> |
compiler.h: Make __always_inline match glibc definition, preventing redefine error
This makes __always_inline match glibc's cdefs.h file, which prevents redefinition errors which can happen e.g., if
compiler.h: Make __always_inline match glibc definition, preventing redefine error
This makes __always_inline match glibc's cdefs.h file, which prevents redefinition errors which can happen e.g., if glibc limits.h is included before kvm-unit-tests compiler.h.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Message-Id: <20230327122248.2693856-1-npiggin@gmail.com> Signed-off-by: Thomas Huth <thuth@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 ...
|
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 ...
|
c3770197 | 04-Oct-2021 |
Varad Gautam <varad.gautam@suse.com> |
x86 UEFI: Copy code from Linux
Copy UEFI-related definitions from Linux, so the follow-up commits can develop UEFI function calls based on these definitions, without relying on GNU-EFI library.
Sig
x86 UEFI: Copy code from Linux
Copy UEFI-related definitions from Linux, so the follow-up commits can develop UEFI function calls based on these definitions, without relying on GNU-EFI library.
Signed-off-by: Varad Gautam <varad.gautam@suse.com> Message-Id: <20211004204931.1537823-3-zxwang42@gmail.com> Signed-off-by: Zixuan Wang <zxwang42@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
1721daed | 13-Oct-2021 |
Andrew Jones <drjones@redhat.com> |
compiler.h: Fix typos in mul and sub overflow checks
Fixes: 4ceb02bf68f0 ("compiler: Add builtin overflow flag and predicate wrappers") Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by:
compiler.h: Fix typos in mul and sub overflow checks
Fixes: 4ceb02bf68f0 ("compiler: Add builtin overflow flag and predicate wrappers") Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Daniele Ahmed <ahmeddan@amazon.com> Message-Id: <20211013164259.88281-2-drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
a9d450af | 09-Sep-2021 |
Sean Christopherson <seanjc@google.com> |
lib: Move __unused attribute macro to compiler.h
Move the __unused macro to linux/compiler.h to co-locate it with the other macros that provide syntactic sugar around __attribute__.
No functional c
lib: Move __unused attribute macro to compiler.h
Move the __unused macro to linux/compiler.h to co-locate it with the other macros that provide syntactic sugar around __attribute__.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210909183207.2228273-4-seanjc@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
16431a73 | 09-Sep-2021 |
Bill Wendling <morbo@google.com> |
lib: define the "noinline" macro
Define "noline" macro to reduce the amount of typing for functions using the "noinline" attribute. Opportunistically convert existing users.
Signed-off-by: Bill We
lib: define the "noinline" macro
Define "noline" macro to reduce the amount of typing for functions using the "noinline" attribute. Opportunistically convert existing users.
Signed-off-by: Bill Wendling <morbo@google.com> [sean: put macro in compiler.h instead of libcflat.h] Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210909183207.2228273-3-seanjc@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
53017303 | 02-Jun-2021 |
Po-Hsu Lin <po-hsu.lin@canonical.com> |
compiler: use __builtin_add_overflow_p for gcc >= 7.1.0
Compilation on Ubuntu Xenial 4.4.0-210-generic i386 with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) will fail with: lib/lin
compiler: use __builtin_add_overflow_p for gcc >= 7.1.0
Compilation on Ubuntu Xenial 4.4.0-210-generic i386 with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) will fail with: lib/linux/compiler.h:37:34: error: implicit declaration of function ‘__builtin_add_overflow_p’ [-Werror=implicit-function-declaration]
From the GCC document[1] it looks like this built-in function was only introduced since 7.1.0
This can be fixed by simply changing the version check from 5.1.0 to 7.1.0
[1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Integer-Overflow-Builtins.html
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com> Message-Id: <20210602082443.20252-1-po-hsu.lin@canonical.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
4ceb02bf | 23-Mar-2021 |
Andrew Jones <drjones@redhat.com> |
compiler: Add builtin overflow flag and predicate wrappers
Checking for overflow can be difficult, but doing so may be a good idea to avoid difficult to debug problems. Compilers that provide builti
compiler: Add builtin overflow flag and predicate wrappers
Checking for overflow can be difficult, but doing so may be a good idea to avoid difficult to debug problems. Compilers that provide builtins for overflow checking allow the checks to be simple enough that we can use them more liberally. The idea for this flag is to wrap a calculation that should have overflow checking, allowing compilers that support it to give us some extra robustness. For example,
#ifdef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW bool overflow = __builtin_mul_overflow(x, y, &z); assert(!overflow); #else /* Older compiler, hopefully we don't overflow... */ z = x * y; #endif
This is a bit ugly though, so when possible we can just use the predicate wrappers, which have an always-false fallback, e.g.
/* Old compilers won't assert on overflow. Oh, well... */ assert(!check_mul_overflow(x, y)); z = x * y;
Signed-off-by: Andrew Jones <drjones@redhat.com>
show more ...
|
b2402d33 | 28-Feb-2020 |
Paolo Bonzini <pbonzini@redhat.com> |
pci: use uint32_t for unsigned long values
The "pci_bar_*" functions use 64-bit masks, but the results are assigned to 32-bit variables; clang complains. Use signed masks that can be sign-extended a
pci: use uint32_t for unsigned long values
The "pci_bar_*" functions use 64-bit masks, but the results are assigned to 32-bit variables; clang complains. Use signed masks that can be sign-extended at will.
Reported-by: Bill Wendling <morbo@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
d5b60621 | 31-Dec-2019 |
Alexandru Elisei <alexandru.elisei@arm.com> |
lib: Add WRITE_ONCE and READ_ONCE implementations in compiler.h
Add the WRITE_ONCE and READ_ONCE macros which are used to prevent the compiler from optimizing a store or a load, respectively, into s
lib: Add WRITE_ONCE and READ_ONCE implementations in compiler.h
Add the WRITE_ONCE and READ_ONCE macros which are used to prevent the compiler from optimizing a store or a load, respectively, into something else.
Cc: Drew Jones <drjones@redhat.com> Cc: Laurent Vivier <lvivier@redhat.com> Cc: Thomas Huth <thuth@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andrew Jones <drjones@redhat.com>
show more ...
|
80c72be7 | 18-Jan-2016 |
Andrew Jones <drjones@redhat.com> |
lib/linux: import pci_regs.h
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Radim KrÄmář <rkrcmar@redhat.com> Message-Id: <1453140064-9040-4-git-send-email-drjones@redhat.com> Sign
lib/linux: import pci_regs.h
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Radim KrÄmář <rkrcmar@redhat.com> Message-Id: <1453140064-9040-4-git-send-email-drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
f3bd1e05 | 18-Jan-2016 |
Andrew Jones <drjones@redhat.com> |
lib: add linux dir for kernel uapi headers
We needed to import some uapi headers, e.g. lib/arm/asm/uapi-psci.h, and will need some others, e.g. pci_regs.h, in the future. Create a linux directory fo
lib: add linux dir for kernel uapi headers
We needed to import some uapi headers, e.g. lib/arm/asm/uapi-psci.h, and will need some others, e.g. pci_regs.h, in the future. Create a linux directory for them in lib so that they can be included with the familiar <linux/header.h> reference.
(Note, x86 has been cheating. lib/x86/pci.c already includes <linux/pci_regs.h>, which it's been getting away with as its include paths are less strict than arm's, i.e. it *does* look in /usr/include)
Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Radim KrÄmář <rkrcmar@redhat.com> Message-Id: <1453140064-9040-2-git-send-email-drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|