Re: [Xen-devel] [PATCH 08/11] xen p2m: transparently change thep2m mappings in the m2p override
From: Konrad Rzeszutek Wilk
Date: Wed Jan 05 2011 - 15:25:50 EST
On Thu, Dec 16, 2010 at 03:25:14PM +0000, Stefano Stabellini wrote:
> On Wed, 15 Dec 2010, Jeremy Fitzhardinge wrote:
> > On 12/15/2010 05:40 AM, stefano.stabellini@xxxxxxxxxxxxx wrote:
> > > From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > >
> > > In m2p_add_override store the original mfn into page->index and then
> > > change the p2m mapping, setting mfns as FOREIGN_FRAME.
> > >
> > > In m2p_remove_override restore the original mapping.
> > >
> > > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > > ---
> > > arch/x86/xen/p2m.c | 4 ++++
> > > 1 files changed, 4 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
> > > index 8db19d5..7dde8e4 100644
> > > --- a/arch/x86/xen/p2m.c
> > > +++ b/arch/x86/xen/p2m.c
> > > @@ -407,8 +407,11 @@ static unsigned long mfn_hash(unsigned long mfn)
> > > void m2p_add_override(unsigned long mfn, struct page *page)
> > > {
> > > unsigned long flags;
> > > + unsigned long pfn = page_to_pfn(page);
> > > page->private = mfn;
> > > + page->index = pfn_to_mfn(pfn);
> >
> > Is there any risk that a page being used for a granted mfn will end up
> > getting xen_create_contiguous_region() applied to it via the DMA API?
> > That would be messy...
>
> I don't think so because AFAIK xen_create_contiguous_region is only
> called:
>
> - by xen_swiotlb_fixup on xen_io_tlb_start (+ offset) that has been
> allocated using alloc_bootmem;
Right, so during bootime.
>
> - by xen_swiotlb_alloc_coherent on memory allocated using
> __get_free_pages.
Which is called by the DMA API by 'dma_alloc_coherent' or by
the PCI API 'pci_alloc_consistent'. So most (if not all) are
done during startup of the device drivers. Thought it
might be that some drivers do allocate it during runtime.
So I think it is OK as long as you get to __set_phys_to_machine
_before_ pci_free_consistent is called.
>
> if in the future xen_create_contiguous_region will be called on other
> memory ranges then maybe, but at the moment there are no problems.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/