]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0014-KVM-x86-SVM-don-t-save-SVM-state-to-SMRAM-when-VM-is.patch
rebase patches on top of Ubuntu-6.1.0-12.12
[pve-kernel.git] / patches / kernel / 0014-KVM-x86-SVM-don-t-save-SVM-state-to-SMRAM-when-VM-is.patch
CommitLineData
4fc427d9
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Maxim Levitsky <mlevitsk@redhat.com>
3Date: Wed, 3 Aug 2022 18:50:10 +0300
4Subject: [PATCH] KVM: x86: SVM: don't save SVM state to SMRAM when VM is not
5 long mode capable
6
7When the guest CPUID doesn't have support for long mode, 32 bit SMRAM
8layout is used and it has no support for preserving EFER and/or SVM
9state.
10
11Note that this isn't relevant to running 32 bit guests on VM which is
12long mode capable - such VM can still run 32 bit guests in compatibility
13mode.
14
15Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
16Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17---
18 arch/x86/kvm/svm/svm.c | 9 +++++++++
19 1 file changed, 9 insertions(+)
20
21diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
12247ad0 22index bfacbef667d7..6b02f99fe70c 100644
4fc427d9
TL
23--- a/arch/x86/kvm/svm/svm.c
24+++ b/arch/x86/kvm/svm/svm.c
12247ad0 25@@ -4394,6 +4394,15 @@ static int svm_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram)
4fc427d9
TL
26 if (!is_guest_mode(vcpu))
27 return 0;
28
29+ /*
30+ * 32 bit SMRAM format doesn't preserve EFER and SVM state.
31+ * SVM should not be enabled by the userspace without marking
32+ * the CPU as at least long mode capable.
33+ */
34+
35+ if (!guest_cpuid_has(vcpu, X86_FEATURE_LM))
36+ return 1;
37+
38 smram->smram64.svm_guest_flag = 1;
39 smram->smram64.svm_guest_vmcb_gpa = svm->nested.vmcb12_gpa;
40