From nobody Wed Dec 17 12:08:08 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B7BA19F47E; Tue, 18 Mar 2025 06:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279752; cv=none; b=EWcFtIeyUeR8txxup5s8jqf8NPgdSf7SttnLXZ+WdoHVcZm51gR+B/fwU4xkhy98h+j0eMhqpBY/H5Jw6LyUp82VfEuwQpf9f2IheJ49BboBqadDhZ1/h0eKcMDM8Z4AlXwkDshwJ4Y3w9eFP4/dCO5gn6QaFrz1J4JdImhIMxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279752; c=relaxed/simple; bh=uP7eKufn3JgmU5kbRTG9Xy3/qL1jXgSZ5x6WrAHn+Wo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nGHGniKMT+VEFANks8Ps/JHuHyoMxfJOaAdnWfmToptvE6i+FnrvzXjBAL/aXRl27DOuEWy6HHD4s4FNCZdcmyfxmn4PbUeeUc8k53Scb6viKpRM7GDXhdagjjkVw7dT4zEcQO+l20Xwcux+xBvoq6UJPnImQjZUw5j+ZU2quhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aSLfT7bX; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aSLfT7bX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742279751; x=1773815751; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=uP7eKufn3JgmU5kbRTG9Xy3/qL1jXgSZ5x6WrAHn+Wo=; b=aSLfT7bXS1jTft1PosX68hoS41blOhQqucbTFYuFpaNHqy8WDt/WNWuw 4NOFwZ6T4o+jG5bQfrx+0Bdo8P7+XaxiXgrLYeYBrISyhom5W/d+0dlHx iNC71/2FbpKHGddVMRnqNuuqJwBfckYtwLqsmQ0iVffBlZRqO5LGTrvzh ZQMX6kPEijSN8p0GUJd3Fw9ylPMHXbfsJx9UMdN9R4HmXi3TMopTwKmhQ 5L04E9lQmh3GqOg7NkiB7GBuxmoZBTc6+yjx+vqunPQ/dUGe611Mi8SJ7 jk2PSXYqzuGQQ2Mc8ftMBFqphSVvxMPiFIGlzMtqKCPxySrUPk2AGd2rP g==; X-CSE-ConnectionGUID: dgo6iRIdR+uoIrmCy0e9IA== X-CSE-MsgGUID: 9PF/FMPxSoWzv3fvSDkQNQ== X-IronPort-AV: E=McAfee;i="6700,10204,11376"; a="53613410" X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="53613410" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:49 -0700 X-CSE-ConnectionGUID: WILfZigVRk6+FTfgaqLbiw== X-CSE-MsgGUID: mVPQ8lvVRlGah2BNZuzz1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="153147531" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.125.109.119]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:48 -0700 From: Vishal Verma Date: Tue, 18 Mar 2025 00:35:06 -0600 Subject: [PATCH v2 1/4] KVM: TDX: Fix definition of tdx_guest_nr_guest_keyids() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-vverma7-cleanup_x86_ops-v2-1-701e82d6b779@intel.com> References: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> In-Reply-To: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Binbin Wu , Rick Edgecombe , Vishal Verma X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1406; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=uP7eKufn3JgmU5kbRTG9Xy3/qL1jXgSZ5x6WrAHn+Wo=; b=owGbwMvMwCXGf25diOft7jLG02pJDOk3RZxdn9dJ7tzAe27j99MqZgELXLIyHmS18PedsDXXk PK+JpLQUcrCIMbFICumyPJ3z0fGY3Lb83kCExxh5rAygQxh4OIUgInU2TH8lfw65UrIYi2W9k/q VVLz2R72GK9bdGKFftyuyqdqCXHbMxgZToTyfLCc+PX/5Qgvdrf5PEsnClXZldta/zn5LPDV6vV ifAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF When CONFIG_INTEL_TDX_HOST=3Dn, the above definition produced an unused-function warning with gcc. error: =E2=80=98tdx_get_nr_guest_keyids=E2=80=99 defined but not used [-W= error=3Dunused-function] 198 | static u32 tdx_get_nr_guest_keyids(void) { return 0; } | ^~~~~~~~~~~~~~~~~~~~~~~ Make the definition 'inline' so that in the config disabled case, the whole thing can be optimized away. Cc: Sean Christopherson Cc: Rick Edgecombe Signed-off-by: Vishal Verma --- arch/x86/include/asm/tdx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index e6b003fe7f5e..fbc22bf39cfd 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -195,7 +195,7 @@ u64 tdh_phymem_page_wbinvd_hkid(u64 hkid, struct page *= page); static inline void tdx_init(void) { } static inline int tdx_cpu_enable(void) { return -ENODEV; } static inline int tdx_enable(void) { return -ENODEV; } -static u32 tdx_get_nr_guest_keyids(void) { return 0; } +static inline u32 tdx_get_nr_guest_keyids(void) { return 0; } static inline const char *tdx_dump_mce_info(struct mce *m) { return NULL; } static inline const struct tdx_sys_info *tdx_get_sysinfo(void) { return NU= LL; } #endif /* CONFIG_INTEL_TDX_HOST */ --=20 2.48.1 From nobody Wed Dec 17 12:08:08 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB1B51DD0C7; Tue, 18 Mar 2025 06:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279753; cv=none; b=sdwyhS6I++al97CXVwOiCO1CNfxiA4BReL6RYyAnlM2IHfwNxMaj7AWd8KYgkTzqUKafGuJXL+sXS85tfZvfNVanUE5Zko7G67jPKBg/4mBYzkTq3VjD2SzxbGY8FL9TuVciSr1ZU0pbu/nDJDGFXIeSx6m0N63oen/wrxeX9xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279753; c=relaxed/simple; bh=JZYQOEQqpTlADIyWTJL4Z9vOxfym9eQpA/0UopUeMLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sgWEfKM7/jSbMQudcAXOlm8WbG2iuG2+wbdZWNa/l+qLZhjOzZHTDulBHlfx1ibKWDUvTWKyiZdyalfCHXfAG3YqsjnILnGcmSQoRncH6Rdf+r8+uCiWmAOXfAD4V1Kz2TNM8nc0I+H+LAtav2f4puNuJv6VHovBzCvnVggECcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=E+RilioM; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="E+RilioM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742279752; x=1773815752; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=JZYQOEQqpTlADIyWTJL4Z9vOxfym9eQpA/0UopUeMLI=; b=E+RilioMA4397IUDeQBqQo31J5bN9jAVccoZlRKP/rep4JyCdhp1kD3Q 5LJ/SkLgdTTjYMBNMrSapOO0SwpF4Njva2cnalJYBAr8u+zCznLLBuu4u Nv5XUy7XyozLCaWTJgQt1kHJD1NLXQDhk85N51u0732U3L8fKYOuTmuTA 12InIeF54Fl6G5waAjes9HTVLr80eOvTfZ191N9r//3YPBCPSuXwq5AJ7 QqO11fMBz5Hwwtk2i3OoxPeqiLpfyzLB9z5ZvRy9D0z9Si8m3BbckZwnh mfZ2sa1odBPRRanOeULcq6p/AX7RnTE0/9k9hG9vZ42JlJvlj/k2HDVBV w==; X-CSE-ConnectionGUID: VGCN1VUTRpqH3tHXAX7slw== X-CSE-MsgGUID: 0rRpZ67+SmCW0YVfIG6vXA== X-IronPort-AV: E=McAfee;i="6700,10204,11376"; a="53613413" X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="53613413" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:50 -0700 X-CSE-ConnectionGUID: KUbsjudYSC+sUEBNIPK5uw== X-CSE-MsgGUID: Ln26XAQsTuGN/xcfwx5KDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="153147537" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.125.109.119]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:48 -0700 From: Vishal Verma Date: Tue, 18 Mar 2025 00:35:07 -0600 Subject: [PATCH v2 2/4] KVM: VMX: Move apicv_pre_state_restore to posted_intr.c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-vverma7-cleanup_x86_ops-v2-2-701e82d6b779@intel.com> References: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> In-Reply-To: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Binbin Wu , Rick Edgecombe , Vishal Verma X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3015; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=JZYQOEQqpTlADIyWTJL4Z9vOxfym9eQpA/0UopUeMLI=; b=owGbwMvMwCXGf25diOft7jLG02pJDOk3RZyTk16t3SRa+nH+7LYjSgz/zKvtkuSTWLbmbDr0T kaf6/T6jlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEzkw2aGf0arbq5XnLrYTdBG xy5+WYrruqyTNtxdv9p3qr9Nj3y3UoThf8TKs54OHo+MtF6Kxgtp57+34ShKPn2mwy3/ZI/BneR 9DAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF In preparation for a cleanup of the x86_ops struct for TDX, which turns several of the ops definitions to macros, move the vt_apicv_pre_state_restore() helper into posted_intr.c. Based on a patch by Sean Christopherson Link: https://lore.kernel.org/kvm/Z6v9yjWLNTU6X90d@google.com/ Cc: Sean Christopherson Cc: Rick Edgecombe Reviewed-by: Binbin Wu Signed-off-by: Vishal Verma --- arch/x86/kvm/vmx/posted_intr.h | 1 + arch/x86/kvm/vmx/main.c | 10 +--------- arch/x86/kvm/vmx/posted_intr.c | 8 ++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/posted_intr.h b/arch/x86/kvm/vmx/posted_intr.h index 68605ca7ef68..9d0677a2ba0e 100644 --- a/arch/x86/kvm/vmx/posted_intr.h +++ b/arch/x86/kvm/vmx/posted_intr.h @@ -11,6 +11,7 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu); void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu); void pi_wakeup_handler(void); void __init pi_init_cpu(int cpu); +void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu); bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu); int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, bool set); diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 320c96e1e80a..9d201ddb794a 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -315,14 +315,6 @@ static void vt_set_virtual_apic_mode(struct kvm_vcpu *= vcpu) return vmx_set_virtual_apic_mode(vcpu); } =20 -static void vt_apicv_pre_state_restore(struct kvm_vcpu *vcpu) -{ - struct pi_desc *pi =3D vcpu_to_pi_desc(vcpu); - - pi_clear_on(pi); - memset(pi->pir, 0, sizeof(pi->pir)); -} - static void vt_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr) { if (is_td_vcpu(vcpu)) @@ -983,7 +975,7 @@ struct kvm_x86_ops vt_x86_ops __initdata =3D { .set_apic_access_page_addr =3D vt_set_apic_access_page_addr, .refresh_apicv_exec_ctrl =3D vt_refresh_apicv_exec_ctrl, .load_eoi_exitmap =3D vt_load_eoi_exitmap, - .apicv_pre_state_restore =3D vt_apicv_pre_state_restore, + .apicv_pre_state_restore =3D pi_apicv_pre_state_restore, .required_apicv_inhibits =3D VMX_REQUIRED_APICV_INHIBITS, .hwapic_isr_update =3D vt_hwapic_isr_update, .sync_pir_to_irr =3D vt_sync_pir_to_irr, diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index f2ca37b3f606..a140af060bb8 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -241,6 +241,14 @@ void __init pi_init_cpu(int cpu) raw_spin_lock_init(&per_cpu(wakeup_vcpus_on_cpu_lock, cpu)); } =20 +void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu) +{ + struct pi_desc *pi =3D vcpu_to_pi_desc(vcpu); + + pi_clear_on(pi); + memset(pi->pir, 0, sizeof(pi->pir)); +} + bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu) { struct pi_desc *pi_desc =3D vcpu_to_pi_desc(vcpu); --=20 2.48.1 From nobody Wed Dec 17 12:08:08 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 545911DE880; Tue, 18 Mar 2025 06:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279754; cv=none; b=AkXXf4lWVG86uwJ1n7uUXhpAH4UYHkDToP2LS63ir+i3uEB3Nko0DHS2SjHE3tQfAwPFhM63O/bbvlsIj6rZyVr/o0Cvjqipb8AbAq2rxuFYBy3bszffwvB5yCLz3+k19m91iw8MFBQ/I//MHbL/xWPxnpIsBxD2uZ6b9FqKcuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279754; c=relaxed/simple; bh=A/NnriKwL9epi1Pnix+4iNtlhu8hsdfsabDWrlRJ6YI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qYFD2Kb4W7QrII6szja53QOjk2jE/moXfzZApXREwYYMHRpVvxtk0Qu/7Du7n3XTT8hEgKW1k++nDgpyaOStT86zGCp31bBj0d7N65aHgaWaAcLCr8sO2qEthLgvoKfRU8Rf1ECq39F5ho49XUBmNwLoVwaMZH1CxjiFIM+cdiQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XjlwoK34; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XjlwoK34" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742279753; x=1773815753; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=A/NnriKwL9epi1Pnix+4iNtlhu8hsdfsabDWrlRJ6YI=; b=XjlwoK34C6ilRSlNj0kepBVNoipZwvYpioByqdzGInQtVbNsWYyHtZDX 42e082cH9POHg5/y+HwBSpCu9PM/RK6bmAv0qA8YePmNraO8Hk0clULO7 vud7zznXFDe7dZNmarLx6YZVBMJ9G9R9vV/JeUhCt8elSq6r+D7PQKOXR 88iu9J/hKTg8cCQFLHmp57lzdh1wh4I9tuESeuo4bAn9+CGa9H2QHndDb DeaTcDdBtbSCXgGlWVB7fs/KweKYpDTnfMO7twRvINwcc7QZ9RBYCKvip 28y/RORMLNQvV+noSO4rAz6hVNcUeVr+ihdMBm0FfyVVKN0OsUDA/4LeL w==; X-CSE-ConnectionGUID: NjfbSMTzRJ+t7+aUpgjsXQ== X-CSE-MsgGUID: gIA7bIJOSECrvhzHXYbpww== X-IronPort-AV: E=McAfee;i="6700,10204,11376"; a="53613416" X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="53613416" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:50 -0700 X-CSE-ConnectionGUID: FyornG8AQAGT4/SQUKPyYg== X-CSE-MsgGUID: s9wF1hSIQHi9+L1/0nam0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="153147543" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.125.109.119]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:49 -0700 From: Vishal Verma Date: Tue, 18 Mar 2025 00:35:08 -0600 Subject: [PATCH v2 3/4] KVM: VMX: Make naming consistent for kvm_complete_insn_gp via define Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-vverma7-cleanup_x86_ops-v2-3-701e82d6b779@intel.com> References: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> In-Reply-To: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Binbin Wu , Rick Edgecombe , Vishal Verma X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1817; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=A/NnriKwL9epi1Pnix+4iNtlhu8hsdfsabDWrlRJ6YI=; b=owGbwMvMwCXGf25diOft7jLG02pJDOk3RZz5OQTjEtmP/lvSGbSm8oO/QL3anJRsZtFrnCsff FM1D/DsKGVhEONikBVTZPm75yPjMbnt+TyBCY4wc1iZQIYwcHEKwEQuyTMyTGFe+Ty+9PirmHjF p1szny778CNN8+TmY0ZTlxjbmq2a/pThf5ormx1vrwuHO0euVrPAB75Ty+W1+W08mo88jw2sYG5 nAwA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF In preparation for defining x86_ops using macros, make the naming of kvm_complete_insn_gp() in the non TDX case more consistent with other vmx_ops - i.e. use a #define to allow it to be referred as vmx_complete_emulated_msr(). Based on a patch by Sean Christopherson Link: https://lore.kernel.org/kvm/Z6v9yjWLNTU6X90d@google.com/ Cc: Sean Christopherson Cc: Rick Edgecombe Signed-off-by: Vishal Verma --- arch/x86/kvm/vmx/x86_ops.h | 1 + arch/x86/kvm/vmx/main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/x86_ops.h b/arch/x86/kvm/vmx/x86_ops.h index 19f770b0fc81..97fcbcb0a503 100644 --- a/arch/x86/kvm/vmx/x86_ops.h +++ b/arch/x86/kvm/vmx/x86_ops.h @@ -58,6 +58,7 @@ void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu); void vmx_update_exception_bitmap(struct kvm_vcpu *vcpu); int vmx_get_feature_msr(u32 msr, u64 *data); int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info); +#define vmx_complete_emulated_msr kvm_complete_insn_gp u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg); void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int s= eg); void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int s= eg); diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 9d201ddb794a..a1388adffa1e 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -240,7 +240,7 @@ static int vt_complete_emulated_msr(struct kvm_vcpu *vc= pu, int err) if (is_td_vcpu(vcpu)) return tdx_complete_emulated_msr(vcpu, err); =20 - return kvm_complete_insn_gp(vcpu, err); + return vmx_complete_emulated_msr(vcpu, err); } =20 #ifdef CONFIG_KVM_SMM --=20 2.48.1 From nobody Wed Dec 17 12:08:08 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A6381DE8AE; Tue, 18 Mar 2025 06:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279754; cv=none; b=BEfV6i3rYOwrPOUjVUZX1S88WfazRMvtA6YYX+GVQNWc9QfWfEbYf20hosjCJpYoAQ33XunHSduKBX04N5/WVD+VIOE+Pnrpx6DsJBxkrsxdhBsPm6hf/8kqsow7CjpbGiOqet9XXtEIHZXw4Fzhlso4mZvER4+JD10A3Xe+w7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742279754; c=relaxed/simple; bh=OIHwUnwim2gr3yi30KLSirjJ0fvA3hBLPCKL43Xd89w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dQ8R9fyEDREJCtCa0n3YG7bkECKT8HnHuU1rdD8ZSKCgHLTKL5n4GTV0ipMXUto+gSvfdL31AOnJUHLwJNz5AwCttuiEDIEK8kAAbjT8wh2PL8W5abv3E6kJSzqvy9k2Qg8JsiwHpY9g4Odul46UUkN+HLbq4XzEIdelhgSQI7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FolztEcG; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FolztEcG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1742279753; x=1773815753; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=OIHwUnwim2gr3yi30KLSirjJ0fvA3hBLPCKL43Xd89w=; b=FolztEcG39/Gr9Stx5dgF7FOzbbGrSBkVbWJ9tOuDrQg2QMufFk8I4yy LuOoxBqc17YLTiiBMRWGbNxx5GPzm2w3QlJo7+wS/HJyRouClnIvlxUZC 6mfU5bG+H4stxyW4Lye1qMJUP+YOoqVJLIuGIVbi8BKeGFA9+cYCyLzOq PCYcwZnOiueIM+gpwTcVCwwDfdwXU1e5JN9fQIehQPxzuThE6wqaRj9wr MMnUbAsHMtZ/2E/yJD+0ck06pXm+MEb4naHGYNdlQtjUz33RhSjdbhB6K libCInqKYWwF1Xssgniu9ena/o3boR332mhi21f/UJ54KTsFVRqyeM7p6 A==; X-CSE-ConnectionGUID: zrrjZzyBT1aqi654QPajXg== X-CSE-MsgGUID: U8PrkX+PRFqHlvS6TAxLZQ== X-IronPort-AV: E=McAfee;i="6700,10204,11376"; a="53613419" X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="53613419" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:51 -0700 X-CSE-ConnectionGUID: 4dZ+5XKCSgiEC1ya+0vvzA== X-CSE-MsgGUID: /XT9HwEgS4+2vJ7TqepWdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,256,1736841600"; d="scan'208";a="153147549" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.125.109.119]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2025 23:35:49 -0700 From: Vishal Verma Date: Tue, 18 Mar 2025 00:35:09 -0600 Subject: [PATCH v2 4/4] KVM: VMX: Clean up and macrofy x86_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250318-vverma7-cleanup_x86_ops-v2-4-701e82d6b779@intel.com> References: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> In-Reply-To: <20250318-vverma7-cleanup_x86_ops-v2-0-701e82d6b779@intel.com> To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Binbin Wu , Rick Edgecombe , Vishal Verma X-Mailer: b4 0.15-dev-c25d1 X-Developer-Signature: v=1; a=openpgp-sha256; l=15645; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=OIHwUnwim2gr3yi30KLSirjJ0fvA3hBLPCKL43Xd89w=; b=owGbwMvMwCXGf25diOft7jLG02pJDOk3RZxbTl/fo3nyUXkax/N7usfvi1/d3RWVl2jEWvH+j wfjr2CDjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAExkpxkjw8wjeW527Fvqrnrc eH41PLVx75E5P6fO8v4Ys8+PRSjn9Q1Ghmt5SvLS7Bstbr89O9lrD8NC9qD/fX1uIme9m3ouVMQ 78gIA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF Eliminate a lot of stub definitions by using macros to define the TDX vs non-TDX versions of various x86_ops. Moving the x86_ops wrappers under CONFIG_KVM_INTEL_TDX also allows nearly all of vmx/main.c to go under a single #ifdef, eliminating trampolines in the generated code, and almost all of the stubs. For example, with CONFIG_KVM_INTEL_TDX=3Dn, before this cleanup, vt_refresh_apicv_exec_ctrl() would produce: 0000000000036490 : 36490: f3 0f 1e fa endbr64 36494: e8 00 00 00 00 call 36499 36495: R_X86_64_PLT32 __fentry__-0x4 36499: e9 00 00 00 00 jmp 3649e 3649a: R_X86_64_PLT32 vmx_refresh_apicv_exec_ctrl= -0x4 3649e: 66 90 xchg %ax,%ax After this patch, this is completely eliminated. Based on a patch by Sean Christopherson Link: https://lore.kernel.org/kvm/Z6v9yjWLNTU6X90d@google.com/ Cc: Sean Christopherson Cc: Rick Edgecombe Signed-off-by: Vishal Verma --- arch/x86/kvm/vmx/tdx.h | 2 +- arch/x86/kvm/vmx/x86_ops.h | 67 +--------------- arch/x86/kvm/vmx/main.c | 192 +++++++++++++++++++++++------------------= ---- 3 files changed, 101 insertions(+), 160 deletions(-) diff --git a/arch/x86/kvm/vmx/tdx.h b/arch/x86/kvm/vmx/tdx.h index 8f8070d0f55e..b43d7a7c8f1c 100644 --- a/arch/x86/kvm/vmx/tdx.h +++ b/arch/x86/kvm/vmx/tdx.h @@ -5,7 +5,7 @@ #include "tdx_arch.h" #include "tdx_errno.h" =20 -#ifdef CONFIG_INTEL_TDX_HOST +#ifdef CONFIG_KVM_INTEL_TDX #include "common.h" =20 int tdx_bringup(void); diff --git a/arch/x86/kvm/vmx/x86_ops.h b/arch/x86/kvm/vmx/x86_ops.h index 97fcbcb0a503..e628318fc3fc 100644 --- a/arch/x86/kvm/vmx/x86_ops.h +++ b/arch/x86/kvm/vmx/x86_ops.h @@ -122,7 +122,7 @@ void vmx_cancel_hv_timer(struct kvm_vcpu *vcpu); #endif void vmx_setup_mce(struct kvm_vcpu *vcpu); =20 -#ifdef CONFIG_INTEL_TDX_HOST +#ifdef CONFIG_KVM_INTEL_TDX void tdx_disable_virtualization_cpu(void); int tdx_vm_init(struct kvm *kvm); void tdx_mmu_release_hkid(struct kvm *kvm); @@ -165,71 +165,6 @@ void tdx_flush_tlb_current(struct kvm_vcpu *vcpu); void tdx_flush_tlb_all(struct kvm_vcpu *vcpu); void tdx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, int root_leve= l); int tdx_gmem_private_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn); -#else -static inline void tdx_disable_virtualization_cpu(void) {} -static inline int tdx_vm_init(struct kvm *kvm) { return -EOPNOTSUPP; } -static inline void tdx_mmu_release_hkid(struct kvm *kvm) {} -static inline void tdx_vm_destroy(struct kvm *kvm) {} -static inline int tdx_vm_ioctl(struct kvm *kvm, void __user *argp) { retur= n -EOPNOTSUPP; } - -static inline int tdx_vcpu_create(struct kvm_vcpu *vcpu) { return -EOPNOTS= UPP; } -static inline void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) = {} -static inline void tdx_vcpu_free(struct kvm_vcpu *vcpu) {} -static inline void tdx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) {} -static inline int tdx_vcpu_pre_run(struct kvm_vcpu *vcpu) { return -EOPNOT= SUPP; } -static inline fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu, bool force_im= mediate_exit) -{ - return EXIT_FASTPATH_NONE; -} -static inline void tdx_prepare_switch_to_guest(struct kvm_vcpu *vcpu) {} -static inline void tdx_vcpu_put(struct kvm_vcpu *vcpu) {} -static inline bool tdx_protected_apic_has_interrupt(struct kvm_vcpu *vcpu)= { return false; } -static inline int tdx_handle_exit(struct kvm_vcpu *vcpu, - enum exit_fastpath_completion fastpath) { return 0; } - -static inline void tdx_deliver_interrupt(struct kvm_lapic *apic, int deliv= ery_mode, - int trig_mode, int vector) {} -static inline void tdx_inject_nmi(struct kvm_vcpu *vcpu) {} -static inline void tdx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason, u= 64 *info1, - u64 *info2, u32 *intr_info, u32 *error_code) {} -static inline bool tdx_has_emulated_msr(u32 index) { return false; } -static inline int tdx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)= { return 1; } -static inline int tdx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)= { return 1; } - -static inline int tdx_vcpu_ioctl(struct kvm_vcpu *vcpu, void __user *argp)= { return -EOPNOTSUPP; } - -static inline int tdx_sept_link_private_spt(struct kvm *kvm, gfn_t gfn, - enum pg_level level, - void *private_spt) -{ - return -EOPNOTSUPP; -} - -static inline int tdx_sept_free_private_spt(struct kvm *kvm, gfn_t gfn, - enum pg_level level, - void *private_spt) -{ - return -EOPNOTSUPP; -} - -static inline int tdx_sept_set_private_spte(struct kvm *kvm, gfn_t gfn, - enum pg_level level, - kvm_pfn_t pfn) -{ - return -EOPNOTSUPP; -} - -static inline int tdx_sept_remove_private_spte(struct kvm *kvm, gfn_t gfn, - enum pg_level level, - kvm_pfn_t pfn) -{ - return -EOPNOTSUPP; -} - -static inline void tdx_flush_tlb_current(struct kvm_vcpu *vcpu) {} -static inline void tdx_flush_tlb_all(struct kvm_vcpu *vcpu) {} -static inline void tdx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa,= int root_level) {} -static inline int tdx_gmem_private_max_mapping_level(struct kvm *kvm, kvm_= pfn_t pfn) { return 0; } #endif =20 #endif /* __KVM_X86_VMX_X86_OPS_H */ diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index a1388adffa1e..218078ba039f 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -10,9 +10,8 @@ #include "tdx.h" #include "tdx_arch.h" =20 -#ifdef CONFIG_INTEL_TDX_HOST +#ifdef CONFIG_KVM_INTEL_TDX static_assert(offsetof(struct vcpu_vmx, vt) =3D=3D offsetof(struct vcpu_td= x, vt)); -#endif =20 static void vt_disable_virtualization_cpu(void) { @@ -880,6 +879,13 @@ static int vt_gmem_private_max_mapping_level(struct kv= m *kvm, kvm_pfn_t pfn) return 0; } =20 +#define vt_op(name) vt_##name +#define vt_op_tdx_only(name) vt_##name +#else /* CONFIG_KVM_INTEL_TDX */ +#define vt_op(name) vmx_##name +#define vt_op_tdx_only(name) NULL +#endif /* CONFIG_KVM_INTEL_TDX */ + #define VMX_REQUIRED_APICV_INHIBITS \ (BIT(APICV_INHIBIT_REASON_DISABLED) | \ BIT(APICV_INHIBIT_REASON_ABSENT) | \ @@ -897,113 +903,113 @@ struct kvm_x86_ops vt_x86_ops __initdata =3D { .hardware_unsetup =3D vmx_hardware_unsetup, =20 .enable_virtualization_cpu =3D vmx_enable_virtualization_cpu, - .disable_virtualization_cpu =3D vt_disable_virtualization_cpu, + .disable_virtualization_cpu =3D vt_op(disable_virtualization_cpu), .emergency_disable_virtualization_cpu =3D vmx_emergency_disable_virtualiz= ation_cpu, =20 - .has_emulated_msr =3D vt_has_emulated_msr, + .has_emulated_msr =3D vt_op(has_emulated_msr), =20 .vm_size =3D sizeof(struct kvm_vmx), =20 - .vm_init =3D vt_vm_init, - .vm_pre_destroy =3D vt_vm_pre_destroy, - .vm_destroy =3D vt_vm_destroy, + .vm_init =3D vt_op(vm_init), + .vm_destroy =3D vt_op(vm_destroy), + .vm_pre_destroy =3D vt_op_tdx_only(vm_pre_destroy), =20 - .vcpu_precreate =3D vt_vcpu_precreate, - .vcpu_create =3D vt_vcpu_create, - .vcpu_free =3D vt_vcpu_free, - .vcpu_reset =3D vt_vcpu_reset, + .vcpu_precreate =3D vt_op(vcpu_precreate), + .vcpu_create =3D vt_op(vcpu_create), + .vcpu_free =3D vt_op(vcpu_free), + .vcpu_reset =3D vt_op(vcpu_reset), =20 - .prepare_switch_to_guest =3D vt_prepare_switch_to_guest, - .vcpu_load =3D vt_vcpu_load, - .vcpu_put =3D vt_vcpu_put, + .prepare_switch_to_guest =3D vt_op(prepare_switch_to_guest), + .vcpu_load =3D vt_op(vcpu_load), + .vcpu_put =3D vt_op(vcpu_put), =20 - .update_exception_bitmap =3D vt_update_exception_bitmap, + .update_exception_bitmap =3D vt_op(update_exception_bitmap), .get_feature_msr =3D vmx_get_feature_msr, - .get_msr =3D vt_get_msr, - .set_msr =3D vt_set_msr, + .get_msr =3D vt_op(get_msr), + .set_msr =3D vt_op(set_msr), =20 - .get_segment_base =3D vt_get_segment_base, - .get_segment =3D vt_get_segment, - .set_segment =3D vt_set_segment, - .get_cpl =3D vt_get_cpl, - .get_cpl_no_cache =3D vt_get_cpl_no_cache, - .get_cs_db_l_bits =3D vt_get_cs_db_l_bits, - .is_valid_cr0 =3D vt_is_valid_cr0, - .set_cr0 =3D vt_set_cr0, - .is_valid_cr4 =3D vt_is_valid_cr4, - .set_cr4 =3D vt_set_cr4, - .set_efer =3D vt_set_efer, - .get_idt =3D vt_get_idt, - .set_idt =3D vt_set_idt, - .get_gdt =3D vt_get_gdt, - .set_gdt =3D vt_set_gdt, - .set_dr6 =3D vt_set_dr6, - .set_dr7 =3D vt_set_dr7, - .sync_dirty_debug_regs =3D vt_sync_dirty_debug_regs, - .cache_reg =3D vt_cache_reg, - .get_rflags =3D vt_get_rflags, - .set_rflags =3D vt_set_rflags, - .get_if_flag =3D vt_get_if_flag, + .get_segment_base =3D vt_op(get_segment_base), + .get_segment =3D vt_op(get_segment), + .set_segment =3D vt_op(set_segment), + .get_cpl =3D vt_op(get_cpl), + .get_cpl_no_cache =3D vt_op(get_cpl_no_cache), + .get_cs_db_l_bits =3D vt_op(get_cs_db_l_bits), + .is_valid_cr0 =3D vt_op(is_valid_cr0), + .set_cr0 =3D vt_op(set_cr0), + .is_valid_cr4 =3D vt_op(is_valid_cr4), + .set_cr4 =3D vt_op(set_cr4), + .set_efer =3D vt_op(set_efer), + .get_idt =3D vt_op(get_idt), + .set_idt =3D vt_op(set_idt), + .get_gdt =3D vt_op(get_gdt), + .set_gdt =3D vt_op(set_gdt), + .set_dr6 =3D vt_op(set_dr6), + .set_dr7 =3D vt_op(set_dr7), + .sync_dirty_debug_regs =3D vt_op(sync_dirty_debug_regs), + .cache_reg =3D vt_op(cache_reg), + .get_rflags =3D vt_op(get_rflags), + .set_rflags =3D vt_op(set_rflags), + .get_if_flag =3D vt_op(get_if_flag), =20 - .flush_tlb_all =3D vt_flush_tlb_all, - .flush_tlb_current =3D vt_flush_tlb_current, - .flush_tlb_gva =3D vt_flush_tlb_gva, - .flush_tlb_guest =3D vt_flush_tlb_guest, + .flush_tlb_all =3D vt_op(flush_tlb_all), + .flush_tlb_current =3D vt_op(flush_tlb_current), + .flush_tlb_gva =3D vt_op(flush_tlb_gva), + .flush_tlb_guest =3D vt_op(flush_tlb_guest), =20 - .vcpu_pre_run =3D vt_vcpu_pre_run, - .vcpu_run =3D vt_vcpu_run, - .handle_exit =3D vt_handle_exit, + .vcpu_pre_run =3D vt_op(vcpu_pre_run), + .vcpu_run =3D vt_op(vcpu_run), + .handle_exit =3D vt_op(handle_exit), .skip_emulated_instruction =3D vmx_skip_emulated_instruction, .update_emulated_instruction =3D vmx_update_emulated_instruction, - .set_interrupt_shadow =3D vt_set_interrupt_shadow, - .get_interrupt_shadow =3D vt_get_interrupt_shadow, - .patch_hypercall =3D vt_patch_hypercall, - .inject_irq =3D vt_inject_irq, - .inject_nmi =3D vt_inject_nmi, - .inject_exception =3D vt_inject_exception, - .cancel_injection =3D vt_cancel_injection, - .interrupt_allowed =3D vt_interrupt_allowed, - .nmi_allowed =3D vt_nmi_allowed, - .get_nmi_mask =3D vt_get_nmi_mask, - .set_nmi_mask =3D vt_set_nmi_mask, - .enable_nmi_window =3D vt_enable_nmi_window, - .enable_irq_window =3D vt_enable_irq_window, - .update_cr8_intercept =3D vt_update_cr8_intercept, + .set_interrupt_shadow =3D vt_op(set_interrupt_shadow), + .get_interrupt_shadow =3D vt_op(get_interrupt_shadow), + .patch_hypercall =3D vt_op(patch_hypercall), + .inject_irq =3D vt_op(inject_irq), + .inject_nmi =3D vt_op(inject_nmi), + .inject_exception =3D vt_op(inject_exception), + .cancel_injection =3D vt_op(cancel_injection), + .interrupt_allowed =3D vt_op(interrupt_allowed), + .nmi_allowed =3D vt_op(nmi_allowed), + .get_nmi_mask =3D vt_op(get_nmi_mask), + .set_nmi_mask =3D vt_op(set_nmi_mask), + .enable_nmi_window =3D vt_op(enable_nmi_window), + .enable_irq_window =3D vt_op(enable_irq_window), + .update_cr8_intercept =3D vt_op(update_cr8_intercept), =20 .x2apic_icr_is_split =3D false, - .set_virtual_apic_mode =3D vt_set_virtual_apic_mode, - .set_apic_access_page_addr =3D vt_set_apic_access_page_addr, - .refresh_apicv_exec_ctrl =3D vt_refresh_apicv_exec_ctrl, - .load_eoi_exitmap =3D vt_load_eoi_exitmap, + .set_virtual_apic_mode =3D vt_op(set_virtual_apic_mode), + .set_apic_access_page_addr =3D vt_op(set_apic_access_page_addr), + .refresh_apicv_exec_ctrl =3D vt_op(refresh_apicv_exec_ctrl), + .load_eoi_exitmap =3D vt_op(load_eoi_exitmap), .apicv_pre_state_restore =3D pi_apicv_pre_state_restore, .required_apicv_inhibits =3D VMX_REQUIRED_APICV_INHIBITS, - .hwapic_isr_update =3D vt_hwapic_isr_update, - .sync_pir_to_irr =3D vt_sync_pir_to_irr, - .deliver_interrupt =3D vt_deliver_interrupt, + .hwapic_isr_update =3D vt_op(hwapic_isr_update), + .sync_pir_to_irr =3D vt_op(sync_pir_to_irr), + .deliver_interrupt =3D vt_op(deliver_interrupt), .dy_apicv_has_pending_interrupt =3D pi_has_pending_interrupt, =20 - .set_tss_addr =3D vt_set_tss_addr, - .set_identity_map_addr =3D vt_set_identity_map_addr, + .set_tss_addr =3D vt_op(set_tss_addr), + .set_identity_map_addr =3D vt_op(set_identity_map_addr), .get_mt_mask =3D vmx_get_mt_mask, =20 - .get_exit_info =3D vt_get_exit_info, - .get_entry_info =3D vt_get_entry_info, + .get_exit_info =3D vt_op(get_exit_info), + .get_entry_info =3D vt_op(get_entry_info), =20 - .vcpu_after_set_cpuid =3D vt_vcpu_after_set_cpuid, + .vcpu_after_set_cpuid =3D vt_op(vcpu_after_set_cpuid), =20 .has_wbinvd_exit =3D cpu_has_vmx_wbinvd_exit, =20 - .get_l2_tsc_offset =3D vt_get_l2_tsc_offset, - .get_l2_tsc_multiplier =3D vt_get_l2_tsc_multiplier, - .write_tsc_offset =3D vt_write_tsc_offset, - .write_tsc_multiplier =3D vt_write_tsc_multiplier, + .get_l2_tsc_offset =3D vt_op(get_l2_tsc_offset), + .get_l2_tsc_multiplier =3D vt_op(get_l2_tsc_multiplier), + .write_tsc_offset =3D vt_op(write_tsc_offset), + .write_tsc_multiplier =3D vt_op(write_tsc_multiplier), =20 - .load_mmu_pgd =3D vt_load_mmu_pgd, + .load_mmu_pgd =3D vt_op(load_mmu_pgd), =20 .check_intercept =3D vmx_check_intercept, .handle_exit_irqoff =3D vmx_handle_exit_irqoff, =20 - .update_cpu_dirty_logging =3D vt_update_cpu_dirty_logging, + .update_cpu_dirty_logging =3D vt_op(update_cpu_dirty_logging), =20 .nested_ops =3D &vmx_nested_ops, =20 @@ -1011,38 +1017,38 @@ struct kvm_x86_ops vt_x86_ops __initdata =3D { .pi_start_assignment =3D vmx_pi_start_assignment, =20 #ifdef CONFIG_X86_64 - .set_hv_timer =3D vt_set_hv_timer, - .cancel_hv_timer =3D vt_cancel_hv_timer, + .set_hv_timer =3D vt_op(set_hv_timer), + .cancel_hv_timer =3D vt_op(cancel_hv_timer), #endif =20 - .setup_mce =3D vt_setup_mce, + .setup_mce =3D vt_op(setup_mce), =20 #ifdef CONFIG_KVM_SMM - .smi_allowed =3D vt_smi_allowed, - .enter_smm =3D vt_enter_smm, - .leave_smm =3D vt_leave_smm, - .enable_smi_window =3D vt_enable_smi_window, + .smi_allowed =3D vt_op(smi_allowed), + .enter_smm =3D vt_op(enter_smm), + .leave_smm =3D vt_op(leave_smm), + .enable_smi_window =3D vt_op(enable_smi_window), #endif =20 - .check_emulate_instruction =3D vt_check_emulate_instruction, - .apic_init_signal_blocked =3D vt_apic_init_signal_blocked, + .check_emulate_instruction =3D vt_op(check_emulate_instruction), + .apic_init_signal_blocked =3D vt_op(apic_init_signal_blocked), .migrate_timers =3D vmx_migrate_timers, =20 - .msr_filter_changed =3D vt_msr_filter_changed, - .complete_emulated_msr =3D vt_complete_emulated_msr, + .msr_filter_changed =3D vt_op(msr_filter_changed), + .complete_emulated_msr =3D vt_op(complete_emulated_msr), =20 .vcpu_deliver_sipi_vector =3D kvm_vcpu_deliver_sipi_vector, =20 .get_untagged_addr =3D vmx_get_untagged_addr, =20 - .mem_enc_ioctl =3D vt_mem_enc_ioctl, - .vcpu_mem_enc_ioctl =3D vt_vcpu_mem_enc_ioctl, + .mem_enc_ioctl =3D vt_op_tdx_only(mem_enc_ioctl), + .vcpu_mem_enc_ioctl =3D vt_op_tdx_only(vcpu_mem_enc_ioctl), =20 - .private_max_mapping_level =3D vt_gmem_private_max_mapping_level + .private_max_mapping_level =3D vt_op_tdx_only(gmem_private_max_mapping_le= vel) }; =20 struct kvm_x86_init_ops vt_init_ops __initdata =3D { - .hardware_setup =3D vt_hardware_setup, + .hardware_setup =3D vt_op(hardware_setup), .handle_intel_pt_intr =3D NULL, =20 .runtime_ops =3D &vt_x86_ops, --=20 2.48.1