Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3653694ybf; Tue, 3 Mar 2020 09:51:53 -0800 (PST) X-Google-Smtp-Source: ADFU+vu7hZH6Mxb4foVDKEv0nyboAaW0jSqvAQRL0rvX0RWkPN4VbNKdgdegCV1qobGZ/r+OjBac X-Received: by 2002:aca:c586:: with SMTP id v128mr3402010oif.166.1583257913518; Tue, 03 Mar 2020 09:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583257913; cv=none; d=google.com; s=arc-20160816; b=BPSro+NhXn8aDHS/N49/090H/7GIn8O6hzxY3ohQMVwNk1D5KqBwi7CfMiJNjozQXU Jd4t061BgxI+aB+SDINy342QuvzSt7KS3sPu4lsNeNER1YXvhCUO5P68XP5jnZSoK1Kf bhbo7IbbDhmu5ZNcr0jE9Yfgtow6MS84e2/DThJkt8nDDDCZCRFh4FHsLONAmUbSbSkg B1EMGH4gyn2xNEL44bZ3WiuB8bogayHxBnQwMJLHqK6PUwpy0RLSf71qiGmO0gpMcLqv hWC7L6FFfemPsOZBIlOiuHx7soUz+BDHwKec6a9vswG61ufblV22bGEzBYdCFsQf1yID 8B9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=blPAI2shH3rWojWqIN0i+nzevMm3EnVDHWcNz3TP2so=; b=v8Y2R/IX/U5ijQ3m3lRJFqmPo1aQTixwuc/+EorZ/nrgnojtwZIan/HqgumkupoS+m AHre9xgT1JUIPgwoRzOVtQPsghHfGjgj3rRRvS6sgHA+BDUvpBd8egga6LT/f+Bchp2B KD3msisNijkSjKbx1rQa0i+3Oxx+3pU4RtWO9LmpOJg68KjB4u9Ax+nc0mud9+mSLBRM ATeube8hQdvILpJcJ3cEzDPrCJbM0XZmSWGQ29ge5akqOb9VV/hcmQ/HspjRYzEoUO93 z0ntwsKMewbG2A5wPXJ17hkae9wd7rfxD9qCXmDW1AQP4b88i5qGdLxahXFIrZ1ViUd1 FcEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t/7tfABG"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v92si4314804otb.160.2020.03.03.09.51.41; Tue, 03 Mar 2020 09:51:53 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="t/7tfABG"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731435AbgCCRut (ORCPT + 99 others); Tue, 3 Mar 2020 12:50:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:58526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731565AbgCCRup (ORCPT ); Tue, 3 Mar 2020 12:50:45 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9BD2214D8; Tue, 3 Mar 2020 17:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257844; bh=mwvdgSaAumLLSTH4CcBe04nOPmVj/nufXabgBS1mi6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t/7tfABG36EJEapjjFk9+LG7qwkVdaBm7ZvgnHCtE1WwS6PYpmojXCOicPhW2lP+X B+Gg+0VuBRbFPcd6J6KmxQLWsZ5kyXPi49Mxpkk4JMek5/5FfnZtA5iWKxUdakaP1n r3O/cwLgNSDWGc8nPBkNqN33RkTFdh+v22ZPBsBo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner Subject: [PATCH 5.5 151/176] lib/vdso: Update coarse timekeeper unconditionally Date: Tue, 3 Mar 2020 18:43:35 +0100 Message-Id: <20200303174322.100950388@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174304.593872177@linuxfoundation.org> References: <20200303174304.593872177@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 9f24c540f7f8eb3a981528da9a9a636a5bdf5987 upstream. The low resolution parts of the VDSO, i.e.: clock_gettime(CLOCK_*_COARSE), clock_getres(), time() can be used even if there is no VDSO capable clocksource. But if an architecture opts out of the VDSO data update then this information becomes stale. This affects ARM when there is no architected timer available. The lack of update causes userspace to use stale data forever. Make the update of the low resolution parts unconditional and only skip the update of the high resolution parts if the architecture requests it. Fixes: 44f57d788e7d ("timekeeping: Provide a generic update_vsyscall() implementation") Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20200114185946.765577901@linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/time/vsyscall.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) --- a/kernel/time/vsyscall.c +++ b/kernel/time/vsyscall.c @@ -28,11 +28,6 @@ static inline void update_vdso_data(stru vdata[CS_RAW].mult = tk->tkr_raw.mult; vdata[CS_RAW].shift = tk->tkr_raw.shift; - /* CLOCK_REALTIME */ - vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME]; - vdso_ts->sec = tk->xtime_sec; - vdso_ts->nsec = tk->tkr_mono.xtime_nsec; - /* CLOCK_MONOTONIC */ vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC]; vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; @@ -70,12 +65,6 @@ static inline void update_vdso_data(stru vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_TAI]; vdso_ts->sec = tk->xtime_sec + (s64)tk->tai_offset; vdso_ts->nsec = tk->tkr_mono.xtime_nsec; - - /* - * Read without the seqlock held by clock_getres(). - * Note: No need to have a second copy. - */ - WRITE_ONCE(vdata[CS_HRES_COARSE].hrtimer_res, hrtimer_resolution); } void update_vsyscall(struct timekeeper *tk) @@ -84,20 +73,17 @@ void update_vsyscall(struct timekeeper * struct vdso_timestamp *vdso_ts; u64 nsec; - if (!__arch_update_vdso_data()) { - /* - * Some architectures might want to skip the update of the - * data page. - */ - return; - } - /* copy vsyscall data */ vdso_write_begin(vdata); vdata[CS_HRES_COARSE].clock_mode = __arch_get_clock_mode(tk); vdata[CS_RAW].clock_mode = __arch_get_clock_mode(tk); + /* CLOCK_REALTIME also required for time() */ + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME]; + vdso_ts->sec = tk->xtime_sec; + vdso_ts->nsec = tk->tkr_mono.xtime_nsec; + /* CLOCK_REALTIME_COARSE */ vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE]; vdso_ts->sec = tk->xtime_sec; @@ -110,7 +96,18 @@ void update_vsyscall(struct timekeeper * nsec = nsec + tk->wall_to_monotonic.tv_nsec; vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &vdso_ts->nsec); - update_vdso_data(vdata, tk); + /* + * Read without the seqlock held by clock_getres(). + * Note: No need to have a second copy. + */ + WRITE_ONCE(vdata[CS_HRES_COARSE].hrtimer_res, hrtimer_resolution); + + /* + * Architectures can opt out of updating the high resolution part + * of the VDSO. + */ + if (__arch_update_vdso_data()) + update_vdso_data(vdata, tk); __arch_update_vsyscall(vdata, tk);