lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 30 Oct 2023 17:04:22 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     x86@...nel.org
Cc:     linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
        Arjan van de Ven <arjan@...ux.intel.com>,
        feng.tang@...el.com
Subject: Re: [PATCH] x86/tsc: Have tsc=recalibrate override things

On Mon, Oct 30, 2023 at 05:00:50PM +0100, Peter Zijlstra wrote:
> ---
>  arch/x86/kernel/tsc.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 15f97c0abc9d..ebca304ecea0 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -1430,14 +1430,13 @@ static void tsc_refine_calibration_work(struct work_struct *work)
>  			hpet ? "HPET" : "PM_TIMER",
>  			(unsigned long)freq / 1000,
>  			(unsigned long)freq % 1000);
> +	} else {
>  
> -		return;
> +		/* Make sure we're within 1% */
> +		if (abs(tsc_khz - freq) > tsc_khz/100)
> +			goto out;
>  	}
>  
> -	/* Make sure we're within 1% */
> -	if (abs(tsc_khz - freq) > tsc_khz/100)
> -		goto out;
> -
>  	tsc_khz = freq;
>  	pr_info("Refined TSC clocksource calibration: %lu.%03lu MHz\n",
>  		(unsigned long)tsc_khz / 1000,
> @@ -1475,18 +1474,19 @@ static int __init init_tsc_clocksource(void)
>  	if (boot_cpu_has(X86_FEATURE_NONSTOP_TSC_S3))
>  		clocksource_tsc.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP;
>  
> -	/*
> -	 * When TSC frequency is known (retrieved via MSR or CPUID), we skip
> -	 * the refined calibration and directly register it as a clocksource.
> -	 */
>  	if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {
>  		if (boot_cpu_has(X86_FEATURE_ART))
>  			art_related_clocksource = &clocksource_tsc;
> -		clocksource_register_khz(&clocksource_tsc, tsc_khz);
> -		clocksource_unregister(&clocksource_tsc_early);
>  
> -		if (!tsc_force_recalibrate)
> -			return 0;
> +		/*
> +		 * When TSC frequency is known (retrieved via MSR or CPUID), we
> +		 * skip the refined calibration and directly register it as a
> +		 * clocksource.
> +		 */
> +		if (!tsc_force_recalibrate) {
> +			clocksource_register_khz(&clocksource_tsc, tsc_khz);
> +			clocksource_unregister(&clocksource_tsc_early);

+			return 0;

Clearly I should step away from the keyboard now.

> +		}
>  	}
>  
>  	schedule_delayed_work(&tsc_irqwork, 0);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ