KVM: SVM: Do not install #UD intercept when SEV is enabled

"Linux Kernel Mailing List" <[email protected]> Sat, 10 Feb 2018 22:00:21 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/35c6f649bbb2e3f367116307273f998f0bf3e08e
Commit:     35c6f649bbb2e3f367116307273f998f0bf3e08e
Parent:     0ede79e1322479221fb0d0a7d2828d8ed033f060
Refname:    refs/heads/master
Author:     Brijesh Singh <[email protected]>
AuthorDate: Mon Dec 4 10:57:39 2017 -0600
Committer:  Brijesh Singh <[email protected]>
CommitDate: Mon Dec 4 13:33:14 2017 -0600

    KVM: SVM: Do not install #UD intercept when SEV is enabled
    
    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 <[email protected]>
    Cc: Ingo Molnar <[email protected]>
    Cc: "H. Peter Anvin" <[email protected]>
    Cc: Paolo Bonzini <[email protected]>
    Cc: "Radim Krčmář" <[email protected]>
    Cc: Joerg Roedel <[email protected]>
    Cc: Borislav Petkov <[email protected]>
    Cc: Tom Lendacky <[email protected]>
    Cc: [email protected]
    Cc: [email protected]
    Cc: [email protected]
    Reviewed-by: Borislav Petkov <[email protected]>
    Signed-off-by: Brijesh Singh <[email protected]>
---
 arch/x86/kvm/svm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f350e9bac9eb..3e848f952b4f 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -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);
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html