RE: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread David Laight
From: Arvind Sankar > Sent: 02 September 2020 17:08 > > On Wed, Sep 02, 2020 at 11:33:46AM -0400, Arvind Sankar wrote: > > Fix this by: > > - Using a memory clobber for the write functions to additionally prevent > > caching/reordering memory accesses across CRn writes. > > - Using a dummy input

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Arvind Sankar
On Wed, Sep 02, 2020 at 08:19:25PM +0200, Miguel Ojeda wrote: > On Wed, Sep 2, 2020 at 5:33 PM Arvind Sankar wrote: > > > > + * The compiler should not reorder volatile asm, however older versions of > > GCC > > + * had a bug (which was fixed in 8.1, 7.3 and 6.5) where they could > > sometimes >

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Miguel Ojeda
On Wed, Sep 2, 2020 at 5:33 PM Arvind Sankar wrote: > > + * The compiler should not reorder volatile asm, however older versions of > GCC > + * had a bug (which was fixed in 8.1, 7.3 and 6.5) where they could sometimes > + * reorder volatile asm. The write functions are not a problem since they

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Arvind Sankar
On Wed, Sep 02, 2020 at 12:16:24PM -0500, Segher Boessenkool wrote: > On Wed, Sep 02, 2020 at 11:33:46AM -0400, Arvind Sankar wrote: > > The CRn accessor functions use __force_order as a dummy operand to > > prevent the compiler from reordering the inline asm. > > > > The fact that the asm is vola

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Segher Boessenkool
On Wed, Sep 02, 2020 at 11:33:46AM -0400, Arvind Sankar wrote: > The CRn accessor functions use __force_order as a dummy operand to > prevent the compiler from reordering the inline asm. > > The fact that the asm is volatile should be enough to prevent this > already, however older versions of GCC

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Arvind Sankar
On Wed, Sep 02, 2020 at 03:58:38PM +, David Laight wrote: > From: Arvind Sankar > > Sent: 02 September 2020 16:34 > > > > The CRn accessor functions use __force_order as a dummy operand to > > prevent the compiler from reordering the inline asm. > > > > The fact that the asm is volatile shoul

Re: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread Arvind Sankar
On Wed, Sep 02, 2020 at 11:33:46AM -0400, Arvind Sankar wrote: > Fix this by: > - Using a memory clobber for the write functions to additionally prevent > caching/reordering memory accesses across CRn writes. > - Using a dummy input operand with an arbitrary constant address for the > read func

RE: [PATCH v2] x86/asm: Replace __force_order with memory clobber

2020-09-02 Thread David Laight
From: Arvind Sankar > Sent: 02 September 2020 16:34 > > The CRn accessor functions use __force_order as a dummy operand to > prevent the compiler from reordering the inline asm. > > The fact that the asm is volatile should be enough to prevent this > already, however older versions of GCC had a b