f372d35f | 21-Feb-2025 |
Sean Christopherson <seanjc@google.com> |
x86: Commit to using __ASSEMBLER__ instead of __ASSEMBLY__
Convert all two of x86's anti-assembly #ifdefs from __ASSEMBLY__ to __ASSEMBLER__. Usage of __ASSEMBLY__ was inherited blindly from the Li
x86: Commit to using __ASSEMBLER__ instead of __ASSEMBLY__
Convert all two of x86's anti-assembly #ifdefs from __ASSEMBLY__ to __ASSEMBLER__. Usage of __ASSEMBLY__ was inherited blindly from the Linux kernel, and must be manually defined, e.g. through build rules or with 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.
Convert only x86 for the time being, as x86 doesn't actually rely on __ASSEMBLY__ (a clever observer will note that it's never #defined on x86). E.g. trying to include x86's page.h doesn't work as is. All other architectures actually rely on __ASSEMBLY__, and will be dealt with separately.
Note, while only gcc appears to officially document __ASSEMBLER__, clang has followed suit since at least clang 6.0, and clang 6.0 doesn't come remotely close to being able to comple KVM-Unit-Tests.
Link: https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros Link: https://lore.kernel.org/r/20250221225406.2228938-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
show more ...
|
386ed5c2 | 11-Dec-2023 |
Oliver Upton <oliver.upton@linux.dev> |
nVMX: add test for posted interrupts
Test virtual posted interrupts under the following conditions:
- vTPR[7:4] >= VECTOR[7:4]: Expect the L2 interrupt to be blocked. The bit correspondin
nVMX: add test for posted interrupts
Test virtual posted interrupts under the following conditions:
- vTPR[7:4] >= VECTOR[7:4]: Expect the L2 interrupt to be blocked. The bit corresponding to the posted interrupt should be set in L2's vIRR. Test with a running guest.
- vTPR[7:4] < VECTOR[7:4]: Expect the interrupt to be delivered and the ISR to execute once. Test with a running and halted guest.
Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Co-developed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Jim Mattson <jmattson@google.com> Link: https://lore.kernel.org/r/20231211185552.3856862-6-jmattson@google.com [sean: add a dedicated SPIN_IRR op to clarify and enhance coverage] Signed-off-by: Sean Christopherson <seanjc@google.com>
show more ...
|
670b1f54 | 30-May-2023 |
Nikos Nikoleris <nikos.nikoleris@arm.com> |
lib: Move acpi header and implementation to lib
Move acpi.h to lib to make it available for other architectures.
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Shaoqin Huang
lib: Move acpi header and implementation to lib
Move acpi.h to lib to make it available for other architectures.
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Shaoqin Huang <shahuang@redhat.com> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
show more ...
|
d6d3a3bd | 02-Nov-2022 |
Sean Christopherson <seanjc@google.com> |
x86: Add a helper for the BSP's final init sequence common to all flavors
Add bsp_rest_init() to dedup bringing up APs and doing SMP initialization across 32-bit, 64-bit, and EFI flavors of KVM-unit
x86: Add a helper for the BSP's final init sequence common to all flavors
Add bsp_rest_init() to dedup bringing up APs and doing SMP initialization across 32-bit, 64-bit, and EFI flavors of KVM-unit-tests. The common bucket will also be used in future to patches to init things that aren't SMP related and thus don't fit in smp_init(), e.g. PMU setup.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221102225110.3023543-15-seanjc@google.com
show more ...
|
0b7501c3 | 15-Jun-2022 |
Varad Gautam <varad.gautam@suse.com> |
x86: Provide a common 64-bit AP entrypoint for EFI and non-EFI
ap_start64() currently serves as the 64-bit entrypoint for non-EFI tests.
Having ap_start64() and save_id() written in asm prevents sh
x86: Provide a common 64-bit AP entrypoint for EFI and non-EFI
ap_start64() currently serves as the 64-bit entrypoint for non-EFI tests.
Having ap_start64() and save_id() written in asm prevents sharing these routines between EFI and non-EFI tests.
Rewrite them in C and use ap_start64 as the 64-bit entrypoint in the EFI boot flow.
With this, EFI tests support -smp > 1. smptest.efi now passes.
Cc: Andrew Jones <drjones@redhat.com> Cc: Marc Orr <marcorr@google.com> Cc: Zixuan Wang <zxwang42@gmail.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: David Rientjes <rientjes@google.com> Cc: Thomas.Lendacky@amd.com Cc: Joerg Roedel <jroedel@suse.de> Cc: Borislav Petkov <bp@alien8.de> Signed-off-by: Varad Gautam <varad.gautam@suse.com> [sean: reset APIC before TSS setup, halt in AP wait loop, add comment] Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20220615232943.1465490-12-seanjc@google.com
show more ...
|
c98ce6e0 | 23-Feb-2022 |
Alexandru Elisei <alexandru.elisei@arm.com> |
Rename --target-efi to --[enable|disable]-efi
Rename --target-efi to --enable-efi to make it similar to autoconf's configure script options. Add the --disable-efi option for symmetry and to make it
Rename --target-efi to --[enable|disable]-efi
Rename --target-efi to --enable-efi to make it similar to autoconf's configure script options. Add the --disable-efi option for symmetry and to make it easy for the option to change from disabled by default to enabled by default in the future.
Suggested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Andrew Jones <drjones@redhat.com>
show more ...
|
f1dcfd54 | 20-Jan-2022 |
Sean Christopherson <seanjc@google.com> |
x86: Overhaul definitions for DR6 and DR7 bits
Clean up the mess that is debugreg.h to follow the nomenclature used by the SDM and the kernel (as best as possible). Use the "new" defines in various
x86: Overhaul definitions for DR6 and DR7 bits
Clean up the mess that is debugreg.h to follow the nomenclature used by the SDM and the kernel (as best as possible). Use the "new" defines in various tests. Opportunistically add a define for VMX's extra flag in vmcs.GUEST_PENDING_DBG_EXCEPTIONS that is set if any DR0-3 trap matched and was enabled.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20220120002923.668708-6-seanjc@google.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 ...
|
30203ea5 | 04-Oct-2021 |
Zixuan Wang <zixuanwang@google.com> |
x86 AMD SEV: Page table with c-bit
AMD SEV introduces c-bit to page table entries. To work with AMD SEV:
1. c-bit should be set for new page table entries 2. address calculation should not us
x86 AMD SEV: Page table with c-bit
AMD SEV introduces c-bit to page table entries. To work with AMD SEV:
1. c-bit should be set for new page table entries 2. address calculation should not use c-bit as part of address
Signed-off-by: Zixuan Wang <zixuanwang@google.com> Message-Id: <20211004204931.1537823-14-zxwang42@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
350bf64a | 04-Oct-2021 |
Zixuan Wang <zixuanwang@google.com> |
x86 AMD SEV: Initial support
AMD Secure Encrypted Virtualization (SEV) is a hardware accelerated memory encryption feature that protects guest VMs from host attacks.
This commit provides set up cod
x86 AMD SEV: Initial support
AMD Secure Encrypted Virtualization (SEV) is a hardware accelerated memory encryption feature that protects guest VMs from host attacks.
This commit provides set up code and a test case for AMD SEV. The set up code checks if SEV is supported and enabled, and then sets SEV c-bit for each page table entry.
To run the test, use
./x86/efi/run x86/amd_sev.efi -object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=1,policy=0x3 -machine memory-encryption=sev0
Co-developed-by: Hyunwook (Wooky) Baek <baekhw@google.com> Signed-off-by: Hyunwook (Wooky) Baek <baekhw@google.com> Signed-off-by: Zixuan Wang <zixuanwang@google.com> Message-Id: <20211004204931.1537823-13-zxwang42@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
e6f65fa4 | 04-Oct-2021 |
Zixuan Wang <zixuanwang@google.com> |
x86 UEFI: Set up page tables
UEFI sets up page tables before executing EFI application binaries. These page tables do not allow user space code to access kernel space memory. But `x86/syscall.c` tes
x86 UEFI: Set up page tables
UEFI sets up page tables before executing EFI application binaries. These page tables do not allow user space code to access kernel space memory. But `x86/syscall.c` test case places a user space function `syscall_tf_user32` inside kernel space memory. When using UEFI page tables, fetching this kernel memory from user space triggers a #PF fault, which is not expected by this test case.
KVM-Unit-Tests defines page tables that allow such behavior. So the solution to this problem is to load KVM-Unit-Tests' page tables:
1. Copy the page table definition from `x86/cstart64.S` 2. Update page table entries with runtime memory addresses 3. Update CR3 register with the new page table root address
Since this commit, `x86/syscall.c` can run in UEFI and generate same output as in Seabios, using the following command:
./x86/efi/run ./x86/syscall.efi --cpu Opteron_G1,vendor=AuthenticAMD
Signed-off-by: Zixuan Wang <zixuanwang@google.com> Message-Id: <20211004204931.1537823-11-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 ...
|
7e33895d | 21-Oct-2021 |
Paolo Bonzini <pbonzini@redhat.com> |
x86: Move 32-bit GDT and TSS to desc.c
Move the GDT and TSS data structures from x86/cstart.S to lib/x86/desc.c, for consistency with the 64-bit version.
Signed-off-by: Paolo Bonzini <pbonzini@redh
x86: Move 32-bit GDT and TSS to desc.c
Move the GDT and TSS data structures from x86/cstart.S to lib/x86/desc.c, for consistency with the 64-bit version.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
dbd38004 | 21-Oct-2021 |
Zixuan Wang <zixuanwang@google.com> |
x86: Move 64-bit GDT and TSS to desc.c
Move the GDT and TSS data structures from x86/cstart64.S to lib/x86/desc.c, so that the follow-up UEFI support commits can reuse these definitions, without re-
x86: Move 64-bit GDT and TSS to desc.c
Move the GDT and TSS data structures from x86/cstart64.S to lib/x86/desc.c, so that the follow-up UEFI support commits can reuse these definitions, without re-defining them in UEFI's boot up assembly code.
Signed-off-by: Zixuan Wang <zixuanwang@google.com> Message-Id: <20211004204931.1537823-2-zxwang42@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
c865f654 | 09-Jun-2021 |
Cornelia Huck <cohuck@redhat.com> |
x86: unify header guards
Standardize header guards to _ASMX86_HEADER_H_, _X86_HEADER_H_, and X86_HEADER_H.
Signed-off-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: David Hildenbrand <david@red
x86: unify header guards
Standardize header guards to _ASMX86_HEADER_H_, _X86_HEADER_H_, and X86_HEADER_H.
Signed-off-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20210609143712.60933-8-cohuck@redhat.com>
show more ...
|
322cdd64 | 15-Jan-2021 |
Claudio Imbrenda <imbrenda@linux.ibm.com> |
lib/asm: Fix definitions of memory areas
Fix the definitions of the memory areas.
Bring the headers in line with the rest of the asm headers, by having the appropriate #ifdef _ASM$ARCH_ guarding th
lib/asm: Fix definitions of memory areas
Fix the definitions of the memory areas.
Bring the headers in line with the rest of the asm headers, by having the appropriate #ifdef _ASM$ARCH_ guarding the headers.
Fixes: d74708246bd9 ("lib/asm: Add definitions of memory areas")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Message-Id: <20210115123730.381612-5-imbrenda@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
ea71612b | 15-Jan-2021 |
Claudio Imbrenda <imbrenda@linux.ibm.com> |
lib/x86: fix page.h to include the generic header
Bring x86 in line with the other architectures and include the generic header at asm-generic/page.h . This provides the macros PAGE_SHIFT, PAGE_SIZE
lib/x86: fix page.h to include the generic header
Bring x86 in line with the other architectures and include the generic header at asm-generic/page.h . This provides the macros PAGE_SHIFT, PAGE_SIZE, PAGE_MASK, virt_to_pfn, and pfn_to_virt.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> Message-Id: <20210115123730.381612-2-imbrenda@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
d7470824 | 02-Oct-2020 |
Claudio Imbrenda <imbrenda@linux.ibm.com> |
lib/asm: Add definitions of memory areas
Add definitions and boundaries of memory areas for some architectures. This is needed by the next patch.
Most architectures only get one generic memory area
lib/asm: Add definitions of memory areas
Add definitions and boundaries of memory areas for some architectures. This is needed by the next patch.
Most architectures only get one generic memory area, wherease x86 and s390x get some more attention:
x86 gets * low area (32-bit addresses) * high PAE area (36-bit addresses) * the rest
s390x gets * low area (31-bit addresses) * the rest
Notice that the number indicates the order in which the areas are scanned when more than one area is indicated. The default order tries to get allocations from higher address ranges before trying lower ones. This tries to keep the precious lower addresses as free as possible.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-Id: <20201002154420.292134-4-imbrenda@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
a991ed2f | 01-Sep-2020 |
Roman Bolshakov <r.bolshakov@yadro.com> |
lib: Bundle debugreg.h from the kernel
x86/vmx_tests.c depends on the kernel header and can't be compiled otherwise on x86_64-elf gcc on macOS.
Cc: Jim Mattson <jmattson@google.com> Cc: Peter Shier
lib: Bundle debugreg.h from the kernel
x86/vmx_tests.c depends on the kernel header and can't be compiled otherwise on x86_64-elf gcc on macOS.
Cc: Jim Mattson <jmattson@google.com> Cc: Peter Shier <pshier@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Cameron Esfahani <dirty@apple.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> Message-Id: <20200901085056.33391-5-r.bolshakov@yadro.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
be704aff | 19-Aug-2020 |
Peter Shier <pshier@google.com> |
x86: vmx: Add test for MTF on a guest MOV-to-CR0 that enables PAE
Verify that when L2 guest enables PAE paging and L0 intercept of L2 MOV to CR0 reflects MTF exit to L1, subsequent resume to L2 corr
x86: vmx: Add test for MTF on a guest MOV-to-CR0 that enables PAE
Verify that when L2 guest enables PAE paging and L0 intercept of L2 MOV to CR0 reflects MTF exit to L1, subsequent resume to L2 correctly preserves PDPTE array specified by L2 CR3.
Signed-off-by: Jim Mattson <jmattson@google.com> Reviewed-by: Peter Shier <pshier@google.com> Signed-off-by: Peter Shier <pshier@google.com> Message-Id: <20200819205633.1393378-1-pshier@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
5b70cbdb | 22-Jun-2020 |
Claudio Imbrenda <imbrenda@linux.ibm.com> |
x86: add missing PAGE_ALIGN macro from page.h
The PAGE_ALIGN macro is present in all other page.h headers, including the generic one.
This patch adds the missing PAGE_ALIGN macro to ib/x86/asm/page
x86: add missing PAGE_ALIGN macro from page.h
The PAGE_ALIGN macro is present in all other page.h headers, including the generic one.
This patch adds the missing PAGE_ALIGN macro to ib/x86/asm/page.h
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-Id: <20200622162141.279716-3-imbrenda@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
71a6a145 | 17-Jan-2018 |
Andrew Jones <drjones@redhat.com> |
bitops: add fls
Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> |
4363f1d9 | 23-Oct-2017 |
Paolo Bonzini <pbonzini@redhat.com> |
x86: introduce pgd_t and pteval_t
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |