linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, John Stultz <john.stultz@linaro.org>,
	Will Deacon <will.deacon@arm.com>,
	Daniel Mentz <danielmentz@google.com>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Prarit Bhargava <prarit@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Stephen Boyd <stephen.boyd@linaro.org>,
	Miroslav Lichvar <mlichvar@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 4.11 40/58] arm64/vdso: Fix nsec handling for CLOCK_MONOTONIC_RAW
Date: Tue, 27 Jun 2017 16:12:43 +0200	[thread overview]
Message-ID: <20170627141115.120537947@linuxfoundation.org> (raw)
In-Reply-To: <20170627141113.402913097@linuxfoundation.org>

4.11-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Will Deacon <will.deacon@arm.com>

commit dbb236c1ceb697a559e0694ac4c9e7b9131d0b16 upstream.

Recently vDSO support for CLOCK_MONOTONIC_RAW was added in
49eea433b326 ("arm64: Add support for CLOCK_MONOTONIC_RAW in
clock_gettime() vDSO"). Noticing that the core timekeeping code
never set tkr_raw.xtime_nsec, the vDSO implementation didn't
bother exposing it via the data page and instead took the
unshifted tk->raw_time.tv_nsec value which was then immediately
shifted left in the vDSO code.

Unfortunately, by accellerating the MONOTONIC_RAW clockid, it
uncovered potential 1ns time inconsistencies caused by the
timekeeping core not handing sub-ns resolution.

Now that the core code has been fixed and is actually setting
tkr_raw.xtime_nsec, we need to take that into account in the
vDSO by adding it to the shifted raw_time value, in order to
fix the user-visible inconsistency. Rather than do that at each
use (and expand the data page in the process), instead perform
the shift/addition operation when populating the data page and
remove the shift from the vDSO code entirely.

[jstultz: minor whitespace tweak, tried to improve commit
 message to make it more clear this fixes a regression]
Reported-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Tested-by: Daniel Mentz <danielmentz@google.com>
Acked-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Stephen Boyd <stephen.boyd@linaro.org>
Cc: Miroslav Lichvar <mlichvar@redhat.com>
Link: http://lkml.kernel.org/r/1496965462-20003-4-git-send-email-john.stultz@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm64/kernel/vdso.c              |    5 +++--
 arch/arm64/kernel/vdso/gettimeofday.S |    1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -221,10 +221,11 @@ void update_vsyscall(struct timekeeper *
 		/* tkr_mono.cycle_last == tkr_raw.cycle_last */
 		vdso_data->cs_cycle_last	= tk->tkr_mono.cycle_last;
 		vdso_data->raw_time_sec		= tk->raw_time.tv_sec;
-		vdso_data->raw_time_nsec	= tk->raw_time.tv_nsec;
+		vdso_data->raw_time_nsec	= (tk->raw_time.tv_nsec <<
+						   tk->tkr_raw.shift) +
+						  tk->tkr_raw.xtime_nsec;
 		vdso_data->xtime_clock_sec	= tk->xtime_sec;
 		vdso_data->xtime_clock_nsec	= tk->tkr_mono.xtime_nsec;
-		/* tkr_raw.xtime_nsec == 0 */
 		vdso_data->cs_mono_mult		= tk->tkr_mono.mult;
 		vdso_data->cs_raw_mult		= tk->tkr_raw.mult;
 		/* tkr_mono.shift == tkr_raw.shift */
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -256,7 +256,6 @@ monotonic_raw:
 	seqcnt_check fail=monotonic_raw
 
 	/* All computations are done with left-shifted nsecs. */
-	lsl	x14, x14, x12
 	get_nsec_per_sec res=x9
 	lsl	x9, x9, x12
 

  parent reply	other threads:[~2017-06-27 14:25 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 14:12 [PATCH 4.11 00/58] 4.11.8-stable review Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 01/58] clk: sunxi-ng: a31: Correct lcd1-ch1 clock register offset Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 02/58] clk: sunxi-ng: v3s: Fix usb otg device reset bit Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 03/58] clk: sunxi-ng: sun5i: Fix ahb_bist_clk definition Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 05/58] xen-blkback: dont leak stack data via response ring Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 06/58] ALSA: firewire-lib: Fix stall of process context at packet error Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 07/58] ALSA: pcm: Dont treat NULL chmap as a fatal error Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 08/58] ALSA: hda - Add Coffelake PCI ID Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 09/58] ALSA: hda - Apply quirks to Broxton-T, too Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 10/58] fs/exec.c: account for argv/envp pointers Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 11/58] powerpc/perf: Fix oops when kthread execs user process Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 12/58] autofs: sanity check status reported with AUTOFS_DEV_IOCTL_FAIL Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 13/58] fs/dax.c: fix inefficiency in dax_writeback_mapping_range() Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 14/58] lib/cmdline.c: fix get_options() overflow while parsing ranges Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 15/58] perf/x86/intel: Add 1G DTLB load/store miss support for SKL Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 19/58] KVM: s390: gaccess: fix real-space designation asce handling for gmap shadows Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 20/58] KVM: PPC: Book3S HV: Cope with host using large decrementer mode Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 21/58] KVM: PPC: Book3S HV: Preserve userspace HTM state properly Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 22/58] KVM: PPC: Book3S HV: Ignore timebase offset on POWER9 DD1 Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 23/58] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 24/58] KVM: PPC: Book3S HV: Restore critical SPRs to host values on guest exit Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 25/58] KVM: PPC: Book3S HV: Save/restore host values of debug registers Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 26/58] CIFS: Improve readdir verbosity Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 27/58] CIFS: Fix some return values in case of error in crypt_message Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 28/58] cxgb4: notify uP to route ctrlq compl to rdma rspq Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 29/58] HID: Add quirk for Dell PIXART OEM mouse Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 30/58] random: silence compiler warnings and fix race Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 31/58] signal: Only reschedule timers on signals timers have sent Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 32/58] powerpc/kprobes: Pause function_graph tracing during jprobes handling Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 33/58] powerpc/64s: Handle data breakpoints in Radix mode Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 34/58] Input: i8042 - add Fujitsu Lifebook AH544 to notimeout list Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 35/58] brcmfmac: add parameter to pass error code in firmware callback Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 36/58] brcmfmac: use firmware callback upon failure to load Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 37/58] brcmfmac: unbind all devices upon failure in firmware callback Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 38/58] time: Fix clock->read(clock) race around clocksource changes Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 39/58] time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting Greg Kroah-Hartman
2017-06-27 14:12 ` Greg Kroah-Hartman [this message]
2017-06-27 14:12 ` [PATCH 4.11 41/58] target: Fix kref->refcount underflow in transport_cmd_finish_abort Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 42/58] iscsi-target: Fix delayed logout processing greater than SECONDS_FOR_LOGOUT_COMP Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 43/58] iscsi-target: Reject immediate data underflow larger than SCSI transfer length Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 44/58] drm/radeon: add a PX quirk for another K53TK variant Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 45/58] drm/radeon: add a quirk for Toshiba Satellite L20-183 Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 48/58] drm/amdgpu: add Polaris12 DID Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 49/58] ACPI / scan: Apply default enumeration to devices with ACPI drivers Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 50/58] ACPI / scan: Fix enumeration for special SPI and I2C devices Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 52/58] drm: Fix GETCONNECTOR regression Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 53/58] usb: gadget: f_fs: avoid out of bounds access on comp_desc Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 54/58] spi: double time out tolerance Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 55/58] net: phy: fix marvell phy status reading Greg Kroah-Hartman
2017-06-27 14:12 ` [PATCH 4.11 56/58] netfilter: xtables: zero padding in data_to_user Greg Kroah-Hartman
2017-06-27 14:13 ` [PATCH 4.11 57/58] netfilter: xtables: fix build failure from COMPAT_XT_ALIGN outside CONFIG_COMPAT Greg Kroah-Hartman
2017-06-27 14:13 ` [PATCH 4.11 58/58] brcmfmac: fix uninitialized warning in brcmf_usb_probe_phase2() Greg Kroah-Hartman
2017-06-27 19:04 ` [PATCH 4.11 00/58] 4.11.8-stable review Guenter Roeck
2017-06-28 12:03   ` Greg Kroah-Hartman
2017-06-28 13:53 ` Shuah Khan
2017-06-28 15:22   ` Greg Kroah-Hartman

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=20170627141115.120537947@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=danielmentz@google.com \
    --cc=john.stultz@linaro.org \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=stephen.boyd@linaro.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).