From: Pete Zaitcev Subject: Reversing the DMA handle Date: Tue, 9 Jan 2007 17:17:10 -0800 Message-ID: <20070109171710.b4cf6ec6.zaitcev@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: zaitcev@redhat.com List-Id: xen-devel@lists.xenproject.org Dear Xen developers: 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? I see some functions which may be useful (e.g. mfn_to_pfn()), but what I need the most is some tribal knowledge about what is the proper way to do it. This includes things like working in both dom0 and domU, not faulting in machine_to_phys_mapping[] while in hot path, and so on. Thank you, -- Pete