From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.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 CF25A36492D for ; Wed, 26 Aug 2026 17:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764379; cv=none; b=XtzP2Hmvd+G0f/G2KeCMvY+7bPca9gNJ4UnF0mtV4yclpBta7uYRyFgohsgPw8jgGpqgNBxkzuefXNJLf6MXRbwPSwNbog30NvCvydr8EcZJGgrNwbClMYnmiMSg9GPjF0As59Nk9TxXHcoolkJXmuiUCGhFNBm/qnvOqLVcD+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764379; c=relaxed/simple; bh=+uDr5cwVaTDiUyoRvqw+6+bOi/G/sFwFQqXd7puX1sw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lklGqz/TeFfDBgVKHtxtsBarJiciLrluLfsdgy0r6ybUZQ1HOjOA4tipHEJHcDcWTrGhF+7zy4ca3h6+smJUrDS1cR7fn5Bqjk0cgLEmpxgLavif7D9uuuGeskYTg4RQPIiYjkc1KXWKCFQZiIjnVujeZ3j0Gmxq/CM18uru23Q= 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=tcdvAP88; arc=none smtp.client-ip=209.85.214.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="tcdvAP88" Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ce7dff6253so909785ad.1 for ; Wed, 26 Aug 2026 10:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764370; x=1788369170; 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=L6siIiM1cF+ZrS/MrgVIwhxh+wLPXtr92wLuqHkS8k0=; b=tcdvAP88URuxrOV9h1bEC5nXW5zuLrceEpTlzUbIYs4XMUE/u4I/6URhyzboZs+FqH IYvTUzyg+uJo5OZKKdgeUN1MG7/9aFUnj/r6z4xBbL6x+LAz16IfPXNu83GlhzTBkins 4calXw6ycRI18+EwnXvgvrhDQDwFnWyKCz5qYKL1ByCA54FmdDq/GRKERT7/3AUIEgkt FfdXNkt5Je2mi8CsUIpJLWKxdFyKOoxhTG+RwvA/3x3ZhBvvZoPg+7ytIaj9z4TTnTzd u0TX2oKsUnLMIyDjhpXmzkD6VjWMbgFE9tfPJt4sqoV1mnwSqDFZ8f92btILEBq48RSE fX+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764370; x=1788369170; 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=L6siIiM1cF+ZrS/MrgVIwhxh+wLPXtr92wLuqHkS8k0=; b=KjSQpoNW2I25zEonZCdH08gS49ElyMbV1NVLuzLz957nyfgpJCjQ3c2yZPsyv7WJME t0gJ3TTJIdepOZZFoiORTZkDN0Iu2kZoF14zE3JkMv3RHbuXjBBu/Stz/Gb2eV1V71xZ YoXH/n98xNKTxZ0QVsTBNLxgEFfbcMkCvG2PtebScGoE/7++3wvdJ1kyhKEv8Iqgr4HH frtPihzfc+McaN7ZfjrG4RluQdAoZu63A/YoqNPpZlbbFoUlZDVEOHb8nw9roY9AGYG9 ZBFIf2Ub5Bo7tx03ldJePT6OiGIX16FNLyZaZN8kNpLGn4WAIvqG+yhYiA7Ysj4FxUpT 3XiQ== X-Forwarded-Encrypted: i=1; AHgh+RqtIyVTAmcvKmlRW4ue3DKYiNPvyGyWs5Xfjp7geqj3kfilkvrvkoUwume5ifGM/EZ/pVdiA3xdLIZXGsY=@vger.kernel.org X-Gm-Message-State: AFuF++kVY8Ea6GWhjfCVseWryNdWMDofWGF9lsfzefGc14ZGKoz1vyWI sjFpFnsEvLMwfzzHOkP9vmMs99u68+DpQoBpfVYQpI5yiVgvH1GXbMUXXAZDRd13IJ17p5X3E0y c64cG5A== X-Received: from plbke13.prod.google.com ([2002:a17:903:340d:b0:2cc:c59c:76ac]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d491:b0:2cf:b9f9:18bb with SMTP id d9443c01a7336-2d726114a0bmr5694605ad.4.1787764369805; Wed, 26 Aug 2026 10:12:49 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:39 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-2-seanjc@google.com> Subject: [PATCH v2 1/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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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 Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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 4c52ab8d0786..274200b0a307 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" @@ -876,6 +877,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) | \ @@ -1000,7 +1069,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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (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 5D0A937EFF3 for ; Wed, 26 Aug 2026 17:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764393; cv=none; b=tftJaOdmo02DnuDRVdcMGzMZQAy//G5FhAJIP7KA2O+Rd5iPeU0pgObl0djrTivAPUfJ6JDJfBd8z49sehE4HNMRllW8yYrHSFTfMPO7dq4rLxLxTuIwm5N41C6h4mKAuUUH3Pf/yyGx90b1mbk/cLpnZxMys7nt86EGAGWnfUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764393; c=relaxed/simple; bh=Xy9bUPMo10wPx+hGK64PejVqPjCe+tnmlzShZBrttKE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oHoeZEUwnJB76EQspI0wqOvyk66rkhNPNtPPRxfXkY/2Qfnk3bUz2f4DzCCDzr5UWvwsuzGPQDDxkG9l2ofg5VVj3uxZAsHXnERRml09YIQOLL1lFeq4xF6xt75gr7033fX/7QoIv+zypA3RSUnisZ5nZQIjlLw3pLB6olaVT5k= 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=EVOa9PuD; arc=none smtp.client-ip=209.85.215.200 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="EVOa9PuD" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cb11535e6a1so1552141a12.0 for ; Wed, 26 Aug 2026 10:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764371; x=1788369171; 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=Df0A62BBX5SuQrh9wZqWxjT6F0PSRl8xPi6joM+3RXg=; b=EVOa9PuDXIcKd8pWFzPPRfhwscpTp5J5uV0C9i6uDlTIsNNgp9mkp86qgsSHpnP7bn sQV5+/L2nu5sk3r0Q+NIVXDsvnwtB3htXkfdEKvIDX59bq9nEvASBhFFPNsq8vLVimBL uELfI3JKLHeMkaoiWEzZxf0aE8t9HwUcwHP3Ywfx4v1vKEXBoem/OdS3BACsiUtJMvzK s4tIKYplTOGhgOX1sT/FVrnQcYm7J9U7A4Yc2UJRysqu+tIgUpVueX0VW1KH3diiXLEj Dsi9Mxn/tHLxrgBwdsX83PfdRxCgtpnhuV0y0yp12z/eRdvNUS/oOYC9/+0lxHDV7SOg wQkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764371; x=1788369171; 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=Df0A62BBX5SuQrh9wZqWxjT6F0PSRl8xPi6joM+3RXg=; b=jHUfhyRbZh2uqdOv05SUXIHW95uN+woJmjgsjf5XfXvkHnWZVNwDUnT6ZoXLH6Ywb+ Z0XnCGcDzy/rH6Ne3QsgFdW+91nC4SB95j8tdfD7Rd4z7vRHs9n5NLgBtINj8vTMWpGl DHjrBvoKVnDVab08yHM/qybPXZD/EHtPXqcM06J0f0iv+7Ndp80t2n4Ybsu1Htt4ljvq S7ahjZww/C1WFE8jCkRqo41y8KO2uNI6h7Q85ipgcp9RHcqjRLM62nj+5aiSLXiMsCfn mQ/niQ3UMLGwvbhur7c2j5+chs42y1Ge0O5FMVcmluUQdfz1AvtNIbX4X0s+cA56BoS4 7C6w== X-Forwarded-Encrypted: i=1; AHgh+RrZvlyrdTt96YyxjUlkNpeXA9u9johhPV+qRAqyIvqHtT0cSfzm7gKcR1kOVlriPtPmzYaznnDwB3+giek=@vger.kernel.org X-Gm-Message-State: AFuF++kH/+HkaklgYPwuRuNpblw8b5qCAMMoez72X97yM6w9h4n4WRpP 9LRqNy2FnpZZdr0cH3oWXmAlPTa7OfMLepoqTSckkZm+jsAzyuXOakDVYRdgEP3hRGmQTofCE+F ltqqzWw== X-Received: from pgby7-n2.prod.google.com ([2002:a05:6a02:6507:20b0:cbe:948f:d640]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3926:b0:848:46a0:3d74 with SMTP id d2e1a72fcca58-8537499bb90mr14451563b3a.9.1787764370966; Wed, 26 Aug 2026 10:12:50 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:40 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-3-seanjc@google.com> Subject: [PATCH v2 2/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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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 274200b0a307..684b87692864 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -945,6 +945,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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.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 47E1E44CF37 for ; Wed, 26 Aug 2026 17:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764386; cv=none; b=uYFplTfUkPzWZm0MWeTcI2LISwFcDNRUVb5fuuFovo7SapKWgkBDNq+QsykO/IfNcuJskmgWeMkGtLt+4YfXHNRrxn+BWBtOEtC2tdByCK4jHzsqmifrAiOB927rEoJ+0eKpzbQz3we9+FhdTZvfB2s6R9T7kVCwVTJeROwL4ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764386; c=relaxed/simple; bh=cKAhG59+Iq84FY0AbDSTajeiuMFZn2chwTWn175Vj/I=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=slsmkabM7wYrrEYHcSjkzFV+LR6jmiofVJxIkJbPToD+ufiy1TC9gPkeIhe6Qw7BEOzDf6jH8pTCST1M9jqbxfXaJO07++AG2ubkKGK0gwzUmIyg8kRNHYyLam+4Q8+M26s3iX6oECu9OVix15F+3bEOBv9ArQa+GzrG+JAT3O4= 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=PiAX40uW; arc=none smtp.client-ip=209.85.215.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="PiAX40uW" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cb6cf425e86so1513106a12.1 for ; Wed, 26 Aug 2026 10:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764373; x=1788369173; 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=dhx91tSB6ociAKcQKQZdcjUCezd51Vy1x/2McQZk6Qc=; b=PiAX40uW4NQBCMnGivNybQdTm5BvwREYNPVXbIRgoGitLTQbeMBAFqcxVDkes5Y0nA bXSLU8hrIGWvdxIH4YMNkz/sBFoHsL0FehbjSJsUamAZGfwBN8QI8n2UuJOaYZijFODi DNt6GQeNYWyRemjZKG/EP3D9aCuyvZOPQmw/qQc0ppL1cDOw7nhP/d+U9bP8acnPC4n+ kDy+Q0VeFY3VJZ2vJIP8HFLBkWMklATjA60QDzJiAEnCPkW03RtfRjxeSgY8STTEG2Lo 6e+aruHxACNBkMm1wlTR7/nUZZ8q/Tpux27tsZpXH+tnWRvWaDkPNpD9ucZrE9qLeO5c 2hAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764373; x=1788369173; 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=dhx91tSB6ociAKcQKQZdcjUCezd51Vy1x/2McQZk6Qc=; b=GdOq1pU1COGwNcznRba+Qa+WTqa6UXBKMB9j6J74l0XhCRgjCqfBxmCuJE2/r5uDnM jZ5XE8loBG+yiUo1WN2B47OkFUewhVlpiEvUdp8lC3BO6OwqHuF1S+F+aAQ6sUo/4Hv4 yu5BMDLTMepseCo4ogqgUV5QsQQfpfpNwIzJ9u1OXKvF5S3IM5pE3tsOq4MqUnhFxGTX aJqVH0mcry5KCesBKiWS6HTFiG5wZNB4pbyslLao+DIcYpoH5Yw5I4sUtWUoCzBGEBQr BxgGS6TyrAb1GpAVMg9nxhWyM3967ipyfWG9EbGjttZmxlPt1x3Qp5Orl+buPuE2/59y EA/A== X-Forwarded-Encrypted: i=1; AHgh+Ro0/pBfW4C5pE6w6ujU62267v24FZrNtPzzx5qRNKty4MS1YtUibc2r977Dg4dzHYbyJhCNdH6fN1Xf0cA=@vger.kernel.org X-Gm-Message-State: AFuF++mXOD/C9LI4N+RE/JZ1dcReQhbKQ2hv4nBj9ZO5uHT+oFPBA9K6 k/8HhPOWsbus4GPx6syJZ14FnHKooJaqgbgJgAHmpIGK75rmjEjEW4RH6wC4F9MxUfbyJmDZobd OWkvamA== X-Received: from pfaz6.prod.google.com ([2002:aa7:91c6:0:b0:852:3a88:2817]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:4289:b0:83e:b443:965e with SMTP id d2e1a72fcca58-85371ba8271mr16961098b3a.3.1787764372164; Wed, 26 Aug 2026 10:12:52 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:41 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-4-seanjc@google.com> Subject: [PATCH v2 3/8] KVM: VMX: Disallowing 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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(). Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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 684b87692864..b1069a8e30a7 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -11,6 +11,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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.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 2936D3A875B for ; Wed, 26 Aug 2026 17:13:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764392; cv=none; b=Caaam8ljfaPkCs6ajpbgzdCe5HwvVT/WRYwXCiILI+qVjvvAVuiRMTudbV36iBPDaz5IdUPd9qzm9XNw9eZXPL09P4RcEZxCW46gc2V2ZPtLq/EANkVpn3PF+3Y4WWPKxeZq4LcxXrFyr+ZNmOb9ish8LWm/6wSxbgOumlrVuNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764392; c=relaxed/simple; bh=OnWNgS5GkQLgB67W1dU5Fp3RGNOLcQQhdr3j6o1TAdA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fnyNHMxmUXNlwx+e3ywAg4o0A10xpaLqvp876ZqwwH6wPu1NJ1qlp+wFxp7rZzJUEkY7lv3BwBml0ZDcPcyzO811uzgq2RziyP9Vv6tZ9BYD22d+mLskvNFJEOQX1zFalkgCb5PuIeHQfaFlQidZ/TYCAARe8B3cDz6mJ44+wEk= 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=Sb1cbiz8; arc=none smtp.client-ip=209.85.215.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="Sb1cbiz8" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cb6cf425e86so1513329a12.1 for ; Wed, 26 Aug 2026 10:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764381; x=1788369181; 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=fWg/bgPEAtiQApk4BQrFPqwBWOStWg6MEXtjNvUfbyI=; b=Sb1cbiz80RnlbqEAXgiDazLN2iomEeiJI5ydfjklLHVma8h0/Ss2XPBXP2PgW1JDxQ JMGVNueif1HjqF5rTxeKhfx2NS8dMJa5VusRsKoqAT0h2FBe01KxeRGVlH55xEis0ahY bgbOWYrC3Iw8t8JW1ILW+6D8Z8SP8PnhxTeEuYiqfpYyN5CWN0gOhqLdeOIj2zX+9EeP xOEaGajaaXHvRPwssaSKKmjAMYlCGHl2/aiyhzrQRqMSSEl7p8bAUdHsiPVudmA/O3GT SMzrku3txUzG39KtzdMqMKmfzEvWa9DDYmI+ed5PYqhtTDotL8UUtqXTOcu9aIaQUB2B cAdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764381; x=1788369181; 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=fWg/bgPEAtiQApk4BQrFPqwBWOStWg6MEXtjNvUfbyI=; b=VvrBBUzQ0Bm6bf5ZcmsLueyqv6+n2rbLDkrRNWrFedFsF4y7pbWIbH5P+tFthgYZPk wQezdJZhrZ9AIn2vcHkuD8EBA6njts7DlOZH9F6CizgBNsbTjysZfHBGVMJJlfORfgwu R2Mq3LAE4QXnZmAvW9LAe8/SL8xqSSWROG6D0p7vfBjeKULFPHv5+h1sQiEsXnYy3ttO XnfG0EJX0EGDJ53I9EkqvX91xVAiyUzHl4YLkhloMa8Yh6b67XZSyhceN/ZtUU3TafPE YA2EEwpSENVT731uKtASUitwim69cF8uwSCK5bReU5E+4Cq1ngUvirAzSboZn6vX31Az GpNw== X-Forwarded-Encrypted: i=1; AHgh+RpkOFJtwiI2KH99O/scMizUi8KIGa/DDRSgdtgptwCNG52xFmQi7mn+ia0Q7T/y4Ej9kiMunhg5kWJK2Gw=@vger.kernel.org X-Gm-Message-State: AFuF++m5AQ2+k7zMWfr7kMLtVR1HOYQc9xgV8hDmGr7SK7oyDH6Rb/5S 2qbp/k1mIYKafWurXBPD8bO2jKG+TfJg5JXs0KyUUKjHdGAY+TbyQ4cKjUdRw9hZO8EmKIphmoK RZ/KKrQ== X-Received: from pgbaz9.prod.google.com ([2002:a05:6a02:49:b0:cbe:95c8:8245]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:2013:b0:3d1:3c2:85b6 with SMTP id adf61e73a8af0-3d103c28dfdmr523373637.5.1787764374218; Wed, 26 Aug 2026 10:12:54 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:42 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-5-seanjc@google.com> Subject: [PATCH v2 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- arch/x86/kvm/vmx/common.h | 4 ++-- arch/x86/kvm/vmx/main.c | 4 ++-- arch/x86/kvm/vmx/posted_intr.c | 18 +++++++++--------- 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, 23 insertions(+), 23 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..359ef3e6ebbe 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() && @@ -219,10 +219,10 @@ 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 @@ -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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 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 2A4503AAF41 for ; Wed, 26 Aug 2026 17:13:06 +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=1787764398; cv=none; b=AHp9mkiM9Mdt/yFJ5EmBxRH8r76NLt+NIvYcgWV14zRsjlX272JNh8j2hWVizODFZGq3IqCeaWsC9Q7kgjl8bEVei6I7TKVsBEqdomYpgiNaE4p0+zPApZizSoLr/y0MinJjnodNrrMdH3uff/UaZH7j7SbHwUJs1uRfP9X7OEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764398; c=relaxed/simple; bh=ETYszkt+PpDnzyBQpct9QDXpj2i+G42vlOEci4TgHog=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tR7PFJi5H7u6n1NjUkGT0F7kzVeQ9375N6wF+/X4Pbp6d1XCfWO0DUCFaFR1KIvMQzZmbxcwKDT2gtJzaS8/LE36Pdw8f88I4rjUTsAMMN4qAL0+H8cdwxfskaroxSJ/UWp6qTOgiGFhdtoS2t70/nLGS7RnNjzEOCqnyjwq6Y0= 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=qiEJrrzj; 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="qiEJrrzj" Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-84859a64079so1495567b3a.3 for ; Wed, 26 Aug 2026 10:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764383; x=1788369183; 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=IvVQPd56KlHv5ygDzHuD2XaX2Xb0ULf5ZrzcKWCrS+0=; b=qiEJrrzj7giOEAQHh4YK38G6DixPccjNYBIZ9MjWvskSU8Gd0WdemrxnHS+7m334eL x/ZLXxsvFqtkhuhVMwikGdOQ7oa7DlF3NrKolzV7CFBttYQB/kTpRoyFCO+TzwQJ0B62 bXiohEhsVVl01c6nkVBflPgTWv/+I7ZQk3pf1LlmuVt3zoM9/vICrph6a0QBdTaeO26L nqANtPiboJvq8gJgpPrc8IKql/5SyJS1N4wgKCAnCOdbr0i43sGM6qaWbDf7ugqs4r3I yP2PbHTpBaJIr5FYJvimrVapUN5o5PBlW+cIWU0NnjKfHF1LqbrzHO1mwDjGnh3JJMmO MJuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764383; x=1788369183; 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=IvVQPd56KlHv5ygDzHuD2XaX2Xb0ULf5ZrzcKWCrS+0=; b=Rv0Fb6970x+Zvbm4Uwz0l5XXuVXHQMpFwMxHAdU+l6CYAPbS7lMC3MhYN9WjED2YQv Xy1Fda1s+po0lOwKrgecgPyrKSne04zpjExQ/XYLjdYtadlUKsyFp7ByNFwsWNO0Jvbz Xcx/XnRtmZtoyjg0xNaMrfTcrnTWAsI0xCoesdu4PcIbGUSspYcTEwvcf+n8nMHCVGL4 uE5CslzpIB8t5q2dkw1ZmzX9HWVml+T2t/KZuFqa6gId8OBHLRDIEzPmijYu+pP0r3iw +X4X13AGU3mSTKJeQ9CbghQ7biT8bI7DItoSaqHVz3Awy7eZAj69Gy5JesQKVTX80kSu TUlg== X-Forwarded-Encrypted: i=1; AHgh+RrrqJiid4Yxmm3K2Sakq/G7dkhyT66w3qYYkfmGA5XYmIB5riVv1+QDCNIs+VfcXUUG8v71k0rkhArAOv0=@vger.kernel.org X-Gm-Message-State: AFuF++kyvXjBmW29nvFgxyJJhnY/OWI4QLn4EJ5VfELvQh/27QF+Tscn 4Yf/+RRp7XeiaUgnTQsWfh1WhMLsUxRt/bzlkSpI9iM9JjqXEYELkQe9jmq7SMutNiC21Q3PUOq +1DLW8w== X-Received: from pgcp11.prod.google.com ([2002:a63:740b:0:b0:cbe:9dc7:9eec]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:21d2:b0:851:c1ba:7aa6 with SMTP id d2e1a72fcca58-85373eb1adcmr14442590b3a.11.1787764382313; Wed, 26 Aug 2026 10:13:02 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:43 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-6-seanjc@google.com> Subject: [PATCH v2 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 6093D456DED for ; Wed, 26 Aug 2026 17:13:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764407; cv=none; b=NUX2KokNCbQgQ70v6XtV0QoIrRDpeKgNrWSpQYof/ydqaW4tLP9exYkhWVEzLYnnsbzc8EC7+mBv7IdZXHV1Xm7MDl5uHOeYljyCBd7hdBw91jcLRkzF1BFTqdUmHsglKIPMjyGo91hfX4iJ2PgsnkPi9GRYLqCM4lZ7ms2sKrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764407; c=relaxed/simple; bh=DwEigifFf2ZKAThwfxHzBagv4JxbtKhCNkN3G11XtrQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mC4tkfcwPV1ze9nu2faH2g+ayLGZAMfde4no1pfOhK/IqdfYQMfDEQccqmVC9L6Eep8bdz+tz2GnQyiZCLtCEw4q3SccRgyaZITarlwjA90+iiVBLleUL94fOO7Nvi3qLsBOZSXURinLje9NK/fTaGLcB4zlujow6XAjQUgflfk= 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=jW298FsG; arc=none smtp.client-ip=209.85.214.200 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="jW298FsG" Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2d6f75c1219so24730155ad.3 for ; Wed, 26 Aug 2026 10:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764384; x=1788369184; 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=YPT+STeueGFc+KdPGYWQIMiF2dG2O4FU++jlmfsqf6g=; b=jW298FsGQozp7VZmqM3jftCOaMzYz5Yx9uaMD4bWrSLfpoDqm/yFYKDc1Apt2GmtjR jpfmcfCUNegzd93xsiTRWJ0V97xxo4uO9+XtO4fryeVQYuMlK+A7kDPcImREToHCx9Eu h8m9fOB6t4Y5Mvtmc2JMOzI0yUcR2YL1Ogepg8t+2lRgtQ5AhE1QJLkC4LjzEi8kddxB lgrOUr16rm2jz7x9geCrIwyTanM2IQsYYSN1uahfQ+dnCJYZEbgph4SAqwfinhJYR57U hC/8H6+29L4dcOnk+AIq6RQbfSi5xomra3LxWOWue3o9FadIhTWihE9kY/LagOtL9J3b s+AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764384; x=1788369184; 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=YPT+STeueGFc+KdPGYWQIMiF2dG2O4FU++jlmfsqf6g=; b=nl5PSAsr7lhZUnsK4AnzXF6Lh6jUbLDdtQjBkvX3Qae0DDw8a5kGcjF6RW5DYt7x0v oHL6iI4MpAfgMpO8J73ujE08kK8fGuWZMeUbkdgb2ldeSZ2WJMhD/U5nwOIa1fRkcA+1 ABWr8lFl44hVAbQxXWs3Iqy0kcVv/HHkHSnnJ3AYw7Ccb11ODpGxnmpLw2y+B7dsRC4K XuHI0zE9DDbpoFLFC/f0Y1Uhm3U4MAqcwcbnt81dsPge7nFv9YhK+BOy9K/YlDsilbeM 5I4gnL3peQHJvav9Mu/C7dvB8S8RMllfcw96HAgX6ZFUBDXd+qK5bj8Y0UwaIQFJ5zRz jDBw== X-Forwarded-Encrypted: i=1; AHgh+RoE46KDbSlb5/SE+nclVaAdcE0zXNwNS1FCEOaDGYsO9amI1+zDzPK7dsuJAGoqEAb5Y05E9+rcdFMCFHM=@vger.kernel.org X-Gm-Message-State: AFuF++kY7zwEbuzCIaRs9zrNGJQp8D3VfZVP3KF/AcdL7Bq0KD0au9l/ B+7bLbTQooF4vkTZLrsSs+KSf39pEDvz7jmQaHi8LW4mEmTRTLCyd803teI/uBRMNzVBMvkFCv4 pMRX8aw== X-Received: from plxe6.prod.google.com ([2002:a17:902:ef46:b0:2c7:e06e:86f6]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1106:b0:2d6:f961:994f with SMTP id d9443c01a7336-2d707a59e04mr140009865ad.8.1787764384081; Wed, 26 Aug 2026 10:13:04 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:44 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-7-seanjc@google.com> Subject: [PATCH v2 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 2026 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 A74383FADFD for ; Wed, 26 Aug 2026 17:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764404; cv=none; b=IvXcL5ro82GGudxfCiHCBBwr89p1UxnJ0Rb8TTB1EbNSd7BgC01eNDm2UHzUhye/n4a2bi7WReI/DYJWPh1CyIBZ94RK5rwEpCUA5emnQ33FEdz9dd7OfC/+anDZehh1OWt0duqxRB6i2J6UAdIDLPG5HTyswNEXcn3DUdnFx+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764404; c=relaxed/simple; bh=nOGiS9Ti/nKAmQSYb61HTD1CEUtTMs2x1FOM2r5GOl8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=iV68J/DdLICRUpxyBdMgG6kbqis6+cGUL76Y8ELgJGqKYgxI2G+pC5BhEGzzUlCDXEcLM2qmm/dm0A40BtJYLyT+qo9aXTNKK8WUeyeCiMF9B7UeLHzhuLAuoxZDYW3r1zX7VOdJHwtzDU9GWLOVk2caNMcomtlVFFfh169iyT0= 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=HfBmG2sZ; arc=none smtp.client-ip=209.85.214.200 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="HfBmG2sZ" Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cfa55c9430so14228115ad.0 for ; Wed, 26 Aug 2026 10:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764386; x=1788369186; 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=ZF+rhrplp7F9IM2HmvOv45+iUbuMSUncaYHQg1vJT4U=; b=HfBmG2sZIM+ybQpySFgklaD9EShNFcuYekLZM9MSvUFh4e17JlkXjXAKahId55krzK uBzsByKqz2E0vyZtkJ2KQMpaFi8If3n/7Ct1uZxHxfmolDN9bSbMEw0wo6IG0q736KNl cf/pmD0/IuCiDVV0lQGpWtL/mBhSkYNHNKGFPIeSsxN+HzJL1nGdF1eiUbJUbLVgNt/j pJDP3rryqiXLX+sc+at77tQJPzEFQm2mbg9WrAFHTsxC4HCc21THjExGONUbL23W3QHu 8FxNWS3JTPpIeuyzP0Q3qcRzlxeHB+6gCYVMZE1tEhi5kK1Jjic3XvGdK5qOWKoZWVNt i2xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764386; x=1788369186; 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=ZF+rhrplp7F9IM2HmvOv45+iUbuMSUncaYHQg1vJT4U=; b=lBg3sF0fRO5yWJsQvbDsZ+ZIMmf3oahBrroZCHOQx9j58+vaNnsap2NbiFGKVsTCle 0H1W5NEMfWp75gm3kMY3ZICORprNshij0NwnjA70Uo5UGY/6240EKR8rkqM/+AsEpiQ8 lMwU6XZ+yKH7qOhlWKGnxrlcM6EnjPd6FLFL/jhvDHy530pIl2Ml78yFs2f9zVWG6gAm 0nipG620yOj+Asp/UiIh0vd+mnZI9Fk7T3UKI8RpVD1l5+GPRbiLqEatL06lOiIjR/Bn 9b9xaOWMIBJRJ38KIZvyiIA3lv0wChLDPv5+kzBMj6ynuJOMD9mA6/wLlP0+utdfCrIr WdoA== X-Forwarded-Encrypted: i=1; AHgh+RpJwjgJD0MSj5oNvf29XfwEFzFeuGe6CsxtBlh3FVeN1hWSUh0iSYnp8OgzHFBRtKW8m77r6ylkFeuJ/ZM=@vger.kernel.org X-Gm-Message-State: AFuF++kXDj3Mq5iEwi7DUQyWBKuRrcVAR/SvE+7gkLjNxDIfwsMKVmt2 j9iqkpLD69qk0JfJmkmwVCGt7dX2xJV9gf67sZZki4uNVZV7XUufu1mG2jWh8r369tjdHHej34w 3MIqhxA== X-Received: from plbko13.prod.google.com ([2002:a17:903:7cd:b0:2c7:f22f:54d6]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:28d:b0:2d7:11d2:1455 with SMTP id d9443c01a7336-2d711d21807mr118795855ad.4.1787764385182; Wed, 26 Aug 2026 10:13:05 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:45 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-8-seanjc@google.com> Subject: [PATCH v2 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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.887.g758fc8c411-goog From nobody Mon Sep 28 04:49:01 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 CA4C64499A4 for ; Wed, 26 Aug 2026 17:13:10 +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=1787764419; cv=none; b=ctp1eKhx86xRG1Qa5lRfNQ5rp/eT/84f1xXMDWEMzA1glU2d5b25/xPsAL1NYE237QGYsGL4OPLNboNZsWHUlhTIX9WX8WsBhlqVe/FcqaxA/u6Xx7UB+Q/dtikVeT6GdxVC/d/iRSgDMZY+ckYtErqdGdAIO/5V9Dy9Pcp5q0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787764419; c=relaxed/simple; bh=Mlsg8m8eBtV+hg6nO5ioNJJ+WffsFvcsb7SrKh7p5Ms=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o195USxs9YmEm4XaFijkOGQ8FGeVhWZ7q3IpAva7+OLj/3uqaROBcPwjEbCYovCZm8eYatGFGjGl9io93HWEME6rlISmL44D9uLV6+SVFOyVzl2RizOcJ9ggju8f3MHoEeYNU5e8asaYlUuA+Ju8s1lqcxb/gyrUdh88Q8tKl8s= 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=F9+vjHaB; 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="F9+vjHaB" Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2d6f75c1219so24730885ad.3 for ; Wed, 26 Aug 2026 10:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787764387; x=1788369187; 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=kg9kkCdY3V4ndzjq2be0bEtfBf3ttr26BVX4eOe7c0Q=; b=F9+vjHaBllEME79L3tgsmXqHgZ7hZOstZUGXKZ89ps5qLImRaUFt5bNsTfPeIp6udB H1yQoCOpzojUtByba+q2J6DPez/FWn9dtKBzvPzraKaSdOlw1Tzh+dKW7MNrjkdd0itl T96DmeN+HR6GzRJh4h5o4zqeydo5yINE9c8LmGrg/jIsFHTboZeSWGciZlfsTmbkJ9pP Ov8PklN0Yl9FIAu6dM1xLuAH3aX8jINlBdoTnWlWe+BK/wc4HZ+gZj+meUVDLCzCqnHj tpnuyksr163EQuh8xf5MqFUM2MqSlv6HMg41wpsOq3uaU+nsCQUclG7gEFrzpSsPzDhD 3v9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787764387; x=1788369187; 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=kg9kkCdY3V4ndzjq2be0bEtfBf3ttr26BVX4eOe7c0Q=; b=okeodQ4fxojLwCVRTCYoz3bzFx/a6/wT43GeMreDbSrIvv9PsAhsTb/50HFUzeFbY+ v+Mw04m8UkeoWHDW8B5zipd4scyJg3ojhT/WNOA0ZtQvFy8hPEAZj5S7Q+ZpCkYAhFJM XKWm+XOpY+dZUaoCwwdDmHgL/jZomJH/3JC+tax2HCrVVgjvZm0gR09WkKvKCZ598my3 dx5R6gDDN65cfqmDzhoLhtV4j/okNtB1f2el104Ihhao1d7hJIK2u3ad4RppnSG0+C7P 9XiIe8+5XCchMh/LQKN266e1uHJuL07StjtsvYNiLf/JUA3PVX2Tv0X8a4ylIfwV0OsF i1eg== X-Forwarded-Encrypted: i=1; AHgh+RqgGm5I497s7xMM7Ah4cQZkOmJ3RS5bSG7XAIShnZqWgWbY4OSxB/2Yd5kIpRlTogHUDP7gXWB1h0TzUrU=@vger.kernel.org X-Gm-Message-State: AFuF++n3y1GyDCVUzpe1bYVGE1FUMBS/ZMSzq/6zZMJ0gU7oW4806Z0z 8fd/X4ErawGx0/nTdhd/x1UWSHe3HECREbXD6d6mwypFvSJHeSmRjtyhVuHi9FKHe8Q80JUK3Oa 4TBq4ug== X-Received: from plhl18.prod.google.com ([2002:a17:903:1212:b0:2ca:d4a3:a7b3]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:3c46:b0:2ca:4f33:e86f with SMTP id d9443c01a7336-2d707b416famr157913905ad.12.1787764386860; Wed, 26 Aug 2026 10:13:06 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 26 Aug 2026 10:12:46 -0700 In-Reply-To: <20260826171246.777729-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: <20260826171246.777729-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.887.g758fc8c411-goog Message-ID: <20260826171246.777729-9-seanjc@google.com> Subject: [PATCH v2 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, Rick Edgecombe , Xiaoyao Li , Binbin Wu , Kai Huang , 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. Signed-off-by: Sean Christopherson Reviewed-by: Kai Huang Reviewed-by: Xiaoyao Li Tested-by: Kai Huang --- 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.887.g758fc8c411-goog