From: Philipp Rudo <prudo@redhat.com>
To: kexec@lists.infradead.org
Subject: [PATCHv4 2/4] arm64/crashdump: unify routine to get page_offset
Date: Thu, 20 Jan 2022 19:09:20 +0100 [thread overview]
Message-ID: <20220120190920.671089d4@rhtmp> (raw)
In-Reply-To: <20220118074812.27702-3-piliu@redhat.com>
Hi Pingfan,
On Tue, 18 Jan 2022 15:48:10 +0800
Pingfan Liu <piliu@redhat.com> wrote:
> 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 <piliu@redhat.com>
> Cc: Kairui Song <kasong@tencent.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Philipp Rudo <prudo@redhat.com>
> To: kexec at lists.infradead.org
looks good
Reviewed-by: Philipp Rudo <prudo@redhat.com>
> ---
> 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 a02019a..0a8d44c 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
> @@ -198,7 +177,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 c6c67e8..33cc258 100644
> --- a/kexec/arch/arm64/kexec-arm64.c
> +++ b/kexec/arch/arm64/kexec-arm64.c
> @@ -909,7 +909,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;
>
> @@ -917,8 +917,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;
> }
> @@ -954,7 +954,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 1844b67..ed99d9d 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)
> {
next prev parent reply other threads:[~2022-01-20 18:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 7:48 [PATCHv4 0/4] arm64: make phys_to_virt() correct Pingfan Liu
2022-01-18 7:48 ` [PATCHv4 1/4] arm64: make phys_offset signed Pingfan Liu
2022-01-20 18:09 ` Philipp Rudo
2022-01-21 1:38 ` Pingfan Liu
2022-01-24 8:58 ` Simon Horman
2022-01-18 7:48 ` [PATCHv4 2/4] arm64/crashdump: unify routine to get page_offset Pingfan Liu
2022-01-20 18:09 ` Philipp Rudo [this message]
2022-01-18 7:48 ` [PATCHv4 3/4] arm64: read VA_BITS from kcore for 52-bits VA kernel Pingfan Liu
2022-01-20 18:09 ` Philipp Rudo
2022-01-18 7:48 ` [PATCHv4 4/4] arm64: fix PAGE_OFFSET calc for flipped mm Pingfan Liu
2022-01-20 18:08 ` Philipp Rudo
2022-01-21 1:36 ` Pingfan Liu
2022-01-24 9:10 ` [PATCHv4 0/4] arm64: make phys_to_virt() correct Simon Horman
2022-01-24 9:53 ` Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220120190920.671089d4@rhtmp \
--to=prudo@redhat.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).