History log of /kvm-unit-tests/lib/x86/setup.c (Results 1 – 25 of 44)
Revision Date Author Comments
# dca3f4c0 24-Feb-2025 Paolo Bonzini <pbonzini@redhat.com>

Merge tag 'kvm-x86-2025.02.21' of https://github.com/kvm-x86/kvm-unit-tests into HEAD

KVM-Unit-Tests x86 changes:

- Expand the per-CPU data+stack area to 12KiB per CPU to reduce the
probability

Merge tag 'kvm-x86-2025.02.21' of https://github.com/kvm-x86/kvm-unit-tests into HEAD

KVM-Unit-Tests x86 changes:

- Expand the per-CPU data+stack area to 12KiB per CPU to reduce the
probability of tests overflowing their stack and clobbering pre-CPU
data.

- Add testcases for LA57 canonical checks.

- Add testcases for LAM.

- Add a smoke test to make sure KVM doesn't bleed split-lock #AC/#DB into
the guest.

- Fix many warts and bugs in the PMU test, and prepare it for PMU version 5
and beyond.

- Many misc fixes and cleanups.

show more ...


# 2821b32d 15-Feb-2025 Sean Christopherson <seanjc@google.com>

x86: Add a macro for the size of the per-CPU stack/data area

Add a macro to define the size of the per-CPU stack/data area so that it's
somewhat possible to make sense of the madness.

Link: https:/

x86: Add a macro for the size of the per-CPU stack/data area

Add a macro to define the size of the per-CPU stack/data area so that it's
somewhat possible to make sense of the madness.

Link: https://lore.kernel.org/r/20250215012032.1206409-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

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


# 169f786f 30-May-2023 Alexandru Elisei <alexandru.elisei@arm.com>

lib/acpi: Convert table names to Linux style

kvm-unit-tests is about to import several table struct definitions from
Linux, convert the names of the existing tables to follow the Linux style.

This

lib/acpi: Convert table names to Linux style

kvm-unit-tests is about to import several table struct definitions from
Linux, convert the names of the existing tables to follow the Linux style.

This is purely a cosmetic change and no functional change is intended.

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

show more ...


# 879e7f07 02-Nov-2022 Like Xu <likexu@tencent.com>

x86/pmu: Snapshot PMU perf_capabilities during BSP initialization

Add a global "struct pmu_caps pmu" to snapshot PMU capabilities
during the final stages of BSP initialization. Use the new hooks to

x86/pmu: Snapshot PMU perf_capabilities during BSP initialization

Add a global "struct pmu_caps pmu" to snapshot PMU capabilities
during the final stages of BSP initialization. Use the new hooks to
snapshot PERF_CAPABILITIES instead of re-reading the MSR every time a
test wants to query capabilities. A software-defined struct will also
simplify extending support to AMD CPUs, as many of the differences
between AMD and Intel can be handled during pmu_init().

Init the PMU caps for all tests so that tests don't need to remember to
call pmu_init() before using any of the PMU helpers, e.g. the nVMX test
uses this_cpu_has_pmu(), which will be converted to rely on the global
struct in a future patch.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Like Xu <likexu@tencent.com>
[sean: reword changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20221102225110.3023543-16-seanjc@google.com

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 ...


# 350e77c3 23-Aug-2022 Vasant Karasulli <vkarasulli@suse.de>

x86: efi: set up the IDT before accessing MSRs.

Reading or writing MSR_IA32_APICBASE is typically an intercepted
operation and causes #VC exception when the test is launched as
an SEV-ES guest.

So

x86: efi: set up the IDT before accessing MSRs.

Reading or writing MSR_IA32_APICBASE is typically an intercepted
operation and causes #VC exception when the test is launched as
an SEV-ES guest.

So calling pre_boot_apic_id() and reset_apic() before the IDT is
set up in setup_idt() and load_idt() might cause problems.

Hence move percpu data setup and reset_apic() call after
setup_idt() and load_idt().

Fixes: 3c50214c97f173f5e0f82c7f248a7c62707d8748 (x86: efi: Provide percpu storage)
Signed-off-by: Vasant Karasulli <vkarasulli@suse.de>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220823094328.8458-1-vkarasulli@suse.de
Signed-off-by: Sean Christopherson <seanjc@google.com>

show more ...


# 14b54ed7 26-Jul-2022 Paolo Bonzini <pbonzini@redhat.com>

Merge tag 'for_paolo' of https://github.com/sean-jc/kvm-unit-tests into HEAD

x86 fixes, cleanups, and new sub-tests:

- Bug fix for the VMX-preemption timer expiration test
- Refactor SVM tests

Merge tag 'for_paolo' of https://github.com/sean-jc/kvm-unit-tests into HEAD

x86 fixes, cleanups, and new sub-tests:

- Bug fix for the VMX-preemption timer expiration test
- Refactor SVM tests to split out NPT tests
- Add tests for MCE banks to MSR test
- Add SMP Support for x86 UEFI tests
- x86: nVMX: Add VMXON #UD test (and exception cleanup)
- PMU cleanup and related nVMX bug fixes

show more ...


# cd6bfb1d 15-Jun-2022 Sean Christopherson <seanjc@google.com>

x86: Add ap_online() to consolidate final "AP is alive!" code

Add ap_online() to consolidate the last stage of onlining an AP CPU.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https

x86: Add ap_online() to consolidate final "AP is alive!" code

Add ap_online() to consolidate the last stage of onlining an AP CPU.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-14-seanjc@google.com

show more ...


# 0afd4dd0 15-Jun-2022 Sean Christopherson <seanjc@google.com>

x86: Rename ap_init() to bringup_aps()

Rename the helper that wakes and waits for APs to bringup_aps(), ap_init()
is terribly confusing because it's called from the BSP, not APs.

Signed-off-by: Sea

x86: Rename ap_init() to bringup_aps()

Rename the helper that wakes and waits for APs to bringup_aps(), ap_init()
is terribly confusing because it's called from the BSP, not APs.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-13-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 ...


# 1542cd7b 15-Jun-2022 Varad Gautam <varad.gautam@suse.com>

x86: efi, smp: Transition APs from 16-bit to 32-bit mode

Sending INIT/SIPI to APs from ap_init() resets them into 16-bit mode
to loop into sipi_entry().

To drive the APs into 32-bit mode, the SIPI

x86: efi, smp: Transition APs from 16-bit to 32-bit mode

Sending INIT/SIPI to APs from ap_init() resets them into 16-bit mode
to loop into sipi_entry().

To drive the APs into 32-bit mode, the SIPI vector needs:
1. A GDT descriptor reachable from 16-bit code (gdt32_descr).
2. A 32-bit entrypoint reachable from 16-bit code (ap_start32).
3. The locations of GDT and the 32-bit entrypoint.

Setting these up at compile time (like on non-EFI builds) is not
possible since EFI builds with -shared -fPIC and efistart64.S cannot
reference any absolute addresses.

Relative addressing is unavailable on 16-bit mode.

Moreover, EFI may not load the 32-bit entrypoint to be reachable from
16-bit mode.

To overcome these problems,
1. Fill the GDT descriptor at runtime after relocating
[sipi_entry-sipi_end] to lowmem. Since sipi_entry does not know the
address of this descriptor, use the last two bytes of SIPI page to
communicate it.
2. Place a call gate in the GDT to point to ap_start32.
3. Popluate sipi_entry() to lcall to ap_start32.

With this, the APs can transition to 32-bit mode and loop at a known
location.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-11-seanjc@google.com

show more ...


# 3c50214c 15-Jun-2022 Varad Gautam <varad.gautam@suse.com>

x86: efi: Provide percpu storage

UEFI tests do not update MSR_GS_BASE during bringup, and continue
using the GS_BASE set up by the UEFI implementation for percpu
storage.

Update this MSR during set

x86: efi: Provide percpu storage

UEFI tests do not update MSR_GS_BASE during bringup, and continue
using the GS_BASE set up by the UEFI implementation for percpu
storage.

Update this MSR during setup_segments64() to allow storing percpu
data at a sane location reserved by the testcase, and ensure that
this happens before any operation that ends up storing to the percpu
space.

Since apic_ops (touched by reset_apic()) is percpu, move reset_apic()
to happen after setup_gdt_tss(); pre_boot_apic_id() works with either
xAPIC or x2APIC, so it's not necessary to put the APIC back into xAPIC]
mode prior to configuring the per-vCPU TSS, GS.base, etc...

With this, ap_init() can now use percpu apic_ops via apic_icr_write().

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
[sean: add comment to call out GS.base dependency]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-9-seanjc@google.com

show more ...


# 77b681d3 15-Jun-2022 Varad Gautam <varad.gautam@suse.com>

x86: Move load_gdt_tss() to desc.c

Split load_gdt_tss() functionality into:
1. Load gdt/tss
2. Setup segments in 64-bit mode and update %cs via far-return

and move load_gdt_tss() to desc.c to share

x86: Move load_gdt_tss() to desc.c

Split load_gdt_tss() functionality into:
1. Load gdt/tss
2. Setup segments in 64-bit mode and update %cs via far-return

and move load_gdt_tss() to desc.c to share this code between
EFI and non-EFI tests.

Move the segment setup code specific to EFI into
setup.c:setup_segments64().

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-7-seanjc@google.com

show more ...


# b397e5a5 15-Jun-2022 Varad Gautam <varad.gautam@suse.com>

x86: Move load_idt() to desc.c

This allows sharing IDT setup code between EFI (-fPIC) and
non-EFI builds.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Sean Christopherson <sea

x86: Move load_idt() to desc.c

This allows sharing IDT setup code between EFI (-fPIC) and
non-EFI builds.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-5-seanjc@google.com

show more ...


# d36b378f 15-Jun-2022 Varad Gautam <varad.gautam@suse.com>

x86: Move ap_init() to smp.c

ap_init() copies the SIPI vector to lowmem, sends INIT/SIPI to APs
and waits on the APs to come up.

Port this routine to C from asm and move it to smp.c to allow sharin

x86: Move ap_init() to smp.c

ap_init() copies the SIPI vector to lowmem, sends INIT/SIPI to APs
and waits on the APs to come up.

Port this routine to C from asm and move it to smp.c to allow sharing
this functionality between the EFI (-fPIC) and non-EFI builds.

Call ap_init() from the EFI setup path to reset the APs to a known
location.

Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220615232943.1465490-4-seanjc@google.com

show more ...


# d8de5a33 21-Jan-2022 Sean Christopherson <seanjc@google.com>

x86: Always use legacy xAPIC to get APIC ID during TSS setup

Force use of xAPIC to retrieve the APIC ID during TSS setup to fix an
issue where an AP can switch apic_ops to point at x2apic_ops before

x86: Always use legacy xAPIC to get APIC ID during TSS setup

Force use of xAPIC to retrieve the APIC ID during TSS setup to fix an
issue where an AP can switch apic_ops to point at x2apic_ops before
setup_tss() completes, leading to a #GP and triple fault due to trying
to read an x2APIC MSR without x2APIC being enabled.

A future patch will make apic_ops a per-cpu pointer, but that's not of
any help for 32-bit, which uses the APIC ID to determine the GS selector,
i.e. 32-bit KUT has a chicken-and-egg problem. All setup_tss() callers
ensure the local APIC is in xAPIC mode, so just force use of xAPIC in
this case.

Fixes: 7e33895 ("x86: Move 32-bit GDT and TSS to desc.c")
Fixes: dbd3800 ("x86: Move 64-bit GDT and TSS to desc.c")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220121231852.1439917-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 832e1c15 06-Apr-2022 Varad Gautam <varad.gautam@suse.com>

x86: efi: Fix pagetable creation

setup_page_table() ends up filling invalid page table entries
at ptl2 due to improper typecasting. This sometimes leads to
unhandled pagefaults when writing to APIC

x86: efi: Fix pagetable creation

setup_page_table() ends up filling invalid page table entries
at ptl2 due to improper typecasting. This sometimes leads to
unhandled pagefaults when writing to APIC registers. Fix it.

Fixes: e6f65fa464 ("x86 UEFI: Set up page tables")
Signed-off-by: Varad Gautam <varad.gautam@suse.com>
Message-Id: <20220406123312.12986-1-varad.gautam@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 1399f7f7 14-Mar-2022 Andrew Jones <drjones@redhat.com>

Merge branch 'misc/queue' into 'master'

misc/queue: Rename TARGET_EFI to CONFIG_EFI

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


# 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 ...


# 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.


# 8238fdca 18-Jan-2022 Paolo Bonzini <pbonzini@redhat.com>

x86 AMD SEV: Skip SEV-ES if SEV is unsupported

Skip the SEV-ES setup if SEV is unsupported. Also update the printf to
include error codes.

Suggested-by: Sean Christopherson <seanjc@google.com>
Sign

x86 AMD SEV: Skip SEV-ES if SEV is unsupported

Skip the SEV-ES setup if SEV is unsupported. Also update the printf to
include error codes.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 91abf0b9 10-Nov-2021 Paolo Bonzini <pbonzini@redhat.com>

Merge branch 'gdt-idt-cleanup' into master


# 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 ...


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

x86 AMD SEV-ES: Set up GHCB page

AMD SEV-ES introduces a GHCB page for guest/host communication. This
page should be unencrypted, i.e. its c-bit should be unset, otherwise
the guest VM may crash whe

x86 AMD SEV-ES: Set up GHCB page

AMD SEV-ES introduces a GHCB page for guest/host communication. This
page should be unencrypted, i.e. its c-bit should be unset, otherwise
the guest VM may crash when #VC exception happens.

By default, KVM-Unit-Tests only sets up 2MiB pages, i.e. only Level 2
page table entries are provided. Unsetting GHCB Level 2 pte's c-bit
still crashes the guest VM. The solution is to unset only its Level 1
pte's c-bit.

This commit provides GHCB page set up code that:

1. finds GHCB Level 1 pte
2. if not found, installs corresponding Level 1 pages
3. unsets GHCB Level 1 pte's c-bit

In this commit, KVM-Unit-Tests can run in an SEV-ES VM and boot into
test cases' main().

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

show more ...


12