From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, agraf@suse.de,
pbonzini@redhat.com, mtosatti@redhat.com, mingo@kernel.org,
peterz@infradead.org, bp@alien8.de, luto@amacapital.net,
rkrcmar@redhat.com, luto@kernel.org,
torvalds@linux-foundation.org, tglx@linutronix.de,
dvlasenk@redhat.com, brgerst@gmail.com
Subject: [tip:x86/urgent] x86/vdso/pvclock: Protect STABLE check with the seqcount
Date: Thu, 14 Jan 2016 01:07:03 -0800 [thread overview]
Message-ID: <tip-78fd8c7288e0a4bba3ad1d69caf9396a6b69cb00@git.kernel.org> (raw)
In-Reply-To: <755dcedb17269e1d7ce12a9a713dea303835137e.1451949191.git.luto@kernel.org>
Commit-ID: 78fd8c7288e0a4bba3ad1d69caf9396a6b69cb00
Gitweb: http://git.kernel.org/tip/78fd8c7288e0a4bba3ad1d69caf9396a6b69cb00
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Mon, 4 Jan 2016 15:14:28 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 13 Jan 2016 11:46:29 +0100
x86/vdso/pvclock: Protect STABLE check with the seqcount
If the clock becomes unstable while we're reading it, we need to
bail. We can do this by simply moving the check into the
seqcount loop.
Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Alexander Graf <agraf@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krcmar <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/755dcedb17269e1d7ce12a9a713dea303835137e.1451949191.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/entry/vdso/vclock_gettime.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
index 8602f06..1a50e09 100644
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vclock_gettime.c
@@ -126,23 +126,23 @@ static notrace cycle_t vread_pvclock(int *mode)
*
* On Xen, we don't appear to have that guarantee, but Xen still
* supplies a valid seqlock using the version field.
-
+ *
* We only do pvclock vdso timing at all if
* PVCLOCK_TSC_STABLE_BIT is set, and we interpret that bit to
* mean that all vCPUs have matching pvti and that the TSC is
* synced, so we can just look at vCPU 0's pvti.
*/
- if (unlikely(!(pvti->flags & PVCLOCK_TSC_STABLE_BIT))) {
- *mode = VCLOCK_NONE;
- return 0;
- }
-
do {
version = pvti->version;
smp_rmb();
+ if (unlikely(!(pvti->flags & PVCLOCK_TSC_STABLE_BIT))) {
+ *mode = VCLOCK_NONE;
+ return 0;
+ }
+
tsc = rdtsc_ordered();
pvti_tsc_to_system_mul = pvti->tsc_to_system_mul;
pvti_tsc_shift = pvti->tsc_shift;
next prev parent reply other threads:[~2016-01-14 9:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-20 11:05 [PATCH v2 0/4] x86: KVM vdso and clock improvements Andy Lutomirski
2015-12-20 11:05 ` [PATCH v2 1/4] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader Andy Lutomirski
2016-01-04 20:26 ` Marcelo Tosatti
2016-01-04 22:33 ` Andy Lutomirski
2016-01-04 22:59 ` Marcelo Tosatti
2016-01-04 23:14 ` [PATCH] x86/vdso/pvclock: Protect STABLE check with the seqcount Andy Lutomirski
2016-01-07 21:02 ` Marcelo Tosatti
2016-01-07 21:13 ` Andy Lutomirski
2016-01-07 21:47 ` Paolo Bonzini
2016-01-08 14:04 ` Marcelo Tosatti
2016-01-12 19:48 ` Andy Lutomirski
2016-01-13 10:46 ` Ingo Molnar
2016-01-14 9:07 ` tip-bot for Andy Lutomirski [this message]
2015-12-20 11:05 ` [PATCH v2 2/4] x86/vdso: Get pvclock data from the vvar VMA instead of the fixmap Andy Lutomirski
2015-12-20 11:05 ` [PATCH v2 3/4] x86/vdso: Remove pvclock fixmap machinery Andy Lutomirski
2015-12-20 11:05 ` [PATCH v2 4/4] x86/vdso: Enable vdso pvclock access on all vdso variants Andy Lutomirski
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=tip-78fd8c7288e0a4bba3ad1d69caf9396a6b69cb00@git.kernel.org \
--to=tipbot@zytor.com \
--cc=agraf@suse.de \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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
Powered by JetHome