Received: by 10.223.176.5 with SMTP id f5csp993631wra; Fri, 2 Feb 2018 09:23:21 -0800 (PST) X-Google-Smtp-Source: AH8x224VNNj9Xb76osOFqqqUfGNdmJpx1E70Hr0LvsUPuLoLGuWj5tcZHSykxi4juBtibrRf8rjw X-Received: by 2002:a17:902:7844:: with SMTP id e4-v6mr15425913pln.83.1517592201748; Fri, 02 Feb 2018 09:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592201; cv=none; d=google.com; s=arc-20160816; b=McNnQhjOvuKSanlayp3C3dZH96r7K/okX2T9/jhsV9VSbzAatrf9wKz0rdUIgbiw3g 0SY4R80KYP7JWQpdzqEZUDAdKRIDfSHWZJn3KHom7aYH0IEhsupguxTK+d9PqHQbaSEj TJZ7zvLIJo3dZ7RC93SCyyy0WD9K/ny+r+IOvcYxtURMG6NY8Ad0nchrVDQRDCzgkYiV IntMHKDcXn6QGzFXqSPCtcuLJnZqCXkadLCe3pSPbpV2pyBTxn274Axtn7eQkmDaQxG+ POoMsbKZ+0Fll4TA/pHiyVfdGpYP2pvpO9EwD4xL98xw0LTCu1z5QeSZNKSwAUUrIcD9 GHig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gKJrYxE7dX+TQthzbQnbxApgMoxyVjuxuKUZzQg46jE=; b=qZL3ukYvPEucaU9DJQ+3tSHQKKLzcA6PSKpNMVyf0bN4kh8kDYT2L6rcgQ5RKWLlcj 1+f+jdCQ7G5CPpwsv8KHlKZLZ1NAz+XMaxDDC5yAzM78oVbupVxFsZWeEkBNDkGWV0sE cOWCOw4oeNIdaDHO7iWJ3IGaey7rqCblGfb5WuAV8/HBWIDW+7mXVCdjOqNxS1KWJQ6g gCYXvH9Bclgi0naNkY+azw7O/ZcItaNy1QLIlChUpBZ3yTZQrlWmfbRYQ8a56cdMg6D1 yHvJ75YKIqglRn83T8LGEfnWxrkp0zwqbzrduWSnE0X2YOG5rx1IlqOnOyk/6RZNgY9P E7EQ== 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 i14si1684805pgp.516.2018.02.02.09.23.07; Fri, 02 Feb 2018 09:23:21 -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 S1753666AbeBBRUy (ORCPT + 99 others); Fri, 2 Feb 2018 12:20:54 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39178 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753235AbeBBRM7 (ORCPT ); Fri, 2 Feb 2018 12:12:59 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 947B5F09; Fri, 2 Feb 2018 17:12:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , Paolo Bonzini , Sasha Levin Subject: [PATCH 4.14 128/156] KVM: x86: emulate #UD while in guest mode Date: Fri, 2 Feb 2018 17:58:29 +0100 Message-Id: <20180202140846.162276178@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Bonzini [ Upstream commit bd89525a823ce6edddcedbe9aed79faa1b9cf544 ] This reverts commits ae1f57670703656cc9f293722c3b8b6782f8ab3f and ac9b305caa0df6f5b75d294e4b86c1027648991e. If the hardware doesn't support MOVBE, but L0 sets CPUID.01H:ECX.MOVBE in L1's emulated CPUID information, then L1 is likely to pass that CPUID bit through to L2. L2 will expect MOVBE to work, but if L1 doesn't intercept #UD, then any MOVBE instruction executed in L2 will raise #UD, and the exception will be delivered in L2. Commit ac9b305caa0df6f5b75d294e4b86c1027648991e is a better and more complete version of ae1f57670703 ("KVM: nVMX: Do not emulate #UD while in guest mode"); however, neither considers the above case. Suggested-by: Jim Mattson Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm.c | 9 +-------- arch/x86/kvm/vmx.c | 5 +---- 2 files changed, 2 insertions(+), 12 deletions(-) --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -362,7 +362,6 @@ static void recalc_intercepts(struct vcp { struct vmcb_control_area *c, *h; struct nested_state *g; - u32 h_intercept_exceptions; mark_dirty(svm->vmcb, VMCB_INTERCEPTS); @@ -373,14 +372,9 @@ static void recalc_intercepts(struct vcp h = &svm->nested.hsave->control; g = &svm->nested; - /* No need to intercept #UD if L1 doesn't intercept it */ - h_intercept_exceptions = - h->intercept_exceptions & ~(1U << UD_VECTOR); - c->intercept_cr = h->intercept_cr | g->intercept_cr; c->intercept_dr = h->intercept_dr | g->intercept_dr; - c->intercept_exceptions = - h_intercept_exceptions | g->intercept_exceptions; + c->intercept_exceptions = h->intercept_exceptions | g->intercept_exceptions; c->intercept = h->intercept | g->intercept; } @@ -2195,7 +2189,6 @@ static int ud_interception(struct vcpu_s { int er; - WARN_ON_ONCE(is_guest_mode(&svm->vcpu)); er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD); if (er == EMULATE_USER_EXIT) return 0; --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1891,7 +1891,7 @@ static void update_exception_bitmap(stru { u32 eb; - eb = (1u << PF_VECTOR) | (1u << MC_VECTOR) | + eb = (1u << PF_VECTOR) | (1u << UD_VECTOR) | (1u << MC_VECTOR) | (1u << DB_VECTOR) | (1u << AC_VECTOR); if ((vcpu->guest_debug & (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)) == @@ -1909,8 +1909,6 @@ static void update_exception_bitmap(stru */ if (is_guest_mode(vcpu)) eb |= get_vmcs12(vcpu)->exception_bitmap; - else - eb |= 1u << UD_VECTOR; vmcs_write32(EXCEPTION_BITMAP, eb); } @@ -5921,7 +5919,6 @@ static int handle_exception(struct kvm_v return 1; /* already handled by vmx_vcpu_run() */ if (is_invalid_opcode(intr_info)) { - WARN_ON_ONCE(is_guest_mode(vcpu)); er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD); if (er == EMULATE_USER_EXIT) return 0;