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 1EDB8C10F13 for ; Thu, 11 Apr 2019 21:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D358920850 for ; Thu, 11 Apr 2019 21:05:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Uwiyycm6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfDKVFk (ORCPT ); Thu, 11 Apr 2019 17:05:40 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:57436 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbfDKVFk (ORCPT ); Thu, 11 Apr 2019 17:05:40 -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 x3BKnExT006516; Thu, 11 Apr 2019 21:00:32 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=Uq0hidX774LQzTlNOeUxjlxG/QN6Ruc5+LrNmRdJnKA=; b=Uwiyycm62DONdT7NknHTTFIfLhG1txbdztCoOeaX/yYd3cGhgnZbhxLddmRheAYDRX8/ z3UFzsix8bYCIxf/Np1UXuanvREEKsAtIMIc81SQ+kCTP+xWwf/DSuqayc0o922szK+d CNQ+6aMWG+cYHipUbd04Eq6P2AxFi5E2UQdZlIFmoqjHpmYY5Lq0bhI9dIC8cru7cnG2 2I75Fx/1A3SJNoH5PR8xFf8umgmolrRxcj/H60ONqCMPImiKYAaa5xLeVBm1mqPhXoJQ fN4skuoon474WM8I2qwcEY8TI+O7TfFUNB5Qx+iYHuI93xiaiw0m42tGAlJc42zy0H9Z TA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2rpkhtbb49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 21:00:27 +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 x3BL00ba110297; Thu, 11 Apr 2019 21:00:27 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2rpkeknrs1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 21:00:27 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x3BL0QJG001948; Thu, 11 Apr 2019 21:00:26 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:00:26 -0700 Subject: Re: [PATCH v6 3/7] KVM: nVMX: Move guest non-reg state checks to VM-Exit path 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-4-sean.j.christopherson@intel.com> From: Krish Sadhukhan Message-ID: Date: Thu, 11 Apr 2019 14:00:25 -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-4-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=942 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110136 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 lowpriorityscore=0 mlxlogscore=966 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904110136 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: > Per Intel's SDM, volume 3, section Checking and Loading Guest State: > > Because the checking and the loading occur concurrently, a failure may > be discovered only after some state has been loaded. For this reason, > the logical processor responds to such failures by loading state from > the host-state area, as it would for a VM exit. > > In other words, a failed non-register state consistency check results in > a VM-Exit, not VM-Fail. Moving the non-reg state checks also paves the > way for renaming nested_vmx_check_vmentry_postreqs() to align with the > SDM, i.e. nested_vmx_check_vmentry_guest_state(). > > Fixes: 26539bd0e446a ("KVM: nVMX: check vmcs12 for valid activity state") > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/nested.c | 30 +++++++++++++++--------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > index f487aae3233e..fe1323ab6894 100644 > --- a/arch/x86/kvm/vmx/nested.c > +++ b/arch/x86/kvm/vmx/nested.c > @@ -2612,18 +2612,6 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, > return 0; > } > > -/* > - * Checks related to Guest Non-register State > - */ > -static int nested_check_guest_non_reg_state(struct vmcs12 *vmcs12) > -{ > - if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE && > - vmcs12->guest_activity_state != GUEST_ACTIVITY_HLT) > - return -EINVAL; > - > - return 0; > -} > - > static int nested_vmx_check_vmentry_prereqs(struct kvm_vcpu *vcpu, > struct vmcs12 *vmcs12) > { > @@ -2635,9 +2623,6 @@ static int nested_vmx_check_vmentry_prereqs(struct kvm_vcpu *vcpu, > if (nested_check_host_control_regs(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; > > - if (nested_check_guest_non_reg_state(vmcs12)) > - return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > - > return 0; > } > > @@ -2668,6 +2653,18 @@ static int nested_vmx_check_vmcs_link_ptr(struct kvm_vcpu *vcpu, > return r; > } > > +/* > + * Checks related to Guest Non-register State > + */ > +static int nested_check_guest_non_reg_state(struct vmcs12 *vmcs12) > +{ > + if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE && > + vmcs12->guest_activity_state != GUEST_ACTIVITY_HLT) > + return -EINVAL; > + > + return 0; > +} > + > static int nested_vmx_check_vmentry_postreqs(struct kvm_vcpu *vcpu, > struct vmcs12 *vmcs12, > u32 *exit_qual) > @@ -2713,6 +2710,9 @@ static int nested_vmx_check_vmentry_postreqs(struct kvm_vcpu *vcpu, > (vmcs12->guest_bndcfgs & MSR_IA32_BNDCFGS_RSVD))) > return 1; > > + if (nested_check_guest_non_reg_state(vmcs12)) > + return 1; > + > return 0; > } > Reviewed-by: Krish Sadhukhan