Received: by 10.223.185.116 with SMTP id b49csp6342811wrg; Wed, 28 Feb 2018 07:54:11 -0800 (PST) X-Google-Smtp-Source: AG47ELsSkm2n9DEi530bkgornUTQuTw6P+ogGQl3us+7KMxSnttRMewi8VTqsWCZU72ehMn3T83E X-Received: by 2002:a17:902:8a4:: with SMTP id 33-v6mr9450683pll.274.1519833251594; Wed, 28 Feb 2018 07:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833251; cv=none; d=google.com; s=arc-20160816; b=OwZjAw/7Ii1jrg44dGNO4OFCpR8SiFEUhuAce6cldBODtVdRTvgy2gvnnliRJXU0Q3 MJWnfECjDTfEphbfdGkRz8hcYx40Ce3SwwPPIL3qs96vm4rTsYBXTVEKw7/Vi8lYQNaf Phn/TEMc5Du7g9yf+LESHt75QSgYH5+eLewkOjBn/9ml0y9sGsieGzzfcUW9hasFC0f/ XcxcuzW5BSZdbnnkL/MlcgI+ld1gmJWd1UTaVc1TEYsuENFa92AUkjaYIiK3aq/Mz3wQ BIyfklYZDht13zMpxJMjE0j5pj5BM5phj5AaaPYCCFCALi3oC4DZDXFAm4NivRJAt9yG ErEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=0KNh+9ynCrlfDR5pc9QhL9RE3vtrH7JhChnW9L8wyh0=; b=tqh3jLYpRQK6BOBTweWVtT5RHt9zeKR1wq7nhvOWXhOKYPBREkoR+nOMKIzNFAPcNf b/2HJZb/FZ1nCNcdc7PvUQBmhwI4Dy7AaskF+waMge9grcRQwHtNwLPDNKDaeSjbIPT5 tc/CK3uGYfvXRjFMAVVE5t/Niay65DPG7EnGlRRc93fSkhBv8RV1fG0yFQ21KYYbLTWu EYVV41PHSOQdKFiBMvzzHQn1RvzLoTi2o7tMw9U7N5EAwY/6KLZlhaO8chexAQYCFulF +vDDLCkUjBqQbDXGVhQ0Gw+l0a6fI+L50dbWMuhWbfTYizRsCrCChkhBR19VhqZsuScL WHxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si1157021pgr.617.2018.02.28.07.53.56; Wed, 28 Feb 2018 07:54:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933794AbeB1PwA (ORCPT + 99 others); Wed, 28 Feb 2018 10:52:00 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34360 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933379AbeB1Pvx (ORCPT ); Wed, 28 Feb 2018 10:51:53 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yv-0006Xi-DW; Wed, 28 Feb 2018 15:22:33 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yc-0008LF-OH; Wed, 28 Feb 2018 15:22:14 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Paolo Bonzini" , "Wanpeng Li" , "Liran Alon" , "Konrad Rzeszutek Wilk" , "Nikita Leshenko" , "Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?=" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 003/254] KVM: x86: Exit to user-mode on #UD intercept when emulator requires In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Liran Alon commit 61cb57c9ed631c95b54f8e9090c89d18b3695b3c upstream. Instruction emulation after trapping a #UD exception can result in an MMIO access, for example when emulating a MOVBE on a processor that doesn't support the instruction. In this case, the #UD vmexit handler must exit to user mode, but there wasn't any code to do so. Add it for both VMX and SVM. Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Wanpeng Li Reviewed-by: Paolo Bonzini Signed-off-by: Radim Krčmář Signed-off-by: Ben Hutchings --- arch/x86/kvm/svm.c | 2 ++ arch/x86/kvm/vmx.c | 2 ++ 2 files changed, 4 insertions(+) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1776,6 +1776,8 @@ static int ud_interception(struct vcpu_s int er; er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD); + if (er == EMULATE_USER_EXIT) + return 0; if (er != EMULATE_DONE) kvm_queue_exception(&svm->vcpu, UD_VECTOR); return 1; --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4853,6 +4853,8 @@ static int handle_exception(struct kvm_v if (is_invalid_opcode(intr_info)) { er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD); + if (er == EMULATE_USER_EXIT) + return 0; if (er != EMULATE_DONE) kvm_queue_exception(vcpu, UD_VECTOR); return 1;