x86/crypto: aesni: Fix build with LLVM_IAS=1
Subsystems (2)
PATCH v5 1/1 x86/crypto: aesni: Fix build with LLVM_IAS=1
When building with LLVM_IAS=1 means using Clang's Integrated Assembly (IAS) from LLVM/Clang >= v10.0.1-rc1+ instead of GNU/as from GNU/binutils I see the following breakage in Debian/testing AMD64:
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
^
arch/x86/crypto/aesni-intel_asm.S:1598:2: note: while in macro instantiation
GCM_INIT %r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_dec %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1599:2: note: while in macro instantiation
GCM_ENC_DEC dec
^
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
^
arch/x86/crypto/aesni-intel_asm.S:1686:2: note: while in macro instantiation
GCM_INIT %r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_enc %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1687:2: note: while in macro instantiation
GCM_ENC_DEC enc
Craig Topper suggested me in ClangBuiltLinux issue #1050:
Quoted 7 lines
I think the "too many positional arguments" is because the parser isn't able to handle the trailing commas.
The "unknown use of instruction mnemonic" is because the macro was named
GHASH_4_ENCRYPT_4_PARALLEL_DECbut its being instantiated withGHASH_4_ENCRYPT_4_PARALLEL_decI guess gas ignores case on the macro instantiation, but llvm doesn't.
First, I removed the trailing comma in the PRECOMPUTE line.
Second, I substituted:
1. GHASH_4_ENCRYPT_4_PARALLEL_DEC -> GHASH_4_ENCRYPT_4_PARALLEL_dec
2. GHASH_4_ENCRYPT_4_PARALLEL_ENC -> GHASH_4_ENCRYPT_4_PARALLEL_enc
With these changes I was able to build with LLVM_IAS=1 and boot on bare metal.
I confirmed that this works with Linux-kernel v5.7.5 final.
NOTE: This patch is on top of Linux v5.7 final.
Thanks to Craig and especially Nick for double-checking and his comments.
---
Changes v4->v5:
- Drop "5.7" tag from subject line as requested by Herbert Xu
- Add Link to LLVM bug #24494 (thanks Nick)
Changes v3->v4:
- Add <> around email address as desired by Nick
- Add Nick's Reviewed-by
Changes v2->v3:
- Add this Changelog
Changes v1->v2:
- Replace Cc by Suggested-by for Craig
- Replace Cc by Suggested-by for Nick (dropped Cc as desired)
- Really follow the suggestions of Craig
- Drop unneeded comments for my build-environment and Links
arch/x86/crypto/aesni-intel_asm.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/crypto/aesni-intel_asm.S +3 -3
@@ -266,7 +266,7 @@ ALL_F: .octa 0xffffffffffffffffffffffffffffffff PSHUFB_XMM %xmm2, %xmm0 movdqu %xmm0, CurCount(%arg2) # ctx_data.current_counter = iv - PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, + PRECOMPUTE \SUBKEY, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7 movdqu HashKey(%arg2), %xmm13 CALC_AAD_HASH %xmm13, \AAD, \AADLEN, %xmm0, %xmm1, %xmm2, %xmm3, \
@@ -978,7 +978,7 @@ _initial_blocks_done\@: * arg1, %arg3, %arg4 are used as pointers only, not modified * %r11 is the data offset value */ -.macro GHASH_4_ENCRYPT_4_PARALLEL_ENC TMP1 TMP2 TMP3 TMP4 TMP5 \ +.macro GHASH_4_ENCRYPT_4_PARALLEL_enc TMP1 TMP2 TMP3 TMP4 TMP5 \ TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation movdqa \XMM1, \XMM5
@@ -1186,7 +1186,7 @@ aes_loop_par_enc_done\@: * arg1, %arg3, %arg4 are used as pointers only, not modified * %r11 is the data offset value */ -.macro GHASH_4_ENCRYPT_4_PARALLEL_DEC TMP1 TMP2 TMP3 TMP4 TMP5 \ +.macro GHASH_4_ENCRYPT_4_PARALLEL_dec TMP1 TMP2 TMP3 TMP4 TMP5 \ TMP6 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 operation movdqa \XMM1, \XMM5
Signature · 1 line
2.27.0
Herbert Xu
maintainerQuoted 72 lines · Sedat Dilek
When building with LLVM_IAS=1 means using Clang's Integrated Assembly (IAS) from LLVM/Clang >= v10.0.1-rc1+ instead of GNU/as from GNU/binutils I see the following breakage in Debian/testing AMD64:
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,^
arch/x86/crypto/aesni-intel_asm.S:1598:2: note: while in macro instantiation
GCM_INIT%r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_dec%xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1599:2: note: while in macro instantiation
GCM_ENC_DECdec
^
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,^
arch/x86/crypto/aesni-intel_asm.S:1686:2: note: while in macro instantiation
GCM_INIT%r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_enc%xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1687:2: note: while in macro instantiation
GCM_ENC_DECencCraig Topper suggested me in ClangBuiltLinux issue #1050:
Quoted 7 lines
I think the "too many positional arguments" is because the parser isn't able to handle the trailing commas.
The "unknown use of instruction mnemonic" is because the macro was named
GHASH_4_ENCRYPT_4_PARALLEL_DECbut its being instantiated withGHASH_4_ENCRYPT_4_PARALLEL_decI guess gas ignores case on the macro instantiation, but llvm doesn't.First, I removed the trailing comma in the PRECOMPUTE line.
Second, I substituted:
1.GHASH_4_ENCRYPT_4_PARALLEL_DEC->GHASH_4_ENCRYPT_4_PARALLEL_dec
2.GHASH_4_ENCRYPT_4_PARALLEL_ENC->GHASH_4_ENCRYPT_4_PARALLEL_encWith these changes I was able to build with LLVM_IAS=1 and boot on bare metal.
I confirmed that this works with Linux-kernel v5.7.5 final.
NOTE: This patch is on top of Linux v5.7 final.
Thanks to Craig and especially Nick for double-checking and his comments.
Suggested-by Craig Topper <[email protected]>Suggested-by Craig Topper <[email protected]>Suggested-by Nick Desaulniers <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Cc "ClangBuiltLinux" <[email protected]>Signed-off-by Sedat Dilek <[email protected]>---
Changesv4->v5:
- Drop "5.7" tag from subject line as requested by Herbert Xu
- Add Link to LLVM bug #24494 (thanks Nick)Changes
v3->v4:
- Add <> around email address as desired by Nick
- Add Nick's Reviewed-byChanges
v2->v3:
- Add this Changelog
Quoted 8 lines
Changes
v1->v2:
- Replace Cc by Suggested-by for Craig
- Replace Cc by Suggested-by for Nick (dropped Cc as desired)
- Really follow the suggestions of Craig
- Drop unneeded comments for my build-environment and Linksarch/x86/crypto/aesni-intel_asm.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Sedat Dilek
Tested-byQuoted 80 lines · Herbert Xu
Quoted 78 lines · Sedat Dilek
When building with LLVM_IAS=1 means using Clang's Integrated Assembly (IAS) from LLVM/Clang >= v10.0.1-rc1+ instead of GNU/as from GNU/binutils I see the following breakage in Debian/testing AMD64:
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,^
arch/x86/crypto/aesni-intel_asm.S:1598:2: note: while in macro instantiation
GCM_INIT%r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_dec%xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1599:2: note: while in macro instantiation
GCM_ENC_DECdec
^
<instantiation>:15:74: error: too many positional arguments
PRECOMPUTE 8*3+8(%rsp), %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,^
arch/x86/crypto/aesni-intel_asm.S:1686:2: note: while in macro instantiation
GCM_INIT%r9, 8*3 +8(%rsp), 8*3 +16(%rsp), 8*3 +24(%rsp)
^
<instantiation>:47:2: error: unknown use of instruction mnemonic without a size suffix
GHASH_4_ENCRYPT_4_PARALLEL_enc%xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7, %xmm8, enc ^arch/x86/crypto/aesni-intel_asm.S:1687:2: note: while in macro instantiation
GCM_ENC_DECencCraig Topper suggested me in ClangBuiltLinux issue #1050:
Quoted 7 lines
I think the "too many positional arguments" is because the parser isn't able to handle the trailing commas.
The "unknown use of instruction mnemonic" is because the macro was named
GHASH_4_ENCRYPT_4_PARALLEL_DECbut its being instantiated withGHASH_4_ENCRYPT_4_PARALLEL_decI guess gas ignores case on the macro instantiation, but llvm doesn't.First, I removed the trailing comma in the PRECOMPUTE line.
Second, I substituted:
1.GHASH_4_ENCRYPT_4_PARALLEL_DEC->GHASH_4_ENCRYPT_4_PARALLEL_dec
2.GHASH_4_ENCRYPT_4_PARALLEL_ENC->GHASH_4_ENCRYPT_4_PARALLEL_encWith these changes I was able to build with LLVM_IAS=1 and boot on bare metal.
I confirmed that this works with Linux-kernel v5.7.5 final.
NOTE: This patch is on top of Linux v5.7 final.
Thanks to Craig and especially Nick for double-checking and his comments.
Suggested-by Craig Topper <[email protected]>Suggested-by Craig Topper <[email protected]>Suggested-by Nick Desaulniers <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Cc "ClangBuiltLinux" <[email protected]>Signed-off-by Sedat Dilek <[email protected]>---
Changesv4->v5:
- Drop "5.7" tag from subject line as requested by Herbert Xu
- Add Link to LLVM bug #24494 (thanks Nick)Changes
v3->v4:
- Add <> around email address as desired by Nick
- Add Nick's Reviewed-byChanges
v2->v3:
- Add this ChangelogChanges
v1->v2:
- Replace Cc by Suggested-by for Craig
- Replace Cc by Suggested-by for Nick (dropped Cc as desired)
- Really follow the suggestions of Craig
- Drop unneeded comments for my build-environment and Links
Quoted 4 lines
Quoted 2 lines
arch/x86/crypto/aesni-intel_asm.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Patch applied. Thanks.
[ CC Arnd ]
Thanks Herbert.
Last Monday I switched over from Linux v5.7.y to v5.8-rc4 and my patch applied cleanly - I was able to build and boot on bare metal.
One request :
We (ClangBuiltLinux folks) need at least Arnd's patch (see [1])...
"x86: crypto: fix building crc32c with clang ias"
...to be full compliant with LLVM_IAS=1.
We had some discussion internally (see [2]-[4]). Looking at Arnd's patch again: It was also sent to linux-crypto ML (May 27, 2020, 2:17 p.m. UTC).
If you pick this directly, feel free to add my:
If you have any other wishes/requirements, please let me know.
Regards,
- Sedat -
P.S.: If you are interested in the status of LLVM_IAS=1 see [5] - it needs to be updated to my recent experiments with Linux v5.8-rc4. P.S.S.: BTW, a recent version of llvm-toolchain v11.0.0-git is full compliant with LLVM=1 - no GNU/binutils/tools used just LLVM/utilities (beyond GNU/make) :-).
[1] https://lore.kernel.org/patchwork/patch/1248401/
[2] https://github.com/ClangBuiltLinux/linux/issues/1010
[3] https://github.com/ClangBuiltLinux/linux/issues/1010#issuecomment-653759336
[4] https://github.com/ClangBuiltLinux/linux/issues/1010#issuecomment-656406876
[5] https://github.com/ClangBuiltLinux/linux/issues/1049
ADDENDUM: Demonstrate/show used Clang's integrated assembler (IAS):
$ llvm-dwarfdump-11 arch/x86/crypto/crc32c-intel.o
...
0x0000adc3: DW_TAG_compile_unit
DW_AT_stmt_list (0x00000b94)
DW_AT_ranges (0x00000040
[0x0000000000000350, 0x0000000000001430)
[0x0000000000000000, 0x000000000000000a))
DW_AT_name ("arch/x86/crypto/crc32c-pcl-intel-asm_64.S")
DW_AT_comp_dir ("/home/dileks/src/linux-kernel/git")
DW_AT_producer ("Debian clang version
11.0.0-++20200701093119+ffee8040534-1~exp1 ")
DW_AT_language (DW_LANG_Mips_Assembler)
...
- EOT -