From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] arm64: align PHYS_OFFSET to block size
Date: Mon, 30 Mar 2015 15:55:26 +0100 [thread overview]
Message-ID: <20150330145525.GA30015@leverpostej> (raw)
In-Reply-To: <CAKv+Gu84YezZSQmyf4cV34TxMKRPytcFyrrTGO3RFx=_17i-Mg@mail.gmail.com>
On Mon, Mar 30, 2015 at 03:00:31PM +0100, Ard Biesheuvel wrote:
> On 30 March 2015 at 15:49, Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Fri, Mar 27, 2015 at 02:16:19PM +0100, Ard Biesheuvel wrote:
> >> On 26 March 2015 at 07:22, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >> > On 25 March 2015 at 15:59, Catalin Marinas <catalin.marinas@arm.com> wrote:
> >> >> On Mon, Mar 23, 2015 at 04:36:56PM +0100, Ard Biesheuvel wrote:
> >> >>> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> >> >>> index 16134608eecf..fd8434753372 100644
> >> >>> --- a/arch/arm64/kernel/head.S
> >> >>> +++ b/arch/arm64/kernel/head.S
> >> >>> @@ -49,13 +49,15 @@
> >> >>> #ifdef CONFIG_ARM64_64K_PAGES
> >> >>> #define BLOCK_SHIFT PAGE_SHIFT
> >> >>> #define BLOCK_SIZE PAGE_SIZE
> >> >>> -#define TABLE_SHIFT PMD_SHIFT
> >> >>> #else
> >> >>> #define BLOCK_SHIFT SECTION_SHIFT
> >> >>> #define BLOCK_SIZE SECTION_SIZE
> >> >>> -#define TABLE_SHIFT PUD_SHIFT
> >> >>> #endif
> >> >>>
> >> >>> +#define TABLE_SHIFT (BLOCK_SHIFT + PAGE_SHIFT - 3)
> >> >>> +#define TABLE_SIZE (1 << TABLE_SHIFT)
> >> >>> +#define TABLE_MASK (~(TABLE_SIZE - 1))
> >> >>> +
> >> >>> #define KERNEL_START _text
> >> >>> #define KERNEL_END _end
> >> >>>
> >> >>> @@ -237,7 +239,10 @@ ENTRY(stext)
> >> >>> bl el2_setup // Drop to EL1, w20=cpu_boot_mode
> >> >>>
> >> >>> adrp x24, __PHYS_OFFSET
> >> >>> - mov x23, #KIMAGE_OFFSET
> >> >>> + and x23, x24, #~TABLE_MASK // image offset
> >> >>> + and x24, x24, #TABLE_MASK // PHYS_OFFSET
> >> >>> + mov x0, #KIMAGE_OFFSET
> >> >>> + add x23, x23, x0
> >> >>
> >> >> I'm still trying to figure out how this works. Does the code imply that
> >> >> the kernel image can only be loaded within a block size of the
> >> >> PHYS_OFFSET? If that's the case, it's not too flexible.
> >> >
> >> > For now, yes.
> >
> > Can we defer the setting of PHYS_OFFSET until we parse the DT memory
> > nodes?
> >
>
> I experimented a bit with that, but it is quite hairy. Any
> manipulation of the page tables goes through __va/__pa, so you need a
> valid PHYS_OFFSET there to ensure they point at the right physical
> region. But PHYS_OFFSET also needs to be small enough for the DT
> parsing code not to disregard regions that are below it. And then
> there is the memblock limit to ensure that early dynamically allocated
> page tables come from a region that is already mapped.
Could we not use fixmaps to bootstrap the page tables to a state where
we can address them via the linear mapping? That would allow us to
forget about the memblock limit.
If we can do that, then we won't care about PHYS_OFFSET until later, and
we should be able to leave it zero for parsing the DT, then move it up
if necessary (dropping memory we can't address) once we know where
memory is.
This is of course a vast simplification of the work involved ;)
> I think it may be doable, but it would require some significant
> hacking, e.g., call early_init_scan_dt() at its physical address with
> only the ID map loaded and the MMU and caches on, and only after that
> start populating the virtual address space. Or at least only populate
> the lower half, i.e., mappings below PAGE_OFFSET for the kernel and
> the FDT
I thought we were going to use the fixmap for the DT, which would avoid
messiness there, no?
Mark.
next prev parent reply other threads:[~2015-03-30 14:55 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 15:23 [RFC PATCH 0/3] arm64: relocatable kernel proof of concept Ard Biesheuvel
2015-03-16 15:23 ` [RFC PATCH 1/3] arm64: head.S: replace early literals with constant immediates Ard Biesheuvel
2015-03-16 17:14 ` Mark Rutland
2015-03-17 7:01 ` Ard Biesheuvel
2015-03-16 15:23 ` [RFC PATCH 2/3] arm64: add support for relocatable kernel Ard Biesheuvel
2015-03-16 15:23 ` [RFC PATCH 3/3] arm64/efi: use relocated kernel Ard Biesheuvel
2015-03-16 16:09 ` [RFC PATCH 0/3] arm64: relocatable kernel proof of concept Mark Rutland
2015-03-16 16:45 ` Ard Biesheuvel
2015-03-16 17:33 ` Mark Rutland
2015-03-16 17:43 ` Ard Biesheuvel
2015-03-17 16:20 ` Mark Rutland
2015-03-16 23:19 ` Kees Cook
2015-03-17 7:38 ` Ard Biesheuvel
2015-03-17 16:35 ` Mark Rutland
2015-03-17 16:40 ` Ard Biesheuvel
2015-03-17 16:43 ` Mark Rutland
2015-03-23 15:36 ` [PATCH 0/4] RFC: split text and linear mappings using tagged pointers Ard Biesheuvel
2015-03-23 15:36 ` [PATCH 1/4] arm64: use tagged pointers to distinguish kernel text from the linear mapping Ard Biesheuvel
2015-03-25 14:04 ` Catalin Marinas
2015-03-26 1:27 ` Mark Rutland
2015-03-23 15:36 ` [PATCH 2/4] arm64: fixmap: move translation tables to dedicated region Ard Biesheuvel
2015-03-26 1:28 ` Mark Rutland
2015-03-26 6:20 ` Ard Biesheuvel
2015-03-30 14:34 ` Mark Rutland
2015-03-23 15:36 ` [PATCH 3/4] arm64: move kernel text below PAGE_OFFSET Ard Biesheuvel
2015-03-25 14:10 ` Catalin Marinas
2015-03-23 15:36 ` [PATCH 4/4] arm64: align PHYS_OFFSET to block size Ard Biesheuvel
2015-03-25 14:14 ` Catalin Marinas
2015-03-26 6:23 ` Ard Biesheuvel
2015-03-25 14:59 ` Catalin Marinas
2015-03-26 6:22 ` Ard Biesheuvel
2015-03-27 13:16 ` Ard Biesheuvel
2015-03-30 13:49 ` Catalin Marinas
2015-03-30 14:00 ` Ard Biesheuvel
2015-03-30 14:55 ` Mark Rutland [this message]
2015-03-30 15:00 ` Catalin Marinas
2015-03-30 18:08 ` Ard Biesheuvel
2015-03-31 14:49 ` Catalin Marinas
2015-03-31 16:19 ` Catalin Marinas
2015-03-31 16:46 ` Catalin Marinas
2015-03-26 1:26 ` [PATCH 0/4] RFC: split text and linear mappings using tagged pointers Mark Rutland
2015-03-26 6:09 ` 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=20150330145525.GA30015@leverpostej \
--to=mark.rutland@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