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 24193C10F13 for ; Thu, 11 Apr 2019 21:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5C0C2077C for ; Thu, 11 Apr 2019 21:23:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="EC+FHJOQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfDKVX3 (ORCPT ); Thu, 11 Apr 2019 17:23:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44088 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfDKVX3 (ORCPT ); Thu, 11 Apr 2019 17:23:29 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3BL8uN1021833; Thu, 11 Apr 2019 21:23:22 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=RpYbabZbjNn6RwvG5mwTdKiZT8824doirqCTpDSVKdM=; b=EC+FHJOQt6zXaBKVW3oe+TevZUVf7ppu22b7/HQnLQOpH+Jo/HsqJm4fvnfAHz8ErAeF wyAJJbw+mBxbuT4AXTSqPUEoMXyzodcdlh32UlueeqwytXs+Z9O9YF0QGD5C1EV811fE zwLcHnfsUOVMeQdalHHuSa4p29jtTVSiuNL4P/qcRKSImderDo1yxbQCoxvN7Dr57Z6F MRljOXjLC5hFF/xJUedGqTi18uaYUDZ1KyE2OJsS/ocVMLdBdYxEAnTWTTri0AcNPBPS hg2wboDYFTamYjeiucDkvVu6SfVXqqw8hpAW9XGf0hTxRO8xsbETQ0U27flXqOB3g2f7 Ng== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2rpkhtbdqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 21:23:21 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3BLLfFD011212; Thu, 11 Apr 2019 21:23:20 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2rt9uputy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 21:23:20 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x3BLNKF5024395; Thu, 11 Apr 2019 21:23:20 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 14:23:19 -0700 Subject: Re: [PATCH v6 4/7] KVM: nVMX: Rename and split top-level consistency checks to match SDM 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-5-sean.j.christopherson@intel.com> From: Krish Sadhukhan Message-ID: Date: Thu, 11 Apr 2019 14:23:18 -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-5-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=937 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110137 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=963 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110137 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: > Rename the top-level consistency check functions to (loosely) align with > the SDM. Historically, KVM has used the terms "prereq" and "postreq" to > differentiate between consistency checks that lead to VM-Fail and those > that lead to VM-Exit. The terms are vague and potentially misleading, > e.g. "postreq" might be interpreted as occurring after VM-Entry. > > Note, while the SDM lumps controls and host state into a single section, > "Checks on VMX Controls and Host-State Area", split them into separate > top-level functions as the two categories of checks result in different > VM instruction errors. This split will allow for additional cleanup. > > Note #2, "vmentry" is intentionally dropped from the new function names > to avoid confusion with nested_check_vm_entry_controls(), and to keep > the length of the functions names somewhat manageable. > > Suggested-by: Paolo Bonzini > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/nested.c | 39 +++++++++++++++++++++++++-------------- > 1 file changed, 25 insertions(+), 14 deletions(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index fe1323ab6894..b22605d5ee9e 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -2573,6 +2573,17 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu, > return 0; > } > > +static int nested_vmx_check_controls(struct kvm_vcpu *vcpu, > + struct vmcs12 *vmcs12) > +{ > + if (nested_check_vm_execution_controls(vcpu, vmcs12) || > + nested_check_vm_exit_controls(vcpu, vmcs12) || > + nested_check_vm_entry_controls(vcpu, vmcs12)) > + return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > + > + return 0; > +} > + > /* > * Checks related to Host Control Registers and MSRs > */ > @@ -2612,14 +2623,9 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, > return 0; > } > > -static int nested_vmx_check_vmentry_prereqs(struct kvm_vcpu *vcpu, > - struct vmcs12 *vmcs12) > +static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, > + struct vmcs12 *vmcs12) > { > - if (nested_check_vm_execution_controls(vcpu, vmcs12) || > - nested_check_vm_exit_controls(vcpu, vmcs12) || > - nested_check_vm_entry_controls(vcpu, vmcs12)) > - return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > - > if (nested_check_host_control_regs(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; > > @@ -2665,9 +2671,9 @@ static int nested_check_guest_non_reg_state(struct vmcs12 *vmcs12) > return 0; > } > > -static int nested_vmx_check_vmentry_postreqs(struct kvm_vcpu *vcpu, > - struct vmcs12 *vmcs12, > - u32 *exit_qual) > +static int nested_vmx_check_guest_state(struct kvm_vcpu *vcpu, > + struct vmcs12 *vmcs12, > + u32 *exit_qual) > { > bool ia32e; > > @@ -2985,7 +2991,7 @@ int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) > return -1; > } > > - if (nested_vmx_check_vmentry_postreqs(vcpu, vmcs12, &exit_qual)) > + if (nested_vmx_check_guest_state(vcpu, vmcs12, &exit_qual)) > goto vmentry_fail_vmexit; > } > > @@ -3130,7 +3136,11 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) > launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS > : VMXERR_VMRESUME_NONLAUNCHED_VMCS); > > - ret = nested_vmx_check_vmentry_prereqs(vcpu, vmcs12); > + ret = nested_vmx_check_controls(vcpu, vmcs12); > + if (ret) > + return nested_vmx_failValid(vcpu, ret); > + > + ret = nested_vmx_check_host_state(vcpu, vmcs12); > if (ret) > return nested_vmx_failValid(vcpu, ret); > > @@ -5455,8 +5465,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, > return -EINVAL; > } > > - if (nested_vmx_check_vmentry_prereqs(vcpu, vmcs12) || > - nested_vmx_check_vmentry_postreqs(vcpu, vmcs12, &exit_qual)) > + if (nested_vmx_check_controls(vcpu, vmcs12) || > + nested_vmx_check_host_state(vcpu, vmcs12) || > + nested_vmx_check_guest_state(vcpu, vmcs12, &exit_qual)) > return -EINVAL; > > vmx->nested.dirty_vmcs12 = true; It's probably a good idea to add a one-line comment above each of the top-level check functions. Reviewed-by: Krish Sadhukhan