KVM: SVM: Fix DEBUGCTL bugs
Status from this message: Applied patch 6 to kvm-x86 svm (1-5 already went into 6.15).
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 10 repliesApplied
- v25 patches 7 repliesSuperseded
Changes in v3 from the cover letter
- Suppress BTF, as KVM doesn't actually support it. [Ravi]
- Actually load the guest's DEBUGCTL (though amusingly, with BTF squashed, it's guaranteed to be '0' in this scenario). [Ravi]
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | KVM: SVM: Drop DEBUGCTL[5:2] from guest's effective valuearch/ arch/ | +13 | 0 replies | |
| 2/6 | KVM: SVM: Suppress DEBUGCTL.BTF on AMDarch/ arch/ | +10 | 0 replies | |
| 3/6 | KVM: x86: Snapshot the host's DEBUGCTL in common x86arch/ arch/ arch/ +1 more | +4 | 0 replies | |
| 4/6 | KVM: SVM: Manually context switch DEBUGCTL if LBR virtualization is disabledarch/ | +14 | 0 replies | |
| 5/6 | KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQsarch/ | +2 | 0 replies | |
| 6/6 | KVM: SVM: Treat DEBUGCTL[5:2] as reservedarch/ | +0 | 0 replies |
Reviews trailers per patch
1 of 6 patches has a Reviewed-by or Acked-by.
| Patch | Xiaoyao Li | Ravi Bangoria |
|---|---|---|
| Series | Reviewed-and-tested-by | |
| 1/6 | ||
| 2/6 | ||
| 3/6 | R-b | |
| 4/6 | ||
| 5/6 | ||
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/6] KVM: SVM: Fix DEBUGCTL bugs
Fix a long-lurking bug in SVM where KVM runs the guest with the host's DEBUGCTL if LBR virtualization is disabled. AMD CPUs rather stupidly context switch DEBUGCTL if and only if LBR virtualization is enabled (not just supported, but fully enabled).
The bug has gone unnoticed because until recently, the only bits that KVM would leave set were things like BTF, which are guest visible but won't cause functional problems unless guest software is being especially particular about #DBs.
The bug was exposed by the addition of BusLockTrap ("Detect" in the kernel), as the resulting #DBs due to split-lock accesses in guest userspace (lol Steam) get reflected into the guest by KVM.
Note, I don't love suppressing DEBUGCTL.BTF, but practically speaking that's likely the behavior that SVM guests have gotten the vast, vast majority of the time, and given that it's the behavior on Intel, it's (hopefully) a safe option for a fix, e.g. versus trying to add proper BTF virtualization on the fly.
v3:
- Suppress BTF, as KVM doesn't actually support it. [Ravi]
- Actually load the guest's DEBUGCTL (though amusingly, with BTF squashed, it's guaranteed to be '0' in this scenario). [Ravi]
v2:
- Load the guest's DEBUGCTL instead of simply zeroing it on VMRUN.
- Drop bits 5:3 from guest DEBUGCTL so that KVM doesn't let the guest unintentionally enable BusLockTrap (AMD repurposed bits). [Ravi]
- Collect a review. [Xiaoyao]
- Make bits 5:3 fully reserved, in a separate not-for-stable patch.
v1: https://lore.kernel.org/all/[email protected]
Sean Christopherson (6):
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: Treat DEBUGCTL[5:2] as reserved
arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 24 ++++++++++++++++++++++++ arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/vmx/vmx.c | 8 ++------ arch/x86/kvm/vmx/vmx.h | 2 -- arch/x86/kvm/x86.c | 2 ++ 6 files changed, 30 insertions(+), 9 deletions(-)
base-commit: fed48e2967f402f561d80075a20c5c9e16866e53
Signature · 1 line
2.48.1.711.g2feabab25a-goog