Skip to contentSkip to conversation

Newbie: How to implement iommu?

Qemu-devel Brian Wheeler 2 participants 2 messages Apr 6, 2009

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 3 lines · Brian Wheeler

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.

Quoted 5 lines

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.

Quoted 3 lines

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).

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.