Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-05 Thread Will Deacon
On Tue, Jan 05, 2021 at 08:20:51AM -0800, Andy Lutomirski wrote: > > On Jan 5, 2021, at 5:26 AM, Will Deacon wrote: > > Sorry for the slow reply, I was socially distanced from my keyboard. > > > >> On Mon, Dec 28, 2020 at 04:36:11PM -0800, Andy Lutomirski wrote: > >> On Mon, Dec 28, 2020 at 4:11

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-05 Thread Peter Zijlstra
On Tue, Jan 05, 2021 at 08:20:51AM -0800, Andy Lutomirski wrote: > > Interestingly, the architecture recently added a control bit to remove > > this synchronisation from exception return, so if we set that then we'd > > have a problem with SYNC_CORE and adding an ISB would be necessary

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-05 Thread Andy Lutomirski
> On Jan 5, 2021, at 5:26 AM, Will Deacon wrote: > > Hi Andy, > > Sorry for the slow reply, I was socially distanced from my keyboard. > >> On Mon, Dec 28, 2020 at 04:36:11PM -0800, Andy Lutomirski wrote: >> On Mon, Dec 28, 2020 at 4:11 PM Nicholas Piggin wrote: +static inline void

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-05 Thread Will Deacon
Hi Andy, Sorry for the slow reply, I was socially distanced from my keyboard. On Mon, Dec 28, 2020 at 04:36:11PM -0800, Andy Lutomirski wrote: > On Mon, Dec 28, 2020 at 4:11 PM Nicholas Piggin wrote: > > > +static inline void membarrier_sync_core_before_usermode(void) > > > +{ > > > + /* >

RE: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2021-01-01 Thread David Laight
From: Andy Lutomirski > Sent: 29 December 2020 00:36 ... > I mean that the mapping from the name "sync_core" to its semantics is > x86 only. The string "sync_core" appears in the kernel only in > arch/x86, membarrier code, membarrier docs, and a single SGI driver > that is x86-only. Sure, the

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-30 Thread Nicholas Piggin
Excerpts from Russell King - ARM Linux admin's message of December 30, 2020 8:58 pm: > On Wed, Dec 30, 2020 at 10:00:28AM +, Russell King - ARM Linux admin > wrote: >> On Wed, Dec 30, 2020 at 12:33:02PM +1000, Nicholas Piggin wrote: >> > Excerpts from Russell King - ARM Linux admin's message

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-30 Thread Russell King - ARM Linux admin
On Wed, Dec 30, 2020 at 10:00:28AM +, Russell King - ARM Linux admin wrote: > On Wed, Dec 30, 2020 at 12:33:02PM +1000, Nicholas Piggin wrote: > > Excerpts from Russell King - ARM Linux admin's message of December 29, 2020 > > 8:44 pm: > > > On Tue, Dec 29, 2020 at 01:09:12PM +1000, Nicholas

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-30 Thread Russell King - ARM Linux admin
On Wed, Dec 30, 2020 at 12:33:02PM +1000, Nicholas Piggin wrote: > Excerpts from Russell King - ARM Linux admin's message of December 29, 2020 > 8:44 pm: > > On Tue, Dec 29, 2020 at 01:09:12PM +1000, Nicholas Piggin wrote: > >> I think it should certainly be documented in terms of what guarantees

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-29 Thread Nicholas Piggin
Excerpts from Russell King - ARM Linux admin's message of December 29, 2020 8:44 pm: > On Tue, Dec 29, 2020 at 01:09:12PM +1000, Nicholas Piggin wrote: >> I think it should certainly be documented in terms of what guarantees >> it provides to application, _not_ the kinds of instructions it may or

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-29 Thread Russell King - ARM Linux admin
On Tue, Dec 29, 2020 at 01:09:12PM +1000, Nicholas Piggin wrote: > I think it should certainly be documented in terms of what guarantees > it provides to application, _not_ the kinds of instructions it may or > may not induce the core to execute. And if existing API can't be > re-documented

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Nicholas Piggin
Excerpts from Andy Lutomirski's message of December 29, 2020 10:36 am: > On Mon, Dec 28, 2020 at 4:11 PM Nicholas Piggin wrote: >> >> Excerpts from Andy Lutomirski's message of December 28, 2020 4:28 am: >> > The old sync_core_before_usermode() comments said that a non-icache-syncing >> >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Nicholas Piggin
Excerpts from Andy Lutomirski's message of December 29, 2020 10:56 am: > On Mon, Dec 28, 2020 at 4:36 PM Nicholas Piggin wrote: >> >> Excerpts from Andy Lutomirski's message of December 29, 2020 7:06 am: >> > On Mon, Dec 28, 2020 at 12:32 PM Mathieu Desnoyers >> > wrote: >> >> >> >> - On Dec

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 4:36 PM Nicholas Piggin wrote: > > Excerpts from Andy Lutomirski's message of December 29, 2020 7:06 am: > > On Mon, Dec 28, 2020 at 12:32 PM Mathieu Desnoyers > > wrote: > >> > >> - On Dec 28, 2020, at 2:44 PM, Andy Lutomirski l...@kernel.org wrote: > >> > >> > On

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 4:11 PM Nicholas Piggin wrote: > > Excerpts from Andy Lutomirski's message of December 28, 2020 4:28 am: > > The old sync_core_before_usermode() comments said that a non-icache-syncing > > return-to-usermode instruction is x86-specific and that all other > > architectures

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Nicholas Piggin
Excerpts from Andy Lutomirski's message of December 29, 2020 7:06 am: > On Mon, Dec 28, 2020 at 12:32 PM Mathieu Desnoyers > wrote: >> >> - On Dec 28, 2020, at 2:44 PM, Andy Lutomirski l...@kernel.org wrote: >> >> > On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin >> > wrote:

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 1:09 PM Mathieu Desnoyers wrote: > > - On Dec 27, 2020, at 4:36 PM, Andy Lutomirski l...@kernel.org wrote: > > [...] > > >> You seem to have noticed odd cases on arm64 where this guarantee does not > >> match reality. Where exactly can we find this in the code, and

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Nicholas Piggin
Excerpts from Andy Lutomirski's message of December 28, 2020 4:28 am: > The old sync_core_before_usermode() comments said that a non-icache-syncing > return-to-usermode instruction is x86-specific and that all other > architectures automatically notice cross-modified code on return to > userspace.

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin wrote: > > On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn wrote: > > After chatting with rmk about this (but without claiming that any of > > this is his opinion), based on the manpage, I think membarrier() > > currently doesn't

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Russell King - ARM Linux admin
On Mon, Dec 28, 2020 at 11:44:33AM -0800, Andy Lutomirski wrote: > On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin > wrote: > > > > On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn wrote: > > > After chatting with rmk about this (but without claiming that any of > > > this is

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Mathieu Desnoyers
- On Dec 28, 2020, at 3:24 PM, Russell King, ARM Linux li...@armlinux.org.uk wrote: > On Mon, Dec 28, 2020 at 11:44:33AM -0800, Andy Lutomirski wrote: >> On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin >> wrote: >> > >> > On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Mathieu Desnoyers
- On Dec 28, 2020, at 2:44 PM, Andy Lutomirski l...@kernel.org wrote: > On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin > wrote: >> >> On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn wrote: >> > After chatting with rmk about this (but without claiming that any of >> >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Mathieu Desnoyers
- On Dec 28, 2020, at 4:06 PM, Andy Lutomirski l...@kernel.org wrote: > On Mon, Dec 28, 2020 at 12:32 PM Mathieu Desnoyers > wrote: >> >> - On Dec 28, 2020, at 2:44 PM, Andy Lutomirski l...@kernel.org wrote: >> >> > On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin >> >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Mathieu Desnoyers
- On Dec 27, 2020, at 4:36 PM, Andy Lutomirski l...@kernel.org wrote: [...] >> You seem to have noticed odd cases on arm64 where this guarantee does not >> match reality. Where exactly can we find this in the code, and which part >> of the architecture manual can you point us to which

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 12:32 PM Mathieu Desnoyers wrote: > > - On Dec 28, 2020, at 2:44 PM, Andy Lutomirski l...@kernel.org wrote: > > > On Mon, Dec 28, 2020 at 11:09 AM Russell King - ARM Linux admin > > wrote: > >> > >> On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn wrote: > >> >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Russell King - ARM Linux admin
On Mon, Dec 28, 2020 at 07:29:34PM +0100, Jann Horn wrote: > After chatting with rmk about this (but without claiming that any of > this is his opinion), based on the manpage, I think membarrier() > currently doesn't really claim to be synchronizing caches? It just > serializes cores. So arguably

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 10:30 AM Jann Horn wrote: > > On Mon, Dec 28, 2020 at 6:14 PM Andy Lutomirski wrote: > > On Mon, Dec 28, 2020 at 2:25 AM Russell King - ARM Linux admin > > wrote: > > > > > > On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: > > > > On Sun, Dec 27, 2020 at

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Jann Horn
On Mon, Dec 28, 2020 at 6:14 PM Andy Lutomirski wrote: > On Mon, Dec 28, 2020 at 2:25 AM Russell King - ARM Linux admin > wrote: > > > > On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: > > > On Sun, Dec 27, 2020 at 12:18 PM Mathieu Desnoyers > > > wrote: > > > > > > > > -

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 9:23 AM Russell King - ARM Linux admin wrote: > > On Mon, Dec 28, 2020 at 09:14:23AM -0800, Andy Lutomirski wrote: > > On Mon, Dec 28, 2020 at 2:25 AM Russell King - ARM Linux admin > > wrote: > > > > > > On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Russell King - ARM Linux admin
On Mon, Dec 28, 2020 at 09:14:23AM -0800, Andy Lutomirski wrote: > On Mon, Dec 28, 2020 at 2:25 AM Russell King - ARM Linux admin > wrote: > > > > On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: > > > On Sun, Dec 27, 2020 at 12:18 PM Mathieu Desnoyers > > > wrote: > > > > > > >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Andy Lutomirski
On Mon, Dec 28, 2020 at 2:25 AM Russell King - ARM Linux admin wrote: > > On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: > > On Sun, Dec 27, 2020 at 12:18 PM Mathieu Desnoyers > > wrote: > > > > > > - On Dec 27, 2020, at 1:28 PM, Andy Lutomirski l...@kernel.org wrote: > > >

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-28 Thread Russell King - ARM Linux admin
On Sun, Dec 27, 2020 at 01:36:13PM -0800, Andy Lutomirski wrote: > On Sun, Dec 27, 2020 at 12:18 PM Mathieu Desnoyers > wrote: > > > > - On Dec 27, 2020, at 1:28 PM, Andy Lutomirski l...@kernel.org wrote: > > > > > > > > > I admit that I'm rather surprised that the code worked at all on

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-27 Thread Andy Lutomirski
On Sun, Dec 27, 2020 at 12:18 PM Mathieu Desnoyers wrote: > > - On Dec 27, 2020, at 1:28 PM, Andy Lutomirski l...@kernel.org wrote: > > > > > I admit that I'm rather surprised that the code worked at all on arm64, > > and I'm suspicious that it has never been very well tested. My apologies

Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode()

2020-12-27 Thread Mathieu Desnoyers
- On Dec 27, 2020, at 1:28 PM, Andy Lutomirski l...@kernel.org wrote: > The old sync_core_before_usermode() comments said that a non-icache-syncing > return-to-usermode instruction is x86-specific and that all other > architectures automatically notice cross-modified code on return to >