Skip to content

Commit 8c9244a

Browse files
committed
Merge tag 'kvm-x86-svm-6.8' of https://github.com/kvm-x86/linux into HEAD
KVM SVM changes for 6.8: - Revert a bogus, made-up nested SVM consistency check for TLB_CONTROL. - Advertise flush-by-ASID support for nSVM unconditionally, as KVM always flushes on nested transitions, i.e. always satisfies flush requests. This allows running bleeding edge versions of VMware Workstation on top of KVM. - Sanity check that the CPU supports flush-by-ASID when enabling SEV support. - Fix a benign NMI virtualization bug where KVM would unnecessarily intercept IRET when manually injecting an NMI, e.g. when KVM pends an NMI and injects a second, "simultaneous" NMI.
2 parents 8ecb10b + 72046d0 commit 8c9244a

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,6 @@ static bool nested_svm_check_bitmap_pa(struct kvm_vcpu *vcpu, u64 pa, u32 size)
253253
kvm_vcpu_is_legal_gpa(vcpu, addr + size - 1);
254254
}
255255

256-
static bool nested_svm_check_tlb_ctl(struct kvm_vcpu *vcpu, u8 tlb_ctl)
257-
{
258-
/* Nested FLUSHBYASID is not supported yet. */
259-
switch(tlb_ctl) {
260-
case TLB_CONTROL_DO_NOTHING:
261-
case TLB_CONTROL_FLUSH_ALL_ASID:
262-
return true;
263-
default:
264-
return false;
265-
}
266-
}
267-
268256
static bool __nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
269257
struct vmcb_ctrl_area_cached *control)
270258
{
@@ -284,9 +272,6 @@ static bool __nested_vmcb_check_controls(struct kvm_vcpu *vcpu,
284272
IOPM_SIZE)))
285273
return false;
286274

287-
if (CC(!nested_svm_check_tlb_ctl(vcpu, control->tlb_ctl)))
288-
return false;
289-
290275
if (CC((control->int_ctl & V_NMI_ENABLE_MASK) &&
291276
!vmcb12_is_intercept(control, INTERCEPT_NMI))) {
292277
return false;

arch/x86/kvm/svm/sev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,10 +2191,13 @@ void __init sev_hardware_setup(void)
21912191
/*
21922192
* SEV must obviously be supported in hardware. Sanity check that the
21932193
* CPU supports decode assists, which is mandatory for SEV guests to
2194-
* support instruction emulation.
2194+
* support instruction emulation. Ditto for flushing by ASID, as SEV
2195+
* guests are bound to a single ASID, i.e. KVM can't rotate to a new
2196+
* ASID to effect a TLB flush.
21952197
*/
21962198
if (!boot_cpu_has(X86_FEATURE_SEV) ||
2197-
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)))
2199+
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)) ||
2200+
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_FLUSHBYASID)))
21982201
goto out;
21992202

22002203
/* Retrieve SEV CPUID information */

arch/x86/kvm/svm/svm.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,8 +3563,15 @@ static void svm_inject_nmi(struct kvm_vcpu *vcpu)
35633563
if (svm->nmi_l1_to_l2)
35643564
return;
35653565

3566-
svm->nmi_masked = true;
3567-
svm_set_iret_intercept(svm);
3566+
/*
3567+
* No need to manually track NMI masking when vNMI is enabled, hardware
3568+
* automatically sets V_NMI_BLOCKING_MASK as appropriate, including the
3569+
* case where software directly injects an NMI.
3570+
*/
3571+
if (!is_vnmi_enabled(svm)) {
3572+
svm->nmi_masked = true;
3573+
svm_set_iret_intercept(svm);
3574+
}
35683575
++vcpu->stat.nmi_injections;
35693576
}
35703577

@@ -5079,6 +5086,13 @@ static __init void svm_set_cpu_caps(void)
50795086
kvm_cpu_cap_set(X86_FEATURE_SVM);
50805087
kvm_cpu_cap_set(X86_FEATURE_VMCBCLEAN);
50815088

5089+
/*
5090+
* KVM currently flushes TLBs on *every* nested SVM transition,
5091+
* and so for all intents and purposes KVM supports flushing by
5092+
* ASID, i.e. KVM is guaranteed to honor every L1 ASID flush.
5093+
*/
5094+
kvm_cpu_cap_set(X86_FEATURE_FLUSHBYASID);
5095+
50825096
if (nrips)
50835097
kvm_cpu_cap_set(X86_FEATURE_NRIPS);
50845098

0 commit comments

Comments
 (0)