Skip to content

Commit 8ef9323

Browse files
Merge pull request #9809 from solardiz/development
Specify previously missed register clobbers in AES-NI asm blocks
2 parents a41d52a + 6b2ca18 commit 8ef9323

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix
2+
* Fix missing constraints on the AES-NI inline assembly which is used on
3+
GCC-like compilers when building AES for generic x86_64 targets. This
4+
may have resulted in incorrect code with some compilers, depending on
5+
optimizations. Fixes #9819.

tf-psa-crypto/drivers/builtin/src/aesni.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ int mbedtls_aesni_crypt_ecb(mbedtls_aes_context *ctx,
489489
"movdqu %%xmm0, (%4) \n\t" // export output
490490
:
491491
: "r" (ctx->nr), "r" (ctx->buf + ctx->rk_offset), "r" (mode), "r" (input), "r" (output)
492-
: "memory", "cc", "xmm0", "xmm1");
492+
: "memory", "cc", "xmm0", "xmm1", "0", "1");
493493

494494

495495
return 0;
@@ -679,7 +679,7 @@ static void aesni_setkey_enc_128(unsigned char *rk,
679679
AESKEYGENA(xmm0_xmm1, "0x36") "call 1b \n\t"
680680
:
681681
: "r" (rk), "r" (key)
682-
: "memory", "cc", "0");
682+
: "memory", "cc", "xmm0", "xmm1", "0");
683683
}
684684

685685
/*
@@ -737,7 +737,7 @@ static void aesni_setkey_enc_192(unsigned char *rk,
737737

738738
:
739739
: "r" (rk), "r" (key)
740-
: "memory", "cc", "0");
740+
: "memory", "cc", "xmm0", "xmm1", "xmm2", "0");
741741
}
742742
#endif /* !MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
743743

@@ -805,7 +805,7 @@ static void aesni_setkey_enc_256(unsigned char *rk,
805805
AESKEYGENA(xmm1_xmm2, "0x40") "call 1b \n\t"
806806
:
807807
: "r" (rk), "r" (key)
808-
: "memory", "cc", "0");
808+
: "memory", "cc", "xmm0", "xmm1", "xmm2", "0");
809809
}
810810
#endif /* !MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
811811

0 commit comments

Comments
 (0)