Merge pull request #6979 from daverodgman/const-time-asm-vol

Inhibit compiler from optimising out const-time asm
This commit is contained in:
Gilles Peskine 2023-01-31 11:28:45 +01:00 committed by GitHub
commit f6b9823422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,9 +72,9 @@ static inline uint32_t mbedtls_get_unaligned_volatile_uint32(volatile const unsi
*/
uint32_t r;
#if defined(__arm__) || defined(__thumb__) || defined(__thumb2__)
asm ("ldr %0, [%1]" : "=r" (r) : "r" (p) :);
asm volatile ("ldr %0, [%1]" : "=r" (r) : "r" (p) :);
#elif defined(__aarch64__)
asm ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
#endif
return r;
}