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=-1.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,UNPARSEABLE_RELAY 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 51A1BC10F11 for ; Thu, 11 Apr 2019 00:15:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F6C120850 for ; Thu, 11 Apr 2019 00:15:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cPPcYJHf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbfDKAP2 (ORCPT ); Wed, 10 Apr 2019 20:15:28 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:45576 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfDKAP2 (ORCPT ); Wed, 10 Apr 2019 20:15:28 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x3ANwjLs173543; Thu, 11 Apr 2019 00:15:20 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=QPkdLyE8TaiNLRuHh56kAeRHIwXCBan6CTZf9BRzcdI=; b=cPPcYJHfSt0J4lOstC5Sy3/EKSdiB709V4BEZCQW6LoQY764FAM6dM3IkLWSzGZgKr87 G4enKhbaC4RC1EC53IAgmyhi5UCOjQGs897SfbuTTnBtzQIBO4QG7jQEFzKi/n2HSf4p zFaCrGxJ30gNYEWaLaboazVPwHaMaH7AsBbZffpSWcTIyQbnHH1iVTx1n7ekzKRYsbgc 1wyrlEwZKaQrj/EDDh07fPaoHuQUCPc+qCHGuh34a7AnDiXC9H4VdiJjwu4mODTfoK9x nlktXoiJvVZki6mY9027xYo+oXBhNIfb6QHgPAnfiQWys+K4UrHADLhIa7dQrvRArUze dA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 2rphmep4es-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 00:15:20 +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 x3B0ETTx004098; Thu, 11 Apr 2019 00:15:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2rpkek6fgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Apr 2019 00:15:19 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x3B0FIvB027545; Thu, 11 Apr 2019 00:15:18 GMT Received: from dhcp-10-132-91-102.usdhcp.oraclecorp.com (/10.132.91.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Apr 2019 17:15:18 -0700 Subject: Re: [PATCH 5/6 v5][KVM nVMX]: nested_vmx_check_vmentry_postreqs() should return VMX_EXIT_REASONS_FAILED_VMENTRY | EXIT_REASON_INVALID_STATE for error conditions To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, jmattson@google.com References: <20190408213516.17966-1-krish.sadhukhan@oracle.com> <20190408213516.17966-6-krish.sadhukhan@oracle.com> <15d3f7f7-f377-1295-55a7-5651d7d44349@redhat.com> <20190410160825.GA26808@linux.intel.com> <20190410175530.GA27893@linux.intel.com> From: Krish Sadhukhan Message-ID: <8e52d3b1-ba67-8d02-7fd9-20d2b279ba36@oracle.com> Date: Wed, 10 Apr 2019 17:15:17 -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: <20190410175530.GA27893@linux.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=9223 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904100157 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9223 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904100157 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 04/10/2019 10:55 AM, Sean Christopherson wrote: > On Wed, Apr 10, 2019 at 07:05:30PM +0200, Paolo Bonzini wrote: >> On 10/04/19 18:08, Sean Christopherson wrote: >>> Good point, though IMO it'd be better to go one step further and actually >>> consume the return value in nested_vmx_enter_non_root_mode(). For me, >>> having the exit reason in nested_vmx_check_vmentry_postreqs() is a nice >>> mental reminder that "postreqs" is referring to checks that happen once >>> the CPU has "committed" to VM-Enter. >> It's certainly better if you don't have to return >> VMX_EXIT_REASONS_FAILED_VMENTRY. However, I think it still complicates >> things a bit, after all the result is always EXIT_REASON_INVALID_STATE. >> >> The SDM says "VM-entry failure due to invalid guest state. A VM entry >> failed one of the checks identified in Section 26.3.1" so the bool (or >> 0/-EINVAL) return code is a nice reminder that the function covers a >> subset of 26.3.1. > Heh, for me, returning EXIT_REASON_INVALID_STATE is the reminder that > the function covers 26.3.1. I think the cleaner approach would be to return -EINVAL in both *_pre{post}reqs functions and carry the exit code via a new function parameter. That will make the code more readable. > What if we rename the function to nested_vmx_check_vmentry_guest_state()? > My desire to return the exit reason mostly stems from the name "postreqs" > since I tend to forget what "postreqs" is referring to. And it'd be more > appropriate since the MSR load checks are handled elsewhere and really > should be considered "postreqs" as well. May be we should also rename its counterpart (i.e.,nested_vmx_check_vmentry_prereqs) to something like nested_vmx_check_vmentry_pre_guest_state or something similar ? The SDM doesn't explicitly mention whether MSR loading happens right after guest state is loaded, though it seems that's the order. If so, we should probably put these checks in function called nested_vmx_check_vmentry_msr_load or something like that.