mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add a note about processor memory reordering
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -51,6 +51,13 @@ int mbedtls_aesni_has_support(unsigned int what)
|
|||||||
/* To avoid a race condition, tell the compiler that the assignment
|
/* To avoid a race condition, tell the compiler that the assignment
|
||||||
* `done = 1` and the assignment to `c` may not be reordered.
|
* `done = 1` and the assignment to `c` may not be reordered.
|
||||||
* https://github.com/Mbed-TLS/mbedtls/issues/9840
|
* https://github.com/Mbed-TLS/mbedtls/issues/9840
|
||||||
|
*
|
||||||
|
* Note that we may also be worried about memory access reordering,
|
||||||
|
* but fortunately the x86 memory model is not too wild: stores
|
||||||
|
* from the same thread are observed consistently by other threads.
|
||||||
|
* (See example 8-1 in Sewell et al., "x86-TSO: A Rigorous and Usable
|
||||||
|
* Programmer’s Model for x86 Multiprocessors", CACM, 2010,
|
||||||
|
* https://www.cl.cam.ac.uk/~pes20/weakmemory/cacm.pdf)
|
||||||
*/
|
*/
|
||||||
static volatile int done = 0;
|
static volatile int done = 0;
|
||||||
static volatile unsigned int c = 0;
|
static volatile unsigned int c = 0;
|
||||||
|
Reference in New Issue
Block a user