From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] xen/arm: set the system time in Xen via the XENPF_settime hypercall
Date: Thu, 05 Nov 2015 19:58:32 +0100 [thread overview]
Message-ID: <6188457.uvvdcZaVNM@wuerfel> (raw)
In-Reply-To: <1446743385-12848-3-git-send-email-stefano.stabellini@eu.citrix.com>
On Thursday 05 November 2015 17:09:45 Stefano Stabellini wrote:
> If Linux is running as dom0, call XENPF_settime to update the system
> time in Xen on pvclock_gtod notifications.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
> arch/arm/xen/enlighten.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index b6aea9c..0176db0 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -28,6 +28,7 @@
> #include <linux/cpufreq.h>
> #include <linux/cpu.h>
> #include <linux/console.h>
> +#include <linux/pvclock_gtod.h>
> #include <linux/timekeeping.h>
> #include <clocksource/arm_arch_timer.h>
>
> @@ -123,6 +124,50 @@ static void xen_read_wallclock(struct timespec *ts)
> set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> }
>
> +static int xen_pvclock_gtod_notify(struct notifier_block *nb,
> + unsigned long was_set, void *priv)
> +{
> + /* Protected by the calling core code serialization */
> + static struct timespec next_sync;
> +
> + struct xen_platform_op op;
> + struct timespec now;
Again, use timespec64
> + now = __current_kernel_time();
We don't have __current_kernel_time64() yet, but it is trivial
to add, just follow the example of
current_kernel_time()/current_kernel_time64() and convert the
existing __current_kernel_time() function into a static
inline wrapper for the new __current_kernel_time64().
> + /*
> + * We only take the expensive HV call when the clock was set
> + * or when the 11 minutes RTC synchronization time elapsed.
> + */
> + if (!was_set && timespec_compare(&now, &next_sync) < 0)
> + return NOTIFY_OK;
> +
> + op.interface_version = XENPF_INTERFACE_VERSION;
> + op.cmd = XENPF_settime;
> + op.u.settime.secs = now.tv_sec;
> + op.u.settime.nsecs = now.tv_nsec;
> + op.u.settime.system_time = arch_timer_read_counter();
> + printk("GTOD: Setting to %ld.%ld at %lld\n",
> + (long)op.u.settime.secs,
> + (long)op.u.settime.nsecs,
> + (long long)op.u.settime.system_time);
> + (void)HYPERVISOR_dom0_op(&op);
I guess we will also need a XENPF_settime64 interface, but at
least we can get away with implementing only that one on ARM,
while x86 will have to support both the 32-bit and 64-bit
based variant.
Arnd
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: xen-devel@lists.xensource.com,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 3/3] xen/arm: set the system time in Xen via the XENPF_settime hypercall
Date: Thu, 05 Nov 2015 19:58:32 +0100 [thread overview]
Message-ID: <6188457.uvvdcZaVNM@wuerfel> (raw)
In-Reply-To: <1446743385-12848-3-git-send-email-stefano.stabellini@eu.citrix.com>
On Thursday 05 November 2015 17:09:45 Stefano Stabellini wrote:
> If Linux is running as dom0, call XENPF_settime to update the system
> time in Xen on pvclock_gtod notifications.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
> arch/arm/xen/enlighten.c | 52 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index b6aea9c..0176db0 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -28,6 +28,7 @@
> #include <linux/cpufreq.h>
> #include <linux/cpu.h>
> #include <linux/console.h>
> +#include <linux/pvclock_gtod.h>
> #include <linux/timekeeping.h>
> #include <clocksource/arm_arch_timer.h>
>
> @@ -123,6 +124,50 @@ static void xen_read_wallclock(struct timespec *ts)
> set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
> }
>
> +static int xen_pvclock_gtod_notify(struct notifier_block *nb,
> + unsigned long was_set, void *priv)
> +{
> + /* Protected by the calling core code serialization */
> + static struct timespec next_sync;
> +
> + struct xen_platform_op op;
> + struct timespec now;
Again, use timespec64
> + now = __current_kernel_time();
We don't have __current_kernel_time64() yet, but it is trivial
to add, just follow the example of
current_kernel_time()/current_kernel_time64() and convert the
existing __current_kernel_time() function into a static
inline wrapper for the new __current_kernel_time64().
> + /*
> + * We only take the expensive HV call when the clock was set
> + * or when the 11 minutes RTC synchronization time elapsed.
> + */
> + if (!was_set && timespec_compare(&now, &next_sync) < 0)
> + return NOTIFY_OK;
> +
> + op.interface_version = XENPF_INTERFACE_VERSION;
> + op.cmd = XENPF_settime;
> + op.u.settime.secs = now.tv_sec;
> + op.u.settime.nsecs = now.tv_nsec;
> + op.u.settime.system_time = arch_timer_read_counter();
> + printk("GTOD: Setting to %ld.%ld at %lld\n",
> + (long)op.u.settime.secs,
> + (long)op.u.settime.nsecs,
> + (long long)op.u.settime.system_time);
> + (void)HYPERVISOR_dom0_op(&op);
I guess we will also need a XENPF_settime64 interface, but at
least we can get away with implementing only that one on ARM,
while x86 will have to support both the 32-bit and 64-bit
based variant.
Arnd
next prev parent reply other threads:[~2015-11-05 18:58 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 17:09 [PATCH 0/3] Xen wallclock on arm and arm64 Stefano Stabellini
2015-11-05 17:09 ` Stefano Stabellini
2015-11-05 17:09 ` [PATCH 1/3] xen/arm: introduce xen_read_wallclock Stefano Stabellini
2015-11-05 17:09 ` Stefano Stabellini
2015-11-05 18:53 ` Arnd Bergmann
2015-11-05 18:53 ` Arnd Bergmann
2015-11-06 15:09 ` Stefano Stabellini
2015-11-06 15:09 ` Stefano Stabellini
2015-11-06 15:56 ` Arnd Bergmann
2015-11-06 15:56 ` Arnd Bergmann
2015-11-09 13:53 ` Stefano Stabellini
2015-11-09 13:53 ` Stefano Stabellini
2015-11-09 16:16 ` Arnd Bergmann
2015-11-09 16:16 ` Arnd Bergmann
2015-11-09 17:14 ` Stefano Stabellini
2015-11-09 17:14 ` Stefano Stabellini
2015-11-09 20:42 ` Arnd Bergmann
2015-11-09 20:42 ` Arnd Bergmann
2015-11-06 12:26 ` Mark Rutland
2015-11-06 12:26 ` Mark Rutland
2015-11-06 14:34 ` Stefano Stabellini
2015-11-06 14:34 ` Stefano Stabellini
2015-11-05 17:09 ` [PATCH 2/3] xen/arm: introduce HYPERVISOR_dom0_op on arm and arm64 Stefano Stabellini
2015-11-05 17:09 ` Stefano Stabellini
2015-11-05 17:21 ` [Xen-devel] " Jan Beulich
2015-11-05 17:21 ` Jan Beulich
2015-11-06 14:45 ` Stefano Stabellini
2015-11-06 14:45 ` [Xen-devel] " Stefano Stabellini
2015-11-05 17:09 ` [PATCH 3/3] xen/arm: set the system time in Xen via the XENPF_settime hypercall Stefano Stabellini
2015-11-05 17:09 ` Stefano Stabellini
2015-11-05 17:45 ` [Xen-devel] " David Vrabel
2015-11-05 17:45 ` David Vrabel
2015-11-06 14:59 ` Stefano Stabellini
2015-11-06 14:59 ` Stefano Stabellini
2015-11-05 18:58 ` Arnd Bergmann [this message]
2015-11-05 18:58 ` Arnd Bergmann
2015-11-09 14:10 ` Stefano Stabellini
2015-11-09 14:10 ` Stefano Stabellini
2015-11-09 16:10 ` Arnd Bergmann
2015-11-09 16:10 ` Arnd Bergmann
2015-11-09 17:17 ` Stefano Stabellini
2015-11-09 17:17 ` Stefano Stabellini
2015-11-09 17:42 ` Stefano Stabellini
2015-11-09 17:42 ` Stefano Stabellini
2015-11-09 20:45 ` Arnd Bergmann
2015-11-09 20:45 ` Arnd Bergmann
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=6188457.uvvdcZaVNM@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.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.