Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2352174pxt; Sun, 8 Aug 2021 20:58:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOtHNAt+88tPjTCD5XL3s0xh1HAP8iFcg0nIua3Tul7E3xCN/k1RD3IW5GyR4zxD2ArYdQ X-Received: by 2002:a17:906:2497:: with SMTP id e23mr20702871ejb.194.1628481492640; Sun, 08 Aug 2021 20:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628481492; cv=none; d=google.com; s=arc-20160816; b=SExsXI8dEGr+BOzWUiMS7uTcVNTuuaSOOVb9wIGfZ07B/UQ6YXefzj2DVpvWXEn70L Tj52Q2nI7NhThNEjjxFVpQcn0HXnXxrbmOLLs7T0swAA3OtTamxk2mxtDB0KFotwTn/O CEPRrTLDo7UxR5Mr2Ud3o7vUdVeI8Rkg+NxzYpNY6VS+wtmlPox2tAG9msxFTbPeyOlQ aBs3jXuqPN2BIrM4Wa3d7jnP5SYK0r7TUfFc4U9EO2Ib/eHK3rt0te78bxEMEFaFwaCr n1R1oBOGDC/yUrvayjiepPIgZuP5kTRuC0iTlpIIEpwSecgIxJd7fUofu3Jx4RYr15yE 7RvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=p7E4a9rWktVGIBDzzvTRZ/nagfnhI0MN5s6SRD0eK0k=; b=CM/0SbcIIjIc5FEqDi9jRPEPhD5GfphOXlt4ulC8rXRQDc1gldy3OO1wAHIDbp4SZX vOdJ/qT92ZZA4sc1TpuOhK4pDYNV5LhcBi4+iKmL1RmC16ebcjvdZG6pkpftl1WEbzhl qNEFRgw7WLEvlb0QZZZRfOyaq2xGf3ncJhLHQM4+FCOtqCmt9faZ/Ac60YRccOOSiZ88 somKXQ1RQoPdDF9nwcgDAS15Y5ZSZerRPzAKEvQorLrzRc8yFrw/7/Qx5rDUsEs1zk03 ZRJQvFfFo6ohf5sHZoU6tMP0baP3QWBM0qzsbNdItV29Nqwq2rjJk+1SyoWI0p4Al6Xw tj1A== 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 x2si17876551ejy.297.2021.08.08.20.57.50; Sun, 08 Aug 2021 20:58:12 -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 S232887AbhHIDzC (ORCPT + 99 others); Sun, 8 Aug 2021 23:55:02 -0400 Received: from mga18.intel.com ([134.134.136.126]:27870 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbhHIDy7 (ORCPT ); Sun, 8 Aug 2021 23:54:59 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10070"; a="201793156" X-IronPort-AV: E=Sophos;i="5.84,305,1620716400"; d="scan'208";a="201793156" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2021 20:54:39 -0700 X-IronPort-AV: E=Sophos;i="5.84,305,1620716400"; d="scan'208";a="483123513" Received: from arthur-vostro-3668.sh.intel.com ([10.239.13.1]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2021 20:54:34 -0700 From: Zeng Guang To: Paolo Bonzini , Sean Christopherson , 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 Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Zeng Guang , Robert Hoo Subject: [PATCH v4 2/6] KVM: VMX: Extend BUILD_CONTROLS_SHADOW macro to support 64-bit variation Date: Mon, 9 Aug 2021 11:29:21 +0800 Message-Id: <20210809032925.3548-3-guang.zeng@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210809032925.3548-1-guang.zeng@intel.com> References: <20210809032925.3548-1-guang.zeng@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Hoo The Tertiary VM-Exec Control, different from previous control fields, is 64 bit. So extend BUILD_CONTROLS_SHADOW() by adding a 'bit' parameter, to support both 32 bit and 64 bit fields' auxiliary functions building. Also, define the auxiliary functions for Tertiary control field here, using the new BUILD_CONTROLS_SHADOW(). Suggested-by: Sean Christopherson Signed-off-by: Robert Hoo Signed-off-by: Zeng Guang --- arch/x86/kvm/vmx/vmx.h | 51 ++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 3979a947933a..558f61208a6f 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -413,31 +413,34 @@ 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 vcpu_vmx *vmx) \ -{ \ - return vmx->loaded_vmcs->controls_shadow.lname; \ -} \ -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 vcpu_vmx *vmx) \ +{ \ + return vmx->loaded_vmcs->controls_shadow.lname; \ +} \ +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) { -- 2.25.1