Skip to contentSkip to conversation

KVM: x86: Two KVM fixes and a selftest fix

GIT PULL Sean Christopherson 2 participants 2 messages Aug 21, 2025 – Aug 27, 2025

Subsystems (2)
lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

Please pull a few small KVM x86 fixes, along with a rather ugly selftest fix to resolve a collision with linux/overflow.h. Sadly, my attempt at a less ugly fix fell flat, as trying to share linux/overflow.h's definition doesn't work since not all selftests add tools/include to their include path.

Unrelated to this pull request, shameless plug for the guest_memfd mmap() series[1]. We'd like to get it merged sooner than later as there's a bit of a logjam of guest_memfd code piling up. And I've promised others I'll yolo it into kvm-x86 at the end of next week if necessary :-)

Thanks!

P.S. the guest_memfd mmap() series needs one minor fixup in patch 23[2]:

tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
index b86bf89a71e0..b3ca6737f304 100644
@@ -372,7 +372,7 @@ int main(int argc, char *argv[])
         */
        vm_types = kvm_check_cap(KVM_CAP_VM_TYPES);
        if (!vm_types)
-               vm_types = VM_TYPE_DEFAULT;
+               vm_types = BIT(VM_TYPE_DEFAULT);
 
        for_each_set_bit(vm_type, &vm_types, BITS_PER_TYPE(vm_types))
                test_guest_memfd(vm_type);

[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]

The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:

Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-6.17-rc7

for you to fetch changes up to dce1b33ed7430c7189b8cc1567498f9e6bf12731:

selftests: harness: Rename is_signed_type() to avoid collision with overflow.h (2025-08-20 08:04:09 -0700)

----------------------------------------------------------------
KVM x86 fixes and a selftest fix for 6.17-rcN

- Use array_index_nospec() to sanitize the target vCPU ID when handling PV IPIs and yields as the ID is guest-controlled.

- Drop a superfluous cpumask_empty() check when reclaiming SEV memory, as the common case, by far, is that at least one CPU will have entered the VM, and wbnoinvd_on_cpus_mask() will naturally handle the rare case where the set of have_run_cpus is empty.

- Rename the is_signed_type() macro in kselftest_harness.h to is_signed_var() to fix a collision with linux/overflow.h. The collision generates compiler warnings due to the two macros having different implementations.

----------------------------------------------------------------
Sean Christopherson (1):
selftests: harness: Rename is_signed_type() to avoid collision with overflow.h

Thijs Raymakers (1):
KVM: x86: use array_index_nospec with indices that come from guest

Yury Norov (1):
KVM: SEV: don't check have_run_cpus in sev_writeback_caches()

 arch/x86/kvm/lapic.c                        |  2 ++
 arch/x86/kvm/svm/sev.c                      | 10 +++-------
 arch/x86/kvm/x86.c                          |  7 +++++--
 tools/testing/selftests/kselftest_harness.h |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)
maintainer
#1 lore raw
Quoted 5 lines · Sean Christopherson

Please pull a few small KVM x86 fixes, along with a rather ugly selftest fix to resolve a collision with linux/overflow.h. Sadly, my attempt at a less ugly fix fell flat, as trying to share linux/overflow.h's definition doesn't work since not all selftests add tools/include to their include path.

Yes, I saw that from afar.

Quoted 4 lines

Unrelated to this pull request, shameless plug for the guest_memfd mmap() series[1]. We'd like to get it merged sooner than later as there's a bit of a logjam of guest_memfd code piling up. And I've promised others I'll yolo it into kvm-x86 at the end of next week if necessary :-)

Will pull it right after this one. Thanks!

Paolo

Quoted 65 lines

Thanks!

P.S. the guest_memfd mmap() series needs one minor fixup in patch 23[2]:

tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
index b86bf89a71e0..b3ca6737f304 100644
@@ -372,7 +372,7 @@ int main(int argc, char *argv[])
         */
        vm_types = kvm_check_cap(KVM_CAP_VM_TYPES);
        if (!vm_types)
-               vm_types = VM_TYPE_DEFAULT;
+               vm_types = BIT(VM_TYPE_DEFAULT);
 
        for_each_set_bit(vm_type, &vm_types, BITS_PER_TYPE(vm_types))
                test_guest_memfd(vm_type);

[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]

The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:

Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-6.17-rc7

for you to fetch changes up to dce1b33ed7430c7189b8cc1567498f9e6bf12731:

selftests: harness: Rename is_signed_type() to avoid collision with overflow.h (2025-08-20 08:04:09 -0700)

----------------------------------------------------------------
KVM x86 fixes and a selftest fix for 6.17-rcN

- Use array_index_nospec() to sanitize the target vCPU ID when handling PV IPIs and yields as the ID is guest-controlled.

- Drop a superfluous cpumask_empty() check when reclaiming SEV memory, as the common case, by far, is that at least one CPU will have entered the VM, and wbnoinvd_on_cpus_mask() will naturally handle the rare case where the set of have_run_cpus is empty.

- Rename the is_signed_type() macro in kselftest_harness.h to is_signed_var() to fix a collision with linux/overflow.h. The collision generates compiler warnings due to the two macros having different implementations.

----------------------------------------------------------------
Sean Christopherson (1):
selftests: harness: Rename is_signed_type() to avoid collision with overflow.h

Thijs Raymakers (1):
KVM: x86: use array_index_nospec with indices that come from guest

Yury Norov (1):
KVM: SEV: don't check have_run_cpus in sev_writeback_caches()

 arch/x86/kvm/lapic.c                        |  2 ++
 arch/x86/kvm/svm/sev.c                      | 10 +++-------
 arch/x86/kvm/x86.c                          |  7 +++++--
 tools/testing/selftests/kselftest_harness.h |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)