Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for arm64_32 (aka ILP32) on Clang #7808

Merged
merged 15 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.d/fix-ilp32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Bugfix
* Fix a compile failure in the constant_time module when building
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, not worth updating just for that:

Suggested change
* Fix a compile failure in the constant_time module when building
* Fix a compilation failure in the constant_time module when building

for watchos (i.e. for Aarch64 ILP32). Reported by Paulo Coutinho
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, perhaps updating just for that: watchos is not really material here, what's material is arm64_32. Suggested wording: “when building for arm64_32, e.g. for watchOS”.

in #7787.
10 changes: 9 additions & 1 deletion library/constant_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
* only used here.
*/
#if defined(MBEDTLS_EFFICIENT_UNALIGNED_ACCESS) && defined(MBEDTLS_HAVE_ASM)
#if defined(__arm__) || defined(__thumb__) || defined(__thumb2__) || defined(__aarch64__)
#if ((defined(__arm__) || defined(__thumb__) || defined(__thumb2__)) && (UINTPTR_MAX == 0xfffffffful)) || \
(defined(__aarch64__) && ((UINTPTR_MAX == 0xffffffffull) || (UINTPTR_MAX == 0xffffffffffffffffull)))
/* We check pointer sizes to avoid issues with them not matching register size requirements */
#define MBEDTLS_EFFICIENT_UNALIGNED_VOLATILE_ACCESS
#endif
#endif
Expand All @@ -79,7 +81,13 @@ static inline uint32_t mbedtls_get_unaligned_volatile_uint32(volatile const unsi
#if defined(__arm__) || defined(__thumb__) || defined(__thumb2__)
asm volatile ("ldr %0, [%1]" : "=r" (r) : "r" (p) :);
#elif defined(__aarch64__)
#if (UINTPTR_MAX == 0xfffffffful)
/* ILP32: Specify the pointer operand slightly differently, as per #7787. */
asm volatile ("ldr %w0, [%1]" : "=r" (r) : "p" (p) :);
#elif (UINTPTR_MAX == 0xffffffffffffffffull)
/* aarch64 with 64-bit pointers */
asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
#endif
#endif
return r;
}
Expand Down