From: Simon Horman <horms@verge.net.au>
To: Pingfan Liu <piliu@redhat.com>
Cc: kexec@lists.infradead.org
Subject: Re: [PATCH 3/3] arm64: read VA_BITS from kcore for 52-bits VA kernel
Date: Thu, 16 Dec 2021 12:02:36 +0100 [thread overview]
Message-ID: <20211216110236.GB19841@vergenet.net> (raw)
In-Reply-To: <CAF+s44TYhz0_MG0Fpv2e7kTqyLgS2SwpB=+_=QQGv0vdx1qs1A@mail.gmail.com>
On Thu, Dec 16, 2021 at 09:59:42AM +0800, Pingfan Liu wrote:
> On Wed, Dec 15, 2021 at 9:06 PM Signed-off-by@vergenet.net:Simon
> Horman <horms@verge.net.au> wrote:
> >
> > On Fri, Dec 10, 2021 at 11:07:35AM +0800, Pingfan Liu wrote:
> > > phys_to_virt() calculates virtual address. As a important factor,
> > > page_offset is excepted to be accurate.
> > >
> > > Since arm64 kernel exposes va_bits through vmcore, using it.
> > >
> > > Signed-off-by: Pingfan Liu <piliu@redhat.com>
> > > ---
> > > kexec/arch/arm64/kexec-arm64.c | 31 +++++++++++++++++++++++++++----
> > > kexec/arch/arm64/kexec-arm64.h | 1 +
> > > util_lib/elf_info.c | 5 +++++
> > > 3 files changed, 33 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
> > > index bd650e6..ccc92db 100644
> > > --- a/kexec/arch/arm64/kexec-arm64.c
> > > +++ b/kexec/arch/arm64/kexec-arm64.c
> > > @@ -54,7 +54,7 @@
> > > static bool try_read_phys_offset_from_kcore = false;
> > >
> > > /* Machine specific details. */
> > > -static int va_bits;
> > > +static int va_bits = -1;
> > > static unsigned long page_offset;
> > >
> > > /* Global varables the core kexec routines expect. */
> > > @@ -876,7 +876,15 @@ static inline void set_phys_offset(long v, char *set_method)
> > >
> > > static int get_va_bits(void)
> > > {
> > > - unsigned long long stext_sym_addr = get_kernel_sym("_stext");
> > > + unsigned long long stext_sym_addr;
> > > +
> > > + /*
> > > + * if already got from kcore
> > > + */
> > > + if (va_bits != -1)
> > > + goto out;
> >
> > If va_bits is exposed by the kernel then it will be used.
> > Else we continue here. Are there actually cases (old kernels) where
> > we expect to continue. Or could we get rid of the fallback code here?
> >
>
> va_bits is exposed by kernel commit 84c57dbd3c48 ("arm64: kernel:
> arch_crash_save_vmcoreinfo() should depend on CONFIG_CRASH_CORE")
> And the first kernel which contains VA_BITS is v4.19.
> I have no idea about the need for old kernels. Maybe just keep the
> compatible code and throw a warning to remind users?
I suspect that kexec for ARM64 was present in v4.19, so we
should leave this part as-is.
> > > +
> > > + stext_sym_addr = get_kernel_sym("_stext");
> > >
> > > if (stext_sym_addr == 0) {
> > > fprintf(stderr, "Can't get the symbol of _stext.\n");
> > > @@ -900,6 +908,7 @@ static int get_va_bits(void)
> > > return -1;
> > > }
> > >
> > > +out:
> > > dbgprintf("va_bits : %d\n", va_bits);
> > >
> > > return 0;
> > > @@ -917,14 +926,27 @@ int get_page_offset(unsigned long *page_offset)
> > > if (ret < 0)
> > > return ret;
> > >
> >
> > I'm confused about why there is both a (va_bits - 1)
> > and va_bits case here.
> >
>
> It originates from the changes of memory layout on arm64.
> And mostly it is contributed by kernel commit 14c127c957c1 ("arm64:
> mm: Flip kernel VA space"),
> where sees the changes:
> -#define PAGE_OFFSET (UL(0xffffffffffffffff) - \
> (UL(1) << (VA_BITS - 1)) + 1)
> +#define PAGE_OFFSET (UL(0xffffffffffffffff) - \
> + (UL(1) << VA_BITS) + 1)
>
>
> Thanks,
>
> Pingfan
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2021-12-16 11:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 3:07 [PATCH 0/3] arm64: make phys_to_virt() correct Pingfan Liu
2021-12-10 3:07 ` [PATCH 1/3] arm64: make phys_offset signed Pingfan Liu
2021-12-10 3:07 ` [PATCH 2/3] arm64/crashdump: unify routine to get page_offset Pingfan Liu
2021-12-15 13:35 ` Philipp Rudo
2021-12-16 2:58 ` Pingfan Liu
2021-12-10 3:07 ` [PATCH 3/3] arm64: read VA_BITS from kcore for 52-bits VA kernel Pingfan Liu
2021-12-15 13:34 ` Philipp Rudo
2021-12-16 2:46 ` Pingfan Liu
2021-12-16 3:05 ` Pingfan Liu
[not found] ` <20211215130557.GB4314@vergenet.net>
2021-12-16 1:59 ` Pingfan Liu
2021-12-16 11:02 ` Simon Horman [this message]
2021-12-15 1:43 ` [PATCH 0/3] arm64: make phys_to_virt() correct 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=20211216110236.GB19841@vergenet.net \
--to=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=piliu@redhat.com \
/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