[GIT PULL] KVM fixes and cleanups for 6.8-rc5

From: Paolo Bonzini
Date: Fri Feb 16 2024 - 12:11:03 EST


Linus,

The following changes since commit 841c35169323cd833294798e58b9bf63fa4fa1de:

Linux 6.8-rc4 (2024-02-11 12:18:13 -0800)

are available in the Git repository at:

https://git.kernel.org/pub/scm/virt/kvm/kvm.git tags/for-linus

for you to fetch changes up to 9895ceeb5cd61092f147f8d611e2df575879dd6f:

Merge tag 'kvmarm-fixes-6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD (2024-02-16 12:02:38 -0500)

This pull request is mostly a mix of cleanups and fixes in the KVM
selftests, but there are also some small arch/ changes.

Paolo
----------------------------------------------------------------
ARM:

* Avoid dropping the page refcount twice when freeing an unlinked
page-table subtree.

* Don't source the VFIO Kconfig twice

* Fix protected-mode locking order between kvm and vcpus

RISC-V:

* Fix steal-time related sparse warnings

x86:

* Cleanup gtod_is_based_on_tsc() to return "bool" instead of an "int"

* Make a KVM_REQ_NMI request while handling KVM_SET_VCPU_EVENTS if and only
if the incoming events->nmi.pending is non-zero. If the target vCPU is in
the UNITIALIZED state, the spurious request will result in KVM exiting to
userspace, which in turn causes QEMU to constantly acquire and release
QEMU's global mutex, to the point where the BSP is unable to make forward
progress.

* Fix a type (u8 versus u64) goof that results in pmu->fixed_ctr_ctrl being
incorrectly truncated, and ultimately causes KVM to think a fixed counter
has already been disabled (KVM thinks the old value is '0').

* Fix a stack leak in KVM_GET_MSRS where a failed MSR read from userspace
that is ultimately ignored due to ignore_msrs=true doesn't zero the output
as intended.

Selftests cleanups and fixes:

* Remove redundant newlines from error messages.

* Delete an unused variable in the AMX test (which causes build failures when
compiling with -Werror).

* Fail instead of skipping tests if open(), e.g. of /dev/kvm, fails with an
error code other than ENOENT (a Hyper-V selftest bug resulted in an EMFILE,
and the test eventually got skipped).

* Fix TSC related bugs in several Hyper-V selftests.

* Fix a bug in the dirty ring logging test where a sem_post() could be left
pending across multiple runs, resulting in incorrect synchronization between
the main thread and the vCPU worker thread.

* Relax the dirty log split test's assertions on 4KiB mappings to fix false
positives due to the number of mappings for memslot 0 (used for code and
data that is NOT being dirty logged) changing, e.g. due to NUMA balancing.

----------------------------------------------------------------
Andrew Jones (8):
KVM: selftests: Remove redundant newlines
KVM: selftests: aarch64: Remove redundant newlines
KVM: selftests: riscv: Remove redundant newlines
KVM: selftests: s390x: Remove redundant newlines
KVM: selftests: x86_64: Remove redundant newlines
RISC-V: paravirt: steal_time should be static
RISC-V: paravirt: Use correct restricted types
RISC-V: KVM: Use correct restricted types

Masahiro Yamada (1):
KVM: arm64: Do not source virt/lib/Kconfig twice

Mathias Krause (1):
KVM: x86: Fix KVM_GET_MSRS stack info leak

Mingwei Zhang (1):
KVM: x86/pmu: Fix type length error when reading pmu->fixed_ctr_ctrl

Paolo Bonzini (5):
Merge tag 'kvm-x86-fixes-6.8-rcN' of https://github.com/kvm-x86/linux into HEAD
Merge tag 'kvm-x86-selftests-6.8-rcN' of https://github.com/kvm-x86/linux into HEAD
Merge tag 'kvm-riscv-fixes-6.8-1' of https://github.com/kvm-riscv/linux into HEAD
Merge tag 'kvmarm-fixes-6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
Merge tag 'kvmarm-fixes-6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD

Prasad Pandit (1):
KVM: x86: make KVM_REQ_NMI request iff NMI pending for vcpu

Sean Christopherson (4):
KVM: selftests: Reword the NX hugepage test's skip message to be more helpful
KVM: selftests: Delete superfluous, unused "stage" variable in AMX test
KVM: selftests: Fix a semaphore imbalance in the dirty ring logging test
KVM: selftests: Don't assert on exact number of 4KiB in dirty log split test

Sebastian Ene (1):
KVM: arm64: Fix circular locking dependency

Vitaly Kuznetsov (7):
KVM: selftests: Avoid infinite loop in hyperv_features when invtsc is missing
KVM: selftests: Fail tests when open() fails with !ENOENT
KVM: selftests: Generalize check_clocksource() from kvm_clock_test
KVM: selftests: Use generic sys_clocksource_is_tsc() in vmx_nested_tsc_scaling_test
KVM: selftests: Run clocksource dependent tests with hyperv_clocksource_tsc_page too
KVM: selftests: Make hyperv_clock require TSC based system clocksource
KVM: x86: Make gtod_is_based_on_tsc() return 'bool'

Will Deacon (1):
KVM: arm64: Fix double-free following kvm_pgtable_stage2_free_unlinked()

arch/arm64/kvm/Kconfig | 1 -
arch/arm64/kvm/hyp/pgtable.c | 2 -
arch/arm64/kvm/pkvm.c | 27 +++++++----
arch/riscv/kernel/paravirt.c | 6 +--
arch/riscv/kvm/vcpu_sbi_sta.c | 20 ++++----
arch/x86/kvm/vmx/pmu_intel.c | 2 +-
arch/x86/kvm/x86.c | 20 ++++----
tools/testing/selftests/kvm/aarch64/arch_timer.c | 12 ++---
tools/testing/selftests/kvm/aarch64/hypercalls.c | 16 +++----
.../selftests/kvm/aarch64/page_fault_test.c | 6 +--
tools/testing/selftests/kvm/aarch64/smccc_filter.c | 2 +-
.../selftests/kvm/aarch64/vpmu_counter_access.c | 12 ++---
tools/testing/selftests/kvm/demand_paging_test.c | 4 +-
tools/testing/selftests/kvm/dirty_log_perf_test.c | 4 +-
tools/testing/selftests/kvm/dirty_log_test.c | 54 ++++++++++++----------
tools/testing/selftests/kvm/get-reg-list.c | 2 +-
tools/testing/selftests/kvm/guest_print_test.c | 8 ++--
.../testing/selftests/kvm/hardware_disable_test.c | 6 +--
tools/testing/selftests/kvm/include/test_util.h | 2 +
.../selftests/kvm/include/x86_64/processor.h | 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/aarch64/vgic.c | 4 +-
tools/testing/selftests/kvm/lib/elf.c | 2 +-
tools/testing/selftests/kvm/lib/kvm_util.c | 19 ++++----
tools/testing/selftests/kvm/lib/memstress.c | 2 +-
tools/testing/selftests/kvm/lib/riscv/processor.c | 2 +-
tools/testing/selftests/kvm/lib/s390x/processor.c | 2 +-
tools/testing/selftests/kvm/lib/test_util.c | 25 ++++++++++
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 2 +-
tools/testing/selftests/kvm/lib/x86_64/processor.c | 21 +++++++--
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 6 +--
.../kvm/memslot_modification_stress_test.c | 2 +-
tools/testing/selftests/kvm/memslot_perf_test.c | 6 +--
tools/testing/selftests/kvm/riscv/get-reg-list.c | 2 +-
tools/testing/selftests/kvm/rseq_test.c | 4 +-
tools/testing/selftests/kvm/s390x/resets.c | 4 +-
tools/testing/selftests/kvm/s390x/sync_regs_test.c | 20 ++++----
.../testing/selftests/kvm/set_memory_region_test.c | 6 +--
.../selftests/kvm/system_counter_offset_test.c | 2 +-
tools/testing/selftests/kvm/x86_64/amx_test.c | 6 +--
tools/testing/selftests/kvm/x86_64/cpuid_test.c | 4 +-
.../kvm/x86_64/dirty_log_page_splitting_test.c | 21 +++++----
.../testing/selftests/kvm/x86_64/flds_emulation.h | 2 +-
tools/testing/selftests/kvm/x86_64/hyperv_clock.c | 5 +-
.../testing/selftests/kvm/x86_64/hyperv_features.c | 9 ++--
tools/testing/selftests/kvm/x86_64/hyperv_ipi.c | 2 +-
.../selftests/kvm/x86_64/hyperv_tlb_flush.c | 2 +-
.../testing/selftests/kvm/x86_64/kvm_clock_test.c | 42 ++---------------
.../selftests/kvm/x86_64/nx_huge_pages_test.c | 6 +--
.../selftests/kvm/x86_64/platform_info_test.c | 2 +-
.../selftests/kvm/x86_64/pmu_event_filter_test.c | 2 +-
.../selftests/kvm/x86_64/sev_migrate_tests.c | 28 +++++------
.../kvm/x86_64/smaller_maxphyaddr_emulation_test.c | 4 +-
.../testing/selftests/kvm/x86_64/sync_regs_test.c | 10 ++--
.../selftests/kvm/x86_64/ucna_injection_test.c | 8 ++--
.../selftests/kvm/x86_64/userspace_io_test.c | 2 +-
.../selftests/kvm/x86_64/vmx_apic_access_test.c | 2 +-
.../selftests/kvm/x86_64/vmx_dirty_log_test.c | 16 +++----
.../vmx_exception_with_invalid_guest_state.c | 2 +-
.../kvm/x86_64/vmx_nested_tsc_scaling_test.c | 19 +-------
.../testing/selftests/kvm/x86_64/xapic_ipi_test.c | 8 ++--
.../testing/selftests/kvm/x86_64/xcr0_cpuid_test.c | 2 +-
tools/testing/selftests/kvm/x86_64/xss_msr_test.c | 2 +-
65 files changed, 277 insertions(+), 276 deletions(-)