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]
Message-ID: <CY4PR21MB15866351E83212975EA02C34D7149@CY4PR21MB1586.namprd21.prod.outlook.com>
Date:   Tue, 13 Jul 2021 17:25:59 +0000
From:   Michael Kelley <mikelley@...rosoft.com>
To:     Ani Sinha <ani@...sinha.ca>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     "anirban.sinha@...ia.com" <anirban.sinha@...ia.com>,
        KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "x86@...nel.org" <x86@...nel.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>
Subject: RE: [PATCH] Hyper-V: fix for unwanted manipulation of sched_clock
 when TSC marked unstable

From: Ani Sinha <ani@...sinha.ca> Sent: Monday, July 12, 2021 8:05 PM
> 
> Marking TSC as unstable has a side effect of marking sched_clock as
> unstable when TSC is still being used as the sched_clock. This is not
> desirable. Hyper-V ultimately uses a paravirtualized clock source that
> provides a stable scheduler clock even on systems without TscInvariant
> CPU capability. Hence, mark_tsc_unstable() call should be called _after_
> scheduler clock has been changed to the paravirtualized clocksource. This
> will prevent any unwanted manipulation of the sched_clock. Only TSC will
> be correctly marked as unstable.
> 
> Signed-off-by: Ani Sinha <ani@...sinha.ca>
> ---
>  arch/x86/kernel/cpu/mshyperv.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 22f13343b5da..715458b7729a 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -370,8 +370,6 @@ static void __init ms_hyperv_init_platform(void)
>  	if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
>  		wrmsrl(HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x1);
>  		setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> -	} else {
> -		mark_tsc_unstable("running on Hyper-V");
>  	}
> 
>  	/*
> @@ -432,6 +430,12 @@ static void __init ms_hyperv_init_platform(void)
>  	/* Register Hyper-V specific clocksource */
>  	hv_init_clocksource();
>  #endif
> +	/* TSC should be marked as unstable only after Hyper-V
> +	 * clocksource has been initialized. This ensures that the
> +	 * stability of the sched_clock is not altered.
> +	 */

For multi-line comments like the above, the first comment line
should just be "/*".  So:

	/* 
	 * TSC should be marked as unstable only after Hyper-V
	 * clocksource has been initialized. This ensures that the
	 * stability of the sched_clock is not altered.
	 */


> +	if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> +		mark_tsc_unstable("running on Hyper-V");
>  }
> 
>  static bool __init ms_hyperv_x2apic_available(void)
> --
> 2.25.1

Modulo the comment format,

Reviewed-by: Michael Kelley <mikelley@...rosoft.com>
Tested-by: Michael Kelley <mikelley@...rosoft.com> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ