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:   Tue, 17 Jul 2018 11:43:51 -0400
From:   Boris Ostrovsky <boris.ostrovsky@...cle.com>
To:     Pavel Tatashin <pasha.tatashin@...cle.com>,
        steven.sistare@...cle.com, daniel.m.jordan@...cle.com,
        linux@...linux.org.uk, schwidefsky@...ibm.com,
        heiko.carstens@...ibm.com, john.stultz@...aro.org,
        sboyd@...eaurora.org, x86@...nel.org, linux-kernel@...r.kernel.org,
        mingo@...hat.com, tglx@...utronix.de, hpa@...or.com,
        douly.fnst@...fujitsu.com, peterz@...radead.org, prarit@...hat.com,
        feng.tang@...el.com, pmladek@...e.com, gnomes@...rguk.ukuu.org.uk,
        linux-s390@...r.kernel.org, jgross@...e.com
Subject: Re: [PATCH v13 07/18] x86/xen/time: output xen sched_clock time from
 0

On 07/11/2018 08:04 PM, Pavel Tatashin wrote:
> It is expected for sched_clock() to output data from 0, when system boots.
> Add an offset xen_sched_clock_offset (similarly how it is done in other
> hypervisors i.e. kvm_sched_clock_offset) to count sched_clock() from 0,
> when time is first initialized.
>
> Signed-off-by: Pavel Tatashin <pasha.tatashin@...cle.com>
> ---
>  arch/x86/xen/time.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
> index 2ad61bf896d6..3c6f3d603373 100644
> --- a/arch/x86/xen/time.c
> +++ b/arch/x86/xen/time.c
> @@ -31,6 +31,8 @@
>  /* Xen may fire a timer up to this many ns early */
>  #define TIMER_SLOP	100000
>  
> +static u64 xen_sched_clock_offset __read_mostly;
> +
>  /* Get the TSC speed from Xen */
>  static unsigned long xen_tsc_khz(void)
>  {
> @@ -57,6 +59,11 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs)
>  	return xen_clocksource_read();
>  }
>  
> +static u64 xen_sched_clock(void)
> +{
> +	return xen_clocksource_read() - xen_sched_clock_offset;
> +}


Should other invocations of xen_clocksource_read() also be offset?

-boris


> +
>  static void xen_read_wallclock(struct timespec64 *ts)
>  {
>  	struct shared_info *s = HYPERVISOR_shared_info;
> @@ -367,7 +374,7 @@ void xen_timer_resume(void)
>  }
>  
>  static const struct pv_time_ops xen_time_ops __initconst = {
> -	.sched_clock = xen_clocksource_read,
> +	.sched_clock = xen_sched_clock,
>  	.steal_clock = xen_steal_clock,
>  };
>  
> @@ -505,6 +512,7 @@ static void __init xen_time_init(void)
>  
>  void __init xen_init_time_ops(void)
>  {
> +	xen_sched_clock_offset = xen_clocksource_read();
>  	pv_time_ops = xen_time_ops;
>  
>  	x86_init.timers.timer_init = xen_time_init;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ