[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v5 3/4] xen: implement guest_physmap_pin_range and guest_physmap_unpin_range
On Tue, 2013-09-10 at 20:11 +0100, Stefano Stabellini wrote: > On Tue, 10 Sep 2013, Ian Campbell wrote: > > On Mon, 2013-09-09 at 17:06 +0100, Stefano Stabellini wrote: > > > guest_physmap_pin_range pins a range of guest pages so that their p2m > > > mappings won't be changed. > > > guest_physmap_unpin_range unpins the previously pinned pages. > > > The pinning is done using one of the spare bits in the p2m ptes. > > > > > > Use the newly introduce p2m_walker to implement the two functions on > > > ARM. > > > Provide empty stubs for x86. > > > > > > > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> > > > > > > > > > Changes in v5: > > > - return -EBUSY when the P2M_DMA_PIN check fails; > > > - rename _guest_physmap_pin_range to pin_one_pte; > > > - rename _guest_physmap_unpin_range to unpin_one_pte. > > > > > > Changes in v4: > > > - use p2m_walker to implement guest_physmap_pin_range and > > > guest_physmap_unpin_range; > > > - return -EINVAL when the P2M_DMA_PIN check fails; > > > - change the printk into a gdprintk; > > > - add a comment on what type of page can be pinned. > > > --- > > > xen/arch/arm/p2m.c | 48 > > > ++++++++++++++++++++++++++++++++++++++++++++ > > > xen/include/asm-arm/mm.h | 4 +++ > > > xen/include/asm-arm/page.h | 7 +++++- > > > xen/include/asm-x86/p2m.h | 12 +++++++++++ > > > 4 files changed, 70 insertions(+), 1 deletions(-) > > > > > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > > > index a9ceacf..bac6c7e 100644 > > > --- a/xen/arch/arm/p2m.c > > > +++ b/xen/arch/arm/p2m.c > > > @@ -154,6 +154,46 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr) > > > return p2m.maddr; > > > } > > > > > > +static int pin_one_pte(lpae_t *ptep, void *arg, int level) > > > +{ > > > + lpae_t pte = *ptep; > > > + ASSERT(level == 3); > > > + > > > + if ( pte.p2m.avail & P2M_DMA_PIN ) > > > + return -EBUSY; > > > + pte.p2m.avail |= P2M_DMA_PIN; > > > + write_pte(ptep, pte); > > > + return 0; > > > +} > > > + > > > +int guest_physmap_pin_range(struct domain *d, > > > + xen_pfn_t gpfn, > > > + unsigned int order) > > > +{ > > > + return p2m_walker(d, gpfn << PAGE_SHIFT, order, > > > + pin_one_pte, NULL); > > > > If this fails then you will have left some subset of the pages > > successfully pinned. You need to clean it up I think, or be fatal to the > > guest or something. > > Making the failure of guest_physmap_pin_range fatal to the guest would > also solve the non-trivial problem of error handling in memory_exchange. Actually, I don't think this will work. Consider two concurrent I/O operations dispatched by two threads in the same process, to/from non-overlapping regions of the same page. Hrm, we may actually need a reference count on the pin :-( We might need to rethink here -- i.e. use a type count on the underlying machine page rather than a pin in the p2m entry? That kind of makes sense since it will be the underlying page which is exposed to the hardware... Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |