Skip to contentSkip to conversation

lib/crypto: blake2b: Limit frame size workaround to GCC

PATCH Superseded Thorsten Blum 2 participants 2 messages Nov 23, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib/crypto: blake2b: Limit frame size workaround to GCC

The GCC regression only affected i386 and has been fixed since GCC 12.2. However, modern GCC versions still generate large stack frames on other architectures (e.g., 3440 bytes for blake2b_compress_generic() on m68k with GCC 15.1.0). Clang handles these functions efficiently and should work fine with the default warning threshold.

Limit the frame size workaround to GCC only.

---
Changes in v2:
- Restrict frame size workaround to GCC independent of its version or
the architecture
- Update patch title and description
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

---
 lib/crypto/Makefile | 2 ++
 1 file changed, 2 insertions(+)
lib/crypto/Makefile +2 -0
index b5346cebbb55..95a48393ffb4 100644
@@ -33,7 +33,9 @@ obj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
 
 obj-$(CONFIG_CRYPTO_LIB_BLAKE2B) += libblake2b.o
 libblake2b-y := blake2b.o
+ifeq ($(CONFIG_CC_IS_GCC),y)
 CFLAGS_blake2b.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
+endif # CONFIG_CC_IS_GCC
 ifeq ($(CONFIG_CRYPTO_LIB_BLAKE2B_ARCH),y)
 CFLAGS_blake2b.o += -I$(src)/$(SRCARCH)
 libblake2b-$(CONFIG_ARM) += arm/blake2b-neon-core.o
Signature · 1 line
2.51.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Thorsten Blum

The GCC regression only affected i386 and has been fixed since GCC 12.2. However, modern GCC versions still generate large stack frames on other architectures (e.g., 3440 bytes for blake2b_compress_generic() on m68k with GCC 15.1.0). Clang handles these functions efficiently and should work fine with the default warning threshold.

Limit the frame size workaround to GCC only.

Since the below comments are mostly nits:

Quoted 15 lines

---
Changes in v2:
- Restrict frame size workaround to GCC independent of its version or
the architecture
- Update patch title and description
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

---
 lib/crypto/Makefile | 2 ++
 1 file changed, 2 insertions(+)
lib/crypto/Makefile +0 -0
index b5346cebbb55..95a48393ffb4 100644

lib/crypto/Makefile obj-$(CONFIG_CRYPTO_LIB_GF128MUL) += gf128mul.o · line 36

Quoted 4 lines
lib/crypto/Makefile +1 -0
@@ -33,7 +33,9 @@ obj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
 
 obj-$(CONFIG_CRYPTO_LIB_BLAKE2B) += libblake2b.o
 libblake2b-y := blake2b.o
+ifeq ($(CONFIG_CC_IS_GCC),y)

I tend to prefer

ifdef CONFIG_CC_IS_GCC

when the symbol is bool since it is a little easier to understand.

It may be worth a comment about the warnings on other architectures to help future travellers who may be tempted to remove this when the fixed GCC version of that bug report becomes the minimum.

lib/crypto/Makefile obj-$(CONFIG_CRYPTO_LIB_GF128MUL) += gf128mul.o · line 38

Quoted 2 lines
lib/crypto/Makefile +1 -0
 CFLAGS_blake2b.o := -Wframe-larger-than=4096 #  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105930
+endif # CONFIG_CC_IS_GCC

This conditional feels small enough that it does not need this marker but I guess that is maintainer preference.

Quoted 6 lines
lib/crypto/Makefile +0 -0
 ifeq ($(CONFIG_CRYPTO_LIB_BLAKE2B_ARCH),y)
 CFLAGS_blake2b.o += -I$(src)/$(SRCARCH)
 libblake2b-$(CONFIG_ARM) += arm/blake2b-neon-core.o
Signature · 1 line
2.51.1