Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp195016pxb; Fri, 17 Sep 2021 23:37:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNCCU2yfNT9gc3QOG728vdJrNCH3C4v7FcLmALnylzCagImGzl1Z/5D2B2fAqP9oyzif4n X-Received: by 2002:a17:906:912:: with SMTP id i18mr16580123ejd.257.1631947053452; Fri, 17 Sep 2021 23:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631947053; cv=none; d=google.com; s=arc-20160816; b=Ca6yDLqkvFCFptWmbTyzNV09uNxIbIl+19gri1El6hCC0xef3Z59QkGJlbZvT4hOZs zj0xFfuv5/4lpzwfyab8PKvMdbmblzTJuIRBJ8QC7CqO2vO8J83iJU9Cud8+ybRa7TiD 0LwTHo23QEAmJVXuOCwm7GK3o/K2t+eqMpG8Sj9fXbtw9IVxwkkAI2teKIMkUAOOw96N 9v2HjxgHWfOkDFj0QRpX0dPgzhj3+a5XjVDzAea7IB0obDgqoev/93YIC2Y/2TkJbMN0 n5WCwVm6Z6cHVhP03gGZ/3MFkwP+Ovn9nJecvY2ZBSuc7G0W2I+UvgjhSWamqeS5qh0g y4Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=9KVrfiklkVECaeSVg2D0hr5O/EWzrtVcMwf/u9ZnLKs=; b=o8lbd8uCmPat7/GTDm1D4nAfNLLY0G0r6rJ7AaCrWlaylAX7a7tgzIQW/4Mgeq3rNa vGEsQb/oHOnYtbksrM9u2mWsKI09qBrjheYu1ZNvLj7MIAz03uv4Si60oZaBvHlikgee P51X6lAbs6+8RokqekTklSaTowjAV7V8wjuX1OggMX2fD0s9wY2KkUorTzj+Z2FqXS8S 8iQJ2+UjRkH/w6SvXb88ZuOhSoS4p01gG7xzv7eKukiuLWXQkWqU8hENtmE9ZdHwGIW/ 2v40HqusWmhUA+0CtAkhfcGJOTJb3YLqEEFQ0TYAf4qbUvkFahJzpk18ZUpnaG2XgaI2 TVwg== 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 r25si9760292ejc.100.2021.09.17.23.37.10; Fri, 17 Sep 2021 23:37:33 -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 S235239AbhIQQPf (ORCPT + 99 others); Fri, 17 Sep 2021 12:15:35 -0400 Received: from mga03.intel.com ([134.134.136.65]:1339 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232518AbhIQQPa (ORCPT ); Fri, 17 Sep 2021 12:15:30 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10110"; a="222879894" X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="222879894" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2021 09:14:07 -0700 X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="546478238" Received: from zengguan-mobl.ccr.corp.intel.com (HELO [10.254.208.219]) ([10.254.208.219]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2021 09:14:01 -0700 Subject: Re: [PATCH v4 2/6] KVM: VMX: Extend BUILD_CONTROLS_SHADOW macro to support 64-bit variation To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "kvm@vger.kernel.org" , Dave Hansen , "Luck, Tony" , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , "Huang, Kai" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "Hu, Robert" , "Gao, Chao" , Robert Hoo References: <20210809032925.3548-1-guang.zeng@intel.com> <20210809032925.3548-3-guang.zeng@intel.com> From: Zeng Guang Message-ID: <9f8585cd-9c99-b8bd-8400-0fa922b0d361@intel.com> Date: Sat, 18 Sep 2021 00:13:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/11/2021 5:28 AM, Sean Christopherson wrote: > On Mon, Aug 09, 2021, Zeng Guang wrote: >> +static inline u##bits lname##_controls_get(struct vcpu_vmx *vmx) \ >> +{ \ >> + return vmx->loaded_vmcs->controls_shadow.lname; \ >> +} \ > This conflicts with commit 389ab25216c9 ("KVM: nVMX: Pull KVM L0's desired controls > directly from vmcs01"), I believe the correct resolution is: > > --- > arch/x86/kvm/vmx/vmx.h | 59 ++++++++++++++++++++++-------------------- > 1 file changed, 31 insertions(+), 28 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h > index 4858c5fd95f2..1ae43afe52a7 100644 > --- a/arch/x86/kvm/vmx/vmx.h > +++ b/arch/x86/kvm/vmx/vmx.h > @@ -408,35 +408,38 @@ static inline u8 vmx_get_rvi(void) > return vmcs_read16(GUEST_INTR_STATUS) & 0xff; > } > > -#define BUILD_CONTROLS_SHADOW(lname, uname) \ > -static inline void lname##_controls_set(struct vcpu_vmx *vmx, u32 val) \ > -{ \ > - if (vmx->loaded_vmcs->controls_shadow.lname != val) { \ > - vmcs_write32(uname, val); \ > - vmx->loaded_vmcs->controls_shadow.lname = val; \ > - } \ > -} \ > -static inline u32 __##lname##_controls_get(struct loaded_vmcs *vmcs) \ > -{ \ > - return vmcs->controls_shadow.lname; \ > -} \ > -static inline u32 lname##_controls_get(struct vcpu_vmx *vmx) \ > -{ \ > - return __##lname##_controls_get(vmx->loaded_vmcs); \ > -} \ > -static inline void lname##_controls_setbit(struct vcpu_vmx *vmx, u32 val) \ > -{ \ > - lname##_controls_set(vmx, lname##_controls_get(vmx) | val); \ > -} \ > -static inline void lname##_controls_clearbit(struct vcpu_vmx *vmx, u32 val) \ > -{ \ > - lname##_controls_set(vmx, lname##_controls_get(vmx) & ~val); \ > +#define BUILD_CONTROLS_SHADOW(lname, uname, bits) \ > +static inline \ > +void lname##_controls_set(struct vcpu_vmx *vmx, u##bits val) \ > +{ \ > + if (vmx->loaded_vmcs->controls_shadow.lname != val) { \ > + vmcs_write##bits(uname, val); \ > + vmx->loaded_vmcs->controls_shadow.lname = val; \ > + } \ > +} \ > +static inline u##bits __##lname##_controls_get(struct loaded_vmcs *vmcs)\ > +{ \ > + return vmcs->controls_shadow.lname; \ > +} \ > +static inline u##bits lname##_controls_get(struct vcpu_vmx *vmx) \ > +{ \ > + return __##lname##_controls_get(vmx->loaded_vmcs); \ > +} \ > +static inline \ > +void lname##_controls_setbit(struct vcpu_vmx *vmx, u##bits val) \ > +{ \ > + lname##_controls_set(vmx, lname##_controls_get(vmx) | val); \ > +} \ > +static inline \ > +void lname##_controls_clearbit(struct vcpu_vmx *vmx, u##bits val) \ > +{ \ > + lname##_controls_set(vmx, lname##_controls_get(vmx) & ~val); \ > } > -BUILD_CONTROLS_SHADOW(vm_entry, VM_ENTRY_CONTROLS) > -BUILD_CONTROLS_SHADOW(vm_exit, VM_EXIT_CONTROLS) > -BUILD_CONTROLS_SHADOW(pin, PIN_BASED_VM_EXEC_CONTROL) > -BUILD_CONTROLS_SHADOW(exec, CPU_BASED_VM_EXEC_CONTROL) > -BUILD_CONTROLS_SHADOW(secondary_exec, SECONDARY_VM_EXEC_CONTROL) > +BUILD_CONTROLS_SHADOW(vm_entry, VM_ENTRY_CONTROLS, 32) > +BUILD_CONTROLS_SHADOW(vm_exit, VM_EXIT_CONTROLS, 32) > +BUILD_CONTROLS_SHADOW(pin, PIN_BASED_VM_EXEC_CONTROL, 32) > +BUILD_CONTROLS_SHADOW(exec, CPU_BASED_VM_EXEC_CONTROL, 32) > +BUILD_CONTROLS_SHADOW(secondary_exec, SECONDARY_VM_EXEC_CONTROL, 32) > > static inline void vmx_register_cache_reset(struct kvm_vcpu *vcpu) > { > -- I will rebase it. Thanks.