From mboxrd@z Thu Jan 1 00:00:00 1970 From: Liran Alon Subject: Re: [PATCH 3/3] KVM: x86: Don't re-execute instruction when not passing CR2 value Date: Mon, 06 Nov 2017 12:48:20 +0200 Message-ID: <5A003DF4.9060405@ORACLE.COM> References: <1509891703-9735-1-git-send-email-liran.alon@oracle.com> <1509891703-9735-4-git-send-email-liran.alon@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: idan.brown@ORACLE.COM, Liran Alon , Konrad Rzeszutek Wilk To: Paolo Bonzini , rkrcmar@redhat.com, kvm@vger.kernel.org Return-path: Received: from aserp1040.oracle.com ([141.146.126.69]:22502 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751490AbdKFKsc (ORCPT ); Mon, 6 Nov 2017 05:48:32 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 06/11/17 11:21, Paolo Bonzini wrote: > On 05/11/2017 15:21, Liran Alon wrote: >> From: Liran Alon >> >> 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 >> --- >> arch/x86/include/asm/kvm_host.h | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h >> index c73e493adf07..bc1347949cef 100644 >> --- a/arch/x86/include/asm/kvm_host.h >> +++ b/arch/x86/include/asm/kvm_host.h >> @@ -1156,7 +1156,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, >> 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); >> > > You can remove EMULTYPE_NO_REEXECUTE from handle_invalid_guest_state now. Nice catch. Will remove it in next version of this commit. Thanks. > > Thanks, > > Paolo >