]> 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
update submodule and patches to 6.1.14
[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
826eb0ff
FG
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
4fc427d9
TL
9
10When the guest CPUID doesn't have support for long mode, 32 bit SMRAM
11layout is used and it has no support for preserving EFER and/or SVM
12state.
13
14Note that this isn't relevant to running 32 bit guests on VM which is
15long mode capable - such VM can still run 32 bit guests in compatibility
16mode.
17
18Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
19Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
826eb0ff 20Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4fc427d9
TL
21---
22 arch/x86/kvm/svm/svm.c | 9 +++++++++
23 1 file changed, 9 insertions(+)
24
25diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
fc2b61b1 26index 023b6507a539..a7acbe8246b6 100644
4fc427d9
TL
27--- a/arch/x86/kvm/svm/svm.c
28+++ b/arch/x86/kvm/svm/svm.c
fc2b61b1 29@@ -4400,6 +4400,15 @@ static int svm_enter_smm(struct kvm_vcpu *vcpu, union kvm_smram *smram)
4fc427d9
TL
30 if (!is_guest_mode(vcpu))
31 return 0;
32
33+ /*
34+ * 32 bit SMRAM format doesn't preserve EFER and SVM state.
35+ * SVM should not be enabled by the userspace without marking
36+ * the CPU as at least long mode capable.
37+ */
38+
39+ if (!guest_cpuid_has(vcpu, X86_FEATURE_LM))
40+ return 1;
41+
42 smram->smram64.svm_guest_flag = 1;
43 smram->smram64.svm_guest_vmcb_gpa = svm->nested.vmcb12_gpa;
44