浏览代码

arm64: vdso: check sequence counter even for coarse realtime operations

When returning coarse realtime values from clock_gettime, we must still
check the sequence counter to ensure that the kernel does not update
the vdso datapage whilst we are loading the coarse timespec as this
could potentially result in time appearing to go backwards.

This patch delays the coarse realtime check until after we have loaded
successfully from the vdso datapage. This does mean that we always load
the wtm timespec, but conditionalising the load and adding an extra
sequence test is unlikely to buy us anything other than messy code,
particularly as the sequence test implies a read barrier.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Will Deacon 12 年之前
父节点
当前提交
f84a935db4
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      arch/arm64/kernel/vdso/gettimeofday.S

+ 3 - 3
arch/arm64/kernel/vdso/gettimeofday.S

@@ -124,15 +124,15 @@ ENTRY(__kernel_clock_gettime)
 3:	seqcnt_acquire
 3:	seqcnt_acquire
 	ldp	x9, x10, [vdso_data, #VDSO_XTIME_CRS_SEC]
 	ldp	x9, x10, [vdso_data, #VDSO_XTIME_CRS_SEC]
 
 
-	cmp	w0, #CLOCK_MONOTONIC_COARSE
-	b.ne	6f
-
 	/* Get wtm timespec. */
 	/* Get wtm timespec. */
 	ldp	x14, x15, [vdso_data, #VDSO_WTM_CLK_SEC]
 	ldp	x14, x15, [vdso_data, #VDSO_WTM_CLK_SEC]
 
 
 	/* Check the sequence counter. */
 	/* Check the sequence counter. */
 	seqcnt_read w13
 	seqcnt_read w13
 	seqcnt_check w13, 3b
 	seqcnt_check w13, 3b
+
+	cmp	w0, #CLOCK_MONOTONIC_COARSE
+	b.ne	6f
 4:
 4:
 	/* Add on wtm timespec. */
 	/* Add on wtm timespec. */
 	add	x9, x9, x14
 	add	x9, x9, x14