From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 7/7] arm64: allow kernel Image to be loaded anywhere in physical memory
Date: Wed, 14 Oct 2015 12:30:07 +0100 [thread overview]
Message-ID: <561E3CBF.60704@arm.com> (raw)
In-Reply-To: <1442968663-31843-8-git-send-email-ard.biesheuvel@linaro.org>
Hi Ard,
On 23/09/15 01:37, Ard Biesheuvel wrote:
> This relaxes the kernel Image placement requirements, so that it
> may be placed at any 2 MB aligned offset in physical memory.
>
> This is accomplished by ignoring PHYS_OFFSET when installing
> memblocks, and accounting for the apparent virtual offset of
> the kernel Image (in addition to the 64 MB that it is moved
> below PAGE_OFFSET). As a result, virtual address references
> below PAGE_OFFSET are correctly mapped onto physical references
> into the kernel Image regardless of where it sits in memory.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[SNIP]
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 4a1c9d0769f2..675757c01eff 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -21,6 +21,7 @@
> #include <linux/kernel.h>
> #include <linux/errno.h>
> #include <linux/init.h>
> +#include <linux/initrd.h>
> #include <linux/libfdt.h>
> #include <linux/mman.h>
> #include <linux/nodemask.h>
> @@ -432,11 +433,34 @@ static void __init bootstrap_linear_mapping(unsigned long va_offset)
> static void __init map_mem(void)
> {
> struct memblock_region *reg;
> + u64 new_memstart_addr;
> + u64 new_va_offset;
>
> - bootstrap_linear_mapping(KIMAGE_OFFSET);
> + /*
> + * Select a suitable value for the base of physical memory.
> + * This should be equal to or below the lowest usable physical
> + * memory address, and aligned to PUD/PMD size so that we can map
> + * it efficiently.
> + */
> + new_memstart_addr = round_down(memblock_start_of_DRAM(), SZ_1G);
> +
> + /*
> + * Calculate the offset between the kernel text mapping that exists
> + * outside of the linear mapping, and its mapping in the linear region.
> + */
> + new_va_offset = memstart_addr - new_memstart_addr;
> +
> + bootstrap_linear_mapping(new_va_offset);
> +
> + kernel_va_offset = new_va_offset;
> +
> + /* Recalculate virtual addresses of initrd region */
> + if (initrd_start) {
> + initrd_start += new_va_offset;
> + initrd_end += new_va_offset;
> + }
This breaks the build for me, with messages like:
> arch/arm64/mm/built-in.o: In function `map_mem':
> ... arch/arm64/mm/mmu.c:458: undefined reference to `initrd_start'
Wrapping the if with:
> if (IS_ENABLED(CONFIG_BLK_DEV_INITRD))
Solves the problem for me.
Thanks,
James
>
> - kernel_va_offset = KIMAGE_OFFSET;
> - memstart_addr -= KIMAGE_OFFSET;
> + memstart_addr = new_memstart_addr;
>
> /* map all the memory banks */
> for_each_memblock(memory, reg) {
>
next prev parent reply other threads:[~2015-10-14 11:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 0:37 [PATCH v2 0/7] arm64: relax Image placement rules Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 1/7] of/fdt: make memblock minimum physical address arch configurable Ard Biesheuvel
2015-09-23 4:45 ` Mark Rutland
2015-09-23 22:59 ` Rob Herring
2015-09-23 0:37 ` [PATCH v2 2/7] arm64: use more granular reservations for static page table allocations Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 3/7] arm64: split off early mapping code from early_fixmap_init() Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 4/7] arm64: mm: explicitly bootstrap the linear mapping Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 5/7] arm64: move kernel mapping out of linear region Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 6/7] arm64: map linear region as non-executable Ard Biesheuvel
2015-09-23 0:37 ` [PATCH v2 7/7] arm64: allow kernel Image to be loaded anywhere in physical memory Ard Biesheuvel
2015-10-14 11:30 ` James Morse [this message]
2015-10-14 13:25 ` Ard Biesheuvel
2015-10-14 16:34 ` Catalin Marinas
2015-10-14 16:51 ` Ard Biesheuvel
2015-10-15 10:04 ` James Morse
2015-09-24 16:37 ` [PATCH v2 0/7] arm64: relax Image placement rules Suzuki K. Poulose
2015-09-24 16:38 ` Ard Biesheuvel
2015-09-24 23:19 ` Ard Biesheuvel
2015-09-25 8:44 ` Suzuki K. Poulose
2015-09-25 21:53 ` Ard Biesheuvel
2015-10-13 17:07 ` Catalin Marinas
2015-10-13 17:14 ` Ard Biesheuvel
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=561E3CBF.60704@arm.com \
--to=james.morse@arm.com \
--cc=linux-arm-kernel@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).