diff mbox series

crypto: p10-aes-gcm - Add asm markings necessary for kernel code

Message ID Y8ZNoBSX5P0ieJ3t@gondor.apana.org.au
State New
Headers show
Series crypto: p10-aes-gcm - Add asm markings necessary for kernel code | expand

Commit Message

Herbert Xu Jan. 17, 2023, 7:26 a.m. UTC
On Tue, Jan 17, 2023 at 02:47:47PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the crypto tree, today's linux-next build (powerpc
> pseries_le_defconfig) failed like this:
> 
> arch/powerpc/crypto/p10_aes_gcm.o: warning: objtool: .text+0x884: unannotated intra-function call
> arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> ld: arch/powerpc/crypto/p10_aes_gcm.o: ABI version 1 is not compatible with ABI version 2 output
> ld: failed to merge target specific data of file arch/powerpc/crypto/p10_aes_gcm.o
> 
> Caused by commit
> 
>   ca68a96c37eb ("crypto: p10-aes-gcm - An accelerated AES/GCM stitched implementation")
> 
> I have applied the following hack for today.

Thanks Stephen, I'm going to update the previous fix as follows:

---8<---
_GLOBAL is needed instead of .global on Linux in assembly code.

The explicit abiversion setting is removed as the code should
with either ABI.

Mark local functions to avoid objdump warnings.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: cc40379b6e19 ("crypto: p10-aes-gcm - Glue code for AES/GCM stitched implementation")
Fixes: 3b47eccaaff4 ("crypto: p10-aes-gcm - Supporting functions for AES")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Stephen Rothwell Jan. 18, 2023, 3:04 a.m. UTC | #1
Hi Herbert,

On Tue, 17 Jan 2023 15:26:24 +0800 Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Tue, Jan 17, 2023 at 02:47:47PM +1100, Stephen Rothwell wrote:
> > Hi all,
> > 
> > After merging the crypto tree, today's linux-next build (powerpc
> > pseries_le_defconfig) failed like this:
> > 
> > arch/powerpc/crypto/p10_aes_gcm.o: warning: objtool: .text+0x884: unannotated intra-function call
> > arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> > ld: arch/powerpc/crypto/p10_aes_gcm.o: ABI version 1 is not compatible with ABI version 2 output
> > ld: failed to merge target specific data of file arch/powerpc/crypto/p10_aes_gcm.o
> > 
> > Caused by commit
> > 
> >   ca68a96c37eb ("crypto: p10-aes-gcm - An accelerated AES/GCM stitched implementation")
> > 
> > I have applied the following hack for today.  
> 
> Thanks Stephen, I'm going to update the previous fix as follows:

I still get:

arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call

from the powerpc pseries_le_defconfig build (which is otherwise ok).

Now I also get (from a powerpc allyesconfig build):

tmp/cc8g6b4E.s: Assembler messages:
tmp/cc8g6b4E.s: Error: .size expression for gcm_init_p8 does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for .gcm_init_p8 does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for gcm_init_htable does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for .gcm_init_htable does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for gcm_gmult_p8 does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for .gcm_gmult_p8 does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for gcm_ghash_p8 does not evaluate to a constant
tmp/cc8g6b4E.s: Error: .size expression for .gcm_ghash_p8 does not evaluate to a constant
make[4]: *** [next/scripts/Makefile.build:374: arch/powerpc/crypto/ghashp8-ppc.o] Error 1
tmp/ccNrBtc1.s: Assembler messages:
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_set_encrypt_key does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_set_encrypt_key does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_set_decrypt_key does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_set_decrypt_key does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_decrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_decrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_cbc_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_cbc_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_ctr32_encrypt_blocks does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_ctr32_encrypt_blocks does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_xts_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_xts_encrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for aes_p8_xts_decrypt does not evaluate to a constant
tmp/ccNrBtc1.s: Error: .size expression for .aes_p8_xts_decrypt does not evaluate to a constant
make[4]: *** [next/scripts/Makefile.build:374: arch/powerpc/crypto/aesp8-ppc.o] Error 1
make[4]: Target 'arch/powerpc/crypto/' not remade because of errors.

$ grep gcm_init_p8 arch/powerpc/crypto/ghashp8-ppc.s
.align 2 ; .type gcm_init_p8,@function; .globl gcm_init_p8; gcm_init_p8:
.size gcm_init_p8,.-.gcm_init_p8
.size .gcm_init_p8,.-.gcm_init_p8

I have just marked CRYPTO_P10_AES_GCM as BROKEN for today.
Herbert Xu Jan. 18, 2023, 9:24 a.m. UTC | #2
On Wed, Jan 18, 2023 at 02:04:44PM +1100, Stephen Rothwell wrote:
>
> arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
> 
> from the powerpc pseries_le_defconfig build (which is otherwise ok).

Thanks Stephen.  I've reverted these changes completely.

Thanks,
diff mbox series

Patch

diff --git a/arch/powerpc/crypto/aesp8-ppc.pl b/arch/powerpc/crypto/aesp8-ppc.pl
index 50a0a18f35da..cdbcf6e13efc 100644
--- a/arch/powerpc/crypto/aesp8-ppc.pl
+++ b/arch/powerpc/crypto/aesp8-ppc.pl
@@ -121,6 +121,22 @@  my ($inp,$bits,$out,$ptr,$cnt,$rounds)=map("r$_",(3..8));
 my ($zero,$in0,$in1,$key,$rcon,$mask,$tmp)=map("v$_",(0..6));
 my ($stage,$outperm,$outmask,$outhead,$outtail)=map("v$_",(7..11));
 
+sub declare_function() {
+	my ($name) = @_;
+	if ($kernel) {
+		$code .= "SYM_FUNC_START_LOCAL($name)\n";
+	} else {
+		$code .= "L$name:\n";
+	}
+}
+
+sub end_function() {
+	my ($name) = @_;
+	if ($kernel) {
+		$code .= "SYM_FUNC_END($name)\n";
+	}
+}
+
 $code.=<<___;
 .machine	"any"
 
@@ -132,13 +148,18 @@  rcon:
 .long	0x1b000000, 0x1b000000, 0x1b000000, 0x1b000000	?rev
 .long	0x0d0e0f0c, 0x0d0e0f0c, 0x0d0e0f0c, 0x0d0e0f0c	?rev
 .long	0,0,0,0						?asis
-Lconsts:
+___
+&declare_function("consts");
+$code.=<<___;
 	mflr	r0
 	bcl	20,31,\$+4
 	mflr	$ptr	 #vvvvv "distance between . and rcon
 	addi	$ptr,$ptr,-0x48
 	mtlr	r0
 	blr
+___
+&end_function("consts");
+$code.=<<___;
 	.long	0
 	.byte	0,12,0x14,0,0,0,0,0
 .asciz	"AES for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>"
diff --git a/arch/powerpc/crypto/p10_aes_gcm.S b/arch/powerpc/crypto/p10_aes_gcm.S
index 2306ad7c5e36..153388733eae 100644
--- a/arch/powerpc/crypto/p10_aes_gcm.S
+++ b/arch/powerpc/crypto/p10_aes_gcm.S
@@ -38,8 +38,10 @@ 
  # ===================================================================================
  #
 
+#include <asm/ppc_asm.h>
+#include <linux/linkage.h>
+
 .machine        "any"
-.abiversion     1
 .text
 
  # 4x loops
@@ -569,9 +571,7 @@  ppc_aes_gcm_ghash:
  #    rounds is at offset 240 in rk
  #    Xi is at 0 in gcm_table (Xip).
  #
-.global aes_p10_gcm_encrypt
-.align 5
-aes_p10_gcm_encrypt:
+_GLOBAL(aes_p10_gcm_encrypt)
 
 	SAVE_REGS
 
@@ -989,7 +989,7 @@  Normal_block:
  # Handle multiple partial blocks for encrypt and decrypt
  #   operations.
  #
-Do_partial_block:
+SYM_FUNC_START_LOCAL(Do_partial_block)
 	add	17, 15, 5
 	cmpdi	17, 16
 	bgt	Big_block
@@ -1075,6 +1075,7 @@  Save_partial:
 
 Partial_done:
 	blr
+SYM_FUNC_END(Do_partial_block)
 
  #
  # Write partial block
@@ -1082,7 +1083,7 @@  Partial_done:
  # r12 - remaining bytes
  # v15 - partial input data
  #
-Write_partial_block:
+SYM_FUNC_START_LOCAL(Write_partial_block)
 	li		10, 192
 	stxvb16x	15+32, 10, 1		# last block
 
@@ -1097,6 +1098,7 @@  Write_last_byte:
 	stbu		14, 1(10)
         bdnz		Write_last_byte
 	blr
+SYM_FUNC_END(Write_partial_block)
 
 aes_gcm_out:
 	# out = state
@@ -1109,9 +1111,7 @@  aes_gcm_out:
  #
  # 8x Decrypt
  #
-.global aes_p10_gcm_decrypt
-.align 5
-aes_p10_gcm_decrypt:
+_GLOBAL(aes_p10_gcm_decrypt)
 
 	SAVE_REGS
 
diff --git a/arch/powerpc/crypto/ppc-xlate.pl b/arch/powerpc/crypto/ppc-xlate.pl
index 23cca703ce29..d1dcb914858c 100644
--- a/arch/powerpc/crypto/ppc-xlate.pl
+++ b/arch/powerpc/crypto/ppc-xlate.pl
@@ -198,6 +198,7 @@  my $mtsle	= sub {
 };
 
 print "#include <asm/ppc_asm.h>\n" if $flavour =~ /linux/;
+print "#include <linux/linkage.h>\n" if $flavour =~ /linux/;
 
 while($line=<>) {