[PATCH v4 0/4] Select CONFIG_64BIT for sandbox64 and x86_64

Picking up a series from Dan Carpenter and applying requested changes for v2.
I had previously set CONFIG_64BIT for arm64. This patchset does the same thing for sandbox and x86_64. (Mips and riscv were already doing it). This CONFIG option is used in the Makefile to determine if it's a 32 or 64 bit system for the CHECKER.
Makefile 1052 # the checker needs the correct machine size 1053 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
Changes in v4: - Add help text to describe new symbol CONFIG_SPL_64BIT - Split the statement in bloblist.c to be more readable
Changes in v3: Added a new patch 1/4 to make fixes to the source needed by the sandbox patch 2/4. Updated 3/4 to account for x86 being built with a 64 bit U-Boot proper but a 32 bit SPL. Added another patch 4/4 to fix an incorrect use of CONFIG_PHYS_64BIT which should be CONFIG_64BIT at the request of Tom Rini.
Changes in v2: Resubmitted by Andrew Goodbody with changes requested by reviewer
Andrew Goodbody (4): sandbox: Correct guard around readq/writeq sandbox: select CONFIG_64BIT for sandbox x86: select CONFIG_64BIT for X86_64 test: lib: Use CONFIG_64BIT to detect 64 bit compile
arch/Kconfig | 8 ++++++++ arch/arm/Kconfig | 1 + arch/mips/Kconfig | 4 ++++ arch/riscv/Kconfig | 1 + arch/sandbox/Kconfig | 2 ++ arch/sandbox/include/asm/io.h | 4 ++-- arch/x86/Kconfig | 1 + common/bloblist.c | 11 +++++++---- include/limits.h | 3 ++- test/lib/str.c | 8 ++++---- 10 files changed, 32 insertions(+), 11 deletions(-)

In include/linux/io.h the declarations of ioread64 and iowrite64 which make use of readq/writeq are guarded with CONFIG_64BIT so guard the sandbox declarations of readq and writeq also with CONFIG_64BIT.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
(no changes since v3)
Changes in v3: This is a new patch in the series at this point.
arch/sandbox/include/asm/io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 3d09170063..f656f361cd 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -39,13 +39,13 @@ void sandbox_write(void *addr, unsigned int val, enum sandboxio_size_t size); #define readb(addr) sandbox_read((const void *)addr, SB_SIZE_8) #define readw(addr) sandbox_read((const void *)addr, SB_SIZE_16) #define readl(addr) sandbox_read((const void *)addr, SB_SIZE_32) -#ifdef CONFIG_SANDBOX64 +#ifdef CONFIG_64BIT #define readq(addr) sandbox_read((const void *)addr, SB_SIZE_64) #endif #define writeb(v, addr) sandbox_write((void *)addr, v, SB_SIZE_8) #define writew(v, addr) sandbox_write((void *)addr, v, SB_SIZE_16) #define writel(v, addr) sandbox_write((void *)addr, v, SB_SIZE_32) -#ifdef CONFIG_SANDBOX64 +#ifdef CONFIG_64BIT #define writeq(v, addr) sandbox_write((void *)addr, v, SB_SIZE_64) #endif

Select CONFIG_64BIT so that we pass the -m64 option (instead of -m32) to static analysis tools.
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
(no changes since v3)
Changes in v3: Updated commit title
Changes in v2: Moved select of CONFIG_64BIT from SANDBOX64 to HOST_64BIT as suggested by reviewer.
arch/sandbox/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 1c8353d615..db29ca14bd 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -46,6 +46,7 @@ config HOST_32BIT
config HOST_64BIT def_bool $(cc-define,_LP64) + select 64BIT
config HOST_HAS_SDL def_bool $(success,sdl2-config --version)

On Mon, 25 Nov 2024 at 04:56, Andrew Goodbody andrew.goodbody@linaro.org wrote:
Select CONFIG_64BIT so that we pass the -m64 option (instead of -m32) to static analysis tools.
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org
(no changes since v3)
Changes in v3: Updated commit title
Changes in v2: Moved select of CONFIG_64BIT from SANDBOX64 to HOST_64BIT as suggested by reviewer.
arch/sandbox/Kconfig | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 1c8353d615..db29ca14bd 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -46,6 +46,7 @@ config HOST_32BIT
config HOST_64BIT def_bool $(cc-define,_LP64)
select 64BIT
config HOST_HAS_SDL def_bool $(success,sdl2-config --version) -- 2.39.5

Select CONFIG_64BIT so that we pass the -m64 option (instead of -m32) to static analysis tools. Introduce CONFIG_SPL_64BIT and select it for architectures other than x86 with 64 bit builds. Do not select it for x86 builds as x86 uses a 32 bit SPL. Ensure that when limits are set they use CONFIG_64BIT for U-Boot proper and CONFIG_SPL_64BIT for SPL. This is to allow for the 32 bit SPL build used by x86.
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
Changes in v4: - Add help text to describe new symbol CONFIG_SPL_64BIT - Splite statement in bloblist.c to make it more readable
Changes in v3: Introduce CONFIG_SPL_64BIT to allow for x86 building a 32 bit SPL and a 64 bit U-Boot proper.
Changes in v2: Corrected commit title to be x86 not sandbox
arch/Kconfig | 8 ++++++++ arch/arm/Kconfig | 1 + arch/mips/Kconfig | 4 ++++ arch/riscv/Kconfig | 1 + arch/sandbox/Kconfig | 1 + arch/x86/Kconfig | 1 + common/bloblist.c | 11 +++++++---- include/limits.h | 3 ++- 8 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig index 6258788f53..bb2e7bedd1 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -37,6 +37,14 @@ config 32BIT
config 64BIT bool + help + Indicates that U-Boot proper will be built for a 64 bit + architecture. + +config SPL_64BIT + bool + help + Indicates that SPL will be built for a 64 bit architecture.
config SYS_CACHELINE_SIZE int diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7282c4123b..055762b0b9 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -7,6 +7,7 @@ config SYS_ARCH config ARM64 bool select 64BIT + select SPL_64BIT if SPL select PHYS_64BIT select SYS_CACHE_SHIFT_6 imply SPL_SEPARATE_BSS diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 38577af43d..7ea439e857 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -211,6 +211,7 @@ config CPU_MIPS64_R1 bool "MIPS64 Release 1" depends on SUPPORTS_CPU_MIPS64_R1 select 64BIT + select SPL_64BIT if SPL help Choose this option to build a kernel for release 1 through 5 of the MIPS64 architecture. @@ -219,6 +220,7 @@ config CPU_MIPS64_R2 bool "MIPS64 Release 2" depends on SUPPORTS_CPU_MIPS64_R2 select 64BIT + select SPL_64BIT if SPL help Choose this option to build a kernel for release 2 through 5 of the MIPS64 architecture. @@ -227,6 +229,7 @@ config CPU_MIPS64_R6 bool "MIPS64 Release 6" depends on SUPPORTS_CPU_MIPS64_R6 select 64BIT + select SPL_64BIT if SPL help Choose this option to build a kernel for release 6 or later of the MIPS64 architecture. @@ -235,6 +238,7 @@ config CPU_MIPS64_OCTEON bool "Marvell Octeon series of CPUs" depends on SUPPORTS_CPU_MIPS64_OCTEON select 64BIT + select SPL_64BIT if SPL help Choose this option for Marvell Octeon CPUs. These CPUs are between MIPS64 R5 and R6 with other extensions. diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 043d963f63..abb7a984c4 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -120,6 +120,7 @@ config ARCH_RV32I config ARCH_RV64I bool "RV64I" select 64BIT + select SPL_64BIT if SPL select PHYS_64BIT help Choose this option to target the RV64I base integer instruction set. diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index db29ca14bd..4c169034d9 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -47,6 +47,7 @@ config HOST_32BIT config HOST_64BIT def_bool $(cc-define,_LP64) select 64BIT + select SPL_64BIT if SPL
config HOST_HAS_SDL def_bool $(success,sdl2-config --version) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 23a1e21b29..006a59d6fa 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -44,6 +44,7 @@ endchoice
config X86_64 bool + select 64BIT
config SPL_X86_64 bool diff --git a/common/bloblist.c b/common/bloblist.c index ec6ff7a5a9..30ca39a8e5 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -579,11 +579,14 @@ int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig) ulong version = BLOBLIST_REGCONV_VER; ulong sigval;
- sigval = (IS_ENABLED(CONFIG_64BIT)) ? - ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_64) - 1)) | - ((version & BLOBLIST_REGCONV_MASK) << BLOBLIST_REGCONV_SHIFT_64)) : - ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_32) - 1)) | + if ((IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_SPL_BUILD)) || + (IS_ENABLED(CONFIG_SPL_64BIT) && IS_ENABLED(CONFIG_SPL_BUILD))) { + sigval = ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_64) - 1)) | + ((version & BLOBLIST_REGCONV_MASK) << BLOBLIST_REGCONV_SHIFT_64)); + } else { + sigval = ((BLOBLIST_MAGIC & ((1UL << BLOBLIST_REGCONV_SHIFT_32) - 1)) | ((version & BLOBLIST_REGCONV_MASK) << BLOBLIST_REGCONV_SHIFT_32)); + }
if (rzero || rsig != sigval || rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) { diff --git a/include/limits.h b/include/limits.h index 4700cc7a59..1d0bbf69be 100644 --- a/include/limits.h +++ b/include/limits.h @@ -9,7 +9,8 @@ #define UINT32_MAX 0xffffffffU #define UINT64_MAX 0xffffffffffffffffULL
-#ifdef CONFIG_64BIT +#if (defined(CONFIG_64BIT) && !defined(CONFIG_SPL_BUILD)) || \ + (defined(CONFIG_SPL_64BIT) && defined(CONFIG_SPL_BUILD)) #define UINTPTR_MAX UINT64_MAX #else #define UINTPTR_MAX UINT32_MAX

On Mon, 25 Nov 2024 at 04:56, Andrew Goodbody andrew.goodbody@linaro.org wrote:
Select CONFIG_64BIT so that we pass the -m64 option (instead of -m32) to static analysis tools. Introduce CONFIG_SPL_64BIT and select it for architectures other than x86 with 64 bit builds. Do not select it for x86 builds as x86 uses a 32 bit SPL. Ensure that when limits are set they use CONFIG_64BIT for U-Boot proper and CONFIG_SPL_64BIT for SPL. This is to allow for the 32 bit SPL build used by x86.
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org
Changes in v4:
- Add help text to describe new symbol CONFIG_SPL_64BIT
- Splite statement in bloblist.c to make it more readable
Changes in v3: Introduce CONFIG_SPL_64BIT to allow for x86 building a 32 bit SPL and a 64 bit U-Boot proper.
Changes in v2: Corrected commit title to be x86 not sandbox
arch/Kconfig | 8 ++++++++ arch/arm/Kconfig | 1 + arch/mips/Kconfig | 4 ++++ arch/riscv/Kconfig | 1 + arch/sandbox/Kconfig | 1 + arch/x86/Kconfig | 1 + common/bloblist.c | 11 +++++++---- include/limits.h | 3 ++- 8 files changed, 25 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Should use CONFIG_64BIT to detect a 64 bit compile and not CONFIG_PHYS_64BIT. This allows more platforms to run the full test code.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
(no changes since v3)
Changes in v3: New patch added for this version.
test/lib/str.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/lib/str.c b/test/lib/str.c index e62045318c..48351abc75 100644 --- a/test/lib/str.c +++ b/test/lib/str.c @@ -224,13 +224,13 @@ static int str_itoa(struct unit_test_state *uts) ut_asserteq_str("4294967295", simple_itoa(0xffffffff));
/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT +#ifdef CONFIG_64BIT if (sizeof(ulong) == 8) { ut_asserteq_str("9223372036854775807", simple_itoa((1UL << 63) - 1)); ut_asserteq_str("18446744073709551615", simple_itoa(-1)); } -#endif /* CONFIG_PHYS_64BIT */ +#endif /* CONFIG_64BIT */
return 0; } @@ -244,13 +244,13 @@ static int str_xtoa(struct unit_test_state *uts) ut_asserteq_str("ffffffff", simple_xtoa(0xffffffff));
/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT +#ifdef CONFIG_64BIT if (sizeof(ulong) == 8) { ut_asserteq_str("7fffffffffffffff", simple_xtoa((1UL << 63) - 1)); ut_asserteq_str("ffffffffffffffff", simple_xtoa(-1)); } -#endif /* CONFIG_PHYS_64BIT */ +#endif /* CONFIG_64BIT */
return 0; }

On Mon, Nov 25, 2024 at 11:55:50AM +0000, Andrew Goodbody wrote:
Picking up a series from Dan Carpenter and applying requested changes for v2.
I had previously set CONFIG_64BIT for arm64. This patchset does the same thing for sandbox and x86_64. (Mips and riscv were already doing it). This CONFIG option is used in the Makefile to determine if it's a 32 or 64 bit system for the CHECKER.
Makefile 1052 # the checker needs the correct machine size 1053 CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
Unfortunately this currently fails to build for chromebook_coral chromebook_samus_tpl qemu-x86_64 and snow platforms.
participants (3)
-
Andrew Goodbody
-
Simon Glass
-
Tom Rini