Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4321703ybz; Tue, 28 Apr 2020 09:19:54 -0700 (PDT) X-Google-Smtp-Source: APiQypJcaj1HBtsoy9fGUqSO5VtnHbdsBqHoFRqhIW4tpx/m++iU2CRLbfWSjEbOxMXJkYCpBgmZ X-Received: by 2002:a05:6402:4a:: with SMTP id f10mr24239116edu.274.1588090793898; Tue, 28 Apr 2020 09:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588090793; cv=none; d=google.com; s=arc-20160816; b=eXGr2SzDWsKuIiAS3UnP8Se9MQTEFlxtu9kn230SWFaxtgfRJOAc0qvZStj649fngf bzOn5HgyyG8J8LG7+HnqDpWYNguoU5sGsaIPHIoas73XfU9wgQJ/+S6aUhQVx7S82Nx4 iioVxPjeZinG890OoIabOXYsEb2LXrb17bd1HrFRXOYRJVWago8q/HYIHMbjdKk7ybLt CUmqUSYVL7H8r1UzIHOZyehL7qI4e0M9MGJQXAfCz4s9Mje8qyeYPx5yQGKZ/R+5hMb8 MrzwCvIOuQxUTXfujM1KBVlCUThjnC35OvfmPDRn6LmKDC0webCXw7nietMUWnz5WqBM KuEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=QjGBMdrgdwr4wvyRPWIdnDhUH1CzjOgjvhIhGsnJkbw=; b=rnEqGjO97IZ+UIBmrPu8U44yf9MDNtxCmb2ACG87B6rWO2IchjNFYX+8hicDfZd5P6 K3lrl57oSCVZj/CHN9l87tNnXUkcrqvIyyyB1y9HnF9WqFNsaHF5sqbVOwOegaxDaXDQ +/hkc73XxE/+efbRtZbe7gjMoyi2q2Rnf8COmLIaqjuh1+zYS782PU0J2JmTOWZPvDUl 8hUv3B7Iwl/HDZPGTOq3/hTxh3MB81V7XQHhqqfJskpkOAhmuWg8YI6773vcYd9j0UaS WlhZOpeIOC7yXDcqci0Fur3pgA+2pgBY6IymJGLYSbThcIdn6JH5JEOw3R7hxd0yJr2B qYpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy6si2092347ejb.383.2020.04.28.09.19.23; Tue, 28 Apr 2020 09:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728422AbgD1QRm (ORCPT + 99 others); Tue, 28 Apr 2020 12:17:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:37679 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbgD1QRl (ORCPT ); Tue, 28 Apr 2020 12:17:41 -0400 IronPort-SDR: zf7GrIhMBjxFAYhNqoINlsjBiaU5VnMSFSAWszRXvRISkAKbfsUDW+WH0OAkXb1IuoK0LQl2mz 0daagmj8pVwQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 09:17:41 -0700 IronPort-SDR: habY9dDlpjQSbFwhsKrvFROBzve+61bPVytg/y6AG7KN3g3EJj0oWnK86Qswq51t94UxTKiLT8 zElpX3RgXOQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,328,1583222400"; d="scan'208";a="367543361" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga001.fm.intel.com with ESMTP; 28 Apr 2020 09:17:40 -0700 Date: Tue, 28 Apr 2020 09:17:40 -0700 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML Subject: Re: [PATCH] KVM: nVMX: Tweak handling of failure code for nested VM-Enter failure Message-ID: <20200428161740.GE12735@linux.intel.com> References: <20200424171925.1178-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 10:47:04AM -0700, Jim Mattson wrote: > On Fri, Apr 24, 2020 at 10:19 AM Sean Christopherson > wrote: > > if (from_vmentry) { > > exit_reason = EXIT_REASON_MSR_LOAD_FAIL; > > - exit_qual = nested_vmx_load_msr(vcpu, > > - vmcs12->vm_entry_msr_load_addr, > > - vmcs12->vm_entry_msr_load_count); > > - if (exit_qual) > > + failed_msr = nested_vmx_load_msr(vcpu, > > + vmcs12->vm_entry_msr_load_addr, > > + vmcs12->vm_entry_msr_load_count); > > + if (failed_msr) { > > + entry_failure_code = failed_msr; > > This assignment is a bit dodgy from a type perspective, and suggests > that perhaps a better type for the local variable is an > undiscriminated union of the enumerated type and a sufficiently large > unsigned integer type. But I won't be a stickler if you add a comment. > :-) This is a bit ugly. A union doesn't work well because writing the enum field isn't guaranteed to write the full width of the union, i.e. could lead to uninitialized variable usage without additional initialization of the union. The reverse is true as well, e.g. if the compiler sizes the enum to be larger than an unisigned int. Rather than use a common local variable, I think it's best to set vmcs12 directly. That also provides an opportunity to set exit_reason on demand instead of speculatively setting it, which has always bugged me. v2 incoming.