Skip to content

KVM: nSVM: Intercept STGI/CLGI as needed to inject #UD

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 nested, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 Latest2 patches 3 repliesApplied

Changes in v5 from the cover letter

- Separate the STGI/CLGI fixes from everything else.
- Apply the Intel compatibiliy weirdness only to VMLOAD/VMSAVE (to fixup SYSENTER MSRs).
- Re-remove STGI/CLGI intercept clearing in init_vmcb().

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: SVM: Move STGI and CLGI intercept handlingarch/x86/kvm/svm/svm.c+24 -81 reply
2/2KVM: SVM: Recalc instructions intercepts when EFER.SVME is toggledarch/x86/kvm/svm/svm.c+23 -121 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchYosry Ahmed
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/2] KVM: nSVM: Intercept STGI/CLGI as needed to inject #UD

The STGI/CLGI fixes from Kevin's broader "Align SVM with APM defined behaviors" series.

v5:
- Separate the STGI/CLGI fixes from everything else.
- Apply the Intel compatibiliy weirdness only to VMLOAD/VMSAVE (to fixup SYSENTER MSRs).
- Re-remove STGI/CLGI intercept clearing in init_vmcb().

v4:
- https://lore.kernel.org/all/[email protected]
- Dropped "KVM: SVM: Inject #UD for STGI if EFER.SVME=0 and SVM Lock and DEV are not available" as per Sean
- Added back STGI and CLGI intercept clearing in init_vmcb to maintain previous behavior on intel guests. Previously intel guests always had STGI and CLGI intercepts cleared if vgif was enabled. In V3, because the clearing of the intercepts was moved from init_vmcb() to the !guest_cpuid_is_intel_compatible() case in svm_recalc_instruction_intercepts(), the CLGI intercept would be indefinitely set on intel guests. I added back the clearing to init_vmcb() to retain intel guest behavior before this patch.
- In "Raise #UD if VMMCALL instruction is not intercepted" patch:
- Exempt Hyper-V L2 TLB flush hypercalls from the #UD injection, as L0 intentionally intercepts these VMMCALLs on behalf of L1 via the direct hypercall enlightenment.
- Added nested_svm_is_l2_tlb_flush_hcall() which just returns true if the hypercall was a Hyper-V L2 TLB flush hypercall.

v3:
- https://lore.kernel.org/kvm/[email protected]/
- Elaborated on 'Move STGI and CLGI intercept handling' commit message as per Sean
- Fixed bug due to interaction with svm_enable_nmi_window() and 'Move STGI and CLGI intercept handling' as pointed out by Yosry. Code changes suggested by Sean/Yosry.
- Removed open-coded nested_svm_check_permissions() in STGI interception function as per Yosry

v2:
- https://lore.kernel.org/all/[email protected]
- Split up the series into smaller more logical changes as suggested by Sean
- Added patch for injecting #UD for STGI under APM defined conditions as suggested by Sean
- Combined EFER.SVME=0 conditional with intel CPU logic in svm_recalc_instruction_intercepts

Kevin Cheng (2):
KVM: SVM: Move STGI and CLGI intercept handling
KVM: SVM: Recalc instructions intercepts when EFER.SVME is toggled

 arch/x86/kvm/svm/svm.c | 53 +++++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 13 deletions(-)

base-commit: 11439c4635edd669ae435eec308f4ab8a0804808

Signature · 1 line
2.53.0.473.g4a7958ca14-goog