[PATCH] powerpc/kexec/core: use big-endian types for crash variables

Venkat Rao Bagalkote venkat88 at linux.ibm.com
Fri Jan 2 22:12:23 AEDT 2026


On 24/12/25 8:42 pm, Sourabh Jain wrote:
> Use explicit word-sized big-endian types for kexec and crash related
> variables. This makes the endianness unambiguous and avoids type
> mismatches that trigger sparse warnings.
>
> The change addresses sparse warnings like below (seen on both 32-bit
> and 64-bit builds):
>
> CHECK   ../arch/powerpc/kexec/core.c
> sparse:    expected unsigned int static [addressable] [toplevel] [usertype] crashk_base
> sparse:    got restricted __be32 [usertype]
> sparse: warning: incorrect type in assignment (different base types)
> sparse:    expected unsigned int static [addressable] [toplevel] [usertype] crashk_size
> sparse:    got restricted __be32 [usertype]
> sparse: warning: incorrect type in assignment (different base types)
> sparse:    expected unsigned long long static [addressable] [toplevel] mem_limit
> sparse:    got restricted __be32 [usertype]
> sparse: warning: incorrect type in assignment (different base types)
> sparse:    expected unsigned int static [addressable] [toplevel] [usertype] kernel_end
> sparse:    got restricted __be32 [usertype]
>
> No functional change intended.
>
> Fixes: ea961a828fe7 ("powerpc: Fix endian issues in kexec and crash dump code")
> Reported-by: kernel test robot <lkp at intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512221405.VHPKPjnp-lkp@intel.com/
> Cc: Christophe Leroy (CS GROUP) <chleroy at kernel.org>
> Cc: Hari Bathini <hbathini at linux.ibm.com>
> Cc: Madhavan Srinivasan <maddy at linux.ibm.com>
> Cc: Mahesh Salgaonkar <mahesh at linux.ibm.com>
> Cc: Michael Ellerman <mpe at ellerman.id.au>
> Cc: Ritesh Harjani (IBM) <ritesh.list at gmail.com>
> Cc: Sachin Sant <sachinp at linux.ibm.com>
> Cc: Shivang Upadhyay <shivangu at linux.ibm.com>
> Cc: Venkat Rao Bagalkote <venkat88 at linux.ibm.com>
> Cc: kexec at lists.infradead.org
> Signed-off-by: Sourabh Jain <sourabhjain at linux.ibm.com>
> ---


Tested this patch, by applying on top of mainline repo and it fixes the 
reported issue.

Please add below tag.


Tested-by: Venkat Rao Bagalkote <venkat88 at linux.ibm.com>



Logs:


make -C /root/linux O=/root/build_dir ARCH=powerpc CC=clang W=1 C=1 
CHECKFLAGS="-Wbitwise -Wcast-to-as -Waddress-space" V=1 arch/powerpc/kexec/
make: Entering directory '/root/linux'
make  -C /root/build_dir \
-f /root/linux/Makefile arch/powerpc/kexec/
make[1]: Entering directory '/root/build_dir'
make --no-print-directory -C /root/build_dir \
-f /root/linux/Makefile arch/powerpc/kexec/
ln -fsn /root/linux source
# GEN     Makefile
   { echo "# Automatically generated by /root/linux/Makefile: don't 
edit"; echo "export KBUILD_OUTPUT = /root/build_dir"; echo "include 
/root/linux/Makefile"; } > Makefile
test -e .gitignore || \
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
make -f /root/linux/scripts/Makefile.build 
obj=arch/powerpc/kernel/syscalls all
make -f /root/linux/scripts/Makefile.build obj=scripts/basic
make -f /root/linux/scripts/Makefile.build obj=scripts/dtc
make -f /root/linux/scripts/Makefile.build obj=scripts
set -e; mkdir -p include/config/; trap "rm -f 
include/config/.tmp_kernel.release" EXIT; { 
/root/linux/scripts/setlocalversion /root/linux; } > 
include/config/.tmp_kernel.release; if [ ! -r 
include/config/kernel.release ] || ! cmp -s 
include/config/kernel.release include/config/.tmp_kernel.release; then : 
'  UPD     include/config/kernel.release'; mv -f 
include/config/.tmp_kernel.release include/config/kernel.release; fi
make -f /root/linux/scripts/Makefile.asm-headers 
obj=arch/powerpc/include/generated/uapi/asm \
generic=include/uapi/asm-generic
make -f /root/linux/scripts/Makefile.asm-headers 
obj=arch/powerpc/include/generated/asm \
generic=include/asm-generic
set -e; mkdir -p include/generated/uapi/linux/; trap "rm -f 
include/generated/uapi/linux/.tmp_version.h" EXIT; {     if [ 0 -gt 255 
]; then echo \#define LINUX_VERSION_CODE 398335; else echo \#define 
LINUX_VERSION_CODE 398080; fi; echo '#define KERNEL_VERSION(a,b,c) (((a) 
<< 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))'; echo \#define 
LINUX_VERSION_MAJOR 6; echo \#define LINUX_VERSION_PATCHLEVEL 19; echo 
\#define LINUX_VERSION_SUBLEVEL 0; } > 
include/generated/uapi/linux/.tmp_version.h; if [ ! -r 
include/generated/uapi/linux/version.h ] || ! cmp -s 
include/generated/uapi/linux/version.h 
include/generated/uapi/linux/.tmp_version.h; then : '  UPD 
  include/generated/uapi/linux/version.h'; mv -f 
include/generated/uapi/linux/.tmp_version.h 
include/generated/uapi/linux/version.h; fi
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_utsrelease.h" EXIT; {     if [ `echo -n 
"6.19.0-rc3-00153-g662be6163c58" | wc -c ` -gt 64 ]; then echo 
'"6.19.0-rc3-00153-g662be6163c58" exceeds 64 characters' >&2; exit 1; 
fi; echo \#define UTS_RELEASE \"6.19.0-rc3-00153-g662be6163c58\"; } > 
include/generated/.tmp_utsrelease.h; if [ ! -r 
include/generated/utsrelease.h ] || ! cmp -s 
include/generated/utsrelease.h include/generated/.tmp_utsrelease.h; then 
: '  UPD  include/generated/utsrelease.h'; mv -f 
include/generated/.tmp_utsrelease.h include/generated/utsrelease.h; fi
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_compile.h" EXIT; { 
/root/linux/scripts/mkcompile_h "ppc" "clang version 18.1.8 (Red Hat, 
Inc. 18.1.8-3.el9)" "ld"; } > include/generated/.tmp_compile.h; if [ ! 
-r include/generated/compile.h ] || ! cmp -s include/generated/compile.h 
include/generated/.tmp_compile.h; then : '  UPD    
  include/generated/compile.h'; mv -f include/generated/.tmp_compile.h 
include/generated/compile.h; fi
/root/linux/scripts/remove-stale-files
make -f /root/linux/scripts/Makefile.build obj=scripts/mod
set -e; mkdir -p scripts/mod/; trap "rm -f 
scripts/mod/.tmp_devicetable-offsets.h" EXIT; {      echo "#ifndef 
__DEVICETABLE_OFFSETS_H__"; echo "#define __DEVICETABLE_OFFSETS_H__"; 
echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was 
generated by Kbuild"; echo " */"; echo ""; sed -ne 
  's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; 
/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) 
\(.*\):#define \1 \2 /* \3 */:; s:->::; p;}' < 
scripts/mod/devicetable-offsets.s; echo ""; echo "#endif"; } > 
scripts/mod/.tmp_devicetable-offsets.h; if [ ! -r 
scripts/mod/devicetable-offsets.h ] || ! cmp -s 
scripts/mod/devicetable-offsets.h 
scripts/mod/.tmp_devicetable-offsets.h; then : '  UPD 
  scripts/mod/devicetable-offsets.h'; mv -f 
scripts/mod/.tmp_devicetable-offsets.h scripts/mod/devicetable-offsets.h; fi
make -f /root/linux/scripts/Makefile.build obj=. prepare
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_timeconst.h" EXIT; { echo 250 | bc -q 
/root/linux/kernel/time/timeconst.bc; } > 
include/generated/.tmp_timeconst.h; if [ ! -r 
include/generated/timeconst.h ] || ! cmp -s 
include/generated/timeconst.h include/generated/.tmp_timeconst.h; then : 
'  UPD     include/generated/timeconst.h'; mv -f 
include/generated/.tmp_timeconst.h include/generated/timeconst.h; fi
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_bounds.h" EXIT; {      echo "#ifndef 
__LINUX_BOUNDS_H__"; echo "#define __LINUX_BOUNDS_H__"; echo "/*"; echo 
" * DO NOT MODIFY."; echo " *"; echo " * This file was generated by 
Kbuild"; echo " */"; echo ""; sed -ne 
  's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; 
/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) 
\(.*\):#define \1 \2 /* \3 */:; s:->::; p;}' < kernel/bounds.s; echo ""; 
echo "#endif"; } > include/generated/.tmp_bounds.h; if [ ! -r 
include/generated/bounds.h ] || ! cmp -s include/generated/bounds.h 
include/generated/.tmp_bounds.h; then : '  UPD    
  include/generated/bounds.h'; mv -f include/generated/.tmp_bounds.h 
include/generated/bounds.h; fi
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_asm-offsets.h" EXIT; {      echo "#ifndef 
__ASM_OFFSETS_H__"; echo "#define __ASM_OFFSETS_H__"; echo "/*"; echo " 
* DO NOT MODIFY."; echo " *"; echo " * This file was generated by 
Kbuild"; echo " */"; echo ""; sed -ne 
  's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; 
/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) 
\(.*\):#define \1 \2 /* \3 */:; s:->::; p;}' < 
arch/powerpc/kernel/asm-offsets.s; echo ""; echo "#endif"; } > 
include/generated/.tmp_asm-offsets.h; if [ ! -r 
include/generated/asm-offsets.h ] || ! cmp -s 
include/generated/asm-offsets.h include/generated/.tmp_asm-offsets.h; 
then : '  UPD  include/generated/asm-offsets.h'; mv -f 
include/generated/.tmp_asm-offsets.h include/generated/asm-offsets.h; fi
set -e; mkdir -p include/generated/; trap "rm -f 
include/generated/.tmp_rq-offsets.h" EXIT; {      echo "#ifndef 
__RQ_OFFSETS_H__"; echo "#define __RQ_OFFSETS_H__"; echo "/*"; echo " * 
DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; 
echo " */"; echo ""; sed -ne 
  's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; 
/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) 
\(.*\):#define \1 \2 /* \3 */:; s:->::; p;}' < 
kernel/sched/rq-offsets.s; echo ""; echo "#endif"; } > 
include/generated/.tmp_rq-offsets.h; if [ ! -r 
include/generated/rq-offsets.h ] || ! cmp -s 
include/generated/rq-offsets.h include/generated/.tmp_rq-offsets.h; then 
: '  UPD  include/generated/rq-offsets.h'; mv -f 
include/generated/.tmp_rq-offsets.h include/generated/rq-offsets.h; fi
# CALL    /root/linux/scripts/checksyscalls.sh
   sh /root/linux/scripts/checksyscalls.sh clang 
-Wp,-MMD,./.missing-syscalls.d -nostdinc 
-I/root/linux/arch/powerpc/include -I./arch/powerpc/include/generated 
-I/root/linux/include -I./include 
-I/root/linux/arch/powerpc/include/uapi 
-I./arch/powerpc/include/generated/uapi -I/root/linux/include/uapi 
-I./include/generated/uapi -include 
/root/linux/include/linux/compiler-version.h -include 
/root/linux/include/linux/kconfig.h -include 
/root/linux/include/linux/compiler_types.h -D__KERNEL__ 
--target=powerpc64le-linux-gnu -fintegrated-as 
-Werror=unknown-warning-option -Werror=ignored-optimization-argument 
-Werror=option-ignored -Werror=unused-command-line-argument -mbig-endian 
-m32 -I /root/linux/arch/powerpc -DHAVE_AS_ATHIGH=1 
-fmacro-prefix-map=/root/linux/= -Wundef -DKBUILD_EXTRA_WARN1 -std=gnu11 
-fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing 
-msoft-float -mcpu=powerpc -mno-prefixed -mno-pcrel -mno-altivec 
-mno-vsx -mno-mma -mno-spe -fno-asynchronous-unwind-tables -mbig-endian 
-fno-delete-null-pointer-checks -O2 -fno-stack-protector 
-fomit-frame-pointer -falign-functions=4 -fstrict-flex-arrays=3 
-fms-extensions -fno-strict-overflow -fno-stack-check 
-fno-builtin-wcslen -Wall -Wextra -Wundef 
-Werror=implicit-function-declaration -Werror=implicit-int 
-Werror=return-type -Werror=strict-prototypes -Wno-format-security 
-Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member 
-Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1024 
-Wno-gnu -Wno-microsoft-anon-tag -Wno-format-overflow-non-kprintf 
-Wno-format-truncation-non-kprintf -Wno-pointer-sign 
-Wcast-function-type -Wimplicit-fallthrough -Werror=date-time 
-Werror=incompatible-pointer-types -Wenum-conversion -Wunused 
-Wmissing-format-attribute -Wmissing-include-dirs 
-Wunused-const-variable -Wno-missing-field-initializers -Wno-type-limits 
-Wno-shift-negative-value -Wno-enum-enum-conversion -Wno-sign-compare 
-Wno-unused-parameter -I/root/linux/. -I.    
-DKBUILD_MODFILE='"./missing-syscalls"' 
-DKBUILD_BASENAME='"missing_syscalls"' 
-DKBUILD_MODNAME='"missing_syscalls"' -D__KBUILD_MODNAME=missing_syscalls
mkdir -p ./tools
make O=/root/build_dir subdir=tools -C /root/linux/tools/ objtool
mkdir -p /root/build_dir/tools/objtool && make O=/root/build_dir 
subdir=tools/objtool --no-print-directory -C objtool
make -C /root/linux/tools/build CFLAGS= LDFLAGS= 
/root/build_dir/tools/objtool/fixdep
if [ ! -f /root/build_dir/tools/objtool/fixdep ]; then             \
     make -f /root/linux/tools/build/Makefile.build dir=. obj=fixdep 
HOSTCFLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11   -I /root/linux/scripts/include";    \
     rm -f /root/build_dir/tools/objtool/fixdep.o;       \
fi
make -f /root/linux/tools/build/Makefile.build dir=. obj=fixdep 
HOSTCFLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11   -I /root/linux/scripts/include"
make -C /root/linux/tools/lib/subcmd/ 
O=/root/build_dir/tools/objtool/libsubcmd \
     DESTDIR=/root/build_dir/tools/objtool/libsubcmd prefix= subdir= \
     CC="gcc" LD="ld" AR="ar" EXTRA_CFLAGS="-std=gnu11 
-fomit-frame-pointer -O2 -g -Werror -Wall -Wextra -Wmissing-prototypes 
-Wmissing-declarations -Wwrite-strings -Wno-implicit-fallthrough 
-Wno-sign-compare -Wno-unused-parameter -I/root/linux/tools/include 
-I/root/linux/tools/include/uapi 
-I/root/linux/tools/arch/powerpc/include/uapi 
-I/root/linux/tools/arch/powerpc/include 
-I/root/linux/tools/objtool/include 
-I/root/linux/tools/objtool/arch/powerpc/include 
-I/root/build_dir/tools/objtool/libsubcmd/include   " \
     /root/build_dir/tools/objtool/libsubcmd/libsubcmd.a install_headers
make -C /root/linux/tools/build CFLAGS= LDFLAGS= 
/root/build_dir/tools/objtool/libsubcmd/fixdep
if [ ! -f /root/build_dir/tools/objtool/libsubcmd/fixdep ]; then         
               \
     make -f /root/linux/tools/build/Makefile.build dir=. obj=fixdep 
HOSTCFLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11   -I /root/linux/scripts/include";    \
     rm -f /root/build_dir/tools/objtool/libsubcmd/fixdep.o;             
     \
fi
make -f /root/linux/tools/build/Makefile.build dir=. obj=fixdep 
HOSTCFLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 
-fomit-frame-pointer -std=gnu11   -I /root/linux/scripts/include"
make[5]: 'install_headers' is up to date.
sh ./sync-check.sh
make -f /root/linux/tools/build/Makefile.build dir=. obj=objtool 
CC="gcc" LD="ld" AR="ar" CFLAGS="-std=gnu11 -fomit-frame-pointer -O2 -g 
-Werror -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations 
-Wwrite-strings -Wno-implicit-fallthrough -Wno-sign-compare 
-Wno-unused-parameter -I/root/linux/tools/include 
-I/root/linux/tools/include/uapi 
-I/root/linux/tools/arch/powerpc/include/uapi 
-I/root/linux/tools/arch/powerpc/include 
-I/root/linux/tools/objtool/include 
-I/root/linux/tools/objtool/arch/powerpc/include 
-I/root/build_dir/tools/objtool/libsubcmd/include   " \
     LDFLAGS="/root/build_dir/tools/objtool/libsubcmd/libsubcmd.a -lelf   "
make -f /root/linux/tools/build/Makefile.build dir=./arch/powerpc 
obj=objtool
make -f /root/linux/scripts/Makefile.build obj=arch/powerpc/kernel/vdso 
include/generated/vdso32-offsets.h
make -f /root/linux/scripts/Makefile.build obj=. need-builtin=1 
need-modorder=1 ./arch/powerpc/kexec/
make -f /root/linux/scripts/Makefile.build obj=arch/powerpc \
need-builtin=1 \
need-modorder=1 \
arch/powerpc/kexec/
make -f /root/linux/scripts/Makefile.build obj=arch/powerpc/kexec \
need-builtin=1 \
need-modorder=1 \
arch/powerpc/kexec/
make[1]: Leaving directory '/root/build_dir'
make: Leaving directory '/root/linux'


Regards,

Venkat.


>   arch/powerpc/kexec/core.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c
> index 104c05520bf0..dc44f11be353 100644
> --- a/arch/powerpc/kexec/core.c
> +++ b/arch/powerpc/kexec/core.c
> @@ -23,6 +23,7 @@
>   #include <asm/firmware.h>
>   
>   #define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)
> +#define __be_word __PASTE(__be, BITS_PER_LONG)
>   
>   #ifdef CONFIG_CRASH_DUMP
>   void machine_crash_shutdown(struct pt_regs *regs)
> @@ -146,25 +147,25 @@ int __init overlaps_crashkernel(unsigned long start, unsigned long size)
>   }
>   
>   /* Values we need to export to the second kernel via the device tree. */
> -static phys_addr_t crashk_base;
> -static phys_addr_t crashk_size;
> -static unsigned long long mem_limit;
> +static __be_word crashk_base;
> +static __be_word crashk_size;
> +static __be_word mem_limit;
>   
>   static struct property crashk_base_prop = {
>   	.name = "linux,crashkernel-base",
> -	.length = sizeof(phys_addr_t),
> +	.length = sizeof(__be_word),
>   	.value = &crashk_base
>   };
>   
>   static struct property crashk_size_prop = {
>   	.name = "linux,crashkernel-size",
> -	.length = sizeof(phys_addr_t),
> +	.length = sizeof(__be_word),
>   	.value = &crashk_size,
>   };
>   
>   static struct property memory_limit_prop = {
>   	.name = "linux,memory-limit",
> -	.length = sizeof(unsigned long long),
> +	.length = sizeof(__be_word),
>   	.value = &mem_limit,
>   };
>   
> @@ -193,11 +194,11 @@ static void __init export_crashk_values(struct device_node *node)
>   }
>   #endif /* CONFIG_CRASH_RESERVE */
>   
> -static phys_addr_t kernel_end;
> +static __be_word kernel_end;
>   
>   static struct property kernel_end_prop = {
>   	.name = "linux,kernel-end",
> -	.length = sizeof(phys_addr_t),
> +	.length = sizeof(__be_word),
>   	.value = &kernel_end,
>   };
>   


More information about the Linuxppc-dev mailing list