[PATCH 4/4] arm64: align PHYS_OFFSET to block size
Catalin Marinas
catalin.marinas at arm.com
Tue Mar 31 09:46:36 PDT 2015
On Tue, Mar 31, 2015 at 05:19:03PM +0100, Catalin Marinas wrote:
> On Tue, Mar 31, 2015 at 03:49:32PM +0100, Catalin Marinas wrote:
> > On Mon, Mar 30, 2015 at 08:08:52PM +0200, Ard Biesheuvel wrote:
> > > But using early_fixmap() implies using the ordinary page tables
> > > manipulation code, which uses __pa/__va
> > > So instead, I should refactor those patches to simply pick a VA offset
> > > and map the FDT there from head.S
> >
> > I haven't dug out those patches yet but in principle you should not care
> > about __va, just __pa for populating the pmd/pud/pgd. Since with
> > fixmap we pre-allocate the page tables in the kernel data section
> > (bm_pud/pmd/pte), a __pa implementation that takes KERNEL_PAGE_OFFSET
> > into account (as per these patches) is enough, you don't really care
> > about the linear PAGE_OFFSET at this stage since you would not provide
> > __pa with such virtual address until after setup_machine_fdt().
>
> Actually, that's wrong, early_fixmap_init() uses pud/pmd_offset which in
> turn use the pmd_offset etc. and pmd_page_vaddr. These would not be
> mapped in the linear mapping at this stage. create_mapping() also uses
> the *_offset() functions, so we have the same issue.
>
> So I think we still need to calculate the default initial PHYS_OFFSET in
> head.S as we currently do, based on the kernel load address so that
> __va() returns a mapping in the initial KERNEL_PAGE_OFFSET range. During
> our own early_init_dt_add_memory_arch(), we calculate the real
> PHYS_OFFSET but don't set it yet. We should defer the setting of the
> real PHYS_OFFSET until we map the first block of memory via
> create_mapping(). We know that we can't cope with allocations before the
> first block anyway, so this approach may work.
Some more brainstorming with Mark, I think we can set the real
PHYS_OFFSET immediately after we map the kernel text into the linear
mapping (and before mapping the RAM with create_mapping) so that we have
access to swapper_pg_dir via this mapping. But we need the initial
swapper be pre-populated with pud/pmd for (1) the kernel text at
KERNEL_PAGE_OFFSET, (2) kernel text in the linear mapping and (3) the
1st GB of PAGE_OFFSET (to avoid memblock allocations until we mapped
some RAM). This way we avoid mandating that the kernel image is only
loaded in the first GB of RAM.
--
Catalin
More information about the linux-arm-kernel
mailing list