[PATCH] PPC: Correct the tophys/tovirt macros

Jason Gunthorpe jgunthorpe at obsidianresearch.com
Fri Oct 5 03:08:41 EST 2012

On Thu, Oct 04, 2012 at 09:19:04PM +1000, Benjamin Herrenschmidt wrote:
> On Sun, 2012-09-30 at 17:28 -0600, Jason Gunthorpe wrote:
> > asm/page.h discusses the calculation for v2p and p2v, it should be:
> > which is the same as:
> >  va = pa + LOAD_OFFSET
> > 
> > tophys/tovirt were using PAGE_OFFSET, which as page.h says, is almost
> > always the same thing.
> > 
> > Signed-off-by: Jason Gunthorpe <jgunthorpe at obsidianresearch.com>
> It's a bit gross tho in that KERNEL_BASE, PHYSICAL_START and LOAD_OFFSET
> are about where the kernel is linked/running, and while the value ends
> up happening to also be the p->v offset (and indeed not by accident), it
> makes the code less clear and more confusing.

Yes, I found the three names confusing.. However LOAD_OFFSET is the
name that include/asm-generic/vmlinux.lds.h and many arch's use for
P2V translation in the linker script, so at least there is some

> I don't have the bandwidth to revisit all that, but I really think that
> whole are area where PAGE_OFFSET doesn't map 0 needs revisiting.

Something like that is also outside my scope.. This patch does fix a
bug I hit when CONFIG_PHYSICAL_START is used, are there problems with
it in other cases?

FWIW, this is part of a larger work that makes CONFIG_PHYSICAL_START
work on PPC404, which is not yet clean enough to post:


More information about the Linuxppc-dev mailing list