android_kernel_xiaomi_sm8450/arch/powerpc
Christophe Leroy 43662ba6ca powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL
[ Upstream commit e7e846dc6c73fbc94ae8b4ec20d05627646416f2 ]

Booting with CONFIG_DEBUG_VIRTUAL leads to following warning when
passing hugepage reservation on command line:

  Kernel command line: hugepagesz=1g hugepages=1 hugepagesz=64m hugepages=1 hugepagesz=256m hugepages=1 noreboot
  HugeTLB: allocating 1 of page size 1.00 GiB failed.  Only allocated 0 hugepages.
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at arch/powerpc/include/asm/io.h:948 __alloc_bootmem_huge_page+0xd4/0x284
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted 6.10.0-rc6-00396-g6b0e82791bd0-dirty #936
  Hardware name: MPC8544DS e500v2 0x80210030 MPC8544 DS
  NIP:  c1020240 LR: c10201d0 CTR: 00000000
  REGS: c13fdd30 TRAP: 0700   Not tainted  (6.10.0-rc6-00396-g6b0e82791bd0-dirty)
  MSR:  00021000 <CE,ME>  CR: 44084288  XER: 20000000

  GPR00: c10201d0 c13fde20 c130b560 e8000000 e8001000 00000000 00000000 c1420000
  GPR08: 00000000 00028001 00000000 00000004 44084282 01066ac0 c0eb7c9c efffe149
  GPR16: c0fc4228 0000005f ffffffff c0eb7d0c c0eb7cc0 c0eb7ce0 ffffffff 00000000
  GPR24: c1441cec efffe153 e8001000 c14240c0 00000000 c1441d64 00000000 e8000000
  NIP [c1020240] __alloc_bootmem_huge_page+0xd4/0x284
  LR [c10201d0] __alloc_bootmem_huge_page+0x64/0x284
  Call Trace:
  [c13fde20] [c10201d0] __alloc_bootmem_huge_page+0x64/0x284 (unreliable)
  [c13fde50] [c10207b8] hugetlb_hstate_alloc_pages+0x8c/0x3e8
  [c13fdeb0] [c1021384] hugepages_setup+0x240/0x2cc
  [c13fdef0] [c1000574] unknown_bootoption+0xfc/0x280
  [c13fdf30] [c0078904] parse_args+0x200/0x4c4
  [c13fdfa0] [c1000d9c] start_kernel+0x238/0x7d0
  [c13fdff0] [c0000434] set_ivor+0x12c/0x168
  Code: 554aa33e 7c042840 3ce0c142 80a7427c 5109a016 50caa016 7c9a2378 7fdcf378 4180000c 7c052040 41810160 7c095040 <0fe00000> 38c00000 40800108 3c60c0eb
  ---[ end trace 0000000000000000 ]---

This is due to virt_addr_valid() using high_memory before it is set.

high_memory is set in mem_init() using max_low_pfn, but max_low_pfn
is available long before, it is set in mem_topology_setup(). So just
like commit daa9ada2093e ("powerpc/mm: Fix boot crash with FLATMEM")
moved the setting of max_mapnr immediately after the call to
mem_topology_setup(), the same can be done for high_memory.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/62b69c4baad067093f39e7e60df0fe27a86b8d2a.1723100702.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-17 15:07:31 +02:00
..
boot powerpc/boot: Only free if realloc() succeeds 2024-09-04 13:17:36 +02:00
configs powerpc/configs: Update defconfig with now user-visible CONFIG_FSL_IFC 2024-08-19 05:41:06 +02:00
crypto crypto: powerpc/crc-vpmsum_test - Fix sparse endianness warning 2020-09-04 17:57:15 +10:00
include powerpc: Avoid nmi_enter/nmi_exit in real mode interrupt. 2024-08-19 05:41:22 +02:00
kernel powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL 2024-10-17 15:07:31 +02:00
kexec powerpc: Set crashkernel offset to mid of RMA region 2022-04-13 21:00:56 +02:00
kvm powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap() 2024-08-19 05:41:05 +02:00
lib powerpc: xor_vmx: Add '-mhard-float' to CFLAGS 2024-04-13 12:59:01 +02:00
math-emu powerpc/math_emu/efp: Include module.h 2022-10-26 13:25:40 +02:00
mm powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL 2024-10-17 15:07:31 +02:00
net powerpc64/bpf: Limit 'ldbrx' to processors compliant with ISA v2.06 2022-02-01 17:25:45 +01:00
oprofile powerpc/oprofile: fix spelling mistake "contex" -> "context" 2020-08-25 01:31:33 +10:00
perf powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks 2024-03-26 18:21:59 -04:00
platforms powerpc/pseries: Whitelist dtl slub object for copying to userspace 2024-07-27 10:40:21 +02:00
purgatory powerpc/purgatory: remove PGO flags 2023-06-21 15:45:37 +02:00
sysdev powerpc/xics: Check return value of kasprintf in icp_native_map_one_cpu 2024-09-04 13:17:34 +02:00
tools powerpc/tools: Remove 90 line limit in checkpatch script 2020-09-08 22:57:11 +10:00
xmon powerpc/xmon: Fix disassembly CPU feature checks 2024-08-19 05:40:52 +02:00
Kbuild powerpc/kexec: Move kexec files into a dedicated subdir. 2019-11-21 15:41:34 +11:00
Kconfig powerpc/kasan: Force thread size increase with KASAN 2022-06-14 18:32:39 +02:00
Kconfig.debug powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y 2023-07-27 08:44:09 +02:00
Makefile powerpc: Fail build if using recordmcount with binutils v2.37 2023-07-27 08:44:26 +02:00
Makefile.postlink powerpc: unrel_branch_check.sh: use nm to find symbol value 2020-09-02 11:00:22 +10:00