kho: check fdt_phys in is_kho_boot()
Subsystems (3)
PATCH 1/1 kho: check fdt_phys in is_kho_boot()
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.
--- kernel/liveupdate/kexec_handover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/liveupdate/kexec_handover.c +1 -1
@@ -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);
Signature · 1 line
2.56.0.257.gf7497c7d27-goog
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 19 lines
During arm64
setup_arch(),efi_init()->reserve_regions()callsis_kho_boot()beforearm64_memblock_init()initializesmemstart_addr. At this pointmemstart_addrstill 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. Callingis_kho_boot()->kho_get_fdt()invokesphys_to_virt(kho_in.fdt_phys), which evaluatesPHYS_OFFSETand triggersVM_BUG_ON(memstart_addr & 1)on arm64 kernels built withCONFIG_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
Quoted 7 lines
Check kho_in.fdt_phys directly in
is_kho_boot()instead of callingkho_get_fdt()so that early boot callers do not invokephys_to_virt()before the linear map offset is initialized.Fixes d6d511639185 ("kexec: introduce is_kho_boot()")Assisted-by Gemini:gemini-3.8-flashSigned-off-by Greg Thelen <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 19 lines · Greg Thelen
During arm64
setup_arch(),efi_init()->reserve_regions()callsis_kho_boot()beforearm64_memblock_init()initializesmemstart_addr. At this pointmemstart_addrstill 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. Callingis_kho_boot()->kho_get_fdt()invokesphys_to_virt(kho_in.fdt_phys), which evaluatesPHYS_OFFSETand triggersVM_BUG_ON(memstart_addr & 1)on arm64 kernels built withCONFIG_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
Quoted 7 lines
Check kho_in.fdt_phys directly in
is_kho_boot()instead of callingkho_get_fdt()so that early boot callers do not invokephys_to_virt()before the linear map offset is initialized.Fixes d6d511639185 ("kexec: introduce is_kho_boot()")Assisted-by Gemini:gemini-3.8-flashSigned-off-by Greg Thelen <[email protected]>
[...]
Signature · 2 lines
Regards, Pratyush Yadav
Mike Rapoport
maintainerHi,
Quoted 9 lines · Greg Thelen
During arm64
setup_arch(),efi_init()->reserve_regions()callsis_kho_boot()beforearm64_memblock_init()initializesmemstart_addr. At this pointmemstart_addrstill 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. Callingis_kho_boot()->kho_get_fdt()invokesphys_to_virt(kho_in.fdt_phys), which evaluatesPHYS_OFFSETand triggersVM_BUG_ON(memstart_addr & 1)on arm64 kernels built withCONFIG_DEBUG_VM=y:
Can't see the forest for the trees ;-)
Can you please translate the gist of the issue from LLMish to English?
Quoted 36 lines
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/0x98Check kho_in.fdt_phys directly in
is_kho_boot()instead of callingkho_get_fdt()so that early boot callers do not invokephys_to_virt()before the linear map offset is initialized.Fixes d6d511639185 ("kexec: introduce is_kho_boot()")Assisted-by Gemini:gemini-3.8-flashSigned-off-by Greg Thelen <[email protected]>--- kernel/liveupdate/kexec_handover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/liveupdate/kexec_handover.c +1
-1@@ -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);Signature · 1 line
2.56.0.257.gf7497c7d27-goog
Signature · 2 lines
Sincerely yours, Mike.
Pasha Tatashin
maintainerI am planning to take this patch, and change the commit message as follows to address Mike's concern:
Quoted 9 lines
During arm64
setup_arch(),efi_init()->reserve_regions()callsis_kho_boot()beforearm64_memblock_init()initializesmemstart_addr. At this pointmemstart_addrstill 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. Callingis_kho_boot()->kho_get_fdt()invokesphys_to_virt(kho_in.fdt_phys), which evaluatesPHYS_OFFSETand triggersVM_BUG_ON(memstart_addr & 1)on arm64 kernels built withCONFIG_DEBUG_VM=y:
Repalce the above two parapgraphs with:
is_kho_boot() is called early in boot before the linear memory map is initialized, so calling phys_to_virt() via kho_get_fdt() there is invalid.
On arm64 (and similarly in upcoming riscv64 support), this triggers BUG_ONs in debug builds, such as:
Quoted 10 lines
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
Quoted 3 lines
Check kho_in.fdt_phys directly in
is_kho_boot()instead of callingkho_get_fdt()so that early boot callers do not invokephys_to_virt()before the linear map offset is initialized.
Replace the above with:
Use kho_in.fdt_phys in is_kho_boot() directly instead of translating it to a virtual address.
Signature · 1 line
Pasha
Quoted 1 line · Greg Thelen
kho: check
fdt_physinis_kho_boot()
Applied, thanks!
https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git/log/?h=fixes
[1/1] kho: check fdt_phys in is_kho_boot()
commit: 58c5852ca96c58cdfdb9646870b217fc54d06a97
Best regards,
Signature · 1 line
Pasha