All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev, lkp@intel.com, oe-kbuild-all@lists.linux.dev
Subject: Re: [PATCH 15/16] x86/kvmclock: Stuff local APIC bus period when core crystal freq comes from CPUID
Date: Wed, 5 Feb 2025 14:11:51 -0800	[thread overview]
Message-ID: <Z6PiJ3HPf86O0mkr@google.com> (raw)
In-Reply-To: <f9d42d5a-a625-4eba-9ee4-c2c42d179df7@stanley.mountain>

On Tue, Feb 04, 2025, Dan Carpenter wrote:
> Hi Sean,
> 
> kernel test robot noticed the following build warnings:
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Sean-Christopherson/x86-tsc-Add-a-standalone-helpers-for-getting-TSC-info-from-CPUID-0x15/20250201-102521
> base:   ebbb8be421eefbe2d47b99c2e1a6dd840d7930f9
> patch link:    https://lore.kernel.org/r/20250201021718.699411-16-seanjc%40google.com
> patch subject: [PATCH 15/16] x86/kvmclock: Stuff local APIC bus period when core crystal freq comes from CPUID
> config: i386-randconfig-141-20250204 (https://download.01.org/0day-ci/archive/20250204/202502041246.3weiY0qo-lkp@intel.com/config)
> compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202502041246.3weiY0qo-lkp@intel.com/
> 
> smatch warnings:
> arch/x86/kernel/kvmclock.c:117 kvm_get_tsc_khz() error: uninitialized symbol 'crystal_khz'.
> 
> vim +/crystal_khz +117 arch/x86/kernel/kvmclock.c
> 
> aea5814308ed7c Sean Christopherson 2025-01-31  105  static unsigned long kvm_get_tsc_khz(void)
> aea5814308ed7c Sean Christopherson 2025-01-31  106  {
> aea5814308ed7c Sean Christopherson 2025-01-31  107  	unsigned int __tsc_khz, crystal_khz;
> aea5814308ed7c Sean Christopherson 2025-01-31  108  
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  109  	/*
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  110  	 * Prefer CPUID over kvmclock when possible, as CPUID also includes the
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  111  	 * core crystal frequency, i.e. the APIC timer frequency.  When the core
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  112  	 * crystal frequency is enumerated in CPUID.0x15, KVM's ABI is that the
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  113  	 * (virtual) APIC BUS runs at the same frequency.
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  114  	 */
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  115  	if (!cpuid_get_tsc_freq(&__tsc_khz, &crystal_khz)) {
> 
> The cpuid_get_tsc_freq() function has a bug so it doesn't actually
> initialize crystal_khz.  It actually uses the uninitialized value, inside
> the function but Smatch doesn't catch that.

Argh.  I caught this in testing and fixed it locally, but clobbered my branch
and accidentally reverted to the broken code when posting.  The bug is way back
in patch 1, I'll point it out there.

Thanks!

> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  116  #ifdef CONFIG_X86_LOCAL_APIC
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31 @117  		lapic_timer_period = crystal_khz * 1000 / HZ;
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  118  #endif
> aea5814308ed7c Sean Christopherson 2025-01-31  119  		return __tsc_khz;
> 32cd84ebbd5dbd Sean Christopherson 2025-01-31  120  	}
> aea5814308ed7c Sean Christopherson 2025-01-31  121  
> aea5814308ed7c Sean Christopherson 2025-01-31  122  	return pvclock_tsc_khz(this_cpu_pvti());
> aea5814308ed7c Sean Christopherson 2025-01-31  123  }
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
> 

  reply	other threads:[~2025-02-05 22:11 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-01  2:17 [PATCH 00/16] x86/tsc: Try to wrangle PV clocks vs. TSC Sean Christopherson
2025-02-01  2:17 ` [PATCH 01/16] x86/tsc: Add a standalone helpers for getting TSC info from CPUID.0x15 Sean Christopherson
2025-02-03  5:55   ` Nikunj A Dadhania
2025-02-03 22:03     ` Sean Christopherson
2025-02-05 22:13   ` Sean Christopherson
2025-02-11 15:01   ` Borislav Petkov
2025-02-11 17:25     ` Sean Christopherson
2025-02-11 18:40       ` Borislav Petkov
2025-02-11 19:03         ` Sean Christopherson
2025-02-01  2:17 ` [PATCH 02/16] x86/tsc: Add standalone helper for getting CPU frequency from CPUID Sean Christopherson
2025-02-01  2:17 ` [PATCH 03/16] x86/tsc: Add helper to register CPU and TSC freq calibration routines Sean Christopherson
2025-02-11 17:32   ` Borislav Petkov
2025-02-11 17:43     ` Sean Christopherson
2025-02-11 20:32       ` Borislav Petkov
2025-02-12 16:49         ` Tom Lendacky
2025-02-01  2:17 ` [PATCH 04/16] x86/sev: Mark TSC as reliable when configuring Secure TSC Sean Christopherson
2025-02-04  8:02   ` Nikunj A Dadhania
2025-02-01  2:17 ` [PATCH 05/16] x86/sev: Move check for SNP Secure TSC support to tsc_early_init() Sean Christopherson
2025-02-04  8:27   ` Nikunj A Dadhania
2025-02-01  2:17 ` [PATCH 06/16] x86/tdx: Override PV calibration routines with CPUID-based calibration Sean Christopherson
2025-02-04 10:16   ` Nikunj A Dadhania
2025-02-04 19:29     ` Sean Christopherson
2025-02-05  3:56       ` Nikunj A Dadhania
2025-02-01  2:17 ` [PATCH 07/16] x86/acrn: Mark TSC frequency as known when using ACRN for calibration Sean Christopherson
2025-02-01  2:17 ` [PATCH 08/16] x86/tsc: Pass KNOWN_FREQ and RELIABLE as params to registration Sean Christopherson
2025-02-03 14:48   ` Tom Lendacky
2025-02-03 19:52     ` Sean Christopherson
2025-02-01  2:17 ` [PATCH 09/16] x86/tsc: Rejects attempts to override TSC calibration with lesser routine Sean Christopherson
2025-02-01  2:17 ` [PATCH 10/16] x86/paravirt: Move handling of unstable PV clocks into paravirt_set_sched_clock() Sean Christopherson
2025-02-01  2:17 ` [PATCH 11/16] x86/paravirt: Don't use a PV sched_clock in CoCo guests with trusted TSC Sean Christopherson
2025-02-01  2:17 ` [PATCH 12/16] x86/kvmclock: Mark TSC as reliable when it's constant and nonstop Sean Christopherson
2025-02-01  2:17 ` [PATCH 13/16] x86/kvmclock: Get CPU base frequency from CPUID when it's available Sean Christopherson
2025-02-01  2:17 ` [PATCH 14/16] x86/kvmclock: Get TSC frequency from CPUID when its available Sean Christopherson
2025-02-01  2:17 ` [PATCH 15/16] x86/kvmclock: Stuff local APIC bus period when core crystal freq comes from CPUID Sean Christopherson
2025-02-04  5:35   ` Dan Carpenter
2025-02-05 22:11     ` Sean Christopherson [this message]
2025-02-01  2:17 ` [PATCH 16/16] x86/kvmclock: Use TSC for sched_clock if it's constant and non-stop Sean Christopherson
2025-02-07 17:23   ` Sean Christopherson
2025-02-08 18:03     ` Michael Kelley
2025-02-10 16:21       ` Sean Christopherson
2025-02-12 16:44         ` Michael Kelley
2025-02-12 22:55           ` Sean Christopherson
2025-02-11 14:39 ` [PATCH 00/16] x86/tsc: Try to wrangle PV clocks vs. TSC Borislav Petkov
2025-02-11 16:28   ` Sean Christopherson
  -- strict thread matches above, loose matches on Subject: below --
2025-02-04  4:59 [PATCH 15/16] x86/kvmclock: Stuff local APIC bus period when core crystal freq comes from CPUID kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z6PiJ3HPf86O0mkr@google.com \
    --to=seanjc@google.com \
    --cc=dan.carpenter@linaro.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.