Skip to contentSkip to conversation

KVM: x86 pull requests for 6.10

DISCUSSION Sean Christopherson 2 participants 8 messages May 10, 2024 – May 12, 2024 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

Nothing notable to say here, this mail exits purely to be the parent.

author reviewer
#1 lore raw

[GIT PULL] KVM: Common changes for 6.10

Nothing too exciting, a few cleanups and a fix for GUEST_MEMFD docs.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-generic-6.10

for you to fetch changes up to 2098acaf24455698c149b27f0347eb4ddc6d2058:

KVM: fix documentation for KVM_CREATE_GUEST_MEMFD (2024-05-03 15:11:23 -0700)

----------------------------------------------------------------
KVM cleanups for 6.10:

- Misc cleanups extracted from the "exit on missing userspace mapping" series, which has been put on hold in anticipation of a "KVM Userfault" approach, which should provide a superset of functionality.

- Remove kvm_make_all_cpus_request_except(), which got added to hack around an AVIC bug, and then became dead code when a more robust fix came along.

- Fix a goof in the KVM_CREATE_GUEST_MEMFD documentation.

----------------------------------------------------------------
Anish Moorthy (3):
KVM: Clarify meaning of hva_to_pfn()'s 'atomic' parameter
KVM: Add function comments for __kvm_read/write_guest_page()
KVM: Simplify error handling in __gfn_to_pfn_memslot()

Carlos López (1):
KVM: fix documentation for KVM_CREATE_GUEST_MEMFD

Venkatesh Srinivas (1):
KVM: Remove kvm_make_all_cpus_request_except()

 Documentation/virt/kvm/api.rst |  2 +-
 include/linux/kvm_host.h       |  2 --
 virt/kvm/kvm_main.c            | 59 +++++++++++++++++-------------------------
 3 files changed, 25 insertions(+), 38 deletions(-)
author reviewer
#2 lore raw

[GIT PULL] KVM: x86: Misc changes for 6.10

In reply to Sean Christopherson

The max mappable GPA changes are the most notable, though unless we really botched the KVM implementation, they should be old news for you.

The other mildly interesting change is a fix for KVM's handling of userspace writes to immutable feature MSRs. The seemingly good idea of simply ignoring the writes, e.g. to avoid a problematic/useless PMU refresh, neglected to consider the fact that access to the MSR might be disallowed. E.g. the VMX MSRs are off limits if nested support is disabled.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-misc-6.10

for you to fetch changes up to 51937f2aae186e335175dde78279aaf0cb5e72ae:

KVM: x86: Remove VT-d mention in posted interrupt tracepoint (2024-05-02 07:54:14 -0700)

----------------------------------------------------------------
KVM x86 misc changes for 6.10:

- Advertise the max mappable GPA in the "guest MAXPHYADDR" CPUID field, which is unused by hardware, so that KVM can communicate its inability to map GPAs that set bits 51:48 due to lack of 5-level paging. Guest firmware is expected to use the information to safely remap BARs in the uppermost GPA space, i.e to avoid placing a BAR at a legal, but unmappable, GPA.

- Use vfree() instead of kvfree() for allocations that always use vcalloc() or __vcalloc().

- Don't completely ignore same-value writes to immutable feature MSRs, as doing so results in KVM failing to reject accesses to MSR that aren't supposed to exist given the vCPU model and/or KVM configuration.

- Don't mark APICv as being inhibited due to ABSENT if APICv is disabled KVM-wide to avoid confusing debuggers (KVM will never bother clearing the ABSENT inhibit, even if userspace enables in-kernel local APIC).

----------------------------------------------------------------
Alejandro Jimenez (2):
KVM: x86: Only set APICV_INHIBIT_REASON_ABSENT if APICv is enabled
KVM: x86: Remove VT-d mention in posted interrupt tracepoint

Gerd Hoffmann (2):
KVM: x86: Don't advertise guest.MAXPHYADDR as host.MAXPHYADDR in CPUID
KVM: x86: Advertise max mappable GPA in CPUID.0x80000008.GuestPhysBits

Li RongQing (1):
KVM: Use vfree for memory allocated by vcalloc()/__vcalloc()

Sean Christopherson (1):
KVM: x86: Allow, don't ignore, same-value writes to immutable MSRs

 arch/x86/kvm/cpuid.c          | 41 +++++++++++++++++++++++++++++++----------
 arch/x86/kvm/mmu.h            |  2 ++
 arch/x86/kvm/mmu/mmu.c        |  5 +++++
 arch/x86/kvm/mmu/page_track.c |  2 +-
 arch/x86/kvm/trace.h          |  4 ++--
 arch/x86/kvm/x86.c            | 28 +++++++++++-----------------
 virt/kvm/kvm_main.c           |  2 +-
 7 files changed, 53 insertions(+), 31 deletions(-)
author reviewer
#3 lore raw

[GIT PULL] KVM: x86: MMU changes for 6.10

In reply to Sean Christopherson

Tag says it all, though I feel the urge to have _something_ here.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-6.10

for you to fetch changes up to 226d9b8f16883ca412ef8efbad6f3594587a8dab:

KVM: x86/mmu: Fix a largely theoretical race in kvm_mmu_track_write() (2024-05-02 07:49:06 -0700)

----------------------------------------------------------------
KVM x86 MMU changes for 6.10:

- Process TDP MMU SPTEs that are are zapped while holding mmu_lock for read after replacing REMOVED_SPTE with '0' and flushing remote TLBs, which allows vCPU tasks to repopulate the zapped region while the zapper finishes tearing down the old, defunct page tables.

- Fix a longstanding, likely benign-in-practice race where KVM could fail to detect a write from kvm_mmu_track_write() to a shadowed GPTE if the GPTE is first page table being shadowed.

----------------------------------------------------------------
David Matlack (1):
KVM: x86/mmu: Process atomically-zapped SPTEs after TLB flush

Sean Christopherson (1):
KVM: x86/mmu: Fix a largely theoretical race in kvm_mmu_track_write()

 arch/x86/kvm/mmu/mmu.c     | 20 +++++++++++--
 arch/x86/kvm/mmu/tdp_mmu.c | 75 ++++++++++++++++++++++++++++++----------------
 2 files changed, 66 insertions(+), 29 deletions(-)
author reviewer
#4 lore raw

[GIT PULL] KVM: Selftests cleanups and fixes for 6.10

In reply to Sean Christopherson

This is 1 of 2 selftests pull request for 6.10. This is (by far) the smaller of the two, and contains fairly localized changes. The most notable fix is to skip tests as needed if the host doesn't support KVM_CAP_USER_MEMORY2, as the selftests currently just fail miserably on KVM_SET_USER_MEMORY_REGION2.

More details about why there are two pull requests in 2 of 2.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests-6.10

for you to fetch changes up to 8a53e13021330a25775a31ced44fbec2225a9443:

KVM: selftests: Require KVM_CAP_USER_MEMORY2 for tests that create memslots (2024-05-02 16:12:28 -0700)

----------------------------------------------------------------
KVM selftests cleanups and fixes for 6.10:

- Enhance the demand paging test to allow for better reporting and stressing of UFFD performance.

- Convert the steal time test to generate TAP-friendly output.

- Fix a flaky false positive in the xen_shinfo_test due to comparing elapsed time across two different clock domains.

- Skip the MONITOR/MWAIT test if the host doesn't actually support MWAIT.

- Avoid unnecessary use of "sudo" in the NX hugepage test to play nice with running in a minimal userspace environment.

- Allow skipping the RSEQ test's sanity check that the vCPU was able to complete a reasonable number of KVM_RUNs, as the assert can fail on a completely valid setup. If the test is run on a large-ish system that is otherwise idle, and the test isn't affined to a low-ish number of CPUs, the vCPU task can be repeatedly migrated to CPUs that are in deep sleep states, which results in the vCPU having very little net runtime before the next migration due to high wakeup latencies.

----------------------------------------------------------------
Anish Moorthy (3):
KVM: selftests: Report per-vcpu demand paging rate from demand paging test
KVM: selftests: Allow many vCPUs and reader threads per UFFD in demand paging test
KVM: selftests: Use EPOLL in userfaultfd_util reader threads

Brendan Jackman (1):
KVM: selftests: Avoid assuming "sudo" exists in NX hugepage test

Colin Ian King (1):
KVM: selftests: Remove second semicolon

Sean Christopherson (1):
KVM: selftests: Require KVM_CAP_USER_MEMORY2 for tests that create memslots

Thomas Huth (1):
KVM: selftests: Use TAP in the steal_time test

Vitaly Kuznetsov (1):
KVM: selftests: Compare wall time from xen shinfo against KVM_GET_CLOCK

Zide Chen (2):
KVM: selftests: Make monitor_mwait require MONITOR/MWAIT feature
KVM: selftests: Allow skipping the KVM_RUN sanity check in rseq_test

 .../selftests/kvm/aarch64/page_fault_test.c        |   4 +-
 tools/testing/selftests/kvm/demand_paging_test.c   |  90 +++++++++---
 .../selftests/kvm/include/userfaultfd_util.h       |  16 ++-
 tools/testing/selftests/kvm/lib/kvm_util.c         |   8 ++
 tools/testing/selftests/kvm/lib/userfaultfd_util.c | 153 ++++++++++++---------
 tools/testing/selftests/kvm/rseq_test.c            |  35 ++++-
 tools/testing/selftests/kvm/steal_time.c           |  47 +++----
 .../selftests/kvm/x86_64/monitor_mwait_test.c      |   1 +
 .../selftests/kvm/x86_64/nx_huge_pages_test.sh     |  13 +-
 .../testing/selftests/kvm/x86_64/xen_shinfo_test.c |  52 +++----
 10 files changed, 282 insertions(+), 137 deletions(-)
author reviewer
#5 lore raw

[GIT PULL] KVM: Selftests "tree"-wide changes for 6.10

In reply to Sean Christopherson

Selftests pull request 2 of 2. I put these changes into a separate branch so that other arch maintainers had a stable target to build on, though AFAIK there are no branches that depend on this, nor that conflict with this.

The most annoying change is to revert kvm_util_base.h back to kvm_util.h. The _entire_ reason for the layer of inclusion indirection was to avoid a handful of explicit ucall_common.h #includes. /facepalm

The other wide-sweeping change is to define _GNU_SOURCE in the Makefile, mostly in response to an annoying warning that was introduced late in 6.9 due kselftest_harness.h using a _GNU_SOURCE-only function, but not guaranteeing that _GNU_SOURCE was defined before stdio.h was first included (I think that was the offending #include).

Long story short, it was/is a bit of a mess, and there will likely be a true tree-wide tools series/patch coming along early in 6.10 to essentially give all of tools the same treatment, i.e. define _GNU_SOURCE for everything. We shouldn't *need* to do anything, though if/when that lands, we may need to remove the definition from KVM selftests' Makefile (like I said, it's a mess).

The following changes since commit a96cb3bf390eebfead5fc7a2092f8452a7997d1b:

Merge x86 bugfixes from Linux 6.9-rc3 (2024-04-19 09:02:22 -0400)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests_utils-6.10

for you to fetch changes up to b093f87fd1957cdfbe518d5bb2caa39ba80c1669:

KVM: selftests: Drop @selector from segment helpers (2024-04-29 12:55:22 -0700)

----------------------------------------------------------------
KVM selftests treewide updates for 6.10:

- Define _GNU_SOURCE for all selftests to fix a warning that was introduced by a change to kselftest_harness.h late in the 6.9 cycle, and because forcing every test to #define _GNU_SOURCE is painful.

- Provide a global psuedo-RNG instance for all tests, so that library code can generate random, but determinstic numbers.

- Use the global pRNG to randomly force emulation of select writes from guest code on x86, e.g. to help validate KVM's emulation of locked accesses.

- Rename kvm_util_base.h back to kvm_util.h, as the weird layer of indirection was added purely to avoid manually #including ucall_common.h in a handful of locations.

- Allocate and initialize x86's GDT, IDT, TSS, segments, and default exception handlers at VM creation, instead of forcing tests to manually trigger the related setup.

----------------------------------------------------------------
Ackerley Tng (1):
KVM: selftests: Fix off-by-one initialization of GDT limit

Sean Christopherson (23):
KVM: selftests: Define _GNU_SOURCE for all selftests code
KVM: selftests: Provide a global pseudo-RNG instance for all tests
KVM: selftests: Provide an API for getting a random bool from an RNG
KVM: selftests: Add global snapshot of kvm_is_forced_emulation_enabled()
KVM: selftests: Add vcpu_arch_put_guest() to do writes from guest code
KVM: selftests: Randomly force emulation on x86 writes from guest code Revert "kvm: selftests: move base kvm_util.h declarations to kvm_util_base.h"
KVM: sefltests: Add kvm_util_types.h to hold common types, e.g. vm_vaddr_t
KVM: selftests: Move GDT, IDT, and TSS fields to x86's kvm_vm_arch
KVM: selftests: Move platform_info_test's main assert into guest code
KVM: selftests: Rework platform_info_test to actually verify #GP
KVM: selftests: Explicitly clobber the IDT in the "delete memslot" testcase
KVM: selftests: Move x86's descriptor table helpers "up" in processor.c
KVM: selftests: Rename x86's vcpu_setup() to vcpu_init_sregs()
KVM: selftests: Init IDT and exception handlers for all VMs/vCPUs on x86
KVM: selftests: Map x86's exception_handlers at VM creation, not vCPU setup
KVM: selftests: Allocate x86's GDT during VM creation
KVM: selftests: Drop superfluous switch() on vm->mode in vcpu_init_sregs()
KVM: selftests: Fold x86's descriptor tables helpers into vcpu_init_sregs()
KVM: selftests: Allocate x86's TSS at VM creation
KVM: selftests: Add macro for TSS selector, rename up code/data macros
KVM: selftests: Init x86's segments during VM creation
KVM: selftests: Drop @selector from segment helpers

 tools/testing/selftests/kvm/Makefile               |    4 +-
 tools/testing/selftests/kvm/aarch64/arch_timer.c   |    3 +-
 .../selftests/kvm/aarch64/page_fault_test.c        |    1 -
 tools/testing/selftests/kvm/aarch64/psci_test.c    |    3 -
 tools/testing/selftests/kvm/aarch64/vgic_init.c    |    1 -
 tools/testing/selftests/kvm/arch_timer.c           |    4 +-
 tools/testing/selftests/kvm/demand_paging_test.c   |    4 +-
 tools/testing/selftests/kvm/dirty_log_perf_test.c  |   10 +-
 tools/testing/selftests/kvm/dirty_log_test.c       |   26 +-
 tools/testing/selftests/kvm/guest_memfd_test.c     |    4 +-
 tools/testing/selftests/kvm/guest_print_test.c     |    1 +
 .../testing/selftests/kvm/hardware_disable_test.c  |    3 -
 .../selftests/kvm/include/aarch64/processor.h      |    2 +
 .../testing/selftests/kvm/include/aarch64/ucall.h  |    2 +-
 tools/testing/selftests/kvm/include/kvm_util.h     | 1111 +++++++++++++++++++-
 .../testing/selftests/kvm/include/kvm_util_base.h  |   15 +-
 .../testing/selftests/kvm/include/kvm_util_types.h |   20 +
 tools/testing/selftests/kvm/include/memstress.h    |    1 -
 tools/testing/selftests/kvm/include/s390x/ucall.h  |    2 +-
 tools/testing/selftests/kvm/include/test_util.h    |   19 +
 .../selftests/kvm/include/userfaultfd_util.h       |    3 -
 .../selftests/kvm/include/x86_64/kvm_util_arch.h   |   28 +
 .../selftests/kvm/include/x86_64/processor.h       |    5 +-
 tools/testing/selftests/kvm/include/x86_64/ucall.h |    2 +-
 .../testing/selftests/kvm/kvm_binary_stats_test.c  |    2 -
 tools/testing/selftests/kvm/kvm_create_max_vcpus.c |    2 -
 tools/testing/selftests/kvm/kvm_page_table_test.c  |    4 +-
 .../testing/selftests/kvm/lib/aarch64/processor.c  |    2 +
 tools/testing/selftests/kvm/lib/assert.c           |    3 -
 tools/testing/selftests/kvm/lib/kvm_util.c         |   12 +-
 tools/testing/selftests/kvm/lib/memstress.c        |   13 +-
 tools/testing/selftests/kvm/lib/riscv/processor.c  |    1 +
 tools/testing/selftests/kvm/lib/test_util.c        |    2 -
 tools/testing/selftests/kvm/lib/ucall_common.c     |    5 +-
 tools/testing/selftests/kvm/lib/userfaultfd_util.c |    3 -
 tools/testing/selftests/kvm/lib/x86_64/processor.c |  308 +++---
 tools/testing/selftests/kvm/lib/x86_64/sev.c       |    1 -
 .../testing/selftests/kvm/max_guest_memory_test.c  |    2 -
 .../kvm/memslot_modification_stress_test.c         |    3 -
 tools/testing/selftests/kvm/riscv/arch_timer.c     |    4 +-
 tools/testing/selftests/kvm/rseq_test.c            |   13 +-
 tools/testing/selftests/kvm/s390x/cmma_test.c      |    3 +-
 tools/testing/selftests/kvm/s390x/memop.c          |    1 +
 tools/testing/selftests/kvm/s390x/sync_regs_test.c |    2 -
 tools/testing/selftests/kvm/s390x/tprot.c          |    1 +
 .../testing/selftests/kvm/set_memory_region_test.c |   13 +-
 tools/testing/selftests/kvm/steal_time.c           |    2 +-
 tools/testing/selftests/kvm/x86_64/amx_test.c      |    4 -
 .../kvm/x86_64/dirty_log_page_splitting_test.c     |    1 +
 .../kvm/x86_64/exit_on_emulation_failure_test.c    |    5 +-
 .../selftests/kvm/x86_64/fix_hypercall_test.c      |    2 -
 tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c |    2 -
 tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c  |    2 -
 tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c  |    3 -
 .../testing/selftests/kvm/x86_64/hyperv_features.c |    6 -
 tools/testing/selftests/kvm/x86_64/hyperv_ipi.c    |    5 -
 .../testing/selftests/kvm/x86_64/hyperv_svm_test.c |    1 -
 .../selftests/kvm/x86_64/hyperv_tlb_flush.c        |    2 -
 tools/testing/selftests/kvm/x86_64/kvm_pv_test.c   |    3 -
 .../selftests/kvm/x86_64/monitor_mwait_test.c      |    3 -
 .../selftests/kvm/x86_64/nested_exceptions_test.c  |    2 -
 .../selftests/kvm/x86_64/nx_huge_pages_test.c      |    3 -
 .../selftests/kvm/x86_64/platform_info_test.c      |   61 +-
 .../selftests/kvm/x86_64/pmu_counters_test.c       |    8 -
 .../selftests/kvm/x86_64/pmu_event_filter_test.c   |    9 -
 .../kvm/x86_64/private_mem_conversions_test.c      |    1 -
 .../testing/selftests/kvm/x86_64/set_boot_cpu_id.c |    1 -
 .../testing/selftests/kvm/x86_64/set_sregs_test.c  |    1 -
 .../kvm/x86_64/smaller_maxphyaddr_emulation_test.c |    6 -
 tools/testing/selftests/kvm/x86_64/smm_test.c      |    1 -
 tools/testing/selftests/kvm/x86_64/state_test.c    |    1 -
 .../selftests/kvm/x86_64/svm_int_ctl_test.c        |    3 -
 .../kvm/x86_64/svm_nested_shutdown_test.c          |    5 +-
 .../kvm/x86_64/svm_nested_soft_inject_test.c       |    5 +-
 .../testing/selftests/kvm/x86_64/sync_regs_test.c  |    2 -
 .../selftests/kvm/x86_64/ucna_injection_test.c     |    7 -
 .../selftests/kvm/x86_64/userspace_msr_exit_test.c |   15 +-
 .../selftests/kvm/x86_64/vmx_dirty_log_test.c      |    3 -
 .../vmx_exception_with_invalid_guest_state.c       |    3 -
 .../selftests/kvm/x86_64/vmx_pmu_caps_test.c       |    4 -
 .../kvm/x86_64/vmx_preemption_timer_test.c         |    1 -
 .../testing/selftests/kvm/x86_64/xapic_ipi_test.c  |    4 -
 .../selftests/kvm/x86_64/xapic_state_test.c        |    1 -
 .../testing/selftests/kvm/x86_64/xcr0_cpuid_test.c |    3 -
 .../testing/selftests/kvm/x86_64/xen_shinfo_test.c |    7 +-
 tools/testing/selftests/kvm/x86_64/xss_msr_test.c  |    2 -
 86 files changed, 1423 insertions(+), 451 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/include/kvm_util_types.h
author reviewer
#6 lore raw

[GIT PULL] KVM: x86: VMX changes for 6.10

In reply to Sean Christopherson

Minor fixes related to EXIT_QUALIFICATION and EPT Misconfigs.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-vmx-6.10

for you to fetch changes up to 23ffe4bbf807c34cd5374f3e53196ccc459707f4:

KVM: nVMX: Add a sanity check that nested PML Full stems from EPT Violations (2024-04-09 10:24:36 -0700)

----------------------------------------------------------------
KVM VMX changes for 6.10:

- Clear vmcs.EXIT_QUALIFICATION when synthesizing an EPT Misconfig VM-Exit to L1, as per the SDM.

- Move kvm_vcpu_arch's exit_qualification into x86_exception, as the field is used only when synthesizing nested EPT violation, i.e. it's not the vCPU's "real" exit_qualification, which is tracked elsewhere.

- Add a sanity check to assert that EPT Violations are the only sources of nested PML Full VM-Exits.

----------------------------------------------------------------
Sean Christopherson (3):
KVM: nVMX: Clear EXIT_QUALIFICATION when injecting an EPT Misconfig
KVM: x86: Move nEPT exit_qualification field from kvm_vcpu_arch to x86_exception
KVM: nVMX: Add a sanity check that nested PML Full stems from EPT Violations

 arch/x86/include/asm/kvm_host.h |  3 ---
 arch/x86/kvm/kvm_emulate.h      |  1 +
 arch/x86/kvm/mmu/paging_tmpl.h  | 14 +++++++-------
 arch/x86/kvm/vmx/nested.c       | 30 ++++++++++++++++++++++++++----
 arch/x86/kvm/vmx/vmx.c          |  2 --
 5 files changed, 34 insertions(+), 16 deletions(-)