Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kho: check fdt_phys in is_kho_boot()
@ 2026-10-23  5:45 Greg Thelen
  2026-10-23  5:49 ` sashiko-bot
  2026-10-23 16:37 ` Pratyush Yadav
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Thelen @ 2026-10-23  5:45 UTC (permalink / raw)
  To: Mike Rapoport, Pasha Tatashin, Pratyush Yadav, Alexander Graf
  Cc: Andrew Morton, Evangelos Petrongonas, kexec, linux-mm,
	linux-kernel, Greg Thelen

During arm64 setup_arch(), efi_init() -> reserve_regions() calls
is_kho_boot() before arm64_memblock_init() initializes memstart_addr.
At this point memstart_addr still holds its initial sentinel value (-1).

When booting via kexec with KHO enabled, kho_populate() sets
kho_in.fdt_phys from the /chosen FDT node. Calling is_kho_boot() ->
kho_get_fdt() invokes phys_to_virt(kho_in.fdt_phys), which evaluates
PHYS_OFFSET and triggers VM_BUG_ON(memstart_addr & 1) on arm64 kernels
built with CONFIG_DEBUG_VM=y:

  kernel BUG at ./arch/arm64/include/asm/memory.h:377!
  Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
  Call trace:
   is_kho_boot+0x2c/0x38 (P)
   efi_init+0x94/0xf8
   setup_arch+0xf0/0x240
   start_kernel+0x84/0x490
   __primary_switched+0x88/0x98

Check kho_in.fdt_phys directly in is_kho_boot() instead of calling
kho_get_fdt() so that early boot callers do not invoke phys_to_virt()
before the linear map offset is initialized.

Fixes: d6d511639185 ("kexec: introduce is_kho_boot()")
Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: Greg Thelen <gthelen@google.com>
---
 kernel/liveupdate/kexec_handover.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 7c4d86daf86d..d81baa38497f 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -1630,7 +1630,7 @@ EXPORT_SYMBOL_GPL(kho_restore_free);
  */
 bool is_kho_boot(void)
 {
-	return !!kho_get_fdt();
+	return !!kho_in.fdt_phys;
 }
 EXPORT_SYMBOL_GPL(is_kho_boot);
 
-- 
2.56.0.257.gf7497c7d27-goog



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kho: check fdt_phys in is_kho_boot()
  2026-10-23  5:45 [PATCH] kho: check fdt_phys in is_kho_boot() Greg Thelen
@ 2026-10-23  5:49 ` sashiko-bot
  2026-10-23 16:37 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-23  5:49 UTC (permalink / raw)
  To: Greg Thelen, Mike Rapoport, Pasha Tatashin, Pratyush Yadav,
	Alexander Graf
  Cc: Andrew Morton, Evangelos Petrongonas, kexec

> During arm64 setup_arch(), efi_init() -> reserve_regions() calls
> is_kho_boot() before arm64_memblock_init() initializes memstart_addr.
> At this point memstart_addr still holds its initial sentinel value (-1).
> 
> When booting via kexec with KHO enabled, kho_populate() sets
> kho_in.fdt_phys from the /chosen FDT node. Calling is_kho_boot() ->
> kho_get_fdt() invokes phys_to_virt(kho_in.fdt_phys), which evaluates
> PHYS_OFFSET and triggers VM_BUG_ON(memstart_addr & 1) on arm64 kernels
> built with CONFIG_DEBUG_VM=y:
> 
>   kernel BUG at ./arch/arm64/include/asm/memory.h:377!
>   Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
>   Call trace:
>    is_kho_boot+0x2c/0x38 (P)
>    efi_init+0x94/0xf8
>    setup_arch+0xf0/0x240
>    start_kernel+0x84/0x490
>    __primary_switched+0x88/0x98
> 
> Check kho_in.fdt_phys directly in is_kho_boot() instead of calling
> kho_get_fdt() so that early boot callers do not invoke phys_to_virt()
> before the linear map offset is initialized.
> 
> Fixes: d6d511639185 ("kexec: introduce is_kho_boot()")
> Assisted-by: Gemini:gemini-3.8-flash
> Signed-off-by: Greg Thelen <gthelen@google.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261023054518.3258350-1-gthelen@google.com?part=1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kho: check fdt_phys in is_kho_boot()
  2026-10-23  5:45 [PATCH] kho: check fdt_phys in is_kho_boot() Greg Thelen
  2026-10-23  5:49 ` sashiko-bot
@ 2026-10-23 16:37 ` Pratyush Yadav
  1 sibling, 0 replies; 3+ messages in thread
From: Pratyush Yadav @ 2026-10-23 16:37 UTC (permalink / raw)
  To: Greg Thelen
  Cc: Mike Rapoport, Pasha Tatashin, Pratyush Yadav, Alexander Graf,
	Andrew Morton, Evangelos Petrongonas, kexec, linux-mm,
	linux-kernel

On Thu, Oct 22 2026, Greg Thelen wrote:

> During arm64 setup_arch(), efi_init() -> reserve_regions() calls
> is_kho_boot() before arm64_memblock_init() initializes memstart_addr.
> At this point memstart_addr still holds its initial sentinel value (-1).
>
> When booting via kexec with KHO enabled, kho_populate() sets
> kho_in.fdt_phys from the /chosen FDT node. Calling is_kho_boot() ->
> kho_get_fdt() invokes phys_to_virt(kho_in.fdt_phys), which evaluates
> PHYS_OFFSET and triggers VM_BUG_ON(memstart_addr & 1) on arm64 kernels
> built with CONFIG_DEBUG_VM=y:
>
>   kernel BUG at ./arch/arm64/include/asm/memory.h:377!
>   Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
>   Call trace:
>    is_kho_boot+0x2c/0x38 (P)
>    efi_init+0x94/0xf8
>    setup_arch+0xf0/0x240
>    start_kernel+0x84/0x490
>    __primary_switched+0x88/0x98
>
> Check kho_in.fdt_phys directly in is_kho_boot() instead of calling
> kho_get_fdt() so that early boot callers do not invoke phys_to_virt()
> before the linear map offset is initialized.
>
> Fixes: d6d511639185 ("kexec: introduce is_kho_boot()")
> Assisted-by: Gemini:gemini-3.8-flash
> Signed-off-by: Greg Thelen <gthelen@google.com>

Reviewed-by: Pratyush Yadav (Google) <pratyush@kernel.org>

[...]

-- 
Regards,
Pratyush Yadav


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-23 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23  5:45 [PATCH] kho: check fdt_phys in is_kho_boot() Greg Thelen
2026-10-23  5:49 ` sashiko-bot
2026-10-23 16:37 ` Pratyush Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox