Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3295608pxj; Tue, 1 Jun 2021 01:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmXrE6q5DV25hkBL/1Hk/EG13BPbQL4tjQ1A68C9ZYIBKWqbbcx8m4RvQcHZ/4yDnYggy3 X-Received: by 2002:a05:6402:40c1:: with SMTP id z1mr30624493edb.97.1622537422444; Tue, 01 Jun 2021 01:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622537422; cv=none; d=google.com; s=arc-20160816; b=CvgUBibShFOYDvnlZm9msVURDXnSsjYK0Kk5hFlM7QylFNsu2Sdr44Tqt9coubD3Cb Yz7zPf9ccUmYetPZ/TK5Jf+XvNo1Bgrfvt9ZztjgSJ2W2dfwhHS9PkR+95cLQiQxbUC+ P25T9Z0qiWA7fms5rc+voI0A1Zn/syXg9AvX1deBjrgsWi01O0x0SrfyEBIZ9J0w7Bt5 fhrNDEzskeErFNx7jqyH2kX098xRzkGbi838+v4lvsVfJrrCm58G3zxg4rB0+CYpAfOV KJ5+MwDIIfFl1VIAQSECMgqnIhDfZVRHYls/U7QXtrNoYXhJNBSdhzCKRAbWIzsYBR9s R1zA== 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:ironport-sdr:ironport-sdr; bh=d4SmyxxTdjW2BIQLQ2WPyqUcEy5Pzn3A+1N3Snoelp8=; b=aurLuZzFUfiQDAH//hT0QYrp3V8F5aD5b1poSxvzQKqmCQ84bvkVIAAaFKqXXrMpOo rGdCrGI/c7sw2BXwNRCJdvF3LodCjyWUvISR2g/T3sPut0J14AwsrMkWRruThNtS6en2 uEqklYRpM44/J73QKOSnvhqM65RP74eZCS2qlZP+/MLOa3e0UzrhosNRLtplIZKQxI/z 6zf22ossazjA2Cdm2Dzk7dT2y5KmlGV8WAkzEMx73E8mlUPXMJahE851lnCIGRM7+w+7 xMXW09G4xWs8R11XXerVJ2ZLG+s2ulPBaAQdL1dpgfXdo1qz2YzkD1L9w/sUAvq75RTL +nPA== 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 ar9si19626227ejc.663.2021.06.01.01.49.59; Tue, 01 Jun 2021 01:50:22 -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 S233516AbhFAIuP (ORCPT + 99 others); Tue, 1 Jun 2021 04:50:15 -0400 Received: from mga07.intel.com ([134.134.136.100]:45129 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbhFAIt5 (ORCPT ); Tue, 1 Jun 2021 04:49:57 -0400 IronPort-SDR: G6AyyxSgF3qS/qwSjf1aBSVX+SwnzWfNV7nizSajaoRwrmtFIFU8teUdLd0+cOzB12YT0HbrJp vOUJZIRSndWg== X-IronPort-AV: E=McAfee;i="6200,9189,10001"; a="267381344" X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="267381344" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 01:48:12 -0700 IronPort-SDR: Jn5COYwlkes7pkXWBE9cgprqyUGeO6ucrN5Hxp6vjaTalHC/Ge5cjiucrJf23XXOBYCkpeGbGo +qYcsFIrZ2iA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,239,1616482800"; d="scan'208";a="437967783" Received: from sqa-gate.sh.intel.com (HELO robert-ivt.tsp.org) ([10.239.48.212]) by orsmga007.jf.intel.com with ESMTP; 01 Jun 2021 01:48:09 -0700 From: Robert Hoo To: pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com, robert.hu@intel.com, robert.hu@linux.intel.com Subject: [PATCH 05/15] kvm/vmx: Extend BUILD_CONTROLS_SHADOW macro to support 64-bit variation Date: Tue, 1 Jun 2021 16:47:44 +0800 Message-Id: <1622537274-146420-6-git-send-email-robert.hu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> References: <1622537274-146420-1-git-send-email-robert.hu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kvm/vmx/vmx.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 008cb87..e0ade10 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -412,31 +412,32 @@ 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) \ +#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_write32(uname, val); \ + vmcs_write##bits(uname, val); \ vmx->loaded_vmcs->controls_shadow.lname = val; \ } \ } \ -static inline u32 lname##_controls_get(struct vcpu_vmx *vmx) \ +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, u32 val) \ +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, u32 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) +BUILD_CONTROLS_SHADOW(tertiary_exec, TERTIARY_VM_EXEC_CONTROL, 64) static inline void vmx_register_cache_reset(struct kvm_vcpu *vcpu) { -- 1.8.3.1