arch/powerpc/kexec/core.c:217:20: sparse: sparse: incorrect type in assignment (different base types)
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9448598b22c50c8a5bb77a9103e2d49f134c9578 commit: 38c64dfe0af12778953846df5f259e913275cfe5 kexec: Include kernel-end even without crashkernel date: 6 weeks ago config: powerpc-randconfig-r111-20251222 (https://download.01.org/0day-ci/archive/20251222/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 42b3483ac4987cae1bdb632398e8a3ce2dea6633) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251222/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> arch/powerpc/kexec/core.c:217:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int static [addressable] [toplevel] [usertype] kernel_end @@ got restricted __be32 [usertype] @@
arch/powerpc/kexec/core.c:217:20: sparse: expected unsigned int static [addressable] [toplevel] [usertype] kernel_end
arch/powerpc/kexec/core.c:217:20: sparse: got restricted __be32 [usertype]
vim +217 arch/powerpc/kexec/core.c
6f29c3298b1821 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-17 203
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 204 static int __init kexec_setup(void)
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 205 {
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 206 struct device_node *node;
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 207
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 208 node = of_find_node_by_path("/chosen");
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 209 if (!node)
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 210 return -ENOENT;
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 211
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 212 /* remove any stale properties so ours can be found */
38c64dfe0af127 arch/powerpc/kexec/core.c Ben Collins 2025-04-21 213 of_remove_property(node, of_find_property(node, kernel_end_prop.name,
38c64dfe0af127 arch/powerpc/kexec/core.c Ben Collins 2025-04-21 214 NULL));
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 215
2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 216 /* information needed by userspace when using default_machine_kexec */ea961a828fe725 arch/powerpc/kernel/machine_kexec.c Anton Blanchard 2014-01-22 @217 kernel_end = cpu_to_be_ulong(__pa(_end));79d1c712958f94 arch/powerpc/kernel/machine_kexec.c Nathan Fontenot 2012-10-02 218 of_add_property(node, &kernel_end_prop);2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 219
:::::: The code at line 217 was first introduced by commit
:::::: ea961a828fe7250e954f086d74d9323c3d44c3e4 powerpc: Fix endian issues in kexec and crash dump code
:::::: TO: Anton Blanchard <[email protected]> :::::: CC: Benjamin Herrenschmidt <[email protected]>
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
+Cc: PowerPC mailing list.
and added some comments below.
Quoted 13 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9448598b22c50c8a5bb77a9103e2d49f134c9578 commit: 38c64dfe0af12778953846df5f259e913275cfe5 kexec: Include kernel-end even without crashkernel date: 6 weeks ago config: powerpc-randconfig-r111-20251222 (https://download.01.org/0day-ci/archive/20251222/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 42b3483ac4987cae1bdb632398e8a3ce2dea6633) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251222/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 4 lines
sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
arch/powerpc/kexec/core.c:217:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int static [addressable] [toplevel] [usertype]kernel_end@@ got restricted__be32[usertype] @@
arch/powerpc/kexec/core.c:217:20: sparse: expected unsigned int static [addressable] [toplevel] [usertype]kernel_end
arch/powerpc/kexec/core.c:217:20: sparse: got restricted__be32[usertype]
If CONFIG_CRASH_DUMP is enabled (which is not done in config shared by kernel test robot) sparse warn about other assignments in the same file. And these warnings are not limited to 32-bit.
../arch/powerpc/kexec/core.c:181:29: sparse: warning: incorrect type in assignment (different base types) ../arch/powerpc/kexec/core.c:181:29: sparse: expected unsigned int static [addressable] [toplevel] [usertype] crashk_base ../arch/powerpc/kexec/core.c:181:29: sparse: got restricted __be32 [usertype] ../arch/powerpc/kexec/core.c:183:29: sparse: warning: incorrect type in assignment (different base types) ../arch/powerpc/kexec/core.c:183:29: sparse: expected unsigned int static [addressable] [toplevel] [usertype] crashk_size ../arch/powerpc/kexec/core.c:183:29: sparse: got restricted __be32 [usertype] ../arch/powerpc/kexec/core.c:191:19: sparse: warning: incorrect type in assignment (different base types) ../arch/powerpc/kexec/core.c:191:19: sparse: expected unsigned long long static [addressable] [toplevel] mem_limit ../arch/powerpc/kexec/core.c:191:19: sparse: got restricted __be32 [usertype] ../arch/powerpc/kexec/core.c:217:20: sparse: warning: incorrect type in assignment (different base types) ../arch/powerpc/kexec/core.c:217:20: sparse: expected unsigned int static [addressable] [toplevel] [usertype] kernel_end ../arch/powerpc/kexec/core.c:217:20: sparse: got restricted __be32 [usertype]
CHECK ../arch/powerpc/kexec/core_32.c
To resolve these warnings:
Should we use __force tpyecast and silence the warnings? for example:kernel_end = (__force phys_addr_t) cpu_to_be_ulong(__pa(_end));
Or
Use proper data types __be<32|64> and duplicated the definition and assignment? seems like bit too much.
Or
Do we have better way to handle these warnings? If yes, please share.
- Sourabh Jain
Quoted 27 lines
vim +217
arch/powerpc/kexec/core.c6f29c3298b1821 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-17 203 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 204 static int __init kexec_setup(void) 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 205 { 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 206 struct device_node *node; 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 207 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 208 node = of_find_node_by_path("/chosen"); 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 209 if (!node) 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 210 return -ENOENT; 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 211 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 212 /* remove any stale properties so ours can be found */ 38c64dfe0af127 arch/powerpc/kexec/core.c Ben Collins 2025-04-21 213 of_remove_property(node, of_find_property(node, kernel_end_prop.name, 38c64dfe0af127 arch/powerpc/kexec/core.c Ben Collins 2025-04-21 214 NULL)); 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 215 2e8e4f5b80e101 arch/powerpc/kernel/machine_kexec.c Dale Farnsworth 2008-12-16 216 /* information needed by userspace when using default_machine_kexec */
ea961a828fe725arch/powerpc/kernel/machine_kexec.cAnton Blanchard 2014-01-22 @217kernel_end= cpu_to_be_ulong(__pa(_end));79d1c712958f94arch/powerpc/kernel/machine_kexec.cNathan Fontenot 2012-10-02 218of_add_property(node, &kernel_end_prop);2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 219:::::: The code at line 217 was first introduced by commit
::::::ea961a828fe7250e954f086d74d9323c3d44c3e4powerpc: Fix endian issues in kexec and crash dump code:::::: TO: Anton Blanchard <[email protected]> :::::: CC: Benjamin Herrenschmidt <[email protected]>
Quoted 42 lines · Sourabh Jain
+Cc: PowerPC mailing list.
and added some comments below.
Quoted 13 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:9448598b22c50c8a5bb77a9103e2d49f134c9578
commit:38c64dfe0af12778953846df5f259e913275cfe5kexec: Include kernel-end even without crashkernel
date: 6 weeks ago
config: powerpc-randconfig-r111-20251222 (https://download.01.org/0day-ci/archive/20251222/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project42b3483ac4987cae1bdb632398e8a3ce2dea6633) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251222/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/Quoted 4 lines
sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
arch/powerpc/kexec/core.c:217:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int static [addressable] [toplevel] [usertype]kernel_end@@ got restricted__be32[usertype] @@
arch/powerpc/kexec/core.c:217:20: sparse: expected unsigned int static [addressable] [toplevel] [usertype]kernel_endarch/powerpc/kexec/core.c:217:20: sparse: got restricted__be32[usertype]If
CONFIG_CRASH_DUMPis enabled (which is not done in config shared by kernel test robot) sparse warn about other assignments in the same file. And these warnings are not limited to 32-bit.
../arch/powerpc/kexec/core.c:181:29: sparse: warning: incorrect type in assignment (different base types)../arch/powerpc/kexec/core.c:181:29: sparse: expected unsigned int static [addressable] [toplevel] [usertype]crashk_base../arch/powerpc/kexec/core.c:181:29: sparse: got restricted__be32[usertype]../arch/powerpc/kexec/core.c:183:29: sparse: warning: incorrect type in assignment (different base types)../arch/powerpc/kexec/core.c:183:29: sparse: expected unsigned int static [addressable] [toplevel] [usertype]crashk_size../arch/powerpc/kexec/core.c:183:29: sparse: got restricted__be32[usertype]../arch/powerpc/kexec/core.c:191:19: sparse: warning: incorrect type in assignment (different base types)../arch/powerpc/kexec/core.c:191:19: sparse: expected unsigned long long static [addressable] [toplevel]mem_limit../arch/powerpc/kexec/core.c:191:19: sparse: got restricted__be32[usertype]../arch/powerpc/kexec/core.c:217:20: sparse: warning: incorrect type in assignment (different base types)../arch/powerpc/kexec/core.c:217:20: sparse: expected unsigned int static [addressable] [toplevel] [usertype]kernel_end../arch/powerpc/kexec/core.c:217:20: sparse: got restricted__be32[usertype]
CHECK ../arch/powerpc/kexec/core_32.cTo resolve these warnings:
Quoted 7 lines
Should we use
__forcetpyecast and silence the warnings? for example:kernel_end= (__forcephys_addr_t) cpu_to_be_ulong(__pa(_end));Or
Use proper data types __be<32|64> and duplicated the definition and assignment? seems like bit too much.
Found a better way to define variables as __be<32|64> without duplication, so I have posted a fix:
https://lore.kernel.org/all/[email protected]/
- Sourabh Jain
Quoted 36 lines
Or
Do we have better way to handle these warnings? If yes, please share.
- Sourabh Jain
Quoted 27 lines
vim +217
arch/powerpc/kexec/core.c
6f29c3298b1821arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-17 2032e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 204 static int__initkexec_setup(void)2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 205 {2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 206 structdevice_node*node;2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 2072e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 208 node =of_find_node_by_path("/chosen");2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 209 if (!node)2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 210 return-ENOENT;2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 2112e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 212 /* remove any stale properties so ours can be found */38c64dfe0af127arch/powerpc/kexec/core.c Ben Collins 2025-04-21 213 of_remove_property(node, of_find_property(node, kernel_end_prop.name,38c64dfe0af127arch/powerpc/kexec/core.c Ben Collins 2025-04-21 214 NULL));2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 2152e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 216 /* information needed by userspace when usingdefault_machine_kexec*/ea961a828fe725arch/powerpc/kernel/machine_kexec.cAnton Blanchard 2014-01-22 @217kernel_end= cpu_to_be_ulong(__pa(_end));79d1c712958f94arch/powerpc/kernel/machine_kexec.cNathan Fontenot 2012-10-02 218of_add_property(node, &kernel_end_prop);2e8e4f5b80e101arch/powerpc/kernel/machine_kexec.cDale Farnsworth 2008-12-16 219:::::: The code at line 217 was first introduced by commit
::::::ea961a828fe7250e954f086d74d9323c3d44c3e4powerpc: Fix endian issues in kexec and crash dump code:::::: TO: Anton Blanchard <[email protected]> :::::: CC: Benjamin Herrenschmidt <[email protected]>