From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754137AbbKJP7M (ORCPT ); Tue, 10 Nov 2015 10:59:12 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:30548 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553AbbKJP7J (ORCPT ); Tue, 10 Nov 2015 10:59:09 -0500 X-IronPort-AV: E=Sophos;i="5.20,271,1444694400"; d="scan'208";a="317151631" Date: Tue, 10 Nov 2015 15:58:53 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Arnd Bergmann CC: , Stefano Stabellini , , , Subject: Re: [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall In-Reply-To: <4039287.QS1nrAMb0E@wuerfel> Message-ID: References: <1447156675-7418-7-git-send-email-stefano.stabellini@eu.citrix.com> <4039287.QS1nrAMb0E@wuerfel> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Nov 2015, Arnd Bergmann wrote: > On Tuesday 10 November 2015 11:57:55 Stefano Stabellini wrote: > > + op.u.settime64.nsecs = now.tv_nsec; > > + op.u.settime64.system_time = arch_timer_read_counter() * (u64)NSEC_PER_SEC; > > + do_div(op.u.settime64.system_time, arch_timer_get_rate()); > > NSEC_PER_SEC is a large number, doesn't that multiplication overflow the > 64-bit system_time variable? It could be a concern, you are right. I think I can solve this issue and remove multiple do_divs by calculating nsec_per_tick at initialization time and use it here and in xen_read_wallclock. > > + printk("GTOD: Setting to %llu.%u at %llu\n", > > %llu.%09u > > so you get the leading zeroes. > > > + op.u.settime64.secs, > > + op.u.settime64.nsecs, > > + op.u.settime64.system_time); > > + (void)HYPERVISOR_platform_op(&op); > > Arnd > From mboxrd@z Thu Jan 1 00:00:00 1970 From: stefano.stabellini@eu.citrix.com (Stefano Stabellini) Date: Tue, 10 Nov 2015 15:58:53 +0000 Subject: [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall In-Reply-To: <4039287.QS1nrAMb0E@wuerfel> References: <1447156675-7418-7-git-send-email-stefano.stabellini@eu.citrix.com> <4039287.QS1nrAMb0E@wuerfel> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tue, 10 Nov 2015, Arnd Bergmann wrote: > On Tuesday 10 November 2015 11:57:55 Stefano Stabellini wrote: > > + op.u.settime64.nsecs = now.tv_nsec; > > + op.u.settime64.system_time = arch_timer_read_counter() * (u64)NSEC_PER_SEC; > > + do_div(op.u.settime64.system_time, arch_timer_get_rate()); > > NSEC_PER_SEC is a large number, doesn't that multiplication overflow the > 64-bit system_time variable? It could be a concern, you are right. I think I can solve this issue and remove multiple do_divs by calculating nsec_per_tick at initialization time and use it here and in xen_read_wallclock. > > + printk("GTOD: Setting to %llu.%u at %llu\n", > > %llu.%09u > > so you get the leading zeroes. > > > + op.u.settime64.secs, > > + op.u.settime64.nsecs, > > + op.u.settime64.system_time); > > + (void)HYPERVISOR_platform_op(&op); > > Arnd > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: Re: [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall Date: Tue, 10 Nov 2015 15:58:53 +0000 Message-ID: References: <1447156675-7418-7-git-send-email-stefano.stabellini@eu.citrix.com> <4039287.QS1nrAMb0E@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-path: In-Reply-To: <4039287.QS1nrAMb0E@wuerfel> Sender: linux-kernel-owner@vger.kernel.org To: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, Stefano Stabellini , xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org, Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, 10 Nov 2015, Arnd Bergmann wrote: > On Tuesday 10 November 2015 11:57:55 Stefano Stabellini wrote: > > + op.u.settime64.nsecs = now.tv_nsec; > > + op.u.settime64.system_time = arch_timer_read_counter() * (u64)NSEC_PER_SEC; > > + do_div(op.u.settime64.system_time, arch_timer_get_rate()); > > NSEC_PER_SEC is a large number, doesn't that multiplication overflow the > 64-bit system_time variable? It could be a concern, you are right. I think I can solve this issue and remove multiple do_divs by calculating nsec_per_tick at initialization time and use it here and in xen_read_wallclock. > > + printk("GTOD: Setting to %llu.%u at %llu\n", > > %llu.%09u > > so you get the leading zeroes. > > > + op.u.settime64.secs, > > + op.u.settime64.nsecs, > > + op.u.settime64.system_time); > > + (void)HYPERVISOR_platform_op(&op); > > Arnd >