[PATCH 3/4] kvm: svm: Emulate UMIP instructions on non SEV guest

From: Moger, Babu
Date: Fri Nov 01 2019 - 13:34:00 EST


Emulation of UMIP instructions (sgdt, sidt, sldt, smsw and str) requires
the hypervisor to read and write the guest memory. Guest memory is
encrypted on SEV guest. Hypervisor cannot successfully read or write the
guest memory. So disable emulation on SEV guest. Enable the emulation only
on non SEV guest.

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
arch/x86/kvm/svm.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 79abbdeca148..267dae94e5ca 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1535,6 +1535,15 @@ static void init_vmcb(struct vcpu_svm *svm)
set_intercept(svm, INTERCEPT_NMI);
set_intercept(svm, INTERCEPT_SMI);
set_intercept(svm, INTERCEPT_SELECTIVE_CR0);
+
+ /* Enable interception only on non-sev guest */
+ if (!sev_guest(svm->vcpu.kvm)) {
+ set_intercept(svm, INTERCEPT_STORE_IDTR);
+ set_intercept(svm, INTERCEPT_STORE_GDTR);
+ set_intercept(svm, INTERCEPT_STORE_LDTR);
+ set_intercept(svm, INTERCEPT_STORE_TR);
+ }
+
set_intercept(svm, INTERCEPT_RDPMC);
set_intercept(svm, INTERCEPT_CPUID);
set_intercept(svm, INTERCEPT_INVD);