qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Newbie:  How to implement iommu?
@ 2009-04-06 15:51 Brian Wheeler
  2009-04-06 17:41 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Wheeler @ 2009-04-06 15:51 UTC (permalink / raw)
  To: qemu-devel

I've been going through the source (and the list archives) and I must be
missing something obvious.  

I need to translate an address passed to
cpu_physical_memory_{read,write} via an IOMMU.  I've been told there's a
dma api, but I cannot find any documentation about it, nor can I find an
obvious user of it.

How do I hook into the read/write address translation?  I can see that
the iommu is setup correctly:

typhoon pchip0 read  reg=1, val=0000000080000001
typhoon pchip0 read  reg=5, val=000000003ff00000
typhoon pchip0 read  reg=9, val=0000000000000000

(which basically translates any 32-bit address beginning with 0x80000000
to 0x00000000)

and later in the emulation I'm seeing a bunch of readl messages

Unassigned mem readl 0000000086246ffc

which should have really been looking at physical address 0x6246ffc


So how do I catch cpu_physical_memory_{read,write} calls and put my
address translation in there?


Thanks!
Brian

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] Newbie:  How to implement iommu?
  2009-04-06 15:51 [Qemu-devel] Newbie: How to implement iommu? Brian Wheeler
@ 2009-04-06 17:41 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2009-04-06 17:41 UTC (permalink / raw)
  To: qemu-devel

Brian Wheeler wrote:
> I've been going through the source (and the list archives) and I must be
> missing something obvious.  
>   

Many things in qemu are not obvious and are easy to miss, so you may 
drop this disclaimer in the future, if you like.

> I need to translate an address passed to
> cpu_physical_memory_{read,write} via an IOMMU.  I've been told there's a
> dma api, but I cannot find any documentation about it, nor can I find an
> obvious user of it.
>   

The core dma api is cpu_physical_memory_{map,unmap}(), in exec.c.  One 
user is hw/ide.c, through the helpers in dma-helpers.c.

> So how do I catch cpu_physical_memory_{read,write} calls and put my
> address translation in there?
>   

I guess these should be replaced by a pci_memory_{read,write}() (or 
equivalents for other busses) which would do the translation.  Given 
that the translation changes depending on where you are in the system 
topology, you'd need to pass an identifier representing that (for pci, 
your PCIDevice pointer).

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-06 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-06 15:51 [Qemu-devel] Newbie: How to implement iommu? Brian Wheeler
2009-04-06 17:41 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).