Received: by 10.223.185.116 with SMTP id b49csp6377837wrg; Wed, 28 Feb 2018 08:25:33 -0800 (PST) X-Google-Smtp-Source: AH8x227+kq1o/RyExoejpFwSYqRWMvkvP5sNjxj3ASKW2+36jTfQkSUgt26FaOr8ZcwzFMq3VRq9 X-Received: by 10.99.127.69 with SMTP id p5mr14556477pgn.346.1519835133390; Wed, 28 Feb 2018 08:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519835133; cv=none; d=google.com; s=arc-20160816; b=uDa6BUZQu9JeIGk0S2leEkN2gqOewZ813nkjVoLlWXBSWKqgMYH682+9M2YppAhKsr FuuAh6vsPDlo4sXNkjHxRGxskBhLh9RsXYvd6VGxd2sQfYuNihucdAbLDDK9t4BmW9qn oZQYUEVvWNVR+dmvNoNEOXYs8sqDpnpX8HWrV77+PqGwHsHQeLm05C4a/xGPwYUuKqdK oU61Ezha5DZyJjMA+anMAqMFWa6fsT5GvSHr3AHAHK4c5DS47Hn4ty78m2c2eN+5Ogwc KvQ8w+8Uoz1JJT9Uowgg/bPqgFjmGiPA09H7ujteRd33l9JiVld8kVWw9prU82d54tem ybhA== 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=GGjMI1Po8hVdqcF++wpEqH7somvIVxjWAogVlJEzIyk=; b=OivaJOJiErSI3D12H6LTd8NT7q+lhgTCMiGc4oAKjJnhGmZcFQcdoyybh9ONYbryrH Y/Su1mzOk7yo009CrOt1dIEjIHjbR/4BgfjmDTa1sXmMM42OlI0+l3GMkye9k8k0Uziv gVKdtmZ+qBy0dp2ltXY0vAhuqbT6o1+0kSUz7FGQ/C0QCSSX0kfeasMbGY86f+to992j JIyGbLV/64JQDcczCjsXk2RPZTh3/es/+6gKrssitau55UueGXi6gxjs/JkdEWN8+Tny 5Je1mavU0edVR/nT0v39zPwFHvdfpEfy8Ap+vtCXu1BHTVPypuKMCgJTCvwlPoargPUH igdA== 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 i6si1203831pgq.471.2018.02.28.08.25.18; Wed, 28 Feb 2018 08:25:33 -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 S935166AbeB1QUf (ORCPT + 99 others); Wed, 28 Feb 2018 11:20:35 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35359 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935146AbeB1QUc (ORCPT ); Wed, 28 Feb 2018 11:20:32 -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-0006XU-GO; Wed, 28 Feb 2018 15:22:33 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yc-0008M4-R4; 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, "Nikita Leshenko" , "Konrad Rzeszutek Wilk" , "Liran Alon" , "Wanpeng Li" , "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 005/254] KVM: x86: Don't re-execute instruction when not passing CR2 value 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 9b8ae63798cb97e785a667ff27e43fa6220cb734 upstream. In case of instruction-decode failure or emulation failure, x86_emulate_instruction() will call reexecute_instruction() which will attempt to use the cr2 value passed to x86_emulate_instruction(). However, when x86_emulate_instruction() is called from emulate_instruction(), cr2 is not passed (passed as 0) and therefore it doesn't make sense to execute reexecute_instruction() logic at all. Fixes: 51d8b66199e9 ("KVM: cleanup emulate_instruction") Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Wanpeng Li Signed-off-by: Radim Krčmář Signed-off-by: Ben Hutchings --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/vmx.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -847,7 +847,8 @@ int x86_emulate_instruction(struct kvm_v static inline int emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type) { - return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0); + return x86_emulate_instruction(vcpu, 0, + emulation_type | EMULTYPE_NO_REEXECUTE, NULL, 0); } void kvm_enable_efer_bits(u64); --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -5659,7 +5659,7 @@ static int handle_invalid_guest_state(st if (test_bit(KVM_REQ_EVENT, &vcpu->requests)) return 1; - err = emulate_instruction(vcpu, EMULTYPE_NO_REEXECUTE); + err = emulate_instruction(vcpu, 0); if (err == EMULATE_USER_EXIT) { ++vcpu->stat.mmio_exits;