diff mbox series

riscv: mm: fix truncates issue on RV32

Message ID 20230709171036.1906-1-jszhang@kernel.org (mailing list archive)
State Accepted
Commit b690e266dae2f85f4dfea21fa6a05e3500a51054
Headers show
Series riscv: mm: fix truncates issue on RV32 | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be fixes at HEAD 533925cb7604
conchuod/fixes_present success Fixes tag present in non-next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 4 and now 4
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 8 this patch: 8
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 9 this patch: 9
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success Fixes tag looks correct
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Jisheng Zhang July 9, 2023, 5:10 p.m. UTC
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: decf89f86ecd ("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/
---
 arch/riscv/mm/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Palmer Dabbelt July 12, 2023, 3:52 p.m. UTC | #1
On Mon, 10 Jul 2023 01:10:36 +0800, Jisheng Zhang wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] riscv: mm: fix truncates issue on RV32
      https://git.kernel.org/palmer/c/b690e266dae2

Best regards,
patchwork-bot+linux-riscv@kernel.org July 12, 2023, 4 p.m. UTC | #2
Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Mon, 10 Jul 2023 01:10:36 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - riscv: mm: fix truncates issue on RV32
    https://git.kernel.org/riscv/c/b690e266dae2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 70fb31960b63..9ce504737d18 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1346,7 +1346,7 @@  static void __init reserve_crashkernel(void)
 	 */
 	crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,
 					       search_start,
-					       min(search_end, (unsigned long) SZ_4G));
+					       min(search_end, (unsigned long)(SZ_4G - 1)));
 	if (crash_base == 0) {
 		/* Try again without restricting region to 32bit addressible memory */
 		crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,