[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210203113421.5759-15-weijiang.yang@intel.com>
Date: Wed, 3 Feb 2021 19:34:21 +0800
From: Yang Weijiang <weijiang.yang@...el.com>
To: pbonzini@...hat.com, seanjc@...gle.com, jmattson@...gle.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: yu.c.zhang@...ux.intel.com, Yang Weijiang <weijiang.yang@...el.com>
Subject: [PATCH v15 14/14] KVM: x86: Save/Restore GUEST_SSP to/from SMRAM
Save GUEST_SSP to SMRAM when guest exits to SMM due to SMI and restore it
when guest exits SMM to interrupted normal non-root mode.
Signed-off-by: Yang Weijiang <weijiang.yang@...el.com>
---
arch/x86/kvm/emulate.c | 11 +++++++++++
arch/x86/kvm/x86.c | 10 ++++++++++
2 files changed, 21 insertions(+)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 56cae1ff9e3f..6d4a3181d8bd 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2615,6 +2615,17 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
return r;
}
+ if (kvm_cet_supported()) {
+ struct msr_data msr;
+
+ val = GET_SMSTATE(u64, smstate, 0x7ec8);
+ msr.index = MSR_KVM_GUEST_SSP;
+ msr.host_initiated = true;
+ msr.data = val;
+ /* Mimic host_initiated access to bypass ssp access check. */
+ kvm_x86_ops.set_msr(ctxt->vcpu, &msr);
+ }
+
return X86EMUL_CONTINUE;
}
#endif
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 22eb6b8626a8..f63b713cd71f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8592,6 +8592,16 @@ static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, char *buf)
for (i = 0; i < 6; i++)
enter_smm_save_seg_64(vcpu, buf, i);
+
+ if (kvm_cet_supported()) {
+ struct msr_data msr;
+
+ msr.index = MSR_KVM_GUEST_SSP;
+ msr.host_initiated = true;
+ /* GUEST_SSP is stored in VMCS at vm-exit. */
+ kvm_x86_ops.get_msr(vcpu, &msr);
+ put_smstate(u64, buf, 0x7ec8, msr.data);
+ }
}
#endif
--
2.26.2
Powered by blists - more mailing lists