From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 5/5] KVM: nVMX: VMWRITE emulation: remove unnecessary check for compatibility mode Date: Mon, 7 Sep 2015 13:43:39 +0200 Message-ID: <55ED786B.3090109@redhat.com> References: <20150820193820.GA3593@unote> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: Eugene Korenevsky , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35077 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbbIGLnm (ORCPT ); Mon, 7 Sep 2015 07:43:42 -0400 In-Reply-To: <20150820193820.GA3593@unote> Sender: kvm-owner@vger.kernel.org List-ID: On 20/08/2015 21:38, Eugene Korenevsky wrote: > VMWRITE instruction is not valid in compatibility mode. This is > checked by nested_vmx_check_permission() function which throws #UD if CS.L=0. > The additional check in is_64_bit_mode() for CS.L=0 is useless. This is true, and it matches what handle_vmread does, on the other hand is_long_mode is generally used to test page table type. I think it's clearer if you change handle_vmread to use is_64_bit_mode instead. Paolo > We should check only EFER.LMA=1 which is done by is_long_mode(). > > Signed-off-by: Eugene Korenevsky > --- > arch/x86/kvm/vmx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index f39e24f..12bdaae 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -7034,7 +7034,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu) > field_value = kvm_register_readl(vcpu, > (((vmx_instruction_info) >> 3) & 0xf)); > else { > - mem_op_size = is_64_bit_mode(vcpu) ? 8 : 4; > + mem_op_size = is_long_mode(vcpu) ? 8 : 4; > if (get_vmx_mem_address(vcpu, exit_qualification, > vmx_instruction_info, false, mem_op_size, &gva)) > return 1; > -- 2.1.4