Skip to contentSkip to conversation

KVM: x86: Fixes for 6.14-rcN

GIT PULL Sean Christopherson 2 participants 2 messages Mar 8, 2025 – Mar 9, 2025 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

Please pull a handful of fixes for 6.14. The DEBUGCTL changes are the most urgent, as they fix a bug that was introduced in 6.13 that results in Steam (and other applications) getting killed due to unexpected #DBs.

The following changes since commit c2fee09fc167c74a64adb08656cb993ea475197e:

KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop (2025-02-12 08:59:38 -0800)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-6.14-rcN.2

for you to fetch changes up to f9dc8fb3afc968042bdaf4b6e445a9272071c9f3:

KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM (2025-03-04 09:19:18 -0800)

----------------------------------------------------------------
KVM x86 fixes for 6.14-rcN #2

- Set RFLAGS.IF in C code on SVM to get VMRUN out of the STI shadow.

- Ensure DEBUGCTL is context switched on AMD to avoid running the guest with the host's value, which can lead to unexpected bus lock #DBs.

- Suppress DEBUGCTL.BTF on AMD (to match Intel), as KVM doesn't properly emulate BTF. KVM's lack of context switching has meant BTF has always been broken to some extent.

- Always save DR masks for SNP vCPUs if DebugSwap is *supported*, as the guest can enable DebugSwap without KVM's knowledge.

- Fix a bug in mmu_stress_tests where a vCPU could finish the "writes to RO memory" phase without actually generating a write-protection fault.

- Fix a printf() goof in the SEV smoke test that causes build failures with -Werror.

- Explicitly zero EAX and EBX in CPUID.0x8000_0022 output when PERFMON_V2 isn't supported by KVM.

----------------------------------------------------------------
Sean Christopherson (11):
KVM: SVM: Set RFLAGS.IF=1 in C code, to get VMRUN out of the STI shadow
KVM: selftests: Assert that STI blocking isn't set after event injection
KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective value
KVM: SVM: Suppress DEBUGCTL.BTF on AMD
KVM: x86: Snapshot the host's DEBUGCTL in common x86
KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabled
KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs
KVM: SVM: Save host DR masks on CPUs with DebugSwap
KVM: SVM: Don't rely on DebugSwap to restore host DR0..DR3
KVM: selftests: Ensure all vCPUs hit -EFAULT during initial RO stage
KVM: selftests: Fix printf() format goof in SEV smoke test

Xiaoyao Li (1):
KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM

 arch/x86/include/asm/kvm_host.h                    |  1 +
 arch/x86/kvm/cpuid.c                               |  2 +-
 arch/x86/kvm/svm/sev.c                             | 24 +++++++----
 arch/x86/kvm/svm/svm.c                             | 49 ++++++++++++++++++++++
 arch/x86/kvm/svm/svm.h                             |  2 +-
 arch/x86/kvm/svm/vmenter.S                         | 10 +----
 arch/x86/kvm/vmx/vmx.c                             |  8 +---
 arch/x86/kvm/vmx/vmx.h                             |  2 -
 arch/x86/kvm/x86.c                                 |  2 +
 tools/testing/selftests/kvm/mmu_stress_test.c      | 21 ++++++----
 .../selftests/kvm/x86/nested_exceptions_test.c     |  2 +
 tools/testing/selftests/kvm/x86/sev_smoke_test.c   |  3 +-
 12 files changed, 91 insertions(+), 35 deletions(-)
maintainer
#1 lore raw
Quoted 9 lines · Sean Christopherson

Please pull a handful of fixes for 6.14. The DEBUGCTL changes are the most urgent, as they fix a bug that was introduced in 6.13 that results in Steam (and other applications) getting killed due to unexpected #DBs.

The following changes since commit c2fee09fc167c74a64adb08656cb993ea475197e:

KVM: x86: Load DR6 with guest value only before entering .vcpu_run() loop (2025-02-12 08:59:38 -0800)

Quoted 7 lines

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-fixes-6.14-rcN.2

for you to fetch changes up to f9dc8fb3afc968042bdaf4b6e445a9272071c9f3:

KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM (2025-03-04 09:19:18 -0800)

Pulled, thanks.

Paolo

Quoted 55 lines

----------------------------------------------------------------
KVM x86 fixes for 6.14-rcN #2

- Set RFLAGS.IF in C code on SVM to get VMRUN out of the STI shadow.

- Ensure DEBUGCTL is context switched on AMD to avoid running the guest with the host's value, which can lead to unexpected bus lock #DBs.

- Suppress DEBUGCTL.BTF on AMD (to match Intel), as KVM doesn't properly emulate BTF. KVM's lack of context switching has meant BTF has always been broken to some extent.

- Always save DR masks for SNP vCPUs if DebugSwap is *supported*, as the guest can enable DebugSwap without KVM's knowledge.

- Fix a bug in mmu_stress_tests where a vCPU could finish the "writes to RO memory" phase without actually generating a write-protection fault.

- Fix a printf() goof in the SEV smoke test that causes build failures with -Werror.

- Explicitly zero EAX and EBX in CPUID.0x8000_0022 output when PERFMON_V2 isn't supported by KVM.

----------------------------------------------------------------
Sean Christopherson (11):
KVM: SVM: Set RFLAGS.IF=1 in C code, to get VMRUN out of the STI shadow
KVM: selftests: Assert that STI blocking isn't set after event injection
KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective value
KVM: SVM: Suppress DEBUGCTL.BTF on AMD
KVM: x86: Snapshot the host's DEBUGCTL in common x86
KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabled
KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs
KVM: SVM: Save host DR masks on CPUs with DebugSwap
KVM: SVM: Don't rely on DebugSwap to restore host DR0..DR3
KVM: selftests: Ensure all vCPUs hit -EFAULT during initial RO stage
KVM: selftests: Fix printf() format goof in SEV smoke test

Xiaoyao Li (1):
KVM: x86: Explicitly zero EAX and EBX when PERFMON_V2 isn't supported by KVM

 arch/x86/include/asm/kvm_host.h                    |  1 +
 arch/x86/kvm/cpuid.c                               |  2 +-
 arch/x86/kvm/svm/sev.c                             | 24 +++++++----
 arch/x86/kvm/svm/svm.c                             | 49 ++++++++++++++++++++++
 arch/x86/kvm/svm/svm.h                             |  2 +-
 arch/x86/kvm/svm/vmenter.S                         | 10 +----
 arch/x86/kvm/vmx/vmx.c                             |  8 +---
 arch/x86/kvm/vmx/vmx.h                             |  2 -
 arch/x86/kvm/x86.c                                 |  2 +
 tools/testing/selftests/kvm/mmu_stress_test.c      | 21 ++++++----
 .../selftests/kvm/x86/nested_exceptions_test.c     |  2 +
 tools/testing/selftests/kvm/x86/sev_smoke_test.c   |  3 +-
 12 files changed, 91 insertions(+), 35 deletions(-)