Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1803088pxb; Fri, 10 Sep 2021 14:32:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqpz/LcIUN35Rg8nO4vCDKR2f6uVyjw3io+1ChCzB3m5m2DTPuJc6h2WqOgoTu6y/O6Nd1 X-Received: by 2002:a17:906:ca1:: with SMTP id k1mr11501349ejh.369.1631309562249; Fri, 10 Sep 2021 14:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631309562; cv=none; d=google.com; s=arc-20160816; b=Y4MoJs5RGPv9YyvdjE18sXlzxSbnLSxwlbxRnezAF+yUCPWVJJ2SAbQyxAESl2A08B 6389GbRgWTm181Vt1kpPH6q5WBw24mk0Uy3wUF60HoVhGGsvL9LwYUJzo2l0ovX6YjaC X6P/dtAKovpejgkw3c/R3zFOdQ206PuCXzfg8ldOIm5zkbBmIm8Kynby9MNfAekU9YKY pr1Cwq2fHgCy8eC9bjkT97ypvTs1Uv2U9m85lgsGsxalN8UpYICK3oe9i5J98Mcwk9Z2 gckr47gerxq4bx2iKPDsDwEgjrBBlSqoAeAMI9c7XtDKWeSeqPZe7nV5IZrZEaQbn+Cs SAZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gG9IwTokKzd7dSKb8PeJxanH6u5ukkUKIIJ5lnDDNxI=; b=lgnzGKAqa3M+I6+uFQSWaiW9QIkyzgby+uCa9e+TtUFdDozjmWRucbc8uZwL8ULLHG cCCEKR+DpXQz5dCyWfHIyjYdvekvYsmO9T7cP+UGSD8Q1YySHoAjLQqxCWr+NJFK2hw8 38AjmFthMELRYsIpQXTnSLA+t9rjx3cZrDmXEWpDPixNYtiVVkj65MGl/ARoRMPDoJHQ QkfjnFE2VG+ps7wllvNoPlGRNeFPKb45GdqTepqvB80AarBFF0rU+TIWZX8qtqZAC1hJ AMsrh9EAlmmwZhZrgblrx/4t9kHRwnLG/k7WR1Zxbz2F4RHQf478cR99mSz/xs8WCxQ3 anrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="l/+q/oSU"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm24si5893415ejb.577.2021.09.10.14.32.18; Fri, 10 Sep 2021 14:32:42 -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; dkim=pass header.i=@google.com header.s=20210112 header.b="l/+q/oSU"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234582AbhIJVaI (ORCPT + 99 others); Fri, 10 Sep 2021 17:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbhIJVaH (ORCPT ); Fri, 10 Sep 2021 17:30:07 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6779CC061574 for ; Fri, 10 Sep 2021 14:28:56 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id w6so1976129pll.3 for ; Fri, 10 Sep 2021 14:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gG9IwTokKzd7dSKb8PeJxanH6u5ukkUKIIJ5lnDDNxI=; b=l/+q/oSUDmPIKALXMZ3wqCtJEI78CDp8YhLDB0hTM1i/xoQaF2NJUFB2hU0OSNPn6j 8EguJiZuSqHXLv6mukv7N6+jp0HKzKe9MncTbtbNjrj5oGr3hvzuz5iRpnO9VLpqTdnI SnRUBXZu3KFv/2yjOFSWMYotHqt375Z37om2C8tHekDo8qXK/kcjpsMzsC6nizejtx1U HNE5/5fbyIVRf5iPSj1CWkscu82lKU7c6rFFn+eDCnkE7McNCmnFgCktxI3a/VqJHOA9 ux6zGpUpV6BQGPjnvpSB8TG4lnxiHCot901phaBjcUZBMRaPdpkzPJOjrKO1ugJ4G7+k w3FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gG9IwTokKzd7dSKb8PeJxanH6u5ukkUKIIJ5lnDDNxI=; b=rsX1HR7Lv5Oy9/02798F73hVKzdNSG8A9sW132X8nOqRdnkEMfLY8NeYUwOcW99Px2 Jr0PVHhUxMsxE073Tj2QWQHsgGl7NCH9yUgKbDiHJgpbxIDWfEis4aeHnHzW3dgwh6iA uog1vc/RlrTIxCAIlOnZdzewt8hCvSRbKW583HrUBgtVkPWIbIbLGWOVjVS5yEKOCqON OnWg3ARQTEaO0LwIJ5aOpGjF357/zP9DioIL7F5UOr/Ilf52dgzK56Ef5yHrlFcY0WdH vhdtLYeZ7KeGQFxj+ySG6tWoRQMSIFTJNNkgXfW1dEgZ7367DGQ8KPAKFx/CZYjMdTzl Za9g== X-Gm-Message-State: AOAM5311L4JpwuowuKzVY+juaA1LC88Dkf3QVJWBDdFd9A9o9TEN79Yc tkSDObkMRSbUi3FjDBmwDyoxTw== X-Received: by 2002:a17:90b:1d0e:: with SMTP id on14mr11540807pjb.97.1631309335655; Fri, 10 Sep 2021 14:28:55 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id u12sm10827pjx.31.2021.09.10.14.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 14:28:55 -0700 (PDT) Date: Fri, 10 Sep 2021 21:28:51 +0000 From: Sean Christopherson To: Zeng Guang Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Dave Hansen , Tony Luck , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Robert Hoo Subject: Re: [PATCH v4 2/6] KVM: VMX: Extend BUILD_CONTROLS_SHADOW macro to support 64-bit variation Message-ID: References: <20210809032925.3548-1-guang.zeng@intel.com> <20210809032925.3548-3-guang.zeng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210809032925.3548-3-guang.zeng@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { --