[PATCH] arm64/mm: Introduce a variable to hold base address of linear region

Jin, Yanjiang yanjiang.jin at hxt-semitech.com
Tue Jun 19 02:34:56 PDT 2018

> -----Original Message-----
> From: Will Deacon [mailto:will.deacon at arm.com]
> Sent: 2018年6月19日 16:56
> To: Jin, Yanjiang <yanjiang.jin at hxt-semitech.com>
> Cc: James Morse <james.morse at arm.com>; Bhupesh Sharma
> <bhsharma at redhat.com>; Mark Rutland <mark.rutland at arm.com>; Ard
> Biesheuvel <ard.biesheuvel at linaro.org>; Catalin Marinas
> <catalin.marinas at arm.com>; Kexec Mailing List <kexec at lists.infradead.org>;
> AKASHI Takahiro <takahiro.akashi at linaro.org>; Bhupesh SHARMA
> <bhupesh.linux at gmail.com>; linux-arm-kernel <linux-arm-
> kernel at lists.infradead.org>
> Subject: Re: [PATCH] arm64/mm: Introduce a variable to hold base address of
> linear region
> On Tue, Jun 19, 2018 at 03:02:15AM +0000, Jin, Yanjiang wrote:
> > > You seem to be using this for user-space phys_to_virt() based on
> > > values found in /proc/iomem. This should give you what you want, and
> > > isolate your user-space from the kernel's unexpected naming of variables.
> >
> > I don't know could I simplify this problem?
> > Let's ignore what memstart_addr represents here, we just want to
> > implement
> > phys_to_virt() in an userspace applications(kexec-tools or others).
> >
> > ARM64 Kernel has a below definition:
> >
> > #define __phys_to_virt(x)       ((unsigned long)((x) - PHYS_OFFSET) |
> >
> > So userspace app must know PHYS_OFFSET(equal to memstart_addr now).
> > Seems this is very simple, but memstart_addr has gone through several
> > operations in arm64_memblock_init() depends on different Kernel
> > configurations, so userspace app needs to know many additional definitions as
> following:
> >
> > memblock_start_of_DRAM(),  (ifdef CONFIG_SPARSEMEM_VMEMMAP),
> > memstart_offset_seed.
> >
> > It is hard to know all above in kexec-tools now. Originally I planned
> > to read memstart_addr's value from "/dev/mem", but someone thought not
> > all Kernels enable "/dev/mem", we'd better find a more generic
> > approach. So we want to get some suggestions from ARM kernel community.
> > Can we export this variable in Kernel side through sysconf() or other
> > similar methods? Or someone can provide an effect way to get
> > memstart_addr's value?
> I thought the suggestion from James was to expose this via an ELF NOTE in kcore
> and vmcore (or in the header directly if that's possible, but I'm not sure about it)?

Hi Will,

Thanks for your reply firstly. But same as DEVMEM, kcore is not a must-have, so we can't depend on it.
On the other hand, phys_to_virt() is called during generating vmcore in Kexec-tools, vmcore also can't help this issue.
Unfortunately, not all platforms support analyzing Kernel config in userspace application, so Kexec-tools can't know some key kernel options. If not so, we can simulate the whole arm64_memblock_init()  progress in kexec-tools.

> Will

This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.

More information about the kexec mailing list