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: <alpine.DEB.2.22.394.2107132051590.2135909@anisinha-lenovo>
Date:   Tue, 13 Jul 2021 21:01:06 +0530 (IST)
From:   Ani Sinha <ani@...sinha.ca>
To:     Peter Zijlstra <peterz@...radead.org>
cc:     Wei Liu <wei.liu@...nel.org>, Ani Sinha <ani@...sinha.ca>,
        linux-kernel@...r.kernel.org, anirban.sinha@...ia.com,
        mikelley@...rosoft.com, "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Dexuan Cui <decui@...rosoft.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        linux-hyperv@...r.kernel.org
Subject: Re: [PATCH] Hyper-V: fix for unwanted manipulation of sched_clock
 when TSC marked unstable



On Tue, 13 Jul 2021, Peter Zijlstra wrote:

> On Tue, Jul 13, 2021 at 01:04:46PM +0000, Wei Liu wrote:
> > On Tue, Jul 13, 2021 at 08:35:21AM +0530, Ani Sinha wrote:
> > > 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.
> >
> > Correct me if I'm wrong, what you're trying to address is that
> > sched_clock remains marked as unstable even after Linux has switched to
> > a stable clock source.
> >
> > I think a better approach will be to mark the sched_clock as stable when
> > we switch to the paravirtualized clock source.
>
> No.. unstable->stable transitions are unsound. You get to switch to your
> paravirt clock earlier.
>

I believe manipulating sched_clock was never the intention of the original
author who added the code to mark tsc as unstable on hyper-V:

commit 88c9281a9fba67636ab26c1fd6afbc78a632374f
Author: Vitaly Kuznetsov <vkuznets@...hat.com>
Date:   Wed Aug 19 09:54:24 2015 -0700

    x86/hyperv: Mark the Hyper-V TSC as unstable


The original author simply wanted to mark TSC as unstable on hyper-V
systems because of reasons the above commit log will describe. Sched clock
manipulation happened accidentally because from where the
mark_tsc_unstable() was being called. This patch simply fixes this.

Michael Kelly from Microsoft has tested this patch already.

--Ani

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ