public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-api <linux-api@vger.kernel.org>,
	Andrew Hunter <ahh@google.com>,
	maged michael <maged.michael@gmail.com>,
	Avi Kivity <avi@scylladb.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Dave Watson <davejwatson@fb.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andrea Parri <parri.andrea@gmail.com>,
	"Russell King, ARM Linux" <linux@armlinux.org.uk>,
	Greg Hackmann <ghackmann@google.com>,
	Will Deacon <will.deacon@arm.com>, David Sehr <sehr@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	x86 <x86@kernel.org>, linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [RFC PATCH for 4.15 05/10] x86: Introduce sync_core_before_usermode
Date: Fri, 10 Nov 2017 22:20:30 +0000 (UTC)	[thread overview]
Message-ID: <1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <CALCETrWV+bgUPoS7NqVYhoi7hOyvsfoWw5CnyMrkYz=HYznmXQ@mail.gmail.com>

----- On Nov 10, 2017, at 5:02 PM, Andy Lutomirski luto@kernel.org wrote:

> On Fri, Nov 10, 2017 at 1:37 PM, Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> wrote:
>> Introduce an architecture function that ensures the current CPU
>> issues a core serializing instruction before returning to usermode.
>>
>> This is needed to fix an existing core serialization bug on
>> thread migration, and also needed by the membarrier "sync_core" command.
>>
>> Architectures defining the sync_core_before_usermode() static inline
>> need to define ARCH_HAS_SYNC_CORE_BEFORE_USERMODE.
>>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>> CC: Peter Zijlstra <peterz@infradead.org>
>> CC: Andy Lutomirski <luto@kernel.org>
>> CC: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
>> CC: Boqun Feng <boqun.feng@gmail.com>
>> CC: Andrew Hunter <ahh@google.com>
>> CC: Maged Michael <maged.michael@gmail.com>
>> CC: Avi Kivity <avi@scylladb.com>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Michael Ellerman <mpe@ellerman.id.au>
>> CC: Dave Watson <davejwatson@fb.com>
>> CC: Thomas Gleixner <tglx@linutronix.de>
>> CC: Ingo Molnar <mingo@redhat.com>
>> CC: "H. Peter Anvin" <hpa@zytor.com>
>> CC: Andrea Parri <parri.andrea@gmail.com>
>> CC: Russell King <linux@armlinux.org.uk>
>> CC: Greg Hackmann <ghackmann@google.com>
>> CC: Will Deacon <will.deacon@arm.com>
>> CC: David Sehr <sehr@google.com>
>> CC: Linus Torvalds <torvalds@linux-foundation.org>
>> CC: x86@kernel.org
>> CC: linux-arch@vger.kernel.org
>> ---
>>  arch/x86/Kconfig                 |  1 +
>>  arch/x86/include/asm/processor.h | 10 ++++++++++
>>  include/linux/processor.h        |  6 ++++++
>>  3 files changed, 17 insertions(+)
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index 01f78c1d40b5..54fbb8960d94 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -62,6 +62,7 @@ config X86
>>         select ARCH_HAS_SG_CHAIN
>>         select ARCH_HAS_STRICT_KERNEL_RWX
>>         select ARCH_HAS_STRICT_MODULE_RWX
>> +       select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
>>         select ARCH_HAS_UBSAN_SANITIZE_ALL
>>         select ARCH_HAS_ZONE_DEVICE             if X86_64
>>         select ARCH_HAVE_NMI_SAFE_CMPXCHG
>> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
>> index bdac19ab2488..6ce996a7c730 100644
>> --- a/arch/x86/include/asm/processor.h
>> +++ b/arch/x86/include/asm/processor.h
>> @@ -706,6 +706,16 @@ static inline void sync_core(void)
>>  #endif
>>  }
>>
>> +/*
>> + * Ensure that a core serializing instruction is issued before returning
>> + * to user-mode. x86 implements return to user-space through sysexit and
>> + * sysretq, which are not core serializing.
>> + */
>> +static inline void sync_core_before_usermode(void)
>> +{
>> +       sync_core();
>> +}
> 
> Make this if (!in_interrupt()) sync_core(); please.  We can optimize
> it better later on.

Sure, done. It will be part of the next version of that patch.

Thanks!

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2017-11-10 22:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 21:37 [RFC PATCH for 4.15 0/9] membarrier updates for 4.15 Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 01/10] membarrier: selftest: Test private expedited cmd Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH v7 for 4.15 02/10] membarrier: powerpc: Skip memory barrier in switch_mm() Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH v5 for 4.15 03/10] membarrier: Document scheduler barrier requirements Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 04/10] membarrier: Provide core serializing command Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 05/10] x86: Introduce sync_core_before_usermode Mathieu Desnoyers
2017-11-10 22:02   ` Andy Lutomirski
2017-11-10 22:20     ` Mathieu Desnoyers [this message]
2017-11-10 22:32       ` Mathieu Desnoyers
2017-11-10 23:13         ` Mathieu Desnoyers
2017-11-10 22:36       ` Andy Lutomirski
2017-11-10 22:39         ` Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 06/10] Fix: x86: Add missing core serializing instruction on migration Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH v2 for 4.15 07/10] membarrier: x86: Provide core serializing command Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 08/10] membarrier: selftest: Test private expedited sync core cmd Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 09/10] membarrier: provide SHARED_EXPEDITED command Mathieu Desnoyers
2017-11-10 21:37 ` [RFC PATCH for 4.15 10/10] membarrier: selftest: Test shared expedited cmd Mathieu Desnoyers

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=1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=ahh@google.com \
    --cc=avi@scylladb.com \
    --cc=benh@kernel.crashing.org \
    --cc=boqun.feng@gmail.com \
    --cc=davejwatson@fb.com \
    --cc=ghackmann@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luto@kernel.org \
    --cc=maged.michael@gmail.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=parri.andrea@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=sehr@google.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.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