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

Re: [Xen-devel] Reversing the DMA handle


  • To: Pete Zaitcev <zaitcev@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: Keir Fraser <keir@xxxxxxxxxxxxx>
  • Date: Wed, 10 Jan 2007 11:04:01 +0000
  • Delivery-date: Wed, 10 Jan 2007 03:03:45 -0800
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: Acc0pwh9RsGC46CaEduNDgAX8io7RQ==
  • Thread-topic: [Xen-devel] Reversing the DMA handle

On 10/1/07 01:17, "Pete Zaitcev" <zaitcev@xxxxxxxxxx> wrote:

> I maintain a component in Linux kernel, called usbmon. It provides for
> snooping of USB traffic, analoguously to tcpdump. Due to pequliarities
> of USB API in Linux, usbmon has to take a DMA address (coming from
> dma_alloc_coherent() typically), find the corresponding PFN and call
> pkmap()/memcpy()/pkunmap().
> 
> My question is: how to find PFN under Xen if DMA address is known,
> on x86_64 and i386?

Use mfn_to_local_pfn() which is safe to call from any context. This will
return a !pfn_valid() value if the given MFN actually belongs to a foreign
domain (e.g., we are issuing a DMA on behalf of another guest via netback or
blkback) or if the MFN is not RAM. Otherwise it will return the local PFN.
Of course you may then want to do further translation if that happens to be
in the swiotlb aperture.

 -- Keir


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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