[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: arm: avoid truncation in mfn to paddr conversions



On Mon, 2013-12-02 at 13:14 +0000, Stefano Stabellini wrote:
> On Mon, 2 Dec 2013, Ian Campbell wrote:
> > Although MFNs are 64-bit in the hypercall ABI they are most often unsigned
> > long internally, and therefore be 32-bit on arm32. Physical addresses are
> > always 64-bit via paddr_t.
> > 
> > This means that the common "mfn << PAGE_SHIFT" pattern risks losing some of
> > the top bits of the address is high enough. This need not imply a high 
> > amount
> > of RAM, just a sparse physical address map.
> > 
> > The correct form is ((paddr_t)mfn)<<PAGE_SHIFT and we have the pfn_to_paddr
> > macro which implements this. Grep for PAGE_SHIFT and << and switch to the
> > macro everywhere we can in the arch specific code. Note that page.h is
> > included by mm.h which defines the macro and so remains with the open coded
> > cast. I have inspected the common code matching this pattern and it uses the
> > correct casts where necessary (x86 also has pfn_to_paddr, so as a further
> > cleanup we could fix the common code too, but I haven't done that here).
> > 
> > I observed this as failure to boot a guest on midway, due to trying to map a
> > foreign page which belonged to no guest. I think this likely explains the
> > crashes which Julien has seen too.
> > 
> > Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> 
> Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

Applied. I had to fix up a couple of rejects because I stupidly sent
this patch based on "improve handling of system with non-contiguous RAM
regions". They were trivially resolved though.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.