[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86: Limit the non-architectural constant TSC model checks


  • To: Kevin Lampis <kevin.lampis@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Wed, 3 Dec 2025 18:07:15 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NdQjUmBHbThEu3wLwnA+hvhbsUwyLXlz/w2W1XAjPnI=; b=GoKp3/BRT8z4BjmHjgNX33ilqomimEpcbvdMnwQ9WHbATUDraB0iAvgD3GhKcHooG0QRgrzR4hmXi24hOe2AOKgDxasHtDvafy1Hh2RfyLMFegoOvhVwtoAua7EjZUVkdHbKp1n8US8kQ53UmKHJrOUQlQ8vw2s1BisfycAcipQz0LfMMatU8Z9teAQnggF3ehRtT8zHH4sfD7THtH9Zs1IXsYPWhPkDYkHMpCwARtA6D39I0r7pPR+M5WTQxA/Giw5ODpiPWoi1J4gICRjPMrtTJ74PdvSx5qI2ujTIndGCikZi1IEqBoQmOhXpRgVQqOa65nd+84CEHt06ynuOPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C64aqkEAYSijQfC61tSU8MA4NZWmnqG4JWZcKThiJB3IX0F6j94mHffgtLP6pbxPbCmgVq62RcN9a+gCpzADolF49zbqGfI4UMDDuqeXRYqXdycwfkJnLYaQxDLMhAPaoT1gCoDbih40I6fybby/lCwI7AEUWvcOsWulLwp3n4hO+nehEYeZ8tdiGdGEx+dz/wap4QLhoXSfa2kEEmVEVVGLRrXLwRTNcD6Xs2cZGAd3RP7qFR6XWS0XulggwXo2OdWnZXQOeF+bqjL6ONTcwGwtoc1IreuqdYI2zchZYY9UC+KuJMFSoZ9FvQrnpUCAAxUwSvSqzDwlO7qTBWWtsg==
  • Cc: <jbeulich@xxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <roger.pau@xxxxxxxxxx>, Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 03 Dec 2025 17:07:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed Dec 3, 2025 at 5:06 PM CET, Kevin Lampis wrote:
> There are some older Intel CPUs which have CONSTANT_TSC behavior but
> don't advertise it through CPUID. This change replaces the previous
> open-ended check with a definitive range to make it clear that this only
> applies to a specific set of CPUs and that later CPUs like Family 18+
> won't need to be included.
>
> Signed-off-by: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
> ---
>  xen/arch/x86/cpu/intel.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
> index 2bb9956a79..1c37179bc5 100644
> --- a/xen/arch/x86/cpu/intel.c
> +++ b/xen/arch/x86/cpu/intel.c
> @@ -673,15 +673,15 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
>       /* Work around errata */
>       Intel_errata_workarounds(c);
>  
> -     if ( ( c->family == 15 && c->model >= 0x03 ) ||
> -          ( c->family == 6 && c->model >= 0x0e ) )
> -             __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
> -
> +     /* Use a model specific check for some older CPUs that have
> +      * constant TSC but may not report it via CPUID. */

nit:  This comment, or some variation of it, should (imo) be inside the branch
you add instead. Also, multiline comments follow Xen style elsewhere in
the file.

>       if (cpu_has(c, X86_FEATURE_ITSC)) {
>               __set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
>               __set_bit(X86_FEATURE_NONSTOP_TSC, c->x86_capability);
>               __set_bit(X86_FEATURE_TSC_RELIABLE, c->x86_capability);
> -     }
> +     } else if ( ( c->vfm >= INTEL_P4_PRESCOTT && c->vfm <= 
> INTEL_P4_CEDARMILL ) ||
> +                 ( c->vfm >= INTEL_CORE_YONAH && c->vfm <= INTEL_IVYBRIDGE ) 
> )

I understand this is code motion + macro usage, but it might be worth gating
everything by !cpu_has(c, X86_FEATURE_HYPERVISOR). Otherwise you risk getting
your assumptions wrong when running virtualised.

This might be QEMU TCG, or other shenanigans with live migration when running
virtualised and subject to guest-unaware live-migrations guest-unaware live
migration.

IOW: If you're running virtualised and you have no ITSC it's probably because
your hypervisor didn't want you making assumptions about it based on fam/model
checks.

Not that any CSP would use those processors, but my point stands.

Cheers,
Alejandro



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.