From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4FD4C5AC82 for ; Thu, 6 Aug 2026 23:36:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1385284.1627782 (Exim 4.92) (envelope-from ) id 1ws7dm-000177-Re; Thu, 06 Aug 2026 23:36:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1385284.1627782; Thu, 06 Aug 2026 23:36:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ws7dm-00016d-M3; Thu, 06 Aug 2026 23:36:46 +0000 Received: by outflank-mailman (input) for mailman id 1385284; Thu, 06 Aug 2026 23:36:45 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from <3ihp1agYKCe0hTPcYRVddVaT.RdbmTc-STkTaaXhih.mTcegdYTRi.dgV@flex--seanjc.bounces.google.com>) id 1ws7dl-0000zb-1s for xen-devel@lists.xenproject.org; Thu, 06 Aug 2026 23:36:45 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1ws7dk-00GcT3-Eh for xen-devel@lists.xenproject.org; Fri, 07 Aug 2026 01:36:44 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from <3ihp1agYKCe0hTPcYRVddVaT.RdbmTc-STkTaaXhih.mTcegdYTRi.dgV@flex--seanjc.bounces.google.com>) id 6a751a63-5cb7-0a2a0a5109dd-0a2a45099b3a-14 for ; Fri, 07 Aug 2026 01:36:44 +0200 Received: from [209.85.216.71] (helo=mail-pj1-f71.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from <3ihp1agYKCe0hTPcYRVddVaT.RdbmTc-STkTaaXhih.mTcegdYTRi.dgV@flex--seanjc.bounces.google.com>) id 6a751a8a-be1a-0a2a45090019-d155d847b8c1-3 for ; Fri, 07 Aug 2026 01:36:44 +0200 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e667368f0so4358162a91.2 for ; Thu, 06 Aug 2026 16:36:43 -0700 (PDT) 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 Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=google.com header.i="@google.com" header.h="Content-Type:Cc:To:From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786059402; x=1786664202; darn=lists.xenproject.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=wbY0NuQ4jmVaTb967BiKKQEFZ81rzIFWsnI6s/GLKnk=; b=wU0/80f/2tfxf6oVmy6NECSHzNhhT0Ndg5wkXXqKAGhqPiuL+EINjJO3oVS8DLXj1p /HUcwVU/OTHEEuAovapscHBEkt7Wtwu1nYVMGW2ob28WO1fsIRTFGqIBLPV+2D/iMSBT XyYnb2rxXP0GLJ6De2Cjka/B7+TO0fHWSmmGQnHMcRK/oxwRzEEVSaZdC6v56cipmKn6 b0ZGtLc0UiD8gwnViVlsB9S/ClDqx2tTPJFqH2XulN8Yr7nfRpwy3Tfo+PAyOkgn9/Z+ 5ynifEuCAm/y2nu8IBT2YeRs7dyv79e5r5QY91HeBIswEB7wL7XMWJXj+jbHGl2+PqWK t9Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786059402; x=1786664202; 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=wbY0NuQ4jmVaTb967BiKKQEFZ81rzIFWsnI6s/GLKnk=; b=CZbx8Mx958nQAE7y4AfTwtE5qYUn2BHzwCvm02wpOrzwOBf44xo5cPY+jeiNiI4T1P RWaatoZ/4WOy05zk1ABLwL4QiikvEXff9UM1kIlaZ6azwG6t+LPsNsOfJ/jebj9IrAiM V4h/hD7thojso+ZJ7POOIDBx083F1DNHLOx+Us1B73PlB9X5UC48mh5V1pRmEiaNv5Uz KwhEkull4TmWOkd/XWrgcoM8lCLPue1dQvlQ7QBpi82/Pef6kA1ZVSjxIlroHyGxCHp1 EW+kqX1K8Up8LpqJU4T12YgKsYICxqnsRJ5Lba78zQZ6udunjfsDCAzlpCHWkHN5uixx vr9g== X-Forwarded-Encrypted: i=1; AHgh+Ro10JlYN7uXMq5wdLHHq8IBB/8dlHc9PEDgagA202qntvLP6zSx07oBNhOUFPjwMubOmkafvTSvGt4=@lists.xenproject.org X-Gm-Message-State: AOJu0YwrUa3B3M5+sxN7NrfYUw6JHoKaGB/vhwafgGBarCgAm53lpsLq ryrXsQrTp6dyF/4g8sbZT3731EXww3qFuPAD4HRu/ThidEL37fWsSeqrl8pY5YL7TvjPT8jc5or bThwn2g== X-Received: from pjbcv18.prod.google.com ([2002:a17:90a:fd12:b0:38e:7f2c:2c4b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:264c:b0:37f:e326:6557 with SMTP id 98e67ed59e1d1-3903c598e8amr20096574a91.4.1786059402046; Thu, 06 Aug 2026 16:36:42 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 6 Aug 2026 16:35:32 -0700 In-Reply-To: <20260806233609.212337-1-seanjc@google.com> Mime-Version: 1.0 References: <20260806233609.212337-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Message-ID: <20260806233609.212337-16-seanjc@google.com> Subject: [PATCH v6 15/51] x86/tsc: Kill off x86_platform_ops.calibrate_{cpu,tsc}() hooks From: Sean Christopherson To: Kiryl Shutsemau , Rick Edgecombe , Sean Christopherson , Paolo Bonzini , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Kaher , Alexey Makhalov , Jan Kiszka , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Juergen Gross , Daniel Lezcano , Thomas Gleixner , John Stultz Cc: Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , Miroslav Lichvar , x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Michael Kelley , Tom Lendacky , Nikunj A Dadhania , David Woodhouse , David Woodhouse , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" X-purgate-ID: tlsNG-bad1c0/1786059404-BEAD8034-89559CF6/0/0 X-purgate-type: clean X-purgate-size: 5639 Now that getting the CPU and/or TSC frequencies from the hypervisor uses dedicated hooks, drop x86_platform_ops.calibrate_{cpu,tsc}() and instead directly invoke the correct helper at each phase of (re)calibration. In addition to eliminating unnecessary code, this makes it a bit more obvious when the "late" path invokes pit_hpet_ptimer_calibrate_cpu() instead of x86_platform_ops.calibrate_cpu(). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/tsc.h | 2 -- arch/x86/include/asm/x86_init.h | 4 ---- arch/x86/kernel/tsc.c | 28 ++++++++++++---------------- arch/x86/kernel/x86_init.c | 2 -- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h index b6b86e24e1bf..c09ec485abcd 100644 --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h @@ -95,8 +95,6 @@ extern void mark_tsc_unstable(char *reason); extern int unsynchronized_tsc(void); extern int check_tsc_unstable(void); extern void mark_tsc_async_resets(char *reason); -extern unsigned long native_calibrate_cpu_early(void); -extern unsigned long native_calibrate_tsc(void); extern unsigned long long native_sched_clock_from_tsc(u64 tsc); extern int tsc_clocksource_reliable; diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index 0c89bf40f507..e879e6e83428 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h @@ -295,8 +295,6 @@ struct x86_hyper_runtime { /** * struct x86_platform_ops - platform specific runtime functions - * @calibrate_cpu: calibrate CPU - * @calibrate_tsc: calibrate TSC, if different from CPU * @get_wallclock: get time from HW clock like RTC etc. * @set_wallclock: set time back to HW clock * @iommu_shutdown: set by an IOMMU driver for shutdown if necessary @@ -320,8 +318,6 @@ struct x86_hyper_runtime { * @guest: guest incarnations callbacks */ struct x86_platform_ops { - unsigned long (*calibrate_cpu)(void); - unsigned long (*calibrate_tsc)(void); void (*get_wallclock)(struct timespec64 *ts); int (*set_wallclock)(const struct timespec64 *ts); void (*iommu_shutdown)(void); diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index f42872c9ae99..1d41ef1db27c 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -672,7 +672,7 @@ int cpuid_get_tsc_info(struct cpuid_tsc_info *info) * native_calibrate_tsc - determine TSC frequency * Determine TSC frequency via CPUID, else return 0. */ -unsigned long native_calibrate_tsc(void) +static unsigned long native_calibrate_tsc(void) { struct cpuid_tsc_info info; @@ -904,7 +904,7 @@ static unsigned long pit_hpet_ptimer_calibrate_cpu(void) /** * native_calibrate_cpu_early - can calibrate the cpu early in boot */ -unsigned long native_calibrate_cpu_early(void) +static unsigned long native_calibrate_cpu_early(void) { unsigned long flags, fast_calibrate = cpu_khz_from_cpuid(); @@ -918,7 +918,7 @@ unsigned long native_calibrate_cpu_early(void) return fast_calibrate; } - +#ifndef CONFIG_SMP /** * native_calibrate_cpu - calibrate the cpu */ @@ -931,6 +931,7 @@ static unsigned long native_calibrate_cpu(void) return tsc_freq; } +#endif void recalibrate_cpu_khz(void) { @@ -943,8 +944,8 @@ void recalibrate_cpu_khz(void) if (WARN_ON_ONCE(cpu_feature_enabled(X86_FEATURE_TSC_KNOWN_FREQ))) return; - cpu_khz = x86_platform.calibrate_cpu(); - tsc_khz = x86_platform.calibrate_tsc(); + cpu_khz = native_calibrate_cpu(); + tsc_khz = native_calibrate_tsc(); if (tsc_khz == 0) tsc_khz = cpu_khz; else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) @@ -1458,17 +1459,19 @@ static bool __init determine_cpu_tsc_frequencies(bool early, WARN_ON(cpu_khz || tsc_khz); if (early) { + /* + * Early CPU calibration can only use methods that are available + * early in boot (obviously). + */ if (known_cpu_khz) cpu_khz = known_cpu_khz; else - cpu_khz = x86_platform.calibrate_cpu(); + cpu_khz = native_calibrate_cpu_early(); if (known_tsc_khz) tsc_khz = known_tsc_khz; else - tsc_khz = x86_platform.calibrate_tsc(); + tsc_khz = native_calibrate_tsc(); } else { - /* We should not be here with non-native cpu calibration */ - WARN_ON(x86_platform.calibrate_cpu != native_calibrate_cpu); cpu_khz = pit_hpet_ptimer_calibrate_cpu(); } @@ -1571,13 +1574,6 @@ void __init tsc_init(void) return; } - /* - * native_calibrate_cpu_early can only calibrate using methods that are - * available early in boot. - */ - if (x86_platform.calibrate_cpu == native_calibrate_cpu_early) - x86_platform.calibrate_cpu = native_calibrate_cpu; - if (!tsc_khz) { /* We failed to determine frequencies earlier, try again */ if (!determine_cpu_tsc_frequencies(false, 0, 0)) { diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 252c5827d063..b7a48e622f48 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c @@ -147,8 +147,6 @@ static void enc_kexec_finish_noop(void) {} static bool is_private_mmio_noop(u64 addr) {return false; } struct x86_platform_ops x86_platform __ro_after_init = { - .calibrate_cpu = native_calibrate_cpu_early, - .calibrate_tsc = native_calibrate_tsc, .get_wallclock = mach_get_cmos_time, .set_wallclock = mach_set_cmos_time, .iommu_shutdown = iommu_shutdown_noop, -- 2.55.0.679.g6767b8d81c-goog