From bde864387a104137ff3bd5f0871709846d5c7943 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Tue, 18 Jan 2022 15:48:10 +0800 Subject: arm64/crashdump: unify routine to get page_offset There are two funcs to get page_offset: get_kernel_page_offset() get_page_offset() Since get_kernel_page_offset() does not observe the kernel formula, and remove it. Unify them in order to introduce 52-bits VA kernel more easily in the coming patch. Signed-off-by: Pingfan Liu Reviewed-by: Philipp Rudo Signed-off-by: Simon Horman --- kexec/arch/arm64/crashdump-arm64.c | 23 +---------------------- kexec/arch/arm64/kexec-arm64.c | 8 ++++---- kexec/arch/arm64/kexec-arm64.h | 1 + 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c index d0f22538..7beb1fba 100644 --- a/kexec/arch/arm64/crashdump-arm64.c +++ b/kexec/arch/arm64/crashdump-arm64.c @@ -46,27 +46,6 @@ static struct crash_elf_info elf_info = { .machine = EM_AARCH64, }; -/* - * Note: The returned value is correct only if !CONFIG_RANDOMIZE_BASE. - */ -static uint64_t get_kernel_page_offset(void) -{ - int i; - - if (elf_info.kern_vaddr_start == UINT64_MAX) - return UINT64_MAX; - - /* Current max virtual memory range is 48-bits. */ - for (i = 48; i > 0; i--) - if (!(elf_info.kern_vaddr_start & (1UL << i))) - break; - - if (i <= 0) - return UINT64_MAX; - else - return UINT64_MAX << i; -} - /* * iomem_range_callback() - callback called for each iomem region * @data: not used @@ -203,7 +182,7 @@ int load_crashdump_segments(struct kexec_info *info) if (err) return EFAILED; - elf_info.page_offset = get_kernel_page_offset(); + get_page_offset(&elf_info.page_offset); dbgprintf("%s: page_offset: %016llx\n", __func__, elf_info.page_offset); diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c index 9dc1d8f3..0f8a7688 100644 --- a/kexec/arch/arm64/kexec-arm64.c +++ b/kexec/arch/arm64/kexec-arm64.c @@ -928,7 +928,7 @@ static int get_va_bits(void) * get_page_offset - Helper for getting PAGE_OFFSET */ -static int get_page_offset(void) +int get_page_offset(unsigned long *page_offset) { int ret; @@ -936,8 +936,8 @@ static int get_page_offset(void) if (ret < 0) return ret; - page_offset = (0xffffffffffffffffUL) << (va_bits - 1); - dbgprintf("page_offset : %lx\n", page_offset); + *page_offset = UINT64_MAX << (va_bits - 1); + dbgprintf("page_offset : %lx\n", *page_offset); return 0; } @@ -973,7 +973,7 @@ int get_phys_base_from_pt_load(long *phys_offset) unsigned long long phys_start; unsigned long long virt_start; - ret = get_page_offset(); + ret = get_page_offset(&page_offset); if (ret < 0) return ret; diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h index bfd4172b..5eb9fc03 100644 --- a/kexec/arch/arm64/kexec-arm64.h +++ b/kexec/arch/arm64/kexec-arm64.h @@ -69,6 +69,7 @@ extern struct arm64_mem arm64_mem; uint64_t get_phys_offset(void); uint64_t get_vp_offset(void); +int get_page_offset(unsigned long *offset); static inline void reset_vp_offset(void) { -- cgit 1.2.3-korg