Skip to content

Commit b690e26

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: mm: fix truncation warning on RV32
lkp reports below sparse warning when building for RV32: arch/riscv/mm/init.c:1204:48: sparse: warning: cast truncates bits from constant value (100000000 becomes 0) IMO, the reason we didn't see this truncates bug in real world is "0" means MEMBLOCK_ALLOC_ACCESSIBLE in memblock and there's no RV32 HW with more than 4GB memory. Fix it anyway to make sparse happy. Fixes: decf89f ("riscv: try to allocate crashkern region from 32bit addressible memory") Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202306080034.SLiCiOMn-lkp@intel.com/ Link: https://lore.kernel.org/r/20230709171036.1906-1-jszhang@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 66843b1 commit b690e26

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static void __init reserve_crashkernel(void)
13461346
*/
13471347
crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,
13481348
search_start,
1349-
min(search_end, (unsigned long) SZ_4G));
1349+
min(search_end, (unsigned long)(SZ_4G - 1)));
13501350
if (crash_base == 0) {
13511351
/* Try again without restricting region to 32bit addressible memory */
13521352
crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,

0 commit comments

Comments
 (0)