[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1670059472.3671.1609189779376.JavaMail.zimbra@efficios.com>
Date: Mon, 28 Dec 2020 16:09:39 -0500 (EST)
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Andy Lutomirski <luto@...nel.org>, paulmck <paulmck@...nel.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: "Russell King, ARM Linux" <linux@...linux.org.uk>,
x86 <x86@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Nicholas Piggin <npiggin@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
stable <stable@...r.kernel.org>
Subject: Re: [RFC please help] membarrier: Rewrite
sync_core_before_usermode()
----- On Dec 27, 2020, at 4:36 PM, Andy Lutomirski luto@...nel.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 supports your concern ?
>>
>> Based on the notes I have, use of `eret` on aarch64 guarantees a context
>> synchronizing
>> instruction when returning to user-space.
>
> Based on my reading of the manual, ERET on ARM doesn't synchronize
> anything at all. I can't find any evidence that it synchronizes data
> or instructions, and I've seen reports that the CPU will happily
> speculate right past it.
Reading [1] there appears to be 3 kind of context synchronization events:
- Taking an exception,
- Returning from an exception,
- ISB.
This other source [2] adds (search for Context synchronization operation):
- Exit from Debug state
- Executing a DCPS instruction
- Executing a DRPS instruction
"ERET" falls into the second kind of events, and AFAIU should be context
synchronizing. That was confirmed to me by Will Deacon when membarrier
sync-core was implemented for aarch64. If the architecture reference manuals
are wrong, is there an errata ?
As for the algorithm to use on ARMv8 to update instructions, see [2]
B2.3.4 Implication of caches for the application programmer
"Synchronization and coherency issues between data and instruction accesses"
Membarrier only takes care of making sure the "ISB" part of the algorithm can be
done easily and efficiently on multiprocessor systems.
Thanks,
Mathieu
[1] https://developer.arm.com/documentation/den0024/a/Memory-Ordering/Barriers/ISB-in-more-detail
[2] https://montcs.bloomu.edu/Information/ARMv8/ARMv8-A_Architecture_Reference_Manual_(Issue_A.a).pdf
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Powered by blists - more mailing lists