From 5c88f46c92c9803fd99777573981580f79086f66 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 28 Mar 2026 10:46:17 +0100 Subject: [PATCH] avutil/x86/aes: Only assemble iff HAVE_AESNI_EXTERNAL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids relying on DCE and works around a NASM bug [1]. [1]: https://github.com/netwide-assembler/nasm/issues/216 Reviewed-by: Kacper Michajłow Signed-off-by: Andreas Rheinhardt --- libavutil/aes.c | 2 +- libavutil/x86/Makefile | 4 ++-- libavutil/x86/aes.asm | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavutil/aes.c b/libavutil/aes.c index 273ffcc711..13fadb4a47 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -237,7 +237,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) a->rounds = rounds; a->crypt = decrypt ? aes_decrypt : aes_encrypt; -#if ARCH_X86 && HAVE_X86ASM +#if ARCH_X86 && HAVE_X86ASM && HAVE_AESNI_EXTERNAL ff_init_aes_x86(a, decrypt); #endif diff --git a/libavutil/x86/Makefile b/libavutil/x86/Makefile index bc3c63fe78..590758ce78 100644 --- a/libavutil/x86/Makefile +++ b/libavutil/x86/Makefile @@ -2,8 +2,7 @@ OBJS += x86/cpu.o \ EMMS_OBJS_$(HAVE_MMX_INLINE)_$(HAVE_MMX_EXTERNAL)_$(HAVE_MM_EMPTY) = x86/emms.o -X86ASM-OBJS += x86/aes.o x86/aes_init.o \ - x86/cpuid.o \ +X86ASM-OBJS += x86/cpuid.o \ x86/crc.o \ $(EMMS_OBJS__yes_) \ x86/fixed_dsp.o x86/fixed_dsp_init.o \ @@ -12,4 +11,5 @@ X86ASM-OBJS += x86/aes.o x86/aes_init.o \ x86/lls.o x86/lls_init.o \ x86/tx_float.o x86/tx_float_init.o \ +X86ASM-OBJS-$(HAVE_AESNI_EXTERNAL) += x86/aes.o x86/aes_init.o X86ASM-OBJS-$(CONFIG_PIXELUTILS) += x86/pixelutils.o diff --git a/libavutil/x86/aes.asm b/libavutil/x86/aes.asm index 9a36991ca0..a5dcc4f0fb 100644 --- a/libavutil/x86/aes.asm +++ b/libavutil/x86/aes.asm @@ -86,7 +86,6 @@ cglobal aes_%1rypt_%2, 5, 5, 2 REP_RET %endmacro -%if HAVE_AESNI_EXTERNAL INIT_XMM aesni AES_CRYPT enc, 10 AES_CRYPT enc, 12 @@ -94,4 +93,3 @@ AES_CRYPT enc, 14 AES_CRYPT dec, 10 AES_CRYPT dec, 12 AES_CRYPT dec, 14 -%endif