Received: by 10.192.165.148 with SMTP id m20csp1163438imm; Fri, 27 Apr 2018 13:57:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp4EA8KSjnNVfGSO0qXkTZ+/C1tGNsh9YFjXVE9CH1L42Tx0oy2dPoT0NkKFfV99r2X+tu4 X-Received: by 2002:a17:902:206:: with SMTP id 6-v6mr3601130plc.376.1524862676471; Fri, 27 Apr 2018 13:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524862676; cv=none; d=google.com; s=arc-20160816; b=h8+fpWxxjDZzdV72y0cx6jm+VPQr0gbGOb3PdBl91S1WRO0qTor1fztSAFH+tlyxc9 85JAO6HmNHgCvP1/a6su6Y1jybIa4qCI3H60v43s8mfxj2VsZi5Ij1jTTg8D4VUazxzf BcUc32IG+yzGlAfegSqyEH0Jd01N/aFm8Vql5P/TC8ceigh4/sayD4/6SuPA5StUwr38 b58002MQzvx5z9XpZI06KwrgeJg+JTrqh0EzxzgQs2bmEY3TXm813bRBUHh2FJBhsHT+ VNyWzoOk8vTjiSAOnxqX4zjRfrjhgr6rbTMY1NVgzO1/NZimr52+CdpbNcItcI/eFwCR nlRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=yzy3C9gh28k2YOdUFgauqBt/wrw/9dCPJfGfkOE7S8k=; b=qFbiupT8s4j7+Vjr9goDSTQO1UQhjgJEa/mXI+4X+mL2e7q7UEugkxafz9O3pn+Q+d 2pFjatlaKrzmRXoM4wRJaX+pYaIO/LxMmE/7ihI/ErQJZUrb1pS0xJImid9udZmeTzIB RGrObMUKppDzqyilj8+tbMpVgtI/Bb3AHrKNjOVFirhdE9ICB4xVWathbLwZjHAyB2XE BnchKkkhcy64Epb5Pspgk4ldArArjU5UjocyHocHYjGYPknwm1LkRs0LPLDY9X7m5RLT iWgsfZO/2yZwfPmw7TJuBdkqfFTM2WFwusuCujsB+xBFubfHlHmKNw0v1uEVd/XBo4uC yvcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si1873284plb.549.2018.04.27.13.57.40; Fri, 27 Apr 2018 13:57:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759245AbeD0U43 (ORCPT + 99 others); Fri, 27 Apr 2018 16:56:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58302 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758944AbeD0U42 (ORCPT ); Fri, 27 Apr 2018 16:56:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47F7A8DC4A; Fri, 27 Apr 2018 20:56:27 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id C6BF12026985; Fri, 27 Apr 2018 20:56:22 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Fri, 27 Apr 2018 22:56:22 +0200 Date: Fri, 27 Apr 2018 22:56:22 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Arnd Bergmann Cc: Thomas Gleixner , y2038@lists.linaro.org, Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Jan Kiszka , Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Joao Martins , "Rafael J. Wysocki" , Andy Shevchenko , Borislav Petkov , Andy Lutomirski , John Stultz , linux-kernel@vger.kernel.org, jailhouse-dev@googlegroups.com, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH] [v3] x86: Convert x86_platform_ops to timespec64 Message-ID: <20180427205621.GE23874@flask> References: <20180427201435.3194219-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180427201435.3194219-1-arnd@arndb.de> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 27 Apr 2018 20:56:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 27 Apr 2018 20:56:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-04-27 22:13+0200, Arnd Bergmann: > 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 > Signed-off-by: Arnd Bergmann > --- > v2 changes: > - move comment block (Boris) > - remove unnecessary type cast (Boris) > - fix format string (0day bot) > - fix include order (0day bot) > > v3 changes: > - add jailhouse specific change > - avoid include file header by relying on another > patch ("timekeeping: Remove timespec64 hack") > > Not sure how we want to merge this (assuming the last modification > worked, this has seen little testing). The "timekeeping: Remove > timespec64 hack" patch should go through the timekeeping branch > in tip, while this one is for x86. I assume the linux-tip maintainers > can come up with a plan. > --- > diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h > @@ -12,7 +12,7 @@ void pvclock_set_flags(u8 flags); > unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src); > void pvclock_read_wallclock(struct pvclock_wall_clock *wall, > struct pvclock_vcpu_time_info *vcpu, > - struct timespec *ts); > + struct timespec64 *ts); > void pvclock_resume(void); > > void pvclock_touch_watchdogs(void); > diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > @@ -53,7 +53,7 @@ static struct pvclock_wall_clock *wall_clock; > * 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; > @@ -72,7 +72,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 -ENODEV; > } > diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c > @@ -123,28 +123,35 @@ 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. > + */ (Modern TSC extensions stripped pvclock of all advantages, so we'll likely abandon pvclock by then.) > 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); > } > > void pvclock_set_pvti_cpu0_va(struct pvclock_vsyscall_time_info *pvti) kvmclock and pvclock changes Acked-by: Radim Krčmář