package/ibm-sw-tpm2: fix build with gcc-15.x
PATCH 1/1 package/ibm-sw-tpm2: fix build with gcc-15.x
Fixes:
https://autobuild.buildroot.net/results/d43/d4364f6e3636c696471bf8cba6d308439130e53a/
In function 'MakeIv',
inlined from 'TestSymmetricAlgorithm' at AlgorithmTests.c:197:25:
AlgorithmTests.c:181:23: error: writing 32 bytes into a region of size
16 [-Werror=stringop-overflow=]
The build error occurs with gcc 15.x on some platforms, gcc 14.x is not affected.
These defconfigs build without this patch:
BR2_x86_64=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=y
BR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=y
BR2_x86_64=y
BR2_PACKAGE_IBM_SW_TPM2=y
This gcc-15 based defconfig is broken:
BR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_PACKAGE_IBM_SW_TPM2=y
The build error is not related to the recent bump of the package from rev183-2024-03-27 to rev183-2026-08-26 because no changes were committed upstream to AlgorithmTests.c since rev183-2024-03-27:
https://github.com/kgoldman/ibmswtpm2/commits/master/src/AlgorithmTests.c
--- ...15-stringop-overflow-error-in-MakeIv.patch | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 package/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patch
package/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patch new file +45 -0
@@ -0,0 +1,45 @@ +From b35faee1224f5bccf759464e69f724a03421c8a9 Mon Sep 17 00:00:00 2001 +From: Arthur Gautier <[email protected]> +Date: Tue, 9 Jun 2026 21:52:07 -0700 +Subject: [PATCH] tpm2: fix GCC 15 stringop-overflow error in MakeIv + +When compiling with GCC 15 using `CFLAGS=-march=x86-64-v4`, the compiler's +aggressively optimized vectorizer triggers a false-positive +-Wstringop-overflow error. Because x86-64-v4 enables wide AVX-512 registers, +the compiler misinterprets the loop unrolling and warns that a 64-byte +vector write is overflowing the destination buffer: +``` + tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c:158:17: error: + writing 64 bytes into a region of size 15 [-Werror=stringop-overflow=] + 158 | *iv = i; +``` + +This fixes the warning by marking the `iv` output pointer parameter as +`volatile`. This inhibits the over-aggressive loop vectorization on this +specific buffer, silencing the compiler error without changing the +underlying logic. + +Signed-off-by: Arthur Gautier <[email protected]> + +Source: https://github.com/stefanberger/libtpms/commit/2d9b00c4e42677cd0a9b67344f4d873ddc409a21 +Upstream: https://github.com/kgoldman/ibmswtpm2/pull/25 + +[Bernd: rebased for ibm-sw-tpm2 package] +Signed-off-by: Bernd Kuhls <[email protected]> +--- + src/AlgorithmTests.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/AlgorithmTests.c b/src/AlgorithmTests.c +index e8549adca..28d8e780a 100644 +--- a/src/AlgorithmTests.c ++++ b/src/AlgorithmTests.c +@@ -162,7 +162,7 @@ + // Internal function to make the appropriate IV depending on the mode. + static UINT32 MakeIv(TPM_ALG_ID mode, // IN: symmetric mode + UINT32 size, // IN: block size of the algorithm +- BYTE* iv // OUT: IV to fill in ++ volatile BYTE* iv // OUT: IV to fill in + ) + { + BYTE i;
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni via buildroot
AppliedQuoted 31 lines · Bernd Kuhls
Fixes:
https://autobuild.buildroot.net/results/d43/d4364f6e3636c696471bf8cba6d308439130e53a/In function 'MakeIv',
inlined from 'TestSymmetricAlgorithm' at AlgorithmTests.c:197:25:
AlgorithmTests.c:181:23: error: writing 32 bytes into a region of size
16 [-Werror=stringop-overflow=]The build error occurs with gcc 15.x on some platforms, gcc 14.x is not affected.
These defconfigs build without this patch:
BR2_x86_64=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=yBR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=yBR2_x86_64=y
BR2_PACKAGE_IBM_SW_TPM2=yThis gcc-15 based defconfig is broken:
BR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_PACKAGE_IBM_SW_TPM2=y
Quoted 6 lines
The build error is not related to the recent bump of the package from rev183-2024-03-27 to rev183-2026-08-26 because no changes were committed upstream to
AlgorithmTests.csince rev183-2024-03-27:
https://github.com/kgoldman/ibmswtpm2/commits/master/src/AlgorithmTests.cSigned-off-by Bernd Kuhls <[email protected]>
Applied to master, thanks!
Best regards,
Thomas Petazzoni
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Raphaël Mélotte via buildroot
AppliedIn reply of:
Quoted 31 lines
Fixes:
https://autobuild.buildroot.net/results/d43/d4364f6e3636c696471bf8cba6d308439130e53a/In function 'MakeIv',
inlined from 'TestSymmetricAlgorithm' at AlgorithmTests.c:197:25:
AlgorithmTests.c:181:23: error: writing 32 bytes into a region of size
16 [-Werror=stringop-overflow=]The build error occurs with gcc 15.x on some platforms, gcc 14.x is not affected.
These defconfigs build without this patch:
BR2_x86_64=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=yBR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_GCC_VERSION_14_X=y
BR2_PACKAGE_IBM_SW_TPM2=yBR2_x86_64=y
BR2_PACKAGE_IBM_SW_TPM2=yThis gcc-15 based defconfig is broken:
BR2_x86_64=y
BR2_x86_x86_64_v4=y
BR2_PACKAGE_IBM_SW_TPM2=y
Quoted 6 lines
The build error is not related to the recent bump of the package from rev183-2024-03-27 to rev183-2026-08-26 because no changes were committed upstream to
AlgorithmTests.csince rev183-2024-03-27:
https://github.com/kgoldman/ibmswtpm2/commits/master/src/AlgorithmTests.cSigned-off-by Bernd Kuhls <[email protected]>
Applied to 2026.08.x. Thanks
Quoted 46 lines
--- ...15-stringop-overflow-error-in-MakeIv.patch | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 package/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patchpackage/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patch new file +35
-0@@ -0,0 +1,45 @@ +From b35faee1224f5bccf759464e69f724a03421c8a9 Mon Sep 17 00:00:00 2001 +From: Arthur Gautier <[email protected]> +Date: Tue, 9 Jun 2026 21:52:07 -0700 +Subject: [PATCH] tpm2: fix GCC 15 stringop-overflow error in MakeIv + +When compiling with GCC 15 using `CFLAGS=-march=x86-64-v4`, the compiler's +aggressively optimized vectorizer triggers a false-positive +-Wstringop-overflow error. Because x86-64-v4 enables wide AVX-512 registers, +the compiler misinterprets the loop unrolling and warns that a 64-byte +vector write is overflowing the destination buffer: +``` + tpm2/TPMCmd/tpm/src/crypt/AlgorithmTests.c:158:17: error: + writing 64 bytes into a region of size 15 [-Werror=stringop-overflow=] + 158 | *iv = i; +``` + +This fixes the warning by marking the `iv` output pointer parameter as +`volatile`. This inhibits the over-aggressive loop vectorization on this +specific buffer, silencing the compiler error without changing the +underlying logic. + +Signed-off-by: Arthur Gautier <[email protected]> + +Source: https://github.com/stefanberger/libtpms/commit/2d9b00c4e42677cd0a9b67344f4d873ddc409a21 +Upstream: https://github.com/kgoldman/ibmswtpm2/pull/25 + +[Bernd: rebased for ibm-sw-tpm2 package] +Signed-off-by: Bernd Kuhls <[email protected]> +--- + src/AlgorithmTests.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/AlgorithmTests.c b/src/AlgorithmTests.c +index e8549adca..28d8e780a 100644 +--- a/src/AlgorithmTests.c
package/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patch line 45
Quoted 10 lines
package/ibm-sw-tpm2/0003-tpm2-fix-GCC-15-stringop-overflow-error-in-MakeIv.patch new file +10
-0++++ b/src/AlgorithmTests.c +@@ -162,7 +162,7 @@ + // Internal function to make the appropriate IV depending on the mode. + static UINT32 MakeIv(TPM_ALG_ID mode, // IN: symmetric mode + UINT32 size, // IN: block size of the algorithm +- BYTE* iv // OUT: IV to fill in ++ volatile BYTE* iv // OUT: IV to fill in + ) + { + BYTE i;
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot