Skip to contentSkip to conversation

KVM: Fixes for 7.4-rcN

GIT PULL Sean Christopherson 2 participants 3 messages Nov 19 – Nov 21 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

Please pull a somewhat random smattering of fixes. The biggest (but probably not scariest?) is to rework single-vCPU kicks to ensure waiting requests actually wait. It's big only because PPC is weird and required refactoring a bunch of code just to avoid throwing in more hacks. Including this many patches obviously isn't ideal, but failing to wait breaks the flow to force vCPUs to invalidate their SNP VMSA. Prior to 7.4 the race condition was all but impossible to hit, but in-place conversion makes it a *lot* easier to hit the window, which is why I included the fix here.

Speaking of PPC, the scariest fix for me is the patch to actually implement kvm_arch_flush_shadow_all(). Some PPC folks reviewed it, so it's probably good? But I'm still flabbergasted that such a blatant bug has gone unnoticed for so long, which makes we worried I'm missing something.

The following changes since commit 7475ea8b58616b33c04afb976cf0fbaad9dd63fb:

Linux 7.4-rc2 (2026-11-08 16:22:20 -0800)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-7.4-rc4

for you to fetch changes up to bcc359264f15095d3d167535cf5de0b7e4800279:

KVM: nVMX: Clear nested.smm.guest_mode on a failed RSM-to-L2 (2026-11-10 14:42:26 -0800)

----------------------------------------------------------------
KVM fixes for 7.4-rcN

- Mitigate a class of (x86) bugs where KVM can read/write guest (userspace) memory using the wrong mm, i.e. using the wrong user page tables.

- Don't force a full nested VMX VM-Exit when destroying a vCPU, as processing the MSR load/store lists and writing back the shadow vmcs12 is wildly wrong when VM is dying.

- Implement "flush shadow all" on KVM PPC to ensure KVM's mappings are torn down when the VM and/or owning process is dying.

- Provide empty installation rules for architectures that aren't supported by KVM selftests to fix build issues in CI environments.

- Fix KVM selftests' rules for generating arm64's sysreg headers so that the headers are properly (re)generated on incremental builds.

- Clear only the VMCB save area on an intercepted SHUTDOWN on SVM, partly to avoid unnecessary churn, but mostly to prevent KVM from clobbering the PML index.

- Update the tracked pCPU on task migration for both vmcb01 and vmcb02 to fix an edge case where KVM can use a stale ASID across pCPUs.

- Rework the single-vCPU kick logic to fix a bug where KVM would fail to wait for a target vCPU to respond if another in-flight, non-waiting kick changed the vCPU's mode to EXITING_GUEST_MODE.

- Clear nVMX's smm.guest_most when freeing nested state, and if a RSM to L2 ultimately fails (and queues a TRIPLE_FAULT to L1).
----------------------------------------------------------------
Amirmohammad Eftekhar (1):
KVM: nVMX: Clear nested.smm.guest_mode on a failed RSM-to-L2

Fuad Tabba (1):
KVM: selftests: Fix arm64 sysreg header dependencies

Josef Bacik (1):
KVM: nVMX: Clear nested.smm.guest_mode when freeing nested state

Sasha Levin (1):
KVM: selftests: Provide empty installation rules on unsupported ARCHs

Sean Christopherson (10):
KVM: Reject user accesses to guest memory if current->mm != kvm->mm
KVM: nVMX: Don't force a full nested VM-Exit when destroying a vCPU
KVM: PPC: Flush/zap all memslots on kvm_arch_flush_shadow_all()
KVM: s390: Drop unused and unreachable kvm_arch_vcpu_should_kick()
KVM: Add a @force param to __kvm_vcpu_kick() for PPC backwards compatibility
KVM: PPC: Explicitly force IPIs when directly kicking vCPUs
KVM: MIPS: Rework kvm_arch_vcpu_should_kick() to use standard implementation
KVM: Move kvm_arch_vcpu_should_kick() to common code as kvm_vcpu_should_kick()
KVM: Plumb the full request into __kvm_vcpu_kick()
KVM: Drop kvm_vcpu_should_kick() and use kvm_request_needs_ipi()

Shivansh Dhiman (1):
KVM: SVM: Clear VMCB save area instead of entire VMCB on shutdown intercept

Yosry Ahmed (1):
KVM: SVM: Update tracked pCPU on pCPU switch

 arch/arm64/kvm/arm.c                     |  5 ---
 arch/loongarch/kvm/vcpu.c                |  5 ---
 arch/mips/kvm/mips.c                     |  5 ---
 arch/powerpc/include/asm/kvm_host.h      |  1 -
 arch/powerpc/include/asm/kvm_ppc.h       | 13 +++++++-
 arch/powerpc/kvm/book3s.c                |  4 +--
 arch/powerpc/kvm/book3s_pr.c             |  2 +-
 arch/powerpc/kvm/booke.c                 |  6 ++--
 arch/powerpc/kvm/e500_emulate.c          |  2 +-
 arch/powerpc/kvm/powerpc.c               | 18 +++++++----
 arch/riscv/kvm/vcpu.c                    |  5 ---
 arch/s390/kvm/s390/s390.c                |  7 -----
 arch/x86/kvm/svm/svm.c                   | 43 ++++++++++++++++++--------
 arch/x86/kvm/vmx/nested.c                | 10 +++++-
 arch/x86/kvm/vmx/sgx.c                   |  2 +-
 arch/x86/kvm/vmx/vmx.c                   | 15 ++++++---
 arch/x86/kvm/x86.c                       |  5 ---
 include/linux/kvm_host.h                 | 32 ++++++++++++++++----
 tools/testing/selftests/kvm/Makefile     |  4 +--
 tools/testing/selftests/kvm/Makefile.kvm | 16 +++++++---
 virt/kvm/kvm_main.c                      | 52 +++++++++++++++++---------------
 21 files changed, 149 insertions(+), 103 deletions(-)
maintainer
#1 lore raw
Quoted 10 lines · Sean Christopherson

Please pull a somewhat random smattering of fixes. The biggest (but probably not scariest?) is to rework single-vCPU kicks to ensure waiting requests actually wait. It's big only because PPC is weird and required refactoring a bunch of code just to avoid throwing in more hacks. Including this many patches obviously isn't ideal, but failing to wait breaks the flow to force vCPUs to invalidate their SNP VMSA. Prior to 7.4 the race condition was all but impossible to hit, but in-place conversion makes it a *lot* easier to hit the window, which is why I included the fix here.

Quoted 4 lines

Speaking of PPC, the scariest fix for me is the patch to actually implement kvm_arch_flush_shadow_all(). Some PPC folks reviewed it, so it's probably good? But I'm still flabbergasted that such a blatant bug has gone unnoticed for so long, which makes we worried I'm missing something.

Pulled, thanks. I'll give it another round of reviews...

Paolo

Quoted 98 lines

The following changes since commit 7475ea8b58616b33c04afb976cf0fbaad9dd63fb:

Linux 7.4-rc2 (2026-11-08 16:22:20 -0800)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-7.4-rc4

for you to fetch changes up to bcc359264f15095d3d167535cf5de0b7e4800279:

KVM: nVMX: Clear nested.smm.guest_mode on a failed RSM-to-L2 (2026-11-10 14:42:26 -0800)

----------------------------------------------------------------
KVM fixes for 7.4-rcN

- Mitigate a class of (x86) bugs where KVM can read/write guest (userspace) memory using the wrong mm, i.e. using the wrong user page tables.

- Don't force a full nested VMX VM-Exit when destroying a vCPU, as processing the MSR load/store lists and writing back the shadow vmcs12 is wildly wrong when VM is dying.

- Implement "flush shadow all" on KVM PPC to ensure KVM's mappings are torn down when the VM and/or owning process is dying.

- Provide empty installation rules for architectures that aren't supported by KVM selftests to fix build issues in CI environments.

- Fix KVM selftests' rules for generating arm64's sysreg headers so that the headers are properly (re)generated on incremental builds.

- Clear only the VMCB save area on an intercepted SHUTDOWN on SVM, partly to avoid unnecessary churn, but mostly to prevent KVM from clobbering the PML index.

- Update the tracked pCPU on task migration for both vmcb01 and vmcb02 to fix an edge case where KVM can use a stale ASID across pCPUs.

- Rework the single-vCPU kick logic to fix a bug where KVM would fail to wait for a target vCPU to respond if another in-flight, non-waiting kick changed the vCPU's mode to EXITING_GUEST_MODE.

- Clear nVMX's smm.guest_most when freeing nested state, and if a RSM to L2 ultimately fails (and queues a TRIPLE_FAULT to L1).
----------------------------------------------------------------
Amirmohammad Eftekhar (1):
KVM: nVMX: Clear nested.smm.guest_mode on a failed RSM-to-L2

Fuad Tabba (1):
KVM: selftests: Fix arm64 sysreg header dependencies

Josef Bacik (1):
KVM: nVMX: Clear nested.smm.guest_mode when freeing nested state

Sasha Levin (1):
KVM: selftests: Provide empty installation rules on unsupported ARCHs

Sean Christopherson (10):
KVM: Reject user accesses to guest memory if current->mm != kvm->mm
KVM: nVMX: Don't force a full nested VM-Exit when destroying a vCPU
KVM: PPC: Flush/zap all memslots on kvm_arch_flush_shadow_all()
KVM: s390: Drop unused and unreachable kvm_arch_vcpu_should_kick()
KVM: Add a @force param to __kvm_vcpu_kick() for PPC backwards compatibility
KVM: PPC: Explicitly force IPIs when directly kicking vCPUs
KVM: MIPS: Rework kvm_arch_vcpu_should_kick() to use standard implementation
KVM: Move kvm_arch_vcpu_should_kick() to common code as kvm_vcpu_should_kick()
KVM: Plumb the full request into __kvm_vcpu_kick()
KVM: Drop kvm_vcpu_should_kick() and use kvm_request_needs_ipi()

Shivansh Dhiman (1):
KVM: SVM: Clear VMCB save area instead of entire VMCB on shutdown intercept

Yosry Ahmed (1):
KVM: SVM: Update tracked pCPU on pCPU switch

 arch/arm64/kvm/arm.c                     |  5 ---
 arch/loongarch/kvm/vcpu.c                |  5 ---
 arch/mips/kvm/mips.c                     |  5 ---
 arch/powerpc/include/asm/kvm_host.h      |  1 -
 arch/powerpc/include/asm/kvm_ppc.h       | 13 +++++++-
 arch/powerpc/kvm/book3s.c                |  4 +--
 arch/powerpc/kvm/book3s_pr.c             |  2 +-
 arch/powerpc/kvm/booke.c                 |  6 ++--
 arch/powerpc/kvm/e500_emulate.c          |  2 +-
 arch/powerpc/kvm/powerpc.c               | 18 +++++++----
 arch/riscv/kvm/vcpu.c                    |  5 ---
 arch/s390/kvm/s390/s390.c                |  7 -----
 arch/x86/kvm/svm/svm.c                   | 43 ++++++++++++++++++--------
 arch/x86/kvm/vmx/nested.c                | 10 +++++-
 arch/x86/kvm/vmx/sgx.c                   |  2 +-
 arch/x86/kvm/vmx/vmx.c                   | 15 ++++++---
 arch/x86/kvm/x86.c                       |  5 ---
 include/linux/kvm_host.h                 | 32 ++++++++++++++++----
 tools/testing/selftests/kvm/Makefile     |  4 +--
 tools/testing/selftests/kvm/Makefile.kvm | 16 +++++++---
 virt/kvm/kvm_main.c                      | 52 +++++++++++++++++---------------
 21 files changed, 149 insertions(+), 103 deletions(-)