From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754684AbdKJWhF (ORCPT ); Fri, 10 Nov 2017 17:37:05 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46538 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbdKJWhB (ORCPT ); Fri, 10 Nov 2017 17:37:01 -0500 X-Google-Smtp-Source: AGs4zMaJpTk8BtAxcrxe6Q6+6f5zOGy/cLOAz6+alXCp7zlo2mZGYhQTVKyPmFZ7jifcx2hCaAt5Dw== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [RFC PATCH for 4.15 05/10] x86: Introduce sync_core_before_usermode From: Andy Lutomirski X-Mailer: iPhone Mail (15A432) In-Reply-To: <1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com> Date: Fri, 10 Nov 2017 14:36:58 -0800 Cc: Andy Lutomirski , Boqun Feng , Peter Zijlstra , "Paul E. McKenney" , linux-kernel , linux-api , Andrew Hunter , maged michael , Avi Kivity , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Watson , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrea Parri , "Russell King, ARM Linux" , Greg Hackmann , Will Deacon , David Sehr , Linus Torvalds , x86 , linux-arch Message-Id: References: <20171110213717.12457-1-mathieu.desnoyers@efficios.com> <20171110213717.12457-6-mathieu.desnoyers@efficios.com> <1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com> To: Mathieu Desnoyers Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vAAMb9AN010047 > On Nov 10, 2017, at 2:20 PM, Mathieu Desnoyers wrote: > > ----- 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 >> 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 >>> CC: Peter Zijlstra >>> CC: Andy Lutomirski >>> CC: Paul E. McKenney >>> CC: Boqun Feng >>> CC: Andrew Hunter >>> CC: Maged Michael >>> CC: Avi Kivity >>> CC: Benjamin Herrenschmidt >>> CC: Paul Mackerras >>> CC: Michael Ellerman >>> CC: Dave Watson >>> CC: Thomas Gleixner >>> CC: Ingo Molnar >>> CC: "H. Peter Anvin" >>> CC: Andrea Parri >>> CC: Russell King >>> CC: Greg Hackmann >>> CC: Will Deacon >>> CC: David Sehr >>> CC: Linus Torvalds >>> 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! Hmm. Can you also cc stable and make sure it applies by itself? > > Mathieu > > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com > -- > To unsubscribe from this list: send the line "unsubscribe linux-api" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Subject: Re: [RFC PATCH for 4.15 05/10] x86: Introduce sync_core_before_usermode Date: Fri, 10 Nov 2017 14:36:58 -0800 Message-ID: References: <20171110213717.12457-1-mathieu.desnoyers@efficios.com> <20171110213717.12457-6-mathieu.desnoyers@efficios.com> <1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1007217384.13056.1510352430448.JavaMail.zimbra@efficios.com> Sender: linux-kernel-owner@vger.kernel.org To: Mathieu Desnoyers Cc: Andy Lutomirski , Boqun Feng , Peter Zijlstra , "Paul E. McKenney" , linux-kernel , linux-api , Andrew Hunter , maged michael , Avi Kivity , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Watson , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrea Parri , "Russell King, ARM Linux" , Greg Hackmann , Will List-Id: linux-api@vger.kernel.org > On Nov 10, 2017, at 2:20 PM, Mathieu Desnoyers wrote: >=20 > ----- On Nov 10, 2017, at 5:02 PM, Andy Lutomirski luto@kernel.org wrote: >=20 >> On Fri, Nov 10, 2017 at 1:37 PM, Mathieu Desnoyers >> wrote: >>> Introduce an architecture function that ensures the current CPU >>> issues a core serializing instruction before returning to usermode. >>>=20 >>> This is needed to fix an existing core serialization bug on >>> thread migration, and also needed by the membarrier "sync_core" command.= >>>=20 >>> Architectures defining the sync_core_before_usermode() static inline >>> need to define ARCH_HAS_SYNC_CORE_BEFORE_USERMODE. >>>=20 >>> Signed-off-by: Mathieu Desnoyers >>> CC: Peter Zijlstra >>> CC: Andy Lutomirski >>> CC: Paul E. McKenney >>> CC: Boqun Feng >>> CC: Andrew Hunter >>> CC: Maged Michael >>> CC: Avi Kivity >>> CC: Benjamin Herrenschmidt >>> CC: Paul Mackerras >>> CC: Michael Ellerman >>> CC: Dave Watson >>> CC: Thomas Gleixner >>> CC: Ingo Molnar >>> CC: "H. Peter Anvin" >>> CC: Andrea Parri >>> CC: Russell King >>> CC: Greg Hackmann >>> CC: Will Deacon >>> CC: David Sehr >>> CC: Linus Torvalds >>> 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(+) >>>=20 >>> 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/pro= cessor.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 >>> } >>>=20 >>> +/* >>> + * Ensure that a core serializing instruction is issued before returnin= g >>> + * to user-mode. x86 implements return to user-space through sysexit an= d >>> + * sysretq, which are not core serializing. >>> + */ >>> +static inline void sync_core_before_usermode(void) >>> +{ >>> + sync_core(); >>> +} >>=20 >> Make this if (!in_interrupt()) sync_core(); please. We can optimize >> it better later on. >=20 > Sure, done. It will be part of the next version of that patch. >=20 > Thanks! Hmm. Can you also cc stable and make sure it applies by itself? >=20 > Mathieu >=20 >=20 > --=20 > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com > -- > To unsubscribe from this list: send the line "unsubscribe linux-api" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html