On Wed, May 07, 2025 at 09:23:23AM -0600, Tom Rini wrote: > On Wed, May 07, 2025 at 10:47:13AM +0200, Simon Glass wrote: > > Hi Tom, > > > > On Fri, 18 Apr 2025 at 15:39, Tom Rini <tr...@konsulko.com> wrote: > > > > > > On Fri, Apr 18, 2025 at 04:59:13AM -0600, Simon Glass wrote: > > > > > > > From: Simon Glass <simon.gl...@canonical.com> > > > > > > > > Add part of this file from Linux v6.14 so we can include it from the > > > > linux/overflow.h file. Drop the relevant section from kernel.h > > > > > > > > The top of the file is omitted since it defines things used in mbedos > > > > and we get an error on SIZE_MAX. > > > > > > > > Signed-off-by: Simon Glass <simon.gl...@canonical.com> > > > > --- > > > > Error is: > > > > > > > > In file included from include/limits.h:6, > > > > from > > > > lib/mbedtls/external/mbedtls/library/constant_time.c:14: > > > > include/linux/limits.h:7:35: error: missing binary operator before > > > > token "0" > > > > 7 | #define SIZE_MAX (~(size_t)0) > > > > | ^ > > > > lib/mbedtls/external/mbedtls/library/constant_time_internal.h:65:6: > > > > note: in expansion of macro ‘SIZE_MAX’ > > > > 65 | #if (SIZE_MAX > 0xffffffffffffffffULL) > > > > | ^~~~~~~~ > > > > include/linux/limits.h:7:35: error: missing binary operator before > > > > token "0" > > > > 7 | #define SIZE_MAX (~(size_t)0) > > > > | ^ > > > > lib/mbedtls/external/mbedtls/library/constant_time_internal.h:71:8: > > > > note: in expansion of macro ‘SIZE_MAX’ > > > > 71 | #elif (SIZE_MAX > 0xffffffff) || defined(MBEDTLS_HAVE_INT64) > > > > | ^~~~~~~~ > > > > make[3]: *** [scripts/Makefile.build:256: > > > > lib/mbedtls/external/mbedtls/library/constant_time.o] Error 1 > > > > make[2]: *** [scripts/Makefile.build:398: lib/mbedtls] Error 2 > > > > > > > > Changes in v2: > > > > - Add new patch to bring in linux/limits.h > > > > > > > > include/limits.h | 2 ++ > > > > include/linux/kernel.h | 12 ------------ > > > > include/linux/limits.h | 21 +++++++++++++++++++++ > > > > 3 files changed, 23 insertions(+), 12 deletions(-) > > > > create mode 100644 include/linux/limits.h > > > > > > Ugh. I think we need to: > > > - Fix lib/string.c (and Fixes commit 7c7361b98d6e ("lib: implement > > > strnstr()")) to not bring in <limits.h> as that should be limited to > > > mbedtls usage. > > > - Not bring <linux/limits.h> to <limits.h> to start with at least (we > > > can worry about handling wrappers around overflow protection there > > > separately). > > > > There are quite a few places which need the limits. If I remove the > > dups from kernel.h then some things don't compile, at least not > > without including linux/limits,h in limits,h (which it seems to me we > > should do). > > So, looking at things more to understand the problem, mbedTLS uses > constants for types (reasonable choice) and the Linux kernel uses types > and casts (also reasonable choice), and these can't be mixed and > matched, that's what results in the error you see. So, I'll re-evaluate > your v2, that might be the best compromise.
Yeah, for v3 you need to address the comments on 3/3 still. -- Tom
signature.asc
Description: PGP signature