From nobody Tue Aug 25 10:48:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=infradead.org ARC-Seal: i=1; a=rsa-sha256; t=1783113850; cv=none; d=zohomail.com; s=zohoarc; b=SMmDXuCLE8f1m8S3+HX+Zp+WJ5f+ApCdVH5mqoofc3q2CqIkijvpPdZHmv4ZI0sYu3eszHGa0efXc+dK2GPd39ZfPn4N/RotGrATMxKsc179RQEdAwhkM8XnmpjwSnW8rPMxUOJJ2MRL2+2RU58ojtClLC+e52ff+XoqdslLv14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783113850; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=mAoCrW41i2oubtWoRcSbcZKOTJ7hLP/U/r8vkThOrIU=; b=Pg99GczoQy/bHdnxtAsUHMg/F7RUY2WV+U+jneYRnPcd9xC3Q+5THDFDrWH84UNbLX68382QK8Qrm6Lmwjc2HsfWOwEhdFq81FhYfD+zOrrl/xBxBVl8NO5qwBlLnB1HbxqJpfA1kqVrthD4PO9NQdMDTnP9jDUXisw4h/uK560= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783113850986873.3983172724951; Fri, 3 Jul 2026 14:24:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1353904.1609680 (Exim 4.92) (envelope-from ) id 1wflMa-0007iL-Am; Fri, 03 Jul 2026 21:23:56 +0000 Received: by outflank-mailman (output) from mailman id 1353904.1609680; Fri, 03 Jul 2026 21:23:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wflMa-0007h5-4w; Fri, 03 Jul 2026 21:23:56 +0000 Received: by outflank-mailman (input) for mailman id 1353904; Fri, 03 Jul 2026 21:23:53 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wflMX-00071A-7M for xen-devel@lists.xenproject.org; Fri, 03 Jul 2026 21:23:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wflMW-00CejO-KM; Fri, 03 Jul 2026 23:23:52 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a482835-bab6-0a2a0a5309dd-0a2a45038b46-26 for ; Fri, 03 Jul 2026 23:23:52 +0200 Received: from [90.155.92.199] (helo=desiato.infradead.org) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a482868-ec1a-0a2a45030019-5a9b5cc7ba66-3 for ; Fri, 03 Jul 2026 23:23:52 +0200 Received: from [2001:8b0:10b:1::425] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.99.2 #2 (Red Hat Linux)) id 1wflKd-000000059OB-3OKN; Fri, 03 Jul 2026 21:23:31 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.99.2 #2 (Red Hat Linux)) id 1wflKX-00000001RPf-1VR4; Fri, 03 Jul 2026 22:21:49 +0100 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=desiato.20200630 header.d=infradead.org header.i="@infradead.org" header.h="Sender:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description; bh=mAoCrW41i2oubtWoRcSbcZKOTJ7hLP/U/r8vkThOrIU=; b=SCbksCL3C6lCq63v2liwrhb2lA xAbzjM0Ap/EFmihcazXJMLsPc0Gy/LZbYMpy3KNL9NaNPZ08PMTpDHyMT9z4L9DQzWXqndhnhJVT/ KaO3tzV57y2ygHn+F/s78qY2H4870En1P/JMMQzNiMI3AcHjVzKmP29ZJ27qVm3fVpi0kgOi3ocQC Ldb5j68wLws0DZDKidaCijCDu71rnX34BxkzVhC35mPOUB55mdo0urZogZbzzyX9H1Btken59i/zq quARfNTDShyil/B7FPKU929VA3Q43dAMg5lcGHrX+ePGE7kLAD/aHCLdFkn9CykhB+0xJ6rmrTdEl TdTctQvw==; From: David Woodhouse To: Paolo Bonzini , Jonathan Corbet , Shuah Khan , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Vitaly Kuznetsov , Juergen Gross , Boris Ostrovsky , David Woodhouse , Paul Durrant , Jonathan Cameron , Sascha Bischoff , Marc Zyngier , Joey Gouly , Jack Allister , Dongli Zhang , joe.jin@oracle.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-kselftest@vger.kernel.org Subject: [PATCH v6 28/36] KVM: x86: Remove runtime Xen TSC frequency CPUID update Date: Fri, 3 Jul 2026 22:18:07 +0100 Message-ID: <20260703212145.343527-29-dwmw2@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260703212145.343527-1-dwmw2@infradead.org> References: <20260703212145.343527-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-purgate-ID: tlsNG-33051d/1783113832-07B245D1-AD583B97/0/0 X-purgate-type: clean X-purgate-size: 3099 X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1783113852932158500 Content-Type: text/plain; charset="utf-8" From: David Woodhouse Remove the code in kvm_cpuid() that dynamically updates the Xen TSC info CPUID leaf at runtime. This code was updating the wrong sub-leaf anyway (0x40000x03/2 EAX is the *host* TSC frequency per the Xen ABI, not the guest frequency which belongs in 0x40000x03/0 ECX). Userspace now has all the information it needs to populate the Xen TSC info leaves (and the generic 0x40000010 timing leaf) at vCPU setup time: - KVM_GET_CLOCK_GUEST returns the pvclock_vcpu_time_info structure containing tsc_to_system_mul and tsc_shift (Xen leaf index 1) - KVM_VCPU_TSC_SCALE returns the effective TSC and bus frequencies in kHz (Xen leaf index 2, and 0x40000010) - KVM_VCPU_TSC_SCALE returns the raw hardware scaling ratio for precise arithmetic (VMClock) This eliminates the last instance of KVM modifying guest CPUID entries at runtime for timing information. Signed-off-by: David Woodhouse --- arch/x86/kvm/cpuid.c | 16 ---------------- arch/x86/kvm/xen.h | 13 ------------- 2 files changed, 29 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 621d950ec692..826637a0b72d 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -2117,22 +2117,6 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 = *ebx, } else if (function =3D=3D 0x80000007) { if (kvm_hv_invtsc_suppressed(vcpu)) *edx &=3D ~feature_bit(CONSTANT_TSC); - } else if (IS_ENABLED(CONFIG_KVM_XEN) && - kvm_xen_is_tsc_leaf(vcpu, function)) { - /* - * Update guest TSC frequency information if necessary. - * Ignore failures, there is no sane value that can be - * provided if KVM can't get the TSC frequency. - */ - if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) - kvm_guest_time_update(vcpu); - - if (index =3D=3D 1) { - *ecx =3D vcpu->arch.pvclock_tsc_mul; - *edx =3D vcpu->arch.pvclock_tsc_shift; - } else if (index =3D=3D 2) { - *eax =3D div_u64(vcpu->arch.hw_tsc_hz, 1000); - } } } else { *eax =3D *ebx =3D *ecx =3D *edx =3D 0; diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index 59e6128a7bd3..f372855857a8 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -50,14 +50,6 @@ static inline void kvm_xen_sw_enable_lapic(struct kvm_vc= pu *vcpu) kvm_xen_inject_vcpu_vector(vcpu); } =20 -static inline bool kvm_xen_is_tsc_leaf(struct kvm_vcpu *vcpu, u32 function) -{ - return static_branch_unlikely(&kvm_xen_enabled.key) && - vcpu->arch.xen.cpuid.base && - function <=3D vcpu->arch.xen.cpuid.limit && - function =3D=3D (vcpu->arch.xen.cpuid.base | XEN_CPUID_LEAF(3)); -} - static inline bool kvm_xen_msr_enabled(struct kvm *kvm) { return static_branch_unlikely(&kvm_xen_enabled.key) && @@ -177,11 +169,6 @@ static inline bool kvm_xen_timer_enabled(struct kvm_vc= pu *vcpu) { return false; } - -static inline bool kvm_xen_is_tsc_leaf(struct kvm_vcpu *vcpu, u32 function) -{ - return false; -} #endif =20 int kvm_xen_hypercall(struct kvm_vcpu *vcpu); --=20 2.54.0