[PATCH/RFC v7] ARM: boot: Obtain start of physical memory from DTB

Russell King - ARM Linux admin linux at armlinux.org.uk
Sat Aug 15 05:18:27 EDT 2020


On Fri, Aug 14, 2020 at 04:06:03PM +0200, Ard Biesheuvel wrote:
> On Fri, 14 Aug 2020 at 16:03, Linus Walleij <linus.walleij at linaro.org> wrote:
> >
> > On Thu, Jul 23, 2020 at 3:19 AM Stephen Boyd <sboyd at kernel.org> wrote:
> >
> > > > > textofs-$(CONFIG_ARCH_IPQ40XX) := 0x00208000
> > > > > textofs-$(CONFIG_ARCH_MSM8X60) := 0x00208000
> > > > > textofs-$(CONFIG_ARCH_MSM8960) := 0x00208000
> > > >
> > > > But what on earth is this? I just deleted this and the platform
> > > > boots just as well.
> > >
> > > We need to shift the kernel text to start 2MB beyond the start of memory
> > > because there is the shared memory region used to communicate with other
> > > processors in the SoC there. It took a while for us to convince other OS
> > > folks in the company to put shared memory somewhere else besides the
> > > start of RAM, but eventually we won that battle.
> > >
> > > Does your booted kernel have its text section at the start of RAM or is
> > > it offset by 2MB without this change? Check out /proc/iomem to see where
> > > the kernel text is in relation to the start of RAM.
> >
> > The memory on this machine starts at 0x40200000 since the effect
> > of the current code is to take pc &= 0xf8000000 and that results in
> > 0x40000000 and then this adds textofs 0x00208000 to that
> > resulting in 0x40208000 for the kernel physical RAM. Which
> > is what we want to achieve since the RAM starts at
> > 0x40200000.
> >
> > But TEXT_OFFSET is also used inside the kernel to offset the
> > virtual memory. This means that when we set up the virtual
> > memory split, the kernel virtual memory is also bumped by
> > these 2 MB so the virtual memory starts at 0xC0208000
> > instead of 0xC0008000 as is normal.
> >
> > It looks weird to me but maybe someone can explain how
> > logical that is?
> >
> 
> The ARM mm code assumes that the relative alignment between PA and VA
> is 16 MB, so if we skip 2 MB in the physical space, we must do the
> same in the virtual space.

That is a good thing; it makes the virtual to physical translations
easy - we only have facility for offsets with bits 23..0 clear to
make the code rewriting simple.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



More information about the linux-arm-kernel mailing list