]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: Do not install #UD intercept when SEV is enabled
authorBrijesh Singh <brijesh.singh@amd.com>
Mon, 4 Dec 2017 16:57:39 +0000 (10:57 -0600)
committerBrijesh Singh <brijesh.singh@amd.com>
Mon, 4 Dec 2017 19:33:14 +0000 (13:33 -0600)
On #UD, x86_emulate_instruction() fetches the data from guest memory and
decodes the instruction bytes to assist further. When SEV is enabled, the
instruction bytes will be encrypted using the guest-specific key and the
hypervisor will no longer able to fetch the instruction bytes to assist
UD handling. By not installing intercept we let the guest receive and
handle #UD.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: x86@kernel.org
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
arch/x86/kvm/svm.c

index f350e9bac9eb0066518c3f8237f5799279d63ff0..3e848f952b4fde6692f5ebe970dde8c17603fe49 100644 (file)
@@ -1443,8 +1443,10 @@ static void init_vmcb(struct vcpu_svm *svm)
                svm->vmcb->control.int_ctl |= V_GIF_ENABLE_MASK;
        }
 
-       if (sev_guest(svm->vcpu.kvm))
+       if (sev_guest(svm->vcpu.kvm)) {
                svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ENABLE;
+               clr_exception_intercept(svm, UD_VECTOR);
+       }
 
        mark_all_dirty(svm->vmcb);