From nobody Mon Feb 9 16:21:46 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A761F366833; Tue, 3 Feb 2026 18:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770142659; cv=none; b=NCnI5kPzgRoopXYfMVXFXRXQuZPZcLXHCjqCSzft2a/2iRG9HjKEX1Vce337NpVKhcTWCQPWbUPMNxWxV32vNQ8cbucsceRWgK9/GkM6c125Bjovuz6Xaqn01PqpmIVTf9mCMFPXWUNhOuEij+1eBtEPOS/AcEgU7BwsfnqE4X8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770142659; c=relaxed/simple; bh=6h76HamtuX5WAWZxbtzCPlZnwCKgGwSsmIJkkIJPz8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIDHeGUQ0cTrf+GZPvoDgVZPMES2mLs0/IpfN1lI3afJkARUmI0iCfZbpAN+kCocm8MCVjv01GOVPtIoawTBgfz0rJX5ZoPu/0iepd860dtKhP/jXHVlR247WBUZ1HmKsR9uj0/Qlyby2B1ZUHZR2FxrfNuEGcf+rpXFhs7XNvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YQfLJV3U; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YQfLJV3U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770142656; x=1801678656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6h76HamtuX5WAWZxbtzCPlZnwCKgGwSsmIJkkIJPz8A=; b=YQfLJV3U4W00bz3RsQwN46plVpbuHaXH36NgjNvtAXt7a+YHWCZlid3m j390G2IPC0mVc6DbzB+Xr2uRwJtwdiTf1reNMOwdNEcTprjGe9J9KBi0h zMnGPxwuJIUDYj8ER9yM3V+jMSAiYN/fcBSHkqTmrTaaAcpce+o9fRRLw AxHfJ6X2hHVol8zJZPz87bJSOv4Y74jB3Su+1KSLUScpoDBvNTU1fcpPQ 7MBGBK3QKgnAaI2e6fmwiieg7gcnYOug41+X+rN/ESS32nbpy43jYqtV+ zwqhWBFmETECCDsrtMWnnU2PxwKUehy6iquLNByJdeqOnYRI1UaGScb3b A==; X-CSE-ConnectionGUID: RcSblYuhRq2wabtdF3UbfQ== X-CSE-MsgGUID: 4ViusSTBSeenuNxiIuGaRQ== X-IronPort-AV: E=McAfee;i="6800,10657,11691"; a="82433182" X-IronPort-AV: E=Sophos;i="6.21,271,1763452800"; d="scan'208";a="82433182" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2026 10:17:36 -0800 X-CSE-ConnectionGUID: SHh7J4kKSOWnZnd07MoA5g== X-CSE-MsgGUID: jyHEamHNSZOOrGgfhhKNtA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,271,1763452800"; d="scan'208";a="209727496" Received: from khuang2-desk.gar.corp.intel.com (HELO localhost) ([10.124.221.188]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2026 10:17:36 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , Sean Christopherson , linux-kernel@vger.kernel.org Subject: [PATCH 07/32] KVM: VMX: Update APIC timer virtualization on apicv changed Date: Tue, 3 Feb 2026 10:16:50 -0800 Message-ID: <5f8655049106de981021d3d17bedc56574756678.1770116050.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Isaku Yamahata VMX APIC timer virtualization requires the virtual-interrupt delivery. It's part of KVM apicv, and when apicv state is changed, the refresh_apicv_exec_ctrl() callback is invoked. Export a lapic function to update which timer to use for APIC timer emulation and make the VMX backend call it. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/lapic.c | 6 ++++++ arch/x86/kvm/lapic.h | 1 + arch/x86/kvm/vmx/vmx.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 837f446eea41..a2f714eb78b1 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1898,6 +1898,12 @@ static void apic_update_apic_virt_timer(struct kvm_l= apic *apic) apic_cancel_apic_virt_timer(apic); } =20 +void kvm_update_apic_virt_timer(struct kvm_vcpu *vcpu) +{ + apic_update_apic_virt_timer(vcpu->arch.apic); +} +EXPORT_SYMBOL_GPL(kvm_update_apic_virt_timer); + static void apic_update_lvtt(struct kvm_lapic *apic) { u32 timer_mode =3D kvm_lapic_get_reg(apic, APIC_LVTT) & diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index d3fad67a4e78..3c597b670e7e 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -250,6 +250,7 @@ void kvm_lapic_switch_to_apic_virt_timer(struct kvm_vcp= u *vcpu); void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu); bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu); void kvm_lapic_restart_hv_timer(struct kvm_vcpu *vcpu); +void kvm_update_apic_virt_timer(struct kvm_vcpu *vcpu); =20 static inline bool kvm_lapic_apic_virt_timer_in_use(struct kvm_vcpu *vcpu) { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index dcb04fc0b8a7..82e1a0b2a8d2 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4563,6 +4563,8 @@ void vmx_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcp= u) kvm_vcpu_apicv_active(vcpu)); =20 vmx_update_msr_bitmap_x2apic(vcpu); + + kvm_update_apic_virt_timer(vcpu); } =20 static u32 vmx_exec_control(struct vcpu_vmx *vmx) --=20 2.45.2