arm64/crashdump: deduce paddr of _text based on kernel code size
Subsystems (2)
PATCH 1/1 arm64/crashdump: deduce paddr of _text based on kernel code size
kexec-tools commit 61b8c79b0fb7 ("arm64/crashdump-arm64: deduce the paddr of _text") tries to deduce the paddr of _text, but turns out partially.
That commit is based on "The Image must be placed text_offset bytes from a 2MB aligned base address anywhere in usable system RAM and called there" in linux/Documentation/arm64/booting.rst, plus text_offset field is zero.
But in practice, some boot loaders does not obey the convention, and still boots up the kernel successfully.
Revisiting kernel commit e2a073dde921 ("arm64: omit [_text, _stext) from permanent kernel mapping"), the kernel code size changes from (unsigned long)__init_begin - (unsigned long)_text to (unsigned long)__init_begin
- (unsigned long)_stext
And it should be a better factor to decide which label starts the "Kernel code" in /proc/iomem.
--- kexec/arch/arm64/crashdump-arm64.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
kexec/arch/arm64/crashdump-arm64.c +11 -3
@@ -91,14 +91,22 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),return mem_regions_alloc_and_add (&system_memory_rgns, base, length,RANGE_RAM ); else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0) { + +unsigned long long kva_text =get_kernel_sym ("_text" ); +unsigned long long kva_stext =get_kernel_sym ("_stext" ); +unsigned long long kva_text_end =get_kernel_sym ("__init_begin" ); +/* * old: kernel_code.start = __pa_symbol(_text); * new: kernel_code.start = __pa_symbol(_stext); * -* By utilizing the fact that paddr(_text) should align on 2MB, plus -* _stext - _text <= 64K. +* For compatibility, deduce by comparing the gap "__init_begin - _stext" +* and the res size of "Kernel code" in /proc/iomem */ - elf_info.kern_paddr_start = base & ((0xffffffffffffffffUL ) <<21 ); +if (kva_text_end - kva_stext == length) + elf_info.kern_paddr_start = base - (kva_stext - kva_text); +else + elf_info.kern_paddr_start = base; } else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0) elf_info.kern_size = base + length - elf_info.kern_paddr_start;
Signature · 7 lines
2.31.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Simon Horman
AppliedQuoted 17 lines · Pingfan Liu
kexec-tools commit
61b8c79b0fb7("arm64/crashdump-arm64: deduce the paddr of_text") tries to deduce the paddr of_text, but turns out partially.That commit is based on "The Image must be placed
text_offsetbytes from a 2MB aligned base address anywhere in usable system RAM and called there" inlinux/Documentation/arm64/booting.rst, plustext_offsetfield is zero.But in practice, some boot loaders does not obey the convention, and still boots up the kernel successfully.
Revisiting kernel commit
e2a073dde921("arm64: omit [_text,_stext) from permanent kernel mapping"), the kernel code size changes from (unsigned long)__init_begin - (unsigned long)_text to (unsigned long)__init_begin
- (unsigned long)_stext
Quoted 6 lines
And it should be a better factor to decide which label starts the "Kernel code" in
/proc/iomem.Signed-off-by Pingfan Liu <[email protected]>Cc Simon Horman <[email protected]>
Thanks, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec