From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E2C1C10F13 for ; Thu, 11 Apr 2019 22:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED9E02184B for ; Thu, 11 Apr 2019 22:02:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="c8ezjlym" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbfDKWCd (ORCPT ); Thu, 11 Apr 2019 18:02:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51184 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbfDKWCd (ORCPT ); Thu, 11 Apr 2019 18:02:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3BLs0Xb061195; Thu, 11 Apr 2019 22:02:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=ftgsgb9OWux0rIpZIGLCMObX68z8y2LkPnbQkKp03xg=; b=c8ezjlym1fC0l59IGczg+a0yu93unCLhGdByPxNL2KakDU1BXydgNxaxGLcwSTxzeeQh vyD276l0cIjqCxGxK1/PEkFrYX93hvFeMzXSb7Eg1qQmS6ZRDIAVDUGipvAf681BBq2s ta/8QfUx9sEZQM3X/TXtCTSHK7F3b/5KkeXctGGlCstRdpXIDSDlxZBvgDa80HfDmYsf ++dkr8pjFP9kmsKP44GdGVPiaC61Zbxqtf6XcHNU7LX9SOe5XLH5tRk2AAnoDZmimLwv q1wlWjMlKUau2VyZ/uQbfABjRnWKieepJY2hA2GJCtD77T38QHxxfhTdf42MULdSvt/9 AQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2rpmrqkdrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 22:02:25 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3BM1xQx059496; Thu, 11 Apr 2019 22:02:25 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2rtd848pmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 22:02:25 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x3BM2O0H005811; Thu, 11 Apr 2019 22:02:24 GMT Received: from dhcp-10-132-91-102.usdhcp.oraclecorp.com (/10.132.91.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Apr 2019 15:02:24 -0700 Subject: Re: [PATCH v6 6/7] KVM: nVMX: Collapse nested_check_host_control_regs() into its caller To: Sean Christopherson , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: kvm@vger.kernel.org, Karl Heubaum , Jim Mattson References: <20190411191809.8131-1-sean.j.christopherson@intel.com> <20190411191809.8131-7-sean.j.christopherson@intel.com> From: Krish Sadhukhan Message-ID: Date: Thu, 11 Apr 2019 15:02:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20190411191809.8131-7-sean.j.christopherson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9224 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=748 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110140 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9224 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=772 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110140 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 04/11/2019 12:18 PM, Sean Christopherson wrote: > ...now that nested_vmx_check_host_state() returns -EINVAL to indicate > failure, i.e. moving the checks doesn't require changing their return > values to be 'VMXERR_ENTRY_INVALID_HOST_STATE_FIELD'. This eliminates > a misleading function name since nested_check_host_control_regs() was > checking MSRs as well as control registers. > > Alternatively, nested_check_host_control_regs() could be split up, > e.g. into _control_regs(), _debug_regs() and _msrs(), but that's a > bit gratutitous at this time given that the entire function is 30 LoC. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/nested.c | 26 ++++++-------------------- > 1 file changed, 6 insertions(+), 20 deletions(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index 16cff40456ee..98afbe7c15a1 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -2590,13 +2590,11 @@ static int nested_vmx_check_controls(struct kvm_vcpu *vcpu, > return 0; > } > > -/* > - * Checks related to Host Control Registers and MSRs > - */ > -static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, > - struct vmcs12 *vmcs12) > +static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, > + struct vmcs12 *vmcs12, > + u32 *vm_instruction_error) > { > - bool ia32e; > + *vm_instruction_error = VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; > > if (!nested_host_cr0_valid(vcpu, vmcs12->host_cr0) || > !nested_host_cr4_valid(vcpu, vmcs12->host_cr4) || > @@ -2618,8 +2616,8 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, > * the host address-space size VM-exit control. > */ > if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) { > - ia32e = (vmcs12->vm_exit_controls & > - VM_EXIT_HOST_ADDR_SPACE_SIZE) != 0; > + bool ia32e = (vmcs12->vm_exit_controls & > + VM_EXIT_HOST_ADDR_SPACE_SIZE) != 0; > if (!kvm_valid_efer(vcpu, vmcs12->host_ia32_efer) || > ia32e != !!(vmcs12->host_ia32_efer & EFER_LMA) || > ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) > @@ -2629,18 +2627,6 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, > return 0; > } > > -static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, > - struct vmcs12 *vmcs12, > - u32 *vm_instruction_error) > -{ > - *vm_instruction_error = VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; > - > - if (nested_check_host_control_regs(vcpu, vmcs12)) > - return -EINVAL; > - > - return 0; > -} > - > static int nested_vmx_check_vmcs_link_ptr(struct kvm_vcpu *vcpu, > struct vmcs12 *vmcs12) > { Reviewed-by: Krish Sadhukhan