Skip to content

Commit 97ac82d

Browse files
arndbherbertx
authored andcommitted
crypto: aegis - fix badly optimized clang output
Clang sometimes makes very different inlining decisions from gcc. In case of the aegis crypto algorithms, it decides to turn the innermost primitives (and, xor, ...) into separate functions but inline most of the rest. This results in a huge amount of variables spilled on the stack, leading to rather slow execution as well as kernel stack usage beyond the 32-bit warning limit when CONFIG_KASAN is enabled: crypto/aegis256.c:123:13: warning: stack frame size of 648 bytes in function 'crypto_aegis256_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis256.c:366:13: warning: stack frame size of 1264 bytes in function 'crypto_aegis256_crypt' [-Wframe-larger-than=] crypto/aegis256.c:187:13: warning: stack frame size of 656 bytes in function 'crypto_aegis256_decrypt_chunk' [-Wframe-larger-than=] crypto/aegis128l.c:135:13: warning: stack frame size of 832 bytes in function 'crypto_aegis128l_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis128l.c:415:13: warning: stack frame size of 1480 bytes in function 'crypto_aegis128l_crypt' [-Wframe-larger-than=] crypto/aegis128l.c:218:13: warning: stack frame size of 848 bytes in function 'crypto_aegis128l_decrypt_chunk' [-Wframe-larger-than=] crypto/aegis128.c:116:13: warning: stack frame size of 584 bytes in function 'crypto_aegis128_encrypt_chunk' [-Wframe-larger-than=] crypto/aegis128.c:351:13: warning: stack frame size of 1064 bytes in function 'crypto_aegis128_crypt' [-Wframe-larger-than=] crypto/aegis128.c:177:13: warning: stack frame size of 592 bytes in function 'crypto_aegis128_decrypt_chunk' [-Wframe-larger-than=] Forcing the primitives to all get inlined avoids the issue and the resulting code is similar to what gcc produces. Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Nick Desaulniers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent bfb5eb0 commit 97ac82d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crypto/aegis.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ static const union aegis_block crypto_aegis_const[2] = {
3535
} },
3636
};
3737

38-
static inline void crypto_aegis_block_xor(union aegis_block *dst,
39-
const union aegis_block *src)
38+
static __always_inline void crypto_aegis_block_xor(union aegis_block *dst,
39+
const union aegis_block *src)
4040
{
4141
dst->words64[0] ^= src->words64[0];
4242
dst->words64[1] ^= src->words64[1];
4343
}
4444

45-
static inline void crypto_aegis_block_and(union aegis_block *dst,
46-
const union aegis_block *src)
45+
static __always_inline void crypto_aegis_block_and(union aegis_block *dst,
46+
const union aegis_block *src)
4747
{
4848
dst->words64[0] &= src->words64[0];
4949
dst->words64[1] &= src->words64[1];
5050
}
5151

52-
static inline void crypto_aegis_aesenc(union aegis_block *dst,
53-
const union aegis_block *src,
54-
const union aegis_block *key)
52+
static __always_inline void crypto_aegis_aesenc(union aegis_block *dst,
53+
const union aegis_block *src,
54+
const union aegis_block *key)
5555
{
5656
const u8 *s = src->bytes;
5757
const u32 *t = crypto_ft_tab[0];

0 commit comments

Comments
 (0)