From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79547175A8A for ; Fri, 4 Sep 2026 01:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483838; cv=none; b=h7zBNcEIBX5mcTfLRgnfG+7SM5HupvdF0d3DIvG4YGe3Gb4pgAH6CH1DbdDzde5Dsbaj6In/wKHxYrUU5tAi8/WYLzfakmQxA1VWcDIa+J5fFWENH1AFNqNB0JZC6sMzlTd0OBIkQVtEN0K3phg2ROxtZXCPqSk+fKmq3F891HM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483838; c=relaxed/simple; bh=vdDOmhyTdL3/T+cUm/B+tgP10dz8metO6J41MD514SE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=s2BArWnVfMKUBc6QKooeWMm53ZBdEEi6E3A51JwzB/SSf9GBEE6amPKBbeXZoymFM67Y1065SimYpA6/4q0InwIZ++n1fHn2dTZdmaY948OPaz+DwJs76mhqt+5ExyTLAAroszK3C7MqoX37EueBBlB7GOI91vLFC5Ho8WI97p4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=t6vNVbgJ; arc=none smtp.client-ip=209.85.210.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="t6vNVbgJ" Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-854f274dd69so239071b3a.1 for ; Thu, 03 Sep 2026 18:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483837; x=1789088637; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=TgaSozLRQmRkdK8Evd2A6YoYaj7A8H5aikOfjM35Ajs=; b=t6vNVbgJlTSx3U/JBUjDsbfo4RQ4f2JfMueVDIRWTtwVVYh5bxzX1WNhnvtewHamhM PlhYGoY/epStSC8uoG+H9Y13B59eNx5K6F5052xlvOCKy5JhMSsx0nVEpiD9lHMgZGEO mm4nyZqtGXCkHkLItjIN0bzqd1orBZf3cFNbRuRz9LUWA0h9NX5r/Vu3+WzhVmCR3G+5 BDRBNhKIJGpNJ9aV957ZTWmnVLAAPo1KDvY+Dk2/iG1i0qm0nJihDB5shD6brhwGnl7H ur2qctLin2aU0FwBDpLs3OjsArQ99fj40HpvB19MTFQyJR4wana+1iI1QWIoRgad9Jcu idsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483837; x=1789088637; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=TgaSozLRQmRkdK8Evd2A6YoYaj7A8H5aikOfjM35Ajs=; b=T5SMJ0V9aGbSp5OBBOURB61XE/jVko3J0NAKu1Yb6diRliRoJd6vtehpZ8ysPjKnxc 3WKZXR59zOjy1GHcm+ueicEUY/7F9Ui4fyf4w+uBrQ/fIAFj28D4lFOu0rysVML70Ubc ZfSbSz8y0HqgNMCFCk+pdwgN+KRuZjpb4xBkhdNBg7snJBG4zWrNja8SGDtda6b4l+DV b+KjoOHBgwgbuwrpNncuyQm9LbE+avLCiKb1/eRNe/wYntOBgbwPxVs8uzVHiaj1z2EQ Q9UZQhAkgpgPyJJtR7j+DTtKkmUj0AxogN1tu89QqTpD2Q6CPHmoNv2x0dJDlT3aXi5L mCvA== X-Forwarded-Encrypted: i=1; AKwUvBxvRrwd3Fg4/QD+ohoUpmkBpStW7YXkAtjs16ZrP6+xQrlBbVp3au4pMI/EzXlCO65pWbJuWwLvAs6R1Fc=@vger.kernel.org X-Gm-Message-State: AFuF++m//em6qjuhOOtRyUK7et0GWlbfN1syuVflRnXNSUiyosEn/XwV LuzgqDKWbdKWp4s5f5G2LPOLddoRdv9V9G0nU3a24xDw5QaQUcQ6DQv2Ku9niwZpsv+AvFG+Nhs pPWU0sg== X-Received: from pfbfo2.prod.google.com ([2002:a05:6a00:6002:b0:848:569f:3464]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1151:b0:85d:84a5:b7bb with SMTP id d2e1a72fcca58-86168d8c2fdmr3602732b3a.18.1788483836443; Thu, 03 Sep 2026 18:03:56 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:46 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-2-seanjc@google.com> Subject: [PATCH v3 1/8] KVM: VMX: Disallow using to_vmx() in common VT code From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Poison to_vmx() in main.c and posted_intr.c so that attempting to interpret the vCPU as a VMX vCPU will fail at compile time, as opposed to failing at runtime, or worse corrupting state without outright failing. Note, to_tdx() is buried in tdx.c, i.e. isn't broadly reachable, and so doesn't need the same treatment as to_vmx(). Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/main.c | 2 ++ arch/x86/kvm/vmx/posted_intr.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 4c52ab8d0786..ea0d825e556d 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -10,6 +10,8 @@ #include "tdx.h" #include "tdx_arch.h" =20 +#pragma GCC poison to_vmx + #ifdef CONFIG_KVM_INTEL_TDX static_assert(offsetof(struct vcpu_vmx, vt) =3D=3D offsetof(struct vcpu_td= x, vt)); =20 diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 4a6d9a17da23..24221ba553be 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -14,6 +14,8 @@ #include "vmx.h" #include "tdx.h" =20 +#pragma GCC poison to_vmx + /* * Maintain a per-CPU list of vCPUs that need to be awakened by wakeup_han= dler() * when a WAKEUP_VECTOR interrupted is posted. vCPUs are added to the lis= t when --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A563B352C4E for ; Fri, 4 Sep 2026 01:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483840; cv=none; b=Q5LPqeuwG8QpkGreaasO30ejvUZFB3g+gky3Jz/O4bJ1MMBwYGDwiPpxnGsBom+xxlUBq181WQVBu3+MM/ujpQstTQAaV/Q1F6f/jsd1MhyuM9W1eRht68VDBBuZ21F92o7nXCulEebMfjgDgEpdM8S0Wm+fGMbOFJ3W5DeBFrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483840; c=relaxed/simple; bh=Z7WjmCyz0PA8ZuhgOlbJ2FSysCdg3wrQRYnbQ7PKCxM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tZgXCGoQn0VaoQuGz3yEj8G7BdXcuyj0qOSj0DPYSvsdWtVUJ0C6jlUt43/GZLJa54+aEDlIe1p3r+JFJJkNAZKYE45hFGwCUrOBoLPnggbSe7XvxC02QcRpcWTFRi7R+PqI4Mv37uUdzYK25UkXUu3SQWmwZHIxFpOQSvGaUxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GvweUmHG; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GvweUmHG" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-396b9ef3070so657753a91.3 for ; Thu, 03 Sep 2026 18:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483838; x=1789088638; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=rwIVt5DW98yzoIxj1eFFQhL2958LlabcKwUulILLX+Q=; b=GvweUmHGUgfq0NmdYcn1V52BR5wd5eTXe9z2oRaOU70qWYVusnulXk1BUk+Ubwj1ks 5baujFqHGbGCZHOAHKIcdbhicpUn8gDXpxifiDA7tu/1dtRaVc06fmBVhGZ9r4xiCudn Jrf7mt4q4/gsa0wr3loibuGLUl9Do5XLDTTxMWwH4pAv+psffL+Fca1f8Vy1syj3VTk4 utwOFobpkEZjb0xmUQLOid3YXypnWLlQgiZB1fLCjt/ib7XhjRZiPZeR9z7oy6pdUlaX i4VoKDVIVg5091cmb4wl6CBTZwNu5EbsjMy19CuhY5ZlprxFlbyK3xUO3c8BnFGHBskS BpGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483838; x=1789088638; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rwIVt5DW98yzoIxj1eFFQhL2958LlabcKwUulILLX+Q=; b=ZgNmcKuA6u1JD28ZF68eIBQ8Q5zpUc2Ctyj2qzQ6fJY4DMP71BL5vXhGqeKFt6KMxM PNBdle7wQR/rwC74sdkLmNX4MBkO35m6n4n0YusGY+62TimSO5vxKKyndMlDb/xkQD7y VHPv+i1eB54uqKzjA1uztcn0zR7RPVcSUmCK/9ia71AsOKptSWdFRemMWAoXYWbylXP0 ZovW/ANA17WNBLWUL1QnovgUpHRhzcyM4flHYKvT4hRcZi09MNZ3dvZzCcezyIqGnQKf DUBG+w4fR3vCbHaOtBQJt+6qhLEALG2YxQszeAwdp9J8QIXiXi0KvswlVqpCgD8jxqF3 0zvg== X-Forwarded-Encrypted: i=1; AKwUvBwd2NPBqIs7smRla1CM4hnQC5h3wKf9rjWmpivshk3Njhp2eWPmfFwKTgpZ4Jar4ZRHnckDuI6RcjoTsvU=@vger.kernel.org X-Gm-Message-State: AFuF++nfcUFgb87RZ5l2j/MgiLIbPHKaWlce5uDyUdaYqP1biU0462EY CgiUHC5eF0Ha+Un88ZPoAO5MggdK3MmfpVRLbJCVV2Vqo0FUeqC1hBU9j9Gu/9ecsdZaOmUSonx mJ9owcg== X-Received: from pjtd16.prod.google.com ([2002:a17:90b:50:b0:384:f6e1:ff87]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5866:b0:398:e73e:5a13 with SMTP id 98e67ed59e1d1-39b2613272amr3739100a91.9.1788483837661; Thu, 03 Sep 2026 18:03:57 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:47 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-3-seanjc@google.com> Subject: [PATCH v3 2/8] KVM: VMX: Move the shared "IRQs off" exit handler(s) to common code From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move vmx_handle_exit_irqoff() and its helpers to common.h / main.c to capture that it's a common handler and to allow guarding against incorrectly using to_vmx(). Opportunistically use a "vt" prefix instead of "vmx" to communicate that it's a shared handler. No functional change intended. Cc: Rick Edgecombe Cc: Xiaoyao Li Cc: Binbin Wu Cc: Kai Huang Cc: Yan Zhao Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 6 ++++ arch/x86/kvm/vmx/main.c | 71 +++++++++++++++++++++++++++++++++++- arch/x86/kvm/vmx/vmx.c | 74 -------------------------------------- arch/x86/kvm/vmx/x86_ops.h | 1 - 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index 08005676702c..88f637c81353 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -74,6 +74,12 @@ static __always_inline bool is_td_vcpu(struct kvm_vcpu *= vcpu) { return false; } =20 #endif =20 +static inline bool is_xfd_nm_fault(struct kvm_vcpu *vcpu) +{ + return vcpu->arch.guest_fpu.fpstate->xfd && + !kvm_is_cr0_bit_set(vcpu, X86_CR0_TS); +} + static inline bool vt_is_tdx_private_gpa(struct kvm *kvm, gpa_t gpa) { /* For TDX the direct mask is the shared mask. */ diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index ea0d825e556d..9614f43e7987 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include =20 #include "x86_ops.h" @@ -878,6 +879,74 @@ static int vt_gmem_max_mapping_level(struct kvm *kvm, = kvm_pfn_t pfn, #define vt_op_tdx_only(name) NULL #endif /* CONFIG_KVM_INTEL_TDX */ =20 +static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu) +{ + /* + * Save xfd_err to guest_fpu before interrupt is enabled, so the + * MSR value is not clobbered by the host activity before the guest + * has chance to consume it. + * + * Update the guest's XFD_ERR if and only if XFD is enabled, as the #NM + * interception may have been caused by L1 interception. Per the SDM, + * XFD_ERR is not modified for non-XFD #NM, i.e. if CR0.TS=3D1. + * + * Note, XFD_ERR is updated _before_ the #NM interception check, i.e. + * unlike CR2 and DR6, the value is not a payload that is attached to + * the #NM exception. + */ + if (is_xfd_nm_fault(vcpu)) + rdmsrq(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err); +} + +static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info) +{ + /* if exit due to PF check for async PF */ + if (is_page_fault(intr_info)) + vcpu->arch.apf.host_apf_flags =3D kvm_read_and_reset_apf_flags(); + /* if exit due to NM, handle before interrupts are enabled */ + else if (is_nm_fault(intr_info)) + handle_nm_fault_irqoff(vcpu); + /* Handle machine checks before interrupts are enabled */ + else if (is_machine_check(intr_info)) + kvm_machine_check(); +} + +static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu, + u32 intr_info) +{ + unsigned int vector =3D intr_info & INTR_INFO_VECTOR_MASK; + + if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm, + "unexpected VM-Exit interrupt info: 0x%x", intr_info)) + return; + + kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); + x86_entry_from_kvm(EVENT_TYPE_EXTINT, vector); + kvm_after_interrupt(vcpu); + + vcpu->arch.at_instruction_boundary =3D true; +} + +static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu) +{ + if (to_vt(vcpu)->emulation_required) + return; + + switch (vmx_get_exit_reason(vcpu).basic) { + case EXIT_REASON_EXTERNAL_INTERRUPT: + handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu)); + break; + case EXIT_REASON_EXCEPTION_NMI: + handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu)); + break; + case EXIT_REASON_MCE_DURING_VMENTRY: + kvm_machine_check(); + break; + default: + break; + } +} + #define VMX_REQUIRED_APICV_INHIBITS \ (BIT(APICV_INHIBIT_REASON_DISABLED) | \ BIT(APICV_INHIBIT_REASON_ABSENT) | \ @@ -1002,7 +1071,7 @@ struct kvm_x86_ops vt_x86_ops __initdata =3D { .load_mmu_pgd =3D vt_op(load_mmu_pgd), =20 .check_intercept =3D vmx_check_intercept, - .handle_exit_irqoff =3D vmx_handle_exit_irqoff, + .handle_exit_irqoff =3D vt_handle_exit_irqoff, =20 .update_cpu_dirty_logging =3D vt_op(update_cpu_dirty_logging), =20 diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 504630f0eb40..adf2bc13bed2 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5379,12 +5379,6 @@ bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu) (kvm_get_rflags(vcpu) & X86_EFLAGS_AC); } =20 -static bool is_xfd_nm_fault(struct kvm_vcpu *vcpu) -{ - return vcpu->arch.guest_fpu.fpstate->xfd && - !kvm_is_cr0_bit_set(vcpu, X86_CR0_TS); -} - static int vmx_handle_page_fault(struct kvm_vcpu *vcpu, u32 error_code) { unsigned long cr2 =3D vmx_get_exit_qual(vcpu); @@ -7143,74 +7137,6 @@ void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64= *eoi_exit_bitmap) vmcs_write64(EOI_EXIT_BITMAP3, eoi_exit_bitmap[3]); } =20 -static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu) -{ - /* - * Save xfd_err to guest_fpu before interrupt is enabled, so the - * MSR value is not clobbered by the host activity before the guest - * has chance to consume it. - * - * Update the guest's XFD_ERR if and only if XFD is enabled, as the #NM - * interception may have been caused by L1 interception. Per the SDM, - * XFD_ERR is not modified for non-XFD #NM, i.e. if CR0.TS=3D1. - * - * Note, XFD_ERR is updated _before_ the #NM interception check, i.e. - * unlike CR2 and DR6, the value is not a payload that is attached to - * the #NM exception. - */ - if (is_xfd_nm_fault(vcpu)) - rdmsrq(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err); -} - -static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info) -{ - /* if exit due to PF check for async PF */ - if (is_page_fault(intr_info)) - vcpu->arch.apf.host_apf_flags =3D kvm_read_and_reset_apf_flags(); - /* if exit due to NM, handle before interrupts are enabled */ - else if (is_nm_fault(intr_info)) - handle_nm_fault_irqoff(vcpu); - /* Handle machine checks before interrupts are enabled */ - else if (is_machine_check(intr_info)) - kvm_machine_check(); -} - -static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu, - u32 intr_info) -{ - unsigned int vector =3D intr_info & INTR_INFO_VECTOR_MASK; - - if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm, - "unexpected VM-Exit interrupt info: 0x%x", intr_info)) - return; - - kvm_before_interrupt(vcpu, KVM_HANDLING_IRQ); - x86_entry_from_kvm(EVENT_TYPE_EXTINT, vector); - kvm_after_interrupt(vcpu); - - vcpu->arch.at_instruction_boundary =3D true; -} - -void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu) -{ - if (to_vt(vcpu)->emulation_required) - return; - - switch (vmx_get_exit_reason(vcpu).basic) { - case EXIT_REASON_EXTERNAL_INTERRUPT: - handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu)); - break; - case EXIT_REASON_EXCEPTION_NMI: - handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu)); - break; - case EXIT_REASON_MCE_DURING_VMENTRY: - kvm_machine_check(); - break; - default: - break; - } -} - /* * The kvm parameter can be NULL (module initialization, or invocation bef= ore * VM creation). Be sure to check the kvm parameter before using it. diff --git a/arch/x86/kvm/vmx/x86_ops.h b/arch/x86/kvm/vmx/x86_ops.h index 054fd14bb2e1..7ac02c68457f 100644 --- a/arch/x86/kvm/vmx/x86_ops.h +++ b/arch/x86/kvm/vmx/x86_ops.h @@ -27,7 +27,6 @@ void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_even= t); void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu); void vmx_vcpu_put(struct kvm_vcpu *vcpu); int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath); -void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu); int vmx_skip_emulated_instruction(struct kvm_vcpu *vcpu); void vmx_update_emulated_instruction(struct kvm_vcpu *vcpu); bool vmx_unhandleable_emulation_required(struct kvm_vcpu *vcpu); --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9401A36A03F for ; Fri, 4 Sep 2026 01:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483841; cv=none; b=lsquSluJ8Uw2qAS+7NCB3IdqKDwcQ9t47Px9yD/8jlDHSseNcarB3iZPJrdVRUycTdmFNINXvFKG6jCmmMImjOSXRHKi7jnJWfYGfRPOpACWtIr/Kmz5ZLA8QeOBgS26qwIDnqHHPhuoQ1NZp+Olp+D8seIrm8UOYgVc4NaHa3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483841; c=relaxed/simple; bh=hmPFoHDi198piLc+Mjunw9WTBgvQgwN+OdxP0ZAXmZM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BHf2D/FMCookSVmwnJTNLHNXb8NXhl2CJNjw/dOaDsNKFLRybLzLOLsohgOzH1inFSt5czzjeTZnzQLtdagF2neOM/6ljE+NUBtvokZG4R6HwBIx+M+OQzwagrNTBL+eM7GDgxQPHHWrlI6RjOwoxkxfWV3LxXzqwjkgmsmF6aA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gWPbUp10; arc=none smtp.client-ip=209.85.214.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gWPbUp10" Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2d54187d8b0so13849315ad.0 for ; Thu, 03 Sep 2026 18:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483839; x=1789088639; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=vSlMjq8tWu4P44mUn9mh71lQHrhgq0jSndGTEJFOM2U=; b=gWPbUp1039zmHORJOqcwMvVebpdAXtNWuTeyLzADJPmk9trTgoFYUMF9Mt7pMCMP9j UAH+S92LXxo2hTBQfrcgHrtVCQFpZHJX/IbooDblMi/xYtSjZmWmi4izS6X95Gffsank yd236VEddxa65FuIHhEWZvsM08Qe9QcriMUXDMO5lf3MZGc4J4mNolbpqJhWAuO9R8/n cyGxc868kbKThAI4jPHHtvFAjKjO1/p02x9riogbnH1YcwlModWn/zh4/vR6W6hUy0cM 5o+eAyfPEvGZLhvaYPAIFmdN8PQ8NkEqRn6oEpM27cVFamWJPsd3X8LJ0XIr82DKkCKB dn9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483839; x=1789088639; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vSlMjq8tWu4P44mUn9mh71lQHrhgq0jSndGTEJFOM2U=; b=NuJkUmMkwTqMf8hLeg1BVUKgEFuEAEoJNC3LIrs7EB+hnBeMSWPunOHSUFXBTimQ49 06F2xhC/L3dEAYb4XcFw1wQRbdViMP2u/Ukcxf1uI79IgnqKW+V33XChxC1UXckt10no gwwKYQ2asQ8nwQu9WpiRQHRFkrJei5we0qeKuzVlf43I/3pLv9PhaPWM/YnDtNpCfRun vk0O1gPY0Ud1fg7NewflOglWb5FVuvRQopz21W+CGyajz7r/cHbwMTdckTi+FAG2pXMD TjpCTwLQ7R3yypFwtgMpJsHlRen/pVmfAmjDfBplo42WLe0ufaF7vYS3M/AY0A3fXglk jFVA== X-Forwarded-Encrypted: i=1; AKwUvBxRWGE+DYUs64rSxnvVnZAY4K8J9ieGr875fgiBENK6G6zg4IGqStdPW1UqJonMWVZ5ohst8+Z1oEqn6v4=@vger.kernel.org X-Gm-Message-State: AFuF++l6lWFuxF5M3kIF+KR14xoBiPgZdlRt/RhPcS7eCo/nkw+jelx4 uK+RIiczmYw4+MRU2g1hAx7Rsh/Wi/MUUjNh5psecex4aiVoQuomC7gWD3jDwuDCzghXZ5QgwkP 1pnW/FA== X-Received: from plei1.prod.google.com ([2002:a17:902:e481:b0:2ce:9b92:ec60]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:468d:b0:2d9:56d8:75f with SMTP id d9443c01a7336-2db1266772dmr44885415ad.9.1788483838837; Thu, 03 Sep 2026 18:03:58 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:48 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-4-seanjc@google.com> Subject: [PATCH v3 3/8] KVM: VMX: Move the shared NMI handler/trampoline to common code From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move vmx_handle_nmi() to main.c to capture that it's a common handler and to allow guarding against incorrectly using to_vmx(). Opportunistically use a "vt" prefix instead of "vmx" to communicate that it's a shared handler. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 2 +- arch/x86/kvm/vmx/main.c | 11 +++++++++++ arch/x86/kvm/vmx/tdx.c | 2 +- arch/x86/kvm/vmx/vmx.c | 13 +------------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index 88f637c81353..4b1d46eafd0f 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -189,6 +189,6 @@ static inline void __vmx_deliver_posted_interrupt(struc= t kvm_vcpu *vcpu, kvm_vcpu_trigger_posted_interrupt(vcpu, POSTED_INTR_VECTOR); } =20 -noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu); +noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu); =20 #endif /* __KVM_X86_VMX_COMMON_H */ diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 9614f43e7987..b1069a8e30a7 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -947,6 +947,17 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vcp= u) } } =20 +noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu) +{ + if ((u16)vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_EXCEPTION_NMI || + !is_nmi(vmx_get_intr_info(vcpu))) + return; + + kvm_before_interrupt(vcpu, KVM_HANDLING_NMI); + x86_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR); + kvm_after_interrupt(vcpu); +} + #define VMX_REQUIRED_APICV_INHIBITS \ (BIT(APICV_INHIBIT_REASON_DISABLED) | \ BIT(APICV_INHIBIT_REASON_ABSENT) | \ diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index b272c20586a7..46b0e798f8b9 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -974,7 +974,7 @@ static noinstr void tdx_vcpu_enter_exit(struct kvm_vcpu= *vcpu) tdx->exit_gpa =3D tdx->vp_enter_args.r8; vt->exit_intr_info =3D tdx->vp_enter_args.r9; =20 - vmx_handle_nmi(vcpu); + vt_handle_nmi(vcpu); =20 guest_state_exit_irqoff(); } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index adf2bc13bed2..a06dd2d77f10 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7363,17 +7363,6 @@ static fastpath_t vmx_exit_handlers_fastpath(struct = kvm_vcpu *vcpu, } } =20 -noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu) -{ - if ((u16)vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_EXCEPTION_NMI || - !is_nmi(vmx_get_intr_info(vcpu))) - return; - - kvm_before_interrupt(vcpu, KVM_HANDLING_NMI); - x86_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR); - kvm_after_interrupt(vcpu); -} - static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, unsigned int flags) { @@ -7406,7 +7395,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vc= pu *vcpu, if (likely(!vmx_get_exit_reason(vcpu).failed_vmentry)) vmx->idt_vectoring_info =3D vmcs_read32(IDT_VECTORING_INFO_FIELD); =20 - vmx_handle_nmi(vcpu); + vt_handle_nmi(vcpu); =20 out: guest_state_exit_irqoff(); --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8F31370AC0 for ; Fri, 4 Sep 2026 01:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483843; cv=none; b=AmJS6DG3XxoRvuRZlzrvTeUmqcbWIkwmmbFTAii+JsSADuC003MityAZbhWMb/aBl0AzkF12souDoew7Bgf22HhUwpbiVlyPtjG3gUazLPdcu92mfiLcVZgempQWR1QfZ9m4vfdXvs76afzy6oS1lpzFEgQb4VdnwpPzEHd4jOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483843; c=relaxed/simple; bh=EQ3dbwkw2ZVaT4L6zDjc0l81bhCdrmVdynWqbJE1BzA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=X6q6ro4ITNjSFlfXiMahU+sBjWVu6Dx1ERu9Wx2X8i2iwLoVVwQcZReXPMXydayjX0fA5VpMDUEdQE2JQX2IK4If+M7pE00P4hqVTn0Dop8ox0SD6Vw/sSiW38W1l+m1PQyvC3eygS02Uw/nuLzN3WGkkzC+rsQZMOsh7p/kSQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jejQv9jg; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jejQv9jg" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-3823dcc1647so509406a91.3 for ; Thu, 03 Sep 2026 18:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483840; x=1789088640; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=5Vh90jg/qeVICJkXqkXI15uK7I8LepvFnP71xWR+wIU=; b=jejQv9jg8N4Ohtl00tpw1vP/QXZGvzcrp6Z5KOQkLJy2ql6UY5wMHueKJEKX7zRs9o jeShEuW3eQZ620eMC5LmxiVCA5rdnpS6073rt1tHI5v0d7rUaDG/8q3pxm4Z+tvSMj0D zI5onLwakJ7mJp5kkAW0dQ2DfoTh7t5vRNAU3KcwBqad2DNPeJhmteZHWgeYFNFa7KS3 +Pfok/KjgxHegEGCFdHIOPQXJm7GyhHmVnVYbwj6l5dKseEvurr9C2FIzoVNBkCmZM8P F/y173mhvVHjpE+fdt36b2pp34j3r4oCUQBaZkW80MYKIicwSFkUzsmAHhPDC6JLIzS0 mlJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483840; x=1789088640; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5Vh90jg/qeVICJkXqkXI15uK7I8LepvFnP71xWR+wIU=; b=CojXoRUu58yJdwIE/jj/sUh4i7FfSFyCh7HAZNGvU7qe0rPA3olukQaOMwZDsgXZol LTqdVwuzU7u2nf9IYEeIjZrKjbBT5CtNZHyO7bAnkev+A1Yg9KMkOHSp0jBNSDAdfqsM BfQKrlX/a/gT4xdq6WLiOjwfD+FvSr/FmRhB3MmGEHjbrLIeOUPZBo1ab5ByXoRKrozE +TGyzi5TRqcLIoZRrL/pUrmtDrsylm/wAzLWTswd5VS9JPFARdHeG8bYo+H+hYYisJbD oMoI2hO0j9umY3uPEzR+zUceSFrQi+63syDNTNyYdCVmnma1NzeyuxauF2KNyXUDSJgJ YooQ== X-Forwarded-Encrypted: i=1; AKwUvBxPnrlSwiHZSBcRBLKYHJiSvZ0iv7w5Qyx6kAHnGh7quV97MYEhDnW/gK5pMAO5RsG6XMfUvuL6pDAiHH0=@vger.kernel.org X-Gm-Message-State: AFuF++mF1BFxHCSVjyQtT9H+159UmBuIoLXvaycL0T1G4rLUJ6Q7d/kj 1v8pyMcThTPfpSvJXAulq/+tZOOVJKra0UKVyk71Q/OBB/5XHsMWUkWbZxkkMF2JmDx19go0kR8 EW4Oa5A== X-Received: from pjbrs11.prod.google.com ([2002:a17:90b:2b8b:b0:381:27d7:fc1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c05:b0:393:288:29e3 with SMTP id 98e67ed59e1d1-39b26106c44mr3970499a91.10.1788483839974; Thu, 03 Sep 2026 18:03:59 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:49 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-5-seanjc@google.com> Subject: [PATCH v3 4/8] KVM: VMX: Rename posted interrupt prefixes from "vmx" to "vt" From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename all common posted interrupt APIs that use a "vmx" prefix to instead use a "vt" prefix to capture that they are used for both VMX and TDX vCPUs. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 4 ++-- arch/x86/kvm/vmx/main.c | 4 ++-- arch/x86/kvm/vmx/posted_intr.c | 22 +++++++++++----------- arch/x86/kvm/vmx/posted_intr.h | 8 ++++---- arch/x86/kvm/vmx/tdx.c | 6 +++--- arch/x86/kvm/vmx/vmx.c | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index 4b1d46eafd0f..ff4f6a2b6402 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -170,8 +170,8 @@ static inline void kvm_vcpu_trigger_posted_interrupt(st= ruct kvm_vcpu *vcpu, * Post an interrupt to a vCPU's PIR and trigger the vCPU to process the * interrupt if necessary. */ -static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, - struct pi_desc *pi_desc, int vector) +static inline void __vt_deliver_posted_interrupt(struct kvm_vcpu *vcpu, + struct pi_desc *pi_desc, int vector) { if (pi_test_and_set_pir(vector, pi_desc)) return; diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index b1069a8e30a7..8ac6ea58b481 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -1086,8 +1086,8 @@ struct kvm_x86_ops vt_x86_ops __initdata =3D { =20 .update_cpu_dirty_logging =3D vt_op(update_cpu_dirty_logging), =20 - .pi_update_irte =3D vmx_pi_update_irte, - .pi_start_bypass =3D vmx_pi_start_bypass, + .pi_update_irte =3D vt_pi_update_irte, + .pi_start_bypass =3D vt_pi_start_bypass, =20 #ifdef CONFIG_X86_64 .set_hv_timer =3D vt_op(set_hv_timer), diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c index 24221ba553be..2644add54b76 100644 --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -56,7 +56,7 @@ static int pi_try_set_control(struct pi_desc *pi_desc, u6= 4 *pold, u64 new) return 0; } =20 -void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) +void vt_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) { struct pi_desc *pi_desc =3D vcpu_to_pi_desc(vcpu); struct vcpu_vt *vt =3D to_vt(vcpu); @@ -146,11 +146,11 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) pi_set_on(pi_desc); } =20 -static bool vmx_can_use_vtd_pi(struct kvm *kvm) +static bool vt_can_use_vtd_pi(struct kvm *kvm) { /* * Note, reading the number of possible bypass IRQs can race with a - * bypass IRQ being attached to the VM. vmx_pi_start_bypass() ensures + * bypass IRQ being attached to the VM. vt_pi_start_bypass() ensures * blockng vCPUs will see an elevated count or get KVM_REQ_UNBLOCK. */ return irqchip_in_kernel(kvm) && kvm_arch_has_irq_bypass() && @@ -208,7 +208,7 @@ static void pi_enable_wakeup_handler(struct kvm_vcpu *v= cpu) __apic_send_IPI_self(POSTED_INTR_WAKEUP_VECTOR); } =20 -static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu) +static bool vt_needs_pi_wakeup(struct kvm_vcpu *vcpu) { /* * The default posted interrupt vector does nothing when @@ -219,14 +219,14 @@ static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu) * back to the pi_wakeup_handler() function. */ return (vmx_can_use_ipiv(vcpu) && !is_td_vcpu(vcpu)) || - vmx_can_use_vtd_pi(vcpu->kvm); + vt_can_use_vtd_pi(vcpu->kvm); } =20 -void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu) +void vt_vcpu_pi_put(struct kvm_vcpu *vcpu) { struct pi_desc *pi_desc =3D vcpu_to_pi_desc(vcpu); =20 - if (!vmx_needs_pi_wakeup(vcpu)) + if (!vt_needs_pi_wakeup(vcpu)) return; =20 /* @@ -294,17 +294,17 @@ bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu) /* * Kick all vCPUs when the first possible bypass IRQ is attached to a VM, = as * blocking vCPUs may scheduled out without reconfiguring PID.NV to the wa= keup - * vector, i.e. if the bypass IRQ came along after vmx_vcpu_pi_put(). + * vector, i.e. if the bypass IRQ came along after vt_vcpu_pi_put(). */ -void vmx_pi_start_bypass(struct kvm *kvm) +void vt_pi_start_bypass(struct kvm *kvm) { - if (WARN_ON_ONCE(!vmx_can_use_vtd_pi(kvm))) + if (WARN_ON_ONCE(!vt_can_use_vtd_pi(kvm))) return; =20 kvm_make_all_cpus_request(kvm, KVM_REQ_UNBLOCK); } =20 -int vmx_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm, +int vt_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, struct kvm_vcpu *vcpu, u32 vector) { diff --git a/arch/x86/kvm/vmx/posted_intr.h b/arch/x86/kvm/vmx/posted_intr.h index a4af39948cf0..c5860ea828ae 100644 --- a/arch/x86/kvm/vmx/posted_intr.h +++ b/arch/x86/kvm/vmx/posted_intr.h @@ -8,16 +8,16 @@ =20 #include =20 -void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu); -void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu); +void vt_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu); +void vt_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_kernel_irqfd *irqfd, struct kvm *kvm, +int vt_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, struct kvm_vcpu *vcpu, u32 vector); -void vmx_pi_start_bypass(struct kvm *kvm); +void vt_pi_start_bypass(struct kvm *kvm); =20 static inline int pi_find_highest_vector(struct pi_desc *pi_desc) { diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 46b0e798f8b9..36578d4c00ff 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -716,7 +716,7 @@ void tdx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) { struct vcpu_tdx *tdx =3D to_tdx(vcpu); =20 - vmx_vcpu_pi_load(vcpu, cpu); + vt_vcpu_pi_load(vcpu, cpu); if (vcpu->cpu =3D=3D cpu || !is_hkid_assigned(to_kvm_tdx(vcpu->kvm))) return; =20 @@ -826,7 +826,7 @@ static void tdx_prepare_switch_to_host(struct kvm_vcpu = *vcpu) =20 void tdx_vcpu_put(struct kvm_vcpu *vcpu) { - vmx_vcpu_pi_put(vcpu); + vt_vcpu_pi_put(vcpu); tdx_prepare_switch_to_host(vcpu); } =20 @@ -1895,7 +1895,7 @@ void tdx_deliver_interrupt(struct kvm_lapic *apic, in= t delivery_mode, struct vcpu_tdx *tdx =3D to_tdx(vcpu); =20 /* TDX supports only posted interrupt. No lapic emulation. */ - __vmx_deliver_posted_interrupt(vcpu, &tdx->vt.pi_desc, vector); + __vt_deliver_posted_interrupt(vcpu, &tdx->vt.pi_desc, vector); =20 trace_kvm_apicv_accept_irq(vcpu->vcpu_id, delivery_mode, trig_mode, vecto= r); } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index a06dd2d77f10..506be74e3e0f 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1577,12 +1577,12 @@ void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) =20 vmx_vcpu_load_vmcs(vcpu, cpu); =20 - vmx_vcpu_pi_load(vcpu, cpu); + vt_vcpu_pi_load(vcpu, cpu); } =20 void vmx_vcpu_put(struct kvm_vcpu *vcpu) { - vmx_vcpu_pi_put(vcpu); + vt_vcpu_pi_put(vcpu); =20 vmx_prepare_switch_to_host(to_vmx(vcpu)); } @@ -4424,7 +4424,7 @@ static int vmx_deliver_posted_interrupt(struct kvm_vc= pu *vcpu, int vector) if (!vcpu->arch.apic->apicv_active) return -1; =20 - __vmx_deliver_posted_interrupt(vcpu, &vt->pi_desc, vector); + __vt_deliver_posted_interrupt(vcpu, &vt->pi_desc, vector); return 0; } =20 --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75A15374A1F for ; Fri, 4 Sep 2026 01:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483844; cv=none; b=jFrxCMJuYc6hXprBwFApDpxmUruzrNxmEJXcyL9zNaC1iiYa3xqaYc0gQCKLYkQw7XYoRJb2r6iNxaym8gzYqwxGSl2ZPYUo87anSrjxnEk4FX1J+1w5fneWbWLd0q6B5kuv410DnExBGph7sL0Kj6HdaZAH1f1aztttmOzIgzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483844; c=relaxed/simple; bh=X4SZAAkjG92iz3w2ODpwfXxbWrcWBsnNa21J0Q9GDS4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jLH2wGeaBRtGGD8ACvEN5OViT9kujCCs72asCLqcEihX+0L1zP/995KxkSb15ycMGUnNzU/TvlikdHXrrals/INk+uM+FiVRsKUm44rQZd5Oo4PKRn8M9bE4+uhekVvv9xAq9h4uyuObASdkbtnjImFwgDXCxg15FEJ+wGdMtns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DVY3oL8X; arc=none smtp.client-ip=209.85.214.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DVY3oL8X" Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2d6c166bafcso6402625ad.2 for ; Thu, 03 Sep 2026 18:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483841; x=1789088641; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FSfv/bBfAxnRVVgmydjnwKVRqc5YLkAKq3RoNE3C6X8=; b=DVY3oL8XfxHw6bHIhWfXjDioZ7Q9KHTo0H8tiOG46JkBlXqL9qa4jDU8/oKaKTszmZ H2DYxt8P9isX+rYpnjZAg31UzOAWVp1MdW2WxgwCqLpMZAgKSWkc7kdPx5aegPZHa6BK Qa5m2UdLu3pcJMldZjQxdTEOeRjyw66ZbjtwypnL+PN9XASFTWvc/QOzeGsFL/WP/3Ez 3xHJeFG/wKIUysMsHuNKw0cpIi9B8n+zKDhxm7gvwqNjH4AJ10dTE7LqdxROSrX1Nquc TXMw+cWFkboF7mHABTJ0CPlFWscGpxSWLnBAcu/HF5bg03RqIWCPbtf6stEd8mTOKDt7 PN8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483841; x=1789088641; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=FSfv/bBfAxnRVVgmydjnwKVRqc5YLkAKq3RoNE3C6X8=; b=EhyeszF6M/kGwk4n1HtWm6fEJ5fh2Bz+d+22bh9/eEW6CjAkoH1D29QIrVdjS4HEw4 HwLpO9LxRwmCh/8olomIK8TVcScs+YqaZg2GdZYZDUSBz6hQz8P898rIQfwqTSx8OHBf Bm9ov/0SdaHEkybfTfk/0LyZFGQ4ORR/FojQRUSO5Db7EKzRCAyUedRfdf1UyjlmHg15 L6DO5PSxDoeAgNIHd/TNQnIXEOUE75zdbf7RY4bcep8nAP1OFMnQSebExZdCdSJ1KO2e Jqb/VaxkJie+dF4EfiH+kWejthHkjEua7OcoQYu0rZ2QMs+AmRtUEzrFjBgvx7qvOedH ZD9g== X-Forwarded-Encrypted: i=1; AKwUvBw29iT46uKUPtU/FF+WGf3AWPwKJwju6nEYnYXXe+kvixnL2ZQYO16O2QJcYojdC8ALQp1gsbkaiYl84vs=@vger.kernel.org X-Gm-Message-State: AFuF++ks+jfFfKwuPMsflhFQdt1Ho9uAhsKXV5CLysr2T2IrHnjPlmow ZttFPJeIfQ+h1Sk2QHAcwxLqD6QrEtMauvqbQ9ElxqjKF30022pbR21FbEe+deylTW5dSyrabNB JLxMa6Q== X-Received: from plbja8.prod.google.com ([2002:a17:902:efc8:b0:2ca:d0f4:2f91]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:3247:b0:2d7:2edd:d140 with SMTP id d9443c01a7336-2db1232e1cemr43854845ad.3.1788483841108; Thu, 03 Sep 2026 18:04:01 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:50 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-6-seanjc@google.com> Subject: [PATCH v3 5/8] KVM: VMX: Rename EPT violation handler prefix from "vmx" to "vt" From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename __vmx_handle_ept_violation() to __vt_handle_ept_violation to capture that it is shared between VMX and TDX. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 4 ++-- arch/x86/kvm/vmx/tdx.c | 2 +- arch/x86/kvm/vmx/vmx.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index ff4f6a2b6402..35b54938a5f5 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -86,8 +86,8 @@ static inline bool vt_is_tdx_private_gpa(struct kvm *kvm,= gpa_t gpa) return !kvm_is_addr_direct(kvm, gpa); } =20 -static inline int __vmx_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t = gpa, - unsigned long exit_qualification) +static inline int __vt_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t g= pa, + unsigned long exit_qualification) { u64 error_code; =20 diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 36578d4c00ff..a3d6f0fb5951 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1987,7 +1987,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *= vcpu) while (1) { struct kvm_memory_slot *slot; =20 - ret =3D __vmx_handle_ept_violation(vcpu, gpa, exit_qual); + ret =3D __vt_handle_ept_violation(vcpu, gpa, exit_qual); =20 if (ret !=3D RET_PF_RETRY || !local_retry) break; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 506be74e3e0f..2532a9b8e92e 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5991,7 +5991,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu) if (unlikely(allow_smaller_maxphyaddr && !kvm_vcpu_is_legal_gpa(vcpu, gpa= ))) return kvm_emulate_instruction(vcpu, 0); =20 - return __vmx_handle_ept_violation(vcpu, gpa, exit_qualification); + return __vt_handle_ept_violation(vcpu, gpa, exit_qualification); } =20 static int handle_ept_misconfig(struct kvm_vcpu *vcpu) --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A5C9371D1D for ; Fri, 4 Sep 2026 01:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483846; cv=none; b=YtsxUX5kA1IoaboLIgqMVV3iMwtKBXMlaI7PC5Sj4HTipZeMqJe+ia1kNSX0xgOzaeXcRA2bCnTVjhxOn3G7dXyLEXVvBKIE37XhQGNW3jIpgEZ6BQv8iOxTSviYJ//VbL5yHZ31Rvd9yqzHf7ykxxFicz+PVQrUAcxSPeMeLNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483846; c=relaxed/simple; bh=fIjwL/4EMjLTyCf9nPNHnNwHUIHFWzrEIsab3VQBiog=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SGBkFdeZ+3DtJ/fHH4/6Q9zT+tLbF0BBzk2YiWX3k81FZFzx9UAqma9id7TOnO4I7m5GwbJvJeVAC4q7IDNqPIwOZw0cFFaHemt31lv0VSmyvlaqQs1GSsKjV5KcHDhtbKyPAWC8QdE9UibILkZbMhZPaVEI6oo0nndnA5RlTcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Ui1u4CO4; arc=none smtp.client-ip=209.85.215.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ui1u4CO4" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-ca6bd8a190cso766706a12.0 for ; Thu, 03 Sep 2026 18:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483842; x=1789088642; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=0jLHclQygKy/zb7bAwv3owr0/x/cU8tEBK4Us9ZfCjY=; b=Ui1u4CO4tmsem6zJgSlSCTVSPoVc3qZP3ZrX7unN8sa3RvAguLJlpt0Q7NzzkNlGST zmY4uFLoyYLQ0NChPebqT0PVoTNNO4a3C39QJ9rknd7zVf1nB8T3SPQ58YfnvHMTlBOV hFC+0Jvbnjm1+s0LuKDgeW1W9JBh34R2Yd4q6KynKL+7z3RcAFMjgtMmpb5VronAKGsC svKh+moSJ+K5Sqv32QcRmXLLGqg0mhDesEcK2kl2PgP639kExVap+TMpm+e1GxqZxl9w 2ux8xJqpKdW11H3yteCVGl+ctVDn9JeuSHwPa0sqMKjCEIH8aejnNtHcWrUD8l6eW9nV dyvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483842; x=1789088642; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0jLHclQygKy/zb7bAwv3owr0/x/cU8tEBK4Us9ZfCjY=; b=mXSjfCUl7IqkScfTIdcKMDa4Ff8oAntTh/y6b7eaiG+PuFjhN0LLbzBoaeffa7kLj4 ZBTS1hIq/Gb5TZ+rZoEygEKUewHgQNn7zG81v7OnlTfQvEBgYfG/kyy8fVFMiwmwZDOF sn6BHL9o9BsOCSRal9qQv/PTRi5ydbACUCh2b+TdajNVyM96yY9XymaEtGz0QLU8x5fd 68PcXO/bTR6642mKgGSAf7ICjjPIhQfwQBpbXSTI+2AeT9YZC/lHqmcDrUIbldxONMkS rMIfMxxsgueM12rx21XVhkqSKvYcKdvm8lo6jrDt2X5GMBMHd/u+MT7XNPxB2of5AeVR RoEg== X-Forwarded-Encrypted: i=1; AKwUvBx5X63d17FQwdioESlb0uKinSHb7r+7PNW/2qudvz/reRAmUcuUqUN8Wn05s4omZxjc5ybr65wkG6qDGnY=@vger.kernel.org X-Gm-Message-State: AFuF++m9sUY7HFmZI2tp4MErbFRVDPO1hODMPP6QEz+LJoKC73wti0l6 Y56yaHwCSXIMKePaXG50ZcdGs+IXdHmHq0p2Ve7xuJ1giyT2A3/nAEahWJKotBktkjUhiIXkZHH nrMpmmQ== X-Received: from pgid6.prod.google.com ([2002:a63:ed06:0:b0:cc4:2a28:ddb6]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6e95:b0:3cc:f008:8123 with SMTP id adf61e73a8af0-3da39ec3ebamr4212060637.8.1788483842323; Thu, 03 Sep 2026 18:04:02 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:51 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-7-seanjc@google.com> Subject: [PATCH v3 6/8] KVM: VMX: Use dummy pseudo-overlay struct for to_vt() and vt_to_vcpu() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Define a combined vcpu_vmx_tdx structure to represent the common layout of vcpu_vmx and vcpu_tdx, instead of having vcpu_tdx piggyback vcpu_vmx. I.e. require VMX and TDX to match the common definition, not for TDX to match VMX. This will allow moving to_vt() and vt_to_vcpu() to common.h where they belong. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/main.c | 4 +++- arch/x86/kvm/vmx/vmx.h | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 8ac6ea58b481..0151baa56598 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -13,8 +13,10 @@ =20 #pragma GCC poison to_vmx =20 +static_assert(offsetof(struct vcpu_vmx_tdx, vt) =3D=3D offsetof(struct vcp= u_vmx, vt)); + #ifdef CONFIG_KVM_INTEL_TDX -static_assert(offsetof(struct vcpu_vmx, vt) =3D=3D offsetof(struct vcpu_td= x, vt)); +static_assert(offsetof(struct vcpu_vmx_tdx, vt) =3D=3D offsetof(struct vcp= u_tdx, vt)); =20 static void vt_disable_virtualization_cpu(void) { diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index dc8517f15bc4..0415d328e1a5 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -304,14 +304,19 @@ struct kvm_vmx { u64 *pid_table; }; =20 +struct vcpu_vmx_tdx { + struct kvm_vcpu vcpu; + struct vcpu_vt vt; +}; + static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu) { - return &(container_of(vcpu, struct vcpu_vmx, vcpu)->vt); + return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt); } =20 static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt) { - return &(container_of(vt, struct vcpu_vmx, vt)->vcpu); + return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu); } =20 static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kv= m_vcpu *vcpu) --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8629936F90C for ; Fri, 4 Sep 2026 01:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483849; cv=none; b=UpNpygxqs0ZTevsU8iZkVKayFIhEHuFbK+QznO/dQhVsmtktp0bWU3VC045f9V5R6KLlu6hgnaBa9S2byi+q4of3UYOILBztHiv/PRhXj4gTFEa6to/2cuy/joGcLAUnRuQ8lhVU4DtjWH33UNstBSAPuzLwDIWE5hy3D4JkVXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483849; c=relaxed/simple; bh=l4kUd/yWDPJzl0Cfuv69NdJUn93tzn+b1PJKjxDHVIY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lZmVPIAdtpybdfKWKMH8Mb6PDNlPEYTRoFn4TG8Rm+ZMlHHi+X1y2Ndog7ooWy/UZFblGAYB1hJIzSxpzBVm47OLnfoCw9lA2raGyzpMKz4USh3hTuJtCQ4Bqh8Bk+BHwiumJyozsw3PCCF5SuMUbYLZt1WdJheIAK1K/gOjm4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=X93mITEA; arc=none smtp.client-ip=209.85.210.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="X93mITEA" Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-851992f22ccso289459b3a.2 for ; Thu, 03 Sep 2026 18:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483844; x=1789088644; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Sl/i6fy4LSsllHV3Bhew/nOEKF0l8TqNOkYiE2Q8/uw=; b=X93mITEA8o6ow1iTBtPwPCyuP5r23OZZogzxVmHGc9ayy+I3egpDsRQf+Yi2AIdRx2 BRBdg8+LKYewHBey6qNs+MFM686+tP3WW1aDtSmthbkM2fWG7ULViekaRxIFW/sF5eQO tfEzjAF1JLsd4eo/MPCBWGJO384zufxVSQVDUj8s2FWaG7kp/eA57ntWjeY1RAIlBUpl 0KCTc8UNvHxXdimHhuhBEKQpzW5FTY94u5s5iQjKleJF9rjg62doq5SkyeO3v68EYy3N 0rLAw4XTja+eWZ5uRftc6MEEBVMsuNPFRciK++g/RTEs905Z8+GChDAD//0pCWcsiBWk AAEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483844; x=1789088644; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Sl/i6fy4LSsllHV3Bhew/nOEKF0l8TqNOkYiE2Q8/uw=; b=NhTY03Ic2dpatEj8KfcbQcB3tlJ4oztyhVuritQxkxtm0kgOKQU8IMCV13sI2C3RE4 Btt/kMEkcWPdhP4COmt9E3ffUnBlQSNMofV2IVL0RjjdOC428E8Vlk0Bk453ZBypaZMK wxFM3biHmF0qJ61koYG6xZZO1OvkRyq5XRwj9xHU2QEboyvN3L6F6elPnGbUZ1jpF8K2 iTHrLpERxsHOmQoylHwxz2nlpgSzI8VYQOtQ0JjrRyKMShtaHtrdTt0lXJl3Ql9JuQLG YXrqIrI4WiTBe3/mM1eRHWOLypkt/fuxo7StWzJUXlC564AlPHYgHHGfMON1LXAKHiOc jkhw== X-Forwarded-Encrypted: i=1; AKwUvBzmxXsPxPEY1I0wBR57KsanKlu9nkEkSAXmgo+nGh5727wa5Yq/A2PLfNUWv+IhlsIMz8q+YvJ9GYIwHmg=@vger.kernel.org X-Gm-Message-State: AFuF++nvqf7yQT0czWPcxWLCH3IuUGvgXYSyw+kcrnqheIqS/LD/x2wV HK6tLZVnYYU53qGTcWzLVypBZNiBTw2M86gIwVX81WGGE3lhyHSOikTYU5Q4AkbznHabuTXqG2h AFrZZ6w== X-Received: from pfj21.prod.google.com ([2002:a05:6a00:a415:b0:84e:a25:1e6b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:2885:b0:860:507d:503e with SMTP id d2e1a72fcca58-8616a26965emr3667088b3a.20.1788483843524; Thu, 03 Sep 2026 18:04:03 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:52 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-8-seanjc@google.com> Subject: [PATCH v3 7/8] KVM: VMX: Move common VT getters/converters to common.h From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the "to" vCPU converters and common exit information getters from vmx.h to common.h to capture that they are indeed common VT code. Defer renaming their prefixes to isolate the code movement from the massive churn that will result from said renaming. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 44 +++++++++++++++++++++++++++++++++++++++ arch/x86/kvm/vmx/vmx.h | 42 ------------------------------------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index 35b54938a5f5..c9ca0824734a 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -2,10 +2,12 @@ #ifndef __KVM_X86_VMX_COMMON_H #define __KVM_X86_VMX_COMMON_H =20 +#include #include #include =20 #include "mmu.h" +#include "vmx_ops.h" =20 union vmx_exit_reason { struct { @@ -74,6 +76,48 @@ static __always_inline bool is_td_vcpu(struct kvm_vcpu *= vcpu) { return false; } =20 #endif =20 +struct vcpu_vmx_tdx { + struct kvm_vcpu vcpu; + struct vcpu_vt vt; +}; + +static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu) +{ + return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt); +} + +static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt) +{ + return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu); +} + +static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kv= m_vcpu *vcpu) +{ + return to_vt(vcpu)->exit_reason; +} + +static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vc= pu) +{ + struct vcpu_vt *vt =3D to_vt(vcpu); + + if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_1) && + !WARN_ON_ONCE(is_td_vcpu(vcpu))) + vt->exit_qualification =3D vmcs_readl(EXIT_QUALIFICATION); + + return vt->exit_qualification; +} + +static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu) +{ + struct vcpu_vt *vt =3D to_vt(vcpu); + + if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_2) && + !WARN_ON_ONCE(is_td_vcpu(vcpu))) + vt->exit_intr_info =3D vmcs_read32(VM_EXIT_INTR_INFO); + + return vt->exit_intr_info; +} + static inline bool is_xfd_nm_fault(struct kvm_vcpu *vcpu) { return vcpu->arch.guest_fpu.fpstate->xfd && diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h index 0415d328e1a5..3247b55b3484 100644 --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -304,48 +304,6 @@ struct kvm_vmx { u64 *pid_table; }; =20 -struct vcpu_vmx_tdx { - struct kvm_vcpu vcpu; - struct vcpu_vt vt; -}; - -static __always_inline struct vcpu_vt *to_vt(struct kvm_vcpu *vcpu) -{ - return &(container_of(vcpu, struct vcpu_vmx_tdx, vcpu)->vt); -} - -static __always_inline struct kvm_vcpu *vt_to_vcpu(struct vcpu_vt *vt) -{ - return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu); -} - -static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kv= m_vcpu *vcpu) -{ - return to_vt(vcpu)->exit_reason; -} - -static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vc= pu) -{ - struct vcpu_vt *vt =3D to_vt(vcpu); - - if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_1) && - !WARN_ON_ONCE(is_td_vcpu(vcpu))) - vt->exit_qualification =3D vmcs_readl(EXIT_QUALIFICATION); - - return vt->exit_qualification; -} - -static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu) -{ - struct vcpu_vt *vt =3D to_vt(vcpu); - - if (!kvm_register_test_and_mark_available(vcpu, VCPU_REG_EXIT_INFO_2) && - !WARN_ON_ONCE(is_td_vcpu(vcpu))) - vt->exit_intr_info =3D vmcs_read32(VM_EXIT_INTR_INFO); - - return vt->exit_intr_info; -} - void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu); int allocate_vpid(void); void free_vpid(int vpid); --=20 2.55.0.979.g7e5102b832-goog From nobody Fri Sep 4 05:20:02 2026 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 859D337B40A for ; Fri, 4 Sep 2026 01:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483853; cv=none; b=Sloi/f4gpCHWvFXSoUb4Itc1GeICPqOxLP742+QFMeyjn7nONGrdBmKWAVRk/TIU59tGxfZDP6jizNp9TXu/x9WV4kE9w7iMBjoaU0EphtBNUSN6zm3vHvAJRyLfthUm2Vuxd3hTS/XytCMCKGMePAox/8UgQwPCAMF6iBOsl3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788483853; c=relaxed/simple; bh=VGPXQlZM3zYiIjJXKmP0J/C4KEUGfs1eAU33XXQJ8go=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=A4O2+fKhGP7EACEABnyXsjWA3+qISmVa8hxGmt/SQHk9gUWMlSzENFNxnVsGxdIMF4kOb1KopDBp62AdYlKa6Q5J/VQJxj7mZuVQ2dK/+nV/Z3zxdmH3JebhToN0YBmFgjcKC8lmVhlLcnw1MHE+RY/cZb8rl9BorD1wpIhBHvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lcc9GkQF; arc=none smtp.client-ip=209.85.167.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lcc9GkQF" Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-4b3962f71e7so551753b6e.3 for ; Thu, 03 Sep 2026 18:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788483845; x=1789088645; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=JtCM8hZGo3q10xA4m4kRoLqc4XCX1WLO1DlU2VIpNIU=; b=lcc9GkQFgHmomyfkwJR5Yx3btNmqtJyryRvSYL6DFbca5FAGiuwgREMggu/qs+Anq9 kjVIp+M0qF2h5bDV/rxRBlw/PAo2p33M0ccLk5qz8H0H7j4A0piOxLWDvTtMvXynJgLi sC1mpc1/n5dUTLLxHkeC2YD8oXd8sRyoAfSrShH2HjEcPS+jVMZaQ4p+Zyvx9qNolWJW DCN2yR/Ckdu3qXa58Darq3u3tH52YWkufJA4NVPV/8yvUrRzYI73z+lfLWAKHytDDhdd h75nGF6ZKJ0SQxZIss/VAbXw9tgXgZYnlCiaLg0LVVh9U5QwAurCLq1XeOCp4anN23yF amBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788483845; x=1789088645; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=JtCM8hZGo3q10xA4m4kRoLqc4XCX1WLO1DlU2VIpNIU=; b=JOzlOiecNRcgEgKjweTsHFp2/eGEZnvhhVcpPoXHRI/gGMIiqxk/8E+KJbyEVgDBih 9Wzuh0NwOUo0zTXlC5kJko0E4JbvCoO3yeg4HEyRJII695Le6J2jzFBMWd17/UXJdxNw mzZI4Nit1Up6CF6gMK3WbnC9uSKpC4gLLIZ8zJFdi1O58aa8PK6gpTaypwqhQaqZOilG NQhgFW8vJOzlAqQmDmL3+2FOygVytwmfSBf7dFovD0O2hFkgn6uZUxPi4b2YyYKQKRka Dp+YyqcN7xXNWrJaZzny0fcvd31pFOtb5Rd1q9SJMY35THLPEL0GeEusc+usS4eI1Jez pt1Q== X-Forwarded-Encrypted: i=1; AKwUvBwP3EtBOW7yGL7hwEIIe3a2Dmck3uzK5iXtGWMm7v58k6aExIyq4t39PCb5uE7/HmP1PFT/Tj3j6wanmvI=@vger.kernel.org X-Gm-Message-State: AFuF++lvqs2Onzht3zflEePPY3EldkhwWtXkwtUr0IzoLRHPN2uP/2fW hXlmxr4gdHdiHhRnBYXhggvj9dDjV8sa2owKg4XrOUjOhSXjEeQrHHCG80cyDd1AImYZ2oJGfWS ej4B+mw== X-Received: from pgdo11-n1.prod.google.com ([2002:a05:6a02:620b:10b0:cc1:5155:bdd1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:1509:b0:4b3:7c33:456 with SMTP id 5614622812f47-4b96153c38bmr2134759b6e.11.1788483844866; Thu, 03 Sep 2026 18:04:04 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 3 Sep 2026 18:03:53 -0700 In-Reply-To: <20260904010353.3175819-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260904010353.3175819-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.979.g7e5102b832-goog Message-ID: <20260904010353.3175819-9-seanjc@google.com> Subject: [PATCH v3 8/8] KVM: VMX: Rename common exit info getters prefixes from "vmx" to "vt" From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Kai Huang , Rick Edgecombe , Binbin Wu , Yan Zhao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename all common prefixes for the APIs that get exit information common to VMX and TDX from "vmx" to "vt" to capture that they are used for both VMX and TDX vCPUs. No functional change intended. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Tested-by: Kai Huang Signed-off-by: Sean Christopherson Reviewed-by: Binbin Wu --- arch/x86/kvm/vmx/common.h | 6 ++-- arch/x86/kvm/vmx/main.c | 10 +++---- arch/x86/kvm/vmx/nested.c | 36 +++++++++++------------ arch/x86/kvm/vmx/tdx.c | 22 +++++++------- arch/x86/kvm/vmx/vmx.c | 60 +++++++++++++++++++-------------------- 5 files changed, 67 insertions(+), 67 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index c9ca0824734a..3e68fa12aca6 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -91,12 +91,12 @@ static __always_inline struct kvm_vcpu *vt_to_vcpu(stru= ct vcpu_vt *vt) return &(container_of(vt, struct vcpu_vmx_tdx, vt)->vcpu); } =20 -static __always_inline union vmx_exit_reason vmx_get_exit_reason(struct kv= m_vcpu *vcpu) +static __always_inline union vmx_exit_reason vt_get_exit_reason(struct kvm= _vcpu *vcpu) { return to_vt(vcpu)->exit_reason; } =20 -static __always_inline unsigned long vmx_get_exit_qual(struct kvm_vcpu *vc= pu) +static __always_inline unsigned long vt_get_exit_qual(struct kvm_vcpu *vcp= u) { struct vcpu_vt *vt =3D to_vt(vcpu); =20 @@ -107,7 +107,7 @@ static __always_inline unsigned long vmx_get_exit_qual(= struct kvm_vcpu *vcpu) return vt->exit_qualification; } =20 -static __always_inline u32 vmx_get_intr_info(struct kvm_vcpu *vcpu) +static __always_inline u32 vt_get_intr_info(struct kvm_vcpu *vcpu) { struct vcpu_vt *vt =3D to_vt(vcpu); =20 diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 0151baa56598..6e0b3959d73a 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -934,12 +934,12 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vc= pu) if (to_vt(vcpu)->emulation_required) return; =20 - switch (vmx_get_exit_reason(vcpu).basic) { + switch (vt_get_exit_reason(vcpu).basic) { case EXIT_REASON_EXTERNAL_INTERRUPT: - handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu)); + handle_external_interrupt_irqoff(vcpu, vt_get_intr_info(vcpu)); break; case EXIT_REASON_EXCEPTION_NMI: - handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu)); + handle_exception_irqoff(vcpu, vt_get_intr_info(vcpu)); break; case EXIT_REASON_MCE_DURING_VMENTRY: kvm_machine_check(); @@ -951,8 +951,8 @@ static void vt_handle_exit_irqoff(struct kvm_vcpu *vcpu) =20 noinstr void vt_handle_nmi(struct kvm_vcpu *vcpu) { - if ((u16)vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_EXCEPTION_NMI || - !is_nmi(vmx_get_intr_info(vcpu))) + if ((u16)vt_get_exit_reason(vcpu).basic !=3D EXIT_REASON_EXCEPTION_NMI || + !is_nmi(vt_get_intr_info(vcpu))) return; =20 kvm_before_interrupt(vcpu, KVM_HANDLING_NMI); diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 151873407abd..47599e7312cf 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -446,7 +446,7 @@ static void nested_ept_inject_page_fault(struct kvm_vcp= u *vcpu, * "NMI unblocking due to IRET", i.e. the bit can be propagated * as-is from the original EXIT_QUALIFICATION. */ - exit_qualification =3D vmx_get_exit_qual(vcpu) & INTR_INFO_UNBLOCK_NMI; + exit_qualification =3D vt_get_exit_qual(vcpu) & INTR_INFO_UNBLOCK_NMI; } else { if (fault->error_code & PFERR_RSVD_MASK) { vm_exit_reason =3D EXIT_REASON_EPT_MISCONFIG; @@ -472,7 +472,7 @@ static void nested_ept_inject_page_fault(struct kvm_vcp= u *vcpu, * and walks the faulting GPA. */ if (from_hardware) - exit_qualification |=3D vmx_get_exit_qual(vcpu) & mask; + exit_qualification |=3D vt_get_exit_qual(vcpu) & mask; else exit_qualification |=3D fault->exit_qualification & mask; =20 @@ -4747,7 +4747,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, str= uct vmcs12 *vmcs12, { /* update exit information fields: */ vmcs12->vm_exit_reason =3D vm_exit_reason; - if (vmx_get_exit_reason(vcpu).enclave_mode) + if (vt_get_exit_reason(vcpu).enclave_mode) vmcs12->vm_exit_reason |=3D VMX_EXIT_REASONS_SGX_ENCLAVE_MODE; vmcs12->exit_qualification =3D exit_qualification; =20 @@ -5373,7 +5373,7 @@ static int nested_vmx_get_vmptr(struct kvm_vcpu *vcpu= , gpa_t *vmpointer, struct x86_exception e; int r; =20 - if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu), + if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu), vmcs_read32(VMX_INSTRUCTION_INFO), false, sizeof(*vmpointer), &gva)) { *ret =3D 1; @@ -5665,7 +5665,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu) { struct vmcs12 *vmcs12 =3D is_guest_mode(vcpu) ? get_shadow_vmcs12(vcpu) : get_vmcs12(vcpu); - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); u32 instr_info =3D vmcs_read32(VMX_INSTRUCTION_INFO); struct vcpu_vmx *vmx =3D to_vmx(vcpu); struct x86_exception e; @@ -5771,7 +5771,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu) { struct vmcs12 *vmcs12 =3D is_guest_mode(vcpu) ? get_shadow_vmcs12(vcpu) : get_vmcs12(vcpu); - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); u32 instr_info =3D vmcs_read32(VMX_INSTRUCTION_INFO); struct vcpu_vmx *vmx =3D to_vmx(vcpu); struct x86_exception e; @@ -5960,7 +5960,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) /* Emulate the VMPTRST instruction */ static int handle_vmptrst(struct kvm_vcpu *vcpu) { - unsigned long exit_qual =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qual =3D vt_get_exit_qual(vcpu); u32 instr_info =3D vmcs_read32(VMX_INSTRUCTION_INFO); gpa_t current_vmptr =3D to_vmx(vcpu)->nested.current_vmptr; struct x86_exception e; @@ -6021,7 +6021,7 @@ static int handle_invept(struct kvm_vcpu *vcpu) /* According to the Intel VMX instruction reference, the memory * operand is read even if it isn't needed (e.g., for type=3D=3Dglobal) */ - if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu), + if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu), vmx_instruction_info, false, sizeof(operand), &gva)) return 1; r =3D kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e); @@ -6104,7 +6104,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) /* according to the intel vmx instruction reference, the memory * operand is read even if it isn't needed (e.g., for type=3D=3Dglobal) */ - if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu), + if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu), vmx_instruction_info, false, sizeof(operand), &gva)) return 1; r =3D kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e); @@ -6236,8 +6236,8 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu) * EXIT_REASON_VMFUNC as the exit reason. */ nested_vmx_vmexit(vcpu, vmx->vt.exit_reason.full, - vmx_get_intr_info(vcpu), - vmx_get_exit_qual(vcpu)); + vt_get_intr_info(vcpu), + vt_get_exit_qual(vcpu)); return 1; } =20 @@ -6288,7 +6288,7 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcp= u *vcpu, if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS)) return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING); =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); =20 port =3D exit_qualification >> 16; size =3D (exit_qualification & 7) + 1; @@ -6314,7 +6314,7 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vc= pu *vcpu, =20 if (exit_reason.basic =3D=3D EXIT_REASON_MSR_READ_IMM || exit_reason.basic =3D=3D EXIT_REASON_MSR_WRITE_IMM) - msr_index =3D vmx_get_exit_qual(vcpu); + msr_index =3D vt_get_exit_qual(vcpu); else msr_index =3D kvm_ecx_read(vcpu); =20 @@ -6350,7 +6350,7 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vc= pu *vcpu, static bool nested_vmx_exit_handled_cr(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); int cr =3D exit_qualification & 15; int reg; unsigned long val; @@ -6484,7 +6484,7 @@ static bool nested_vmx_l0_wants_exit(struct kvm_vcpu = *vcpu, =20 switch ((u16)exit_reason.basic) { case EXIT_REASON_EXCEPTION_NMI: - intr_info =3D vmx_get_intr_info(vcpu); + intr_info =3D vt_get_intr_info(vcpu); if (is_nmi(intr_info)) return true; else if (is_page_fault(intr_info)) @@ -6567,7 +6567,7 @@ static bool nested_vmx_l1_wants_exit(struct kvm_vcpu = *vcpu, =20 switch ((u16)exit_reason.basic) { case EXIT_REASON_EXCEPTION_NMI: - intr_info =3D vmx_get_intr_info(vcpu); + intr_info =3D vt_get_intr_info(vcpu); if (is_nmi(intr_info)) return true; else if (is_page_fault(intr_info)) @@ -6737,14 +6737,14 @@ bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcp= u) * need to be synthesized by querying the in-kernel LAPIC, but external * interrupts are never reflected to L1 so it's a non-issue. */ - exit_intr_info =3D vmx_get_intr_info(vcpu); + exit_intr_info =3D vt_get_intr_info(vcpu); if (is_exception_with_error_code(exit_intr_info)) { struct vmcs12 *vmcs12 =3D get_vmcs12(vcpu); =20 vmcs12->vm_exit_intr_error_code =3D vmcs_read32(VM_EXIT_INTR_ERROR_CODE); } - exit_qual =3D vmx_get_exit_qual(vcpu); + exit_qual =3D vt_get_exit_qual(vcpu); =20 reflect_vmexit: nested_vmx_vmexit(vcpu, exit_reason.full, exit_intr_info, exit_qual); diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index a3d6f0fb5951..efbb1ac6f51e 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -741,7 +741,7 @@ bool tdx_interrupt_allowed(struct kvm_vcpu *vcpu) * interrupt is always allowed unless TDX guest calls TDVMCALL with HLT, * which passes the interrupt blocked flag. */ - return vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_HLT || + return vt_get_exit_reason(vcpu).basic !=3D EXIT_REASON_HLT || !to_tdx(vcpu)->vp_enter_args.r12; } =20 @@ -759,7 +759,7 @@ static bool tdx_protected_apic_has_interrupt(struct kvm= _vcpu *vcpu) * otherwise the interrupt would have been serviced at the instruction * boundary. */ - if (vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_HLT || + if (vt_get_exit_reason(vcpu).basic !=3D EXIT_REASON_HLT || to_tdx(vcpu)->vp_enter_args.r12) return false; =20 @@ -981,8 +981,8 @@ static noinstr void tdx_vcpu_enter_exit(struct kvm_vcpu= *vcpu) =20 static bool tdx_failed_vmentry(struct kvm_vcpu *vcpu) { - return vmx_get_exit_reason(vcpu).failed_vmentry && - vmx_get_exit_reason(vcpu).full !=3D -1u; + return vt_get_exit_reason(vcpu).failed_vmentry && + vt_get_exit_reason(vcpu).full !=3D -1u; } =20 static fastpath_t tdx_exit_handlers_fastpath(struct kvm_vcpu *vcpu) @@ -1131,7 +1131,7 @@ void tdx_inject_nmi(struct kvm_vcpu *vcpu) =20 static int tdx_handle_exception_nmi(struct kvm_vcpu *vcpu) { - u32 intr_info =3D vmx_get_intr_info(vcpu); + u32 intr_info =3D vt_get_intr_info(vcpu); =20 /* * Machine checks are handled by handle_exception_irqoff(), or by @@ -1903,7 +1903,7 @@ void tdx_deliver_interrupt(struct kvm_lapic *apic, in= t delivery_mode, static inline bool tdx_is_sept_violation_unexpected_pending(struct kvm_vcp= u *vcpu) { u64 eeq_type =3D to_tdx(vcpu)->ext_exit_qualification & TDX_EXT_EXIT_QUAL= _TYPE_MASK; - u64 eq =3D vmx_get_exit_qual(vcpu); + u64 eq =3D vt_get_exit_qual(vcpu); =20 if (eeq_type !=3D TDX_EXT_EXIT_QUAL_TYPE_PENDING_EPT_VIOLATION) return false; @@ -1939,7 +1939,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *= vcpu) /* Only private GPA triggers zero-step mitigation */ local_retry =3D true; } else { - exit_qual =3D vmx_get_exit_qual(vcpu); + exit_qual =3D vt_get_exit_qual(vcpu); /* * EPT violation due to instruction fetch should never be * triggered from shared memory in TDX guest. If such EPT @@ -2021,7 +2021,7 @@ int tdx_complete_emulated_msr(struct kvm_vcpu *vcpu, = int err) return 1; } =20 - if (vmx_get_exit_reason(vcpu).basic =3D=3D EXIT_REASON_MSR_READ) + if (vt_get_exit_reason(vcpu).basic =3D=3D EXIT_REASON_MSR_READ) tdvmcall_set_return_val(vcpu, kvm_read_edx_eax(vcpu)); =20 return 1; @@ -2032,7 +2032,7 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t= fastpath) { struct vcpu_tdx *tdx =3D to_tdx(vcpu); u64 vp_enter_ret =3D tdx->vp_enter_ret; - union vmx_exit_reason exit_reason =3D vmx_get_exit_reason(vcpu); + union vmx_exit_reason exit_reason =3D vt_get_exit_reason(vcpu); =20 if (fastpath !=3D EXIT_FASTPATH_NONE) return 1; @@ -2142,9 +2142,9 @@ void tdx_get_exit_info(struct kvm_vcpu *vcpu, u32 *re= ason, =20 *reason =3D tdx->vt.exit_reason.full; if (*reason !=3D -1u) { - *info1 =3D vmx_get_exit_qual(vcpu); + *info1 =3D vt_get_exit_qual(vcpu); *info2 =3D tdx->ext_exit_qualification; - *intr_info =3D vmx_get_intr_info(vcpu); + *intr_info =3D vt_get_intr_info(vcpu); } else { *info1 =3D 0; *info2 =3D 0; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 2532a9b8e92e..7e35c2d03c69 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1791,7 +1791,7 @@ int vmx_check_emulate_instruction(struct kvm_vcpu *vc= pu, int emul_type, * so that guest userspace can't DoS the guest simply by triggering * emulation (enclaves are CPL3 only). */ - if (vmx_get_exit_reason(vcpu).enclave_mode) { + if (vt_get_exit_reason(vcpu).enclave_mode) { kvm_queue_exception(vcpu, UD_VECTOR); return X86EMUL_PROPAGATE_FAULT; } @@ -1806,7 +1806,7 @@ int vmx_check_emulate_instruction(struct kvm_vcpu *vc= pu, int emul_type, =20 static int skip_emulated_instruction(struct kvm_vcpu *vcpu) { - union vmx_exit_reason exit_reason =3D vmx_get_exit_reason(vcpu); + union vmx_exit_reason exit_reason =3D vt_get_exit_reason(vcpu); unsigned long rip, orig_rip; u32 instr_len; =20 @@ -5381,7 +5381,7 @@ bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu) =20 static int vmx_handle_page_fault(struct kvm_vcpu *vcpu, u32 error_code) { - unsigned long cr2 =3D vmx_get_exit_qual(vcpu); + unsigned long cr2 =3D vt_get_exit_qual(vcpu); =20 if (vcpu->arch.apf.host_apf_flags) goto handle_pf; @@ -5429,7 +5429,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) u32 vect_info; =20 vect_info =3D vmx->idt_vectoring_info; - intr_info =3D vmx_get_intr_info(vcpu); + intr_info =3D vt_get_intr_info(vcpu); =20 /* * Machine checks are handled by handle_exception_irqoff(), or by @@ -5510,7 +5510,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu) =20 switch (ex_no) { case DB_VECTOR: - dr6 =3D vmx_get_exit_qual(vcpu); + dr6 =3D vt_get_exit_qual(vcpu); if (!(vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) { /* @@ -5586,7 +5586,7 @@ static int handle_io(struct kvm_vcpu *vcpu) int size, in, string; unsigned port; =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); string =3D (exit_qualification & 16) !=3D 0; =20 ++vcpu->stat.io_exits; @@ -5675,7 +5675,7 @@ static int handle_cr(struct kvm_vcpu *vcpu) int err; int ret; =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); cr =3D exit_qualification & 15; reg =3D (exit_qualification >> 8) & 15; switch ((exit_qualification >> 4) & 3) { @@ -5753,7 +5753,7 @@ static int handle_dr(struct kvm_vcpu *vcpu) int dr, dr7, reg; int err =3D 1; =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); dr =3D exit_qualification & DEBUG_REG_ACCESS_NUM; =20 /* First, if DR does not exist, trigger UD */ @@ -5849,7 +5849,7 @@ static int handle_interrupt_window(struct kvm_vcpu *v= cpu) =20 static int handle_invlpg(struct kvm_vcpu *vcpu) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); =20 kvm_mmu_invlpg(vcpu, exit_qualification); return kvm_skip_emulated_instruction(vcpu); @@ -5858,7 +5858,7 @@ static int handle_invlpg(struct kvm_vcpu *vcpu) static int handle_apic_access(struct kvm_vcpu *vcpu) { if (likely(fasteoi)) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); int access_type, offset; =20 access_type =3D exit_qualification & APIC_ACCESS_TYPE; @@ -5879,7 +5879,7 @@ static int handle_apic_access(struct kvm_vcpu *vcpu) =20 static int handle_apic_eoi_induced(struct kvm_vcpu *vcpu) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); int vector =3D exit_qualification & 0xff; =20 /* EOI-induced VM exit is trap-like and thus no need to adjust IP */ @@ -5889,7 +5889,7 @@ static int handle_apic_eoi_induced(struct kvm_vcpu *v= cpu) =20 static int handle_apic_write(struct kvm_vcpu *vcpu) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); =20 /* * APIC-write VM-Exit is trap-like, KVM doesn't need to advance RIP and @@ -5917,7 +5917,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) idt_index =3D (vmx->idt_vectoring_info & VECTORING_INFO_VECTOR_MASK); type =3D (vmx->idt_vectoring_info & VECTORING_INFO_TYPE_MASK); =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); =20 reason =3D (u32)exit_qualification >> 30; if (reason =3D=3D TASK_SWITCH_GATE && idt_v) { @@ -5963,7 +5963,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) =20 static int handle_ept_violation(struct kvm_vcpu *vcpu) { - unsigned long exit_qualification =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qualification =3D vt_get_exit_qual(vcpu); gpa_t gpa; =20 /* @@ -6154,7 +6154,7 @@ static int handle_invpcid(struct kvm_vcpu *vcpu) /* According to the Intel instruction reference, the memory operand * is read even if it isn't needed (e.g., for type=3D=3Dall) */ - if (get_vmx_mem_address(vcpu, vmx_get_exit_qual(vcpu), + if (get_vmx_mem_address(vcpu, vt_get_exit_qual(vcpu), vmx_instruction_info, false, sizeof(operand), &gva)) return 1; @@ -6168,7 +6168,7 @@ static int handle_pml_full(struct kvm_vcpu *vcpu) =20 trace_kvm_pml_full(vcpu->vcpu_id); =20 - exit_qualification =3D vmx_get_exit_qual(vcpu); + exit_qualification =3D vt_get_exit_qual(vcpu); =20 /* * PML buffer FULL happened while executing iret from NMI, @@ -6272,7 +6272,7 @@ static int handle_bus_lock_vmexit(struct kvm_vcpu *vc= pu) =20 static int handle_notify(struct kvm_vcpu *vcpu) { - unsigned long exit_qual =3D vmx_get_exit_qual(vcpu); + unsigned long exit_qual =3D vt_get_exit_qual(vcpu); bool context_invalid =3D exit_qual & NOTIFY_VM_CONTEXT_INVALID; =20 ++vcpu->stat.notify_window_exits; @@ -6303,13 +6303,13 @@ static int vmx_get_msr_imm_reg(struct kvm_vcpu *vcp= u) =20 static int handle_rdmsr_imm(struct kvm_vcpu *vcpu) { - return kvm_emulate_rdmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + return kvm_emulate_rdmsr_imm(vcpu, vt_get_exit_qual(vcpu), vmx_get_msr_imm_reg(vcpu)); } =20 static int handle_wrmsr_imm(struct kvm_vcpu *vcpu) { - return kvm_emulate_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + return kvm_emulate_wrmsr_imm(vcpu, vt_get_exit_qual(vcpu), vmx_get_msr_imm_reg(vcpu)); } =20 @@ -6386,10 +6386,10 @@ void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *= reason, struct vcpu_vmx *vmx =3D to_vmx(vcpu); =20 *reason =3D vmx->vt.exit_reason.full; - *info1 =3D vmx_get_exit_qual(vcpu); + *info1 =3D vt_get_exit_qual(vcpu); if (!(vmx->vt.exit_reason.failed_vmentry)) { *info2 =3D vmx->idt_vectoring_info; - *intr_info =3D vmx_get_intr_info(vcpu); + *intr_info =3D vt_get_intr_info(vcpu); if (is_exception_with_error_code(*intr_info)) *error_code =3D vmcs_read32(VM_EXIT_INTR_ERROR_CODE); else @@ -6700,7 +6700,7 @@ void dump_vmcs(struct kvm_vcpu *vcpu) static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpa= th) { struct vcpu_vmx *vmx =3D to_vmx(vcpu); - union vmx_exit_reason exit_reason =3D vmx_get_exit_reason(vcpu); + union vmx_exit_reason exit_reason =3D vt_get_exit_reason(vcpu); u32 vectoring_info =3D vmx->idt_vectoring_info; u16 exit_handler_index; =20 @@ -6864,7 +6864,7 @@ int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t= exit_fastpath) * Exit to user space when bus lock detected to inform that there is * a bus lock in guest. */ - if (vmx_get_exit_reason(vcpu).bus_lock_detected) { + if (vt_get_exit_reason(vcpu).bus_lock_detected) { if (ret > 0) vcpu->run->exit_reason =3D KVM_EXIT_X86_BUS_LOCK; =20 @@ -7176,7 +7176,7 @@ static void vmx_recover_nmi_blocking(struct vcpu_vmx = *vmx) if (vmx->loaded_vmcs->nmi_known_unmasked) return; =20 - exit_intr_info =3D vmx_get_intr_info(&vmx->vcpu); + exit_intr_info =3D vt_get_intr_info(&vmx->vcpu); unblock_nmi =3D (exit_intr_info & INTR_INFO_UNBLOCK_NMI) !=3D 0; vector =3D exit_intr_info & INTR_INFO_VECTOR_MASK; /* @@ -7343,14 +7343,14 @@ static fastpath_t vmx_exit_handlers_fastpath(struct= kvm_vcpu *vcpu, * the fastpath even, all other exits must use the slow path. */ if (is_guest_mode(vcpu) && - vmx_get_exit_reason(vcpu).basic !=3D EXIT_REASON_PREEMPTION_TIMER) + vt_get_exit_reason(vcpu).basic !=3D EXIT_REASON_PREEMPTION_TIMER) return EXIT_FASTPATH_NONE; =20 - switch (vmx_get_exit_reason(vcpu).basic) { + switch (vt_get_exit_reason(vcpu).basic) { case EXIT_REASON_MSR_WRITE: return handle_fastpath_wrmsr(vcpu); case EXIT_REASON_MSR_WRITE_IMM: - return handle_fastpath_wrmsr_imm(vcpu, vmx_get_exit_qual(vcpu), + return handle_fastpath_wrmsr_imm(vcpu, vt_get_exit_qual(vcpu), vmx_get_msr_imm_reg(vcpu)); case EXIT_REASON_PREEMPTION_TIMER: return handle_fastpath_preemption_timer(vcpu, force_immediate_exit); @@ -7392,7 +7392,7 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vc= pu *vcpu, } =20 vmx->vt.exit_reason.full =3D vmcs_read32(VM_EXIT_REASON); - if (likely(!vmx_get_exit_reason(vcpu).failed_vmentry)) + if (likely(!vt_get_exit_reason(vcpu).failed_vmentry)) vmx->idt_vectoring_info =3D vmcs_read32(IDT_VECTORING_INFO_FIELD); =20 vt_handle_nmi(vcpu); @@ -7532,7 +7532,7 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 ru= n_flags) * checking. */ if (vcpu->arch.nested_run_pending && - !vmx_get_exit_reason(vcpu).failed_vmentry) + !vt_get_exit_reason(vcpu).failed_vmentry) ++vcpu->stat.nested_run; =20 vcpu->arch.nested_run_pending =3D 0; @@ -7543,7 +7543,7 @@ fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu, u64 ru= n_flags) =20 trace_kvm_exit(vcpu, KVM_ISA_VMX); =20 - if (unlikely(vmx_get_exit_reason(vcpu).failed_vmentry)) + if (unlikely(vt_get_exit_reason(vcpu).failed_vmentry)) return EXIT_FASTPATH_NONE; =20 vmx->loaded_vmcs->launched =3D 1; --=20 2.55.0.979.g7e5102b832-goog