2023-01-17 03:48:33

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build failure after merge of the crypto tree

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.

From: Stephen Rothwell <[email protected]>
Date: Tue, 17 Jan 2023 14:41:10 +1100
Subject: [PATCH] crypto: p10-aes-gcm - only ABIv1 code has been implemented

Signed-off-by: Stephen Rothwell <[email protected]>
---
arch/powerpc/crypto/Kconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig
index db7d99383993..36928ad14a6b 100644
--- a/arch/powerpc/crypto/Kconfig
+++ b/arch/powerpc/crypto/Kconfig
@@ -97,6 +97,7 @@ config CRYPTO_AES_PPC_SPE
config CRYPTO_P10_AES_GCM
tristate "Stitched AES/GCM acceleration support on P10+ CPU (PPC)"
depends on PPC64
+ depends on PPC64_ELF_ABI_V1
select CRYPTO_LIB_AES
select CRYPTO_ALGAPI
select CRYPTO_AEAD
--
2.35.1

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2023-01-17 07:30:25

by Herbert Xu

[permalink] [raw]
Subject: crypto: p10-aes-gcm - Add asm markings necessary for kernel code

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 <[email protected]>
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 <[email protected]>

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=<>) {

--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2023-01-18 03:11:45

by Stephen Rothwell

[permalink] [raw]
Subject: Re: crypto: p10-aes-gcm - Add asm markings necessary for kernel code

Hi Herbert,

On Tue, 17 Jan 2023 15:26:24 +0800 Herbert Xu <[email protected]> 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.

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2023-01-18 09:28:38

by Sathvika Vasireddy

[permalink] [raw]
Subject: Re: crypto: p10-aes-gcm - Add asm markings necessary for kernel code

Hi Stephen,

On 18/01/23 08:34, Stephen Rothwell wrote:
> Hi Herbert,
>
> On Tue, 17 Jan 2023 15:26:24 +0800 Herbert Xu <[email protected]> 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).

Warnings [1], [2], and [3] are seen with pseries_le_defconfig.

[1] - arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: aes_p8_set_encrypt_key+0x44: unannotated intra-function call
[2] - arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: .text+0x2448: unannotated intra-function call
[3] - arch/powerpc/crypto/aesp8-ppc.o: warning: objtool: .text+0x2d68: unannotated intra-function call

Given that there are no calls to _mcount, one way to address this warning, is by skipping objtool from running on arch/powerpc/crypto/aesp8-ppc.o file.
The below diff works for me.

=====
diff --git a/arch/powerpc/crypto/Makefile b/arch/powerpc/crypto/Makefile
index 5b8252013abd..d00664c8d761 100644
--- a/arch/powerpc/crypto/Makefile
+++ b/arch/powerpc/crypto/Makefile
@@ -31,3 +31,5 @@ targets += aesp8-ppc.S ghashp8-ppc.S

$(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
$(call if_changed,perl)
+
+OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
=====


The other way to fix these warnings is by using ANNOTATE_INTRA_FUNCTION_CALL macro to indicate that the branch target is valid. And, by annotating symbols with SYM_FUNC_START_LOCAL and SYM_FUNC_END macros.
The below diff works for me:

=====
diff --git a/arch/powerpc/crypto/aesp8-ppc.pl b/arch/powerpc/crypto/aesp8-ppc.pl
index cdbcf6e13efc..355e0036869a 100644
--- a/arch/powerpc/crypto/aesp8-ppc.pl
+++ b/arch/powerpc/crypto/aesp8-ppc.pl
@@ -80,6 +80,9 @@
# POWER8[le] 3.96/0.72 0.74 1.1
# POWER8[be] 3.75/0.65 0.66 1.0

+print "#include <linux/objtool.h>\n";
+print "#include <linux/linkage.h>\n";
+
$flavour = shift;

if ($flavour =~ /64/) {
@@ -185,7 +188,8 @@ Lset_encrypt_key:
lis r0,0xfff0
mfspr $vrsave,256
mtspr 256,r0
-
+
+ ANNOTATE_INTRA_FUNCTION_CALL
bl Lconsts
mtlr r11

@@ -3039,7 +3043,7 @@ Lxts_enc6x_ret:
.long 0

.align 5
-_aesp8_xts_enc5x:
+SYM_FUNC_START_LOCAL(_aesp8_xts_enc5x)
vcipher $out0,$out0,v24
vcipher $out1,$out1,v24
vcipher $out2,$out2,v24
@@ -3121,6 +3125,7 @@ _aesp8_xts_enc5x:
blr
.long 0
.byte 0,12,0x14,0,0,0,0,0
+SYM_FUNC_END(_aesp8_xts_enc5x)

.align 5
_aesp8_xts_decrypt6x:
@@ -3727,7 +3732,7 @@ Lxts_dec6x_ret:
.long 0

.align 5
-_aesp8_xts_dec5x:
+SYM_FUNC_START_LOCAL(_aesp8_xts_dec5x)
vncipher $out0,$out0,v24
vncipher $out1,$out1,v24
vncipher $out2,$out2,v24
@@ -3809,6 +3814,7 @@ _aesp8_xts_dec5x:
blr
.long 0
.byte 0,12,0x14,0,0,0,0,0
+SYM_FUNC_END(_aesp8_xts_dec5x)
___
}} }}}

=====


Thanks,
Sathvika

2023-01-18 10:31:21

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto: p10-aes-gcm - Add asm markings necessary for kernel code

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,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt