Merge pull request #4958 from gilles-peskine-arm/make-tests-v-2.16
Backport 2.16: Facilitate reproducing unit tests from all.sh
diff --git a/ChangeLog.d/muladdc-amd64-memory.txt b/ChangeLog.d/muladdc-amd64-memory.txt
new file mode 100644
index 0000000..b834331
--- /dev/null
+++ b/ChangeLog.d/muladdc-amd64-memory.txt
@@ -0,0 +1,4 @@
+Bugfix
+ * Fix missing constraints on x86_64 assembly code for bignum multiplication
+ that broke some bignum operations with (at least) Clang 12.
+ Fixes #4116, #4786, #4917.
diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h
index 6f1201b..f84f965 100644
--- a/include/mbedtls/bn_mul.h
+++ b/include/mbedtls/bn_mul.h
@@ -256,9 +256,9 @@
"addq $8, %%rdi\n"
#define MULADDC_STOP \
- : "+c" (c), "+D" (d), "+S" (s) \
- : "b" (b) \
- : "rax", "rdx", "r8" \
+ : "+c" (c), "+D" (d), "+S" (s), "+m" (*(uint64_t (*)[16]) d) \
+ : "b" (b), "m" (*(const uint64_t (*)[16]) s) \
+ : "rax", "rdx", "r8" \
);
#endif /* AMD64 */