All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org
Cc: "Juergen Gross" <jgross@suse.com>,
	kvm@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>,
	y2038@lists.linaro.org,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"John Stultz" <john.stultz@linaro.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	"Marcos Paulo de Souza" <marcos.souza.org@gmail.com>
Subject: Re: [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64
Date: Thu, 19 Oct 2017 13:46:50 +0200	[thread overview]
Message-ID: <9f0b30dd-9d6e-8b31-bb08-f4ad20acbf9e__26363.5085234002$1508413685$gmane$org@redhat.com> (raw)
In-Reply-To: <20171019105824.3035694-1-arnd@arndb.de>

On 19/10/2017 12:57, Arnd Bergmann wrote:
> The x86 platform operations are fairly isolated, so we can
> change them from using timespec to timespec64. I checked that
> All the users and callers are safe, and there is only one
> critical function that is broken beyond 2106:
> 
> pvclock_read_wallclock() uses a 32-bit number of seconds since
> the epoch to communicate the boot time between host and guest
> in a virtual environment. This will work until 2106, but we
> should ideally find a replacement anyway. I've added a comment
> about it there.
> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2 changes:
> - move comment block (Boris)
> - remove unnecessary type cast (Boris)
> - fix format string (0day bot)
> - fix include order (0day bot)
> ---
>  arch/x86/include/asm/intel_mid_vrtc.h        |  4 ++--
>  arch/x86/include/asm/mc146818rtc.h           |  4 ++--
>  arch/x86/include/asm/pvclock.h               |  2 +-
>  arch/x86/include/asm/x86_init.h              |  7 +++----
>  arch/x86/kernel/kvmclock.c                   |  4 ++--
>  arch/x86/kernel/pvclock.c                    | 15 +++++++++++----
>  arch/x86/kernel/rtc.c                        | 16 ++++++++--------
>  arch/x86/platform/intel-mid/intel_mid_vrtc.c | 12 ++++++------
>  arch/x86/xen/time.c                          | 10 +++++-----
>  9 files changed, 40 insertions(+), 34 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index d88967659098..01c76e8cd4be 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
>   * have elapsed since the hypervisor wrote the data. So we try to account for
>   * that with system time
>   */
> -static void kvm_get_wallclock(struct timespec *now)
> +static void kvm_get_wallclock(struct timespec64 *now)
>  {
>  	struct pvclock_vcpu_time_info *vcpu_time;
>  	int low, high;
> @@ -77,7 +77,7 @@ static void kvm_get_wallclock(struct timespec *now)
>  	put_cpu();
>  }
>  
> -static int kvm_set_wallclock(const struct timespec *now)
> +static int kvm_set_wallclock(const struct timespec64 *now)
>  {
>  	return -1;
>  }
> diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
> index 5c3f6d6a5078..013bef851664 100644
> --- a/arch/x86/kernel/pvclock.c
> +++ b/arch/x86/kernel/pvclock.c
> @@ -121,26 +121,33 @@ u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
>  
>  void pvclock_read_wallclock(struct pvclock_wall_clock *wall_clock,
>  			    struct pvclock_vcpu_time_info *vcpu_time,
> -			    struct timespec *ts)
> +			    struct timespec64 *ts)
>  {
>  	u32 version;
>  	u64 delta;
> -	struct timespec now;
> +	struct timespec64 now;
>  
>  	/* get wallclock at system boot */
>  	do {
>  		version = wall_clock->version;
>  		rmb();		/* fetch version before time */
> +		/*
> +		 * Note: wall_clock->sec is a u32 value, so it can
> +		 * only store dates between 1970 and 2106. To allow
> +		 * times beyond that, we need to create a new hypercall
> +		 * interface with an extended pvclock_wall_clock structure
> +		 * like ARM has.
> +		 */
>  		now.tv_sec  = wall_clock->sec;
>  		now.tv_nsec = wall_clock->nsec;
>  		rmb();		/* fetch time before checking version */
>  	} while ((wall_clock->version & 1) || (version != wall_clock->version));
>  
>  	delta = pvclock_clocksource_read(vcpu_time);	/* time since system boot */
> -	delta += now.tv_sec * (u64)NSEC_PER_SEC + now.tv_nsec;
> +	delta += now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
>  
>  	now.tv_nsec = do_div(delta, NSEC_PER_SEC);
>  	now.tv_sec = delta;
>  
> -	set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> +	set_normalized_timespec64(ts, now.tv_sec, now.tv_nsec);
>  }
For kvmclock.c and pvclock.c,

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-10-19 11:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 10:53 [PATCH 1/2] x86: don't include asm/x86_init.h in asm/setup.h Arnd Bergmann
2017-10-19 10:57 ` [PATCH v2 2/2] x86: convert x86_platform_ops to timespec64 Arnd Bergmann
2017-10-19 10:57   ` Arnd Bergmann
2017-10-19 11:46   ` Paolo Bonzini [this message]
2017-10-19 11:46   ` Paolo Bonzini
2017-10-19 13:46   ` [tip:x86/timers] x86: Convert " tip-bot for Arnd Bergmann
2017-10-19 13:45 ` [tip:x86/timers] x86: Don't include asm/x86_init.h in asm/setup.h tip-bot for Arnd Bergmann
2017-10-20 11:11   ` Ingo Molnar
2017-10-20 11:37     ` Arnd Bergmann
2017-10-20 11:48       ` Thomas Gleixner
2017-10-20 12:09         ` Arnd Bergmann
2017-10-20 11:41     ` Thomas Gleixner
2017-10-20 12:20       ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='9f0b30dd-9d6e-8b31-bb08-f4ad20acbf9e__26363.5085234002$1508413685$gmane$org@redhat.com' \
    --to=pbonzini@redhat.com \
    --cc=arnd@arndb.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=john.stultz@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcos.souza.org@gmail.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.