From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: linux-arm-kernel@lists.infradead.org
Cc: Mark Rutland <mark.rutland@arm.com>,
devicetree@vger.kernel.org, Tony Luck <tony.luck@intel.com>,
linux-ia64@vger.kernel.org, linux-doc@vger.kernel.org,
Pawel Moll <pawel.moll@arm.com>, Jonathan Corbet <corbet@lwn.net>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
kexec@lists.infradead.org, Fenghua Yu <fenghua.yu@intel.com>,
Haren Myneni <hbabu@us.ibm.com>, Rob Herring <robh+dt@kernel.org>,
Eric Biederman <ebiederm@xmission.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
Kumar Gala <galak@codeaurora.org>,
Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH 11/12] kexec: allow architectures to override boot mapping
Date: Wed, 11 May 2016 19:56:17 +0100 [thread overview]
Message-ID: <20160511185616.GP19428@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <E1aviFU-0000jk-9q@rmk-PC.arm.linux.org.uk>
I was going to send the patches to Andrew, but then I noticed this
one has received no acks. What's the situation for this patch?
On Thu, Apr 28, 2016 at 10:28:40AM +0100, Russell King wrote:
> kexec physical addresses are the boot-time view of the system. For
> certain ARM systems (such as Keystone 2), the boot view of the system
> does not match the kernel's view of the system: the boot view uses a
> special alias in the lower 4GB of the physical address space.
>
> To cater for these kinds of setups, we need to translate between the
> boot view physical addresses and the normal kernel view physical
> addresses. This patch extracts the current transation points into
> linux/kexec.h, and allows an architecture to override the functions.
>
> Due to the translations required, we unfortunately end up with six
> translation functions, which are reduced down to four that the
> architecture can override.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> include/linux/kexec.h | 38 ++++++++++++++++++++++++++++++++++++++
> kernel/kexec.c | 3 ++-
> kernel/kexec_core.c | 26 +++++++++++++-------------
> 3 files changed, 53 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 52a3a221bcb2..99cb9dac7909 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -318,6 +318,44 @@ int __weak arch_kexec_apply_relocations_add(const Elf_Ehdr *ehdr,
> int __weak arch_kexec_apply_relocations(const Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
> unsigned int relsec);
>
> +#ifndef page_to_boot_pfn
> +static inline unsigned long page_to_boot_pfn(struct page *page)
> +{
> + return page_to_pfn(page);
> +}
> +#endif
> +
> +#ifndef boot_pfn_to_page
> +static inline struct page *boot_pfn_to_page(unsigned long boot_pfn)
> +{
> + return pfn_to_page(boot_pfn);
> +}
> +#endif
> +
> +#ifndef phys_to_boot_phys
> +static inline unsigned long phys_to_boot_phys(phys_addr_t phys)
> +{
> + return phys;
> +}
> +#endif
> +
> +#ifndef boot_phys_to_phys
> +static inline phys_addr_t boot_phys_to_phys(unsigned long boot_phys)
> +{
> + return boot_phys;
> +}
> +#endif
> +
> +static inline unsigned long virt_to_boot_phys(void *addr)
> +{
> + return phys_to_boot_phys(__pa((unsigned long)addr));
> +}
> +
> +static inline void *boot_phys_to_virt(unsigned long entry)
> +{
> + return phys_to_virt(boot_phys_to_phys(entry));
> +}
> +
> #else /* !CONFIG_KEXEC_CORE */
> struct pt_regs;
> struct task_struct;
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index ee70aef5cd81..dd49d572a5e2 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -48,7 +48,8 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
>
> if (kexec_on_panic) {
> /* Verify we have a valid entry point */
> - if ((entry < crashk_res.start) || (entry > crashk_res.end))
> + if ((entry < phys_to_boot_phys(crashk_res.start)) ||
> + (entry > phys_to_boot_phys(crashk_res.end)))
> return -EADDRNOTAVAIL;
> }
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index f9847e5822e6..d04940ccc58d 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -229,8 +229,8 @@ int sanity_check_segment_list(struct kimage *image)
> mstart = image->segment[i].mem;
> mend = mstart + image->segment[i].memsz - 1;
> /* Ensure we are within the crash kernel limits */
> - if ((mstart < crashk_res.start) ||
> - (mend > crashk_res.end))
> + if ((mstart < phys_to_boot_phys(crashk_res.start)) ||
> + (mend > phys_to_boot_phys(crashk_res.end)))
> return result;
> }
> }
> @@ -354,7 +354,7 @@ static struct page *kimage_alloc_normal_control_pages(struct kimage *image,
> pages = kimage_alloc_pages(KEXEC_CONTROL_MEMORY_GFP, order);
> if (!pages)
> break;
> - pfn = page_to_pfn(pages);
> + pfn = page_to_boot_pfn(pages);
> epfn = pfn + count;
> addr = pfn << PAGE_SHIFT;
> eaddr = epfn << PAGE_SHIFT;
> @@ -480,7 +480,7 @@ static int kimage_add_entry(struct kimage *image, kimage_entry_t entry)
> return -ENOMEM;
>
> ind_page = page_address(page);
> - *image->entry = virt_to_phys(ind_page) | IND_INDIRECTION;
> + *image->entry = virt_to_boot_phys(ind_page) | IND_INDIRECTION;
> image->entry = ind_page;
> image->last_entry = ind_page +
> ((PAGE_SIZE/sizeof(kimage_entry_t)) - 1);
> @@ -535,13 +535,13 @@ void kimage_terminate(struct kimage *image)
> #define for_each_kimage_entry(image, ptr, entry) \
> for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
> ptr = (entry & IND_INDIRECTION) ? \
> - phys_to_virt((entry & PAGE_MASK)) : ptr + 1)
> + boot_phys_to_virt((entry & PAGE_MASK)) : ptr + 1)
>
> static void kimage_free_entry(kimage_entry_t entry)
> {
> struct page *page;
>
> - page = pfn_to_page(entry >> PAGE_SHIFT);
> + page = boot_pfn_to_page(entry >> PAGE_SHIFT);
> kimage_free_pages(page);
> }
>
> @@ -635,7 +635,7 @@ static struct page *kimage_alloc_page(struct kimage *image,
> * have a match.
> */
> list_for_each_entry(page, &image->dest_pages, lru) {
> - addr = page_to_pfn(page) << PAGE_SHIFT;
> + addr = page_to_boot_pfn(page) << PAGE_SHIFT;
> if (addr == destination) {
> list_del(&page->lru);
> return page;
> @@ -650,12 +650,12 @@ static struct page *kimage_alloc_page(struct kimage *image,
> if (!page)
> return NULL;
> /* If the page cannot be used file it away */
> - if (page_to_pfn(page) >
> + if (page_to_boot_pfn(page) >
> (KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) {
> list_add(&page->lru, &image->unusable_pages);
> continue;
> }
> - addr = page_to_pfn(page) << PAGE_SHIFT;
> + addr = page_to_boot_pfn(page) << PAGE_SHIFT;
>
> /* If it is the destination page we want use it */
> if (addr == destination)
> @@ -678,7 +678,7 @@ static struct page *kimage_alloc_page(struct kimage *image,
> struct page *old_page;
>
> old_addr = *old & PAGE_MASK;
> - old_page = pfn_to_page(old_addr >> PAGE_SHIFT);
> + old_page = boot_pfn_to_page(old_addr >> PAGE_SHIFT);
> copy_highpage(page, old_page);
> *old = addr | (*old & ~PAGE_MASK);
>
> @@ -734,7 +734,7 @@ static int kimage_load_normal_segment(struct kimage *image,
> result = -ENOMEM;
> goto out;
> }
> - result = kimage_add_page(image, page_to_pfn(page)
> + result = kimage_add_page(image, page_to_boot_pfn(page)
> << PAGE_SHIFT);
> if (result < 0)
> goto out;
> @@ -795,7 +795,7 @@ static int kimage_load_crash_segment(struct kimage *image,
> char *ptr;
> size_t uchunk, mchunk;
>
> - page = pfn_to_page(maddr >> PAGE_SHIFT);
> + page = boot_pfn_to_page(maddr >> PAGE_SHIFT);
> if (!page) {
> result = -ENOMEM;
> goto out;
> @@ -922,7 +922,7 @@ void __weak crash_free_reserved_phys_range(unsigned long begin,
> unsigned long addr;
>
> for (addr = begin; addr < end; addr += PAGE_SIZE)
> - free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));
> + free_reserved_page(boot_pfn_to_page(addr >> PAGE_SHIFT));
> }
>
> int crash_shrink_memory(unsigned long new_size)
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2016-05-11 18:56 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 9:26 [PATCH 00/12] Fixing TI Keystone2 kexec Russell King - ARM Linux
2016-04-28 9:27 ` [PATCH 01/12] ARM: kexec: fix crashkernel= handling Russell King
[not found] ` <E1aviEe-0000if-VZ-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2016-04-29 14:17 ` Pratyush Anand
2016-04-28 9:27 ` [PATCH 02/12] ARM: provide improved virt_to_idmap() functionality Russell King
2016-04-28 9:27 ` [PATCH 03/12] ARM: kexec: remove 512MB restriction on kexec crashdump Russell King
2016-04-29 14:19 ` Pratyush Anand
[not found] ` <CAHB_GuqOvRof94QdHztPy2B2kKuyKzQ-9uxXHY_g+i5WxsexZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-29 18:10 ` Russell King - ARM Linux
2016-04-30 3:36 ` Pratyush Anand
2016-04-30 8:25 ` Russell King - ARM Linux
2016-04-28 9:28 ` [PATCH 04/12] ARM: provide arm_has_idmap_alias() helper Russell King
2016-04-29 14:21 ` Pratyush Anand
2016-04-28 9:28 ` [PATCH 05/12] ARM: kdump: advertise boot aliased crash kernel resource Russell King
2016-04-28 9:28 ` [PATCH 06/12] ARM: kexec: advertise location of bootable RAM Russell King
2016-04-29 14:56 ` Pratyush Anand
2016-04-29 18:00 ` Russell King - ARM Linux
2016-04-30 3:27 ` Pratyush Anand
2016-04-30 8:20 ` Russell King - ARM Linux
2016-05-02 7:34 ` Pratyush Anand
2016-05-02 10:10 ` Russell King - ARM Linux
2016-05-02 10:48 ` Pratyush Anand
[not found] ` <CAHB_GurHc1aVfzJATpNW5yf5s5KkF=t5s09FbWq3+9+ZX39KUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-03 10:29 ` Russell King - ARM Linux
2016-04-28 9:28 ` [PATCH 07/12] ARM: keystone: dts: add psci command definition Russell King
2016-04-28 9:28 ` [PATCH 08/12] kexec: don't invoke OOM-killer for control page allocation Russell King
2016-04-29 14:57 ` Pratyush Anand
2016-04-28 9:28 ` [PATCH 09/12] kexec: ensure user memory sizes do not wrap Russell King
[not found] ` <E1aviFK-0000jY-1S-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2016-04-29 14:57 ` Pratyush Anand
2016-04-28 9:28 ` [PATCH 10/12] kexec: arrange for paddr_vmcoreinfo_note() to return phys_addr_t Russell King
2016-04-29 15:06 ` Pratyush Anand
2016-04-29 15:16 ` Mark Rutland
2016-04-29 15:47 ` Pratyush Anand
2016-05-03 4:24 ` Baoquan He
2016-05-03 5:53 ` Pratyush Anand
2016-05-03 9:01 ` Baoquan He
[not found] ` <20160503042441.GA2518-ejN7fcUYdH/by3iVrkZq2A@public.gmane.org>
2016-05-03 10:12 ` Russell King - ARM Linux
2016-05-03 12:56 ` Baoquan He
2016-04-29 18:06 ` Russell King - ARM Linux
2016-04-30 3:30 ` Pratyush Anand
2016-04-28 9:28 ` [PATCH 11/12] kexec: allow architectures to override boot mapping Russell King
2016-04-29 15:14 ` Pratyush Anand
2016-04-29 18:08 ` Russell King - ARM Linux
2016-05-11 18:56 ` Russell King - ARM Linux [this message]
2016-05-12 6:26 ` Baoquan He
2016-05-12 8:22 ` Russell King - ARM Linux
2016-04-28 9:28 ` [PATCH 12/12] ARM: kexec: fix kexec for Keystone 2 Russell King
2016-04-28 23:04 ` [PATCH 00/12] Fixing TI Keystone2 kexec Simon Horman
2016-05-11 8:29 ` Dave Young
2016-05-11 8:52 ` Russell King - ARM Linux
2016-05-11 9:13 ` Dave Young
2016-05-11 9:32 ` Russell King - ARM Linux
[not found] ` <20160511093255.GO19428-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2016-05-11 10:31 ` Dave Young
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=20160511185616.GP19428@n2100.arm.linux.org.uk \
--to=linux@armlinux.org.uk \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=ebiederm@xmission.com \
--cc=fenghua.yu@intel.com \
--cc=galak@codeaurora.org \
--cc=hbabu@us.ibm.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=ssantosh@kernel.org \
--cc=tony.luck@intel.com \
--cc=vgoyal@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;
as well as URLs for NNTP newsgroup(s).