Skip to contentSkip to conversation

VT-d support for PV guests

PATCH In review Espen Skoglund 7 participants 18 messages May 19, 2008 – May 26, 2008

lore
Share & tools
lore
#0 lore raw

cover VT-d support for PV guests

Hi,

I've added some preliminary support for VT-d for paravirtualized guests. This must be enabled using an 'iommu_pv' boot parameter (disabled by default).

I've added some python bindigs to allow xend to assign PCI devices to IOMMU for PV guests. For HVM guests this is handled in ioemu. Not sure if it makes sense to handle both cases in one place.

The changes currently hook into get_page_type() in xen/arch/x86/mm.c to map/unmap IOMMU pages when the page types change. This might not be the apropriate place to hook these calls.

The patches I've added are as follows:

xen-vtd-unmap.patch --- Make the VT-d iommu_unmap_page() code
actually do something close to useful.

xen-ptab-dump.path --- There's no point in using 'current' when an
IOMMU page fault is raised. Also, add some page type statistics for DomPage debug output.

xen-iommu-pv.patch --- Add support for iommu_pv_enable boot
parameter and IOMMU assignment of PCI devices to guests.

xen-iommu-pv-mappings.patch --- Hook iommu_{un}map_page() calls
into various Xen locations.

xen-pv-assign.patch --- Allow PCI devices to be assigned to IOMMU
PV guests from xend.

While adding the PV VT-d support I also noticed that there is a lot of duplicated and unused code dealing with VT-d. This really needs to be cleaned up properly. I don't know if the original VT-d submitters already have made plans for doing this.

eSk

#1 lore raw
Quoted 8 lines

While adding the PV VT-d support I also noticed that there is a lot of duplicated and unused code dealing with VT-d. This really needs to be cleaned up properly. I don't know if the original VT-d submitters already have made plans for doing this.

Other than the hardware wait loops which is something we need to clean up, can you give some example of duplicated/unused code in vt-d directory?

Allen

#2 lore raw

[Allen M Kay]

Quoted 8 lines
Quoted 7 lines

While adding the PV VT-d support I also noticed that there is a lot of duplicated and unused code dealing with VT-d. This really needs to be cleaned up properly. I don't know if the original VT-d submitters already have made plans for doing this.

Quoted 5 lines

Other than the hardware wait loops which is something we need to clean up, can you give some example of duplicated/unused code in vt-d directory?

From the top of my head:

iommu_set/free_pgd() in xen/drivers/passthrough/vtd/x86/vtd.c iommu_page_unmapping() in xen/drivers/passthrough/vtd/iommu.c

There's probably more that I can't think of right now.

eSk

#3 lore raw
Quoted 9 lines · Espen Skoglund

[Allen M Kay]

Quoted 7 lines
Quoted 7 lines

While adding the PV VT-d support I also noticed that there is a lot of duplicated and unused code dealing with VT-d. This really needs to be cleaned up properly. I don't know if the original VT-d submitters already have made plans for doing this.

Quoted 9 lines
Quoted 3 lines

Other than the hardware wait loops which is something we need to clean up, can you give some example of duplicated/unused code in vt-d directory?

From the top of my head:

iommu_set/free_pgd() in xen/drivers/passthrough/vtd/x86/vtd.c iommu_page_unmapping() in xen/drivers/passthrough/vtd/iommu.c

In the VT-d development, these code are used once. Now they are indeed useless. We will clean up them later. Thanks!

Randy (Weidong)

Quoted 3 lines

There's probably more that I can't think of right now.

eSk

#4 lore raw
In reply to Espen Skoglund
Quoted 11 lines · Espen Skoglund

I've added some preliminary support for VT-d for paravirtualized guests. This must be enabled using an 'iommu_pv' boot parameter (disabled by default).

I've added some python bindigs to allow xend to assign PCI devices to IOMMU for PV guests. For HVM guests this is handled in ioemu. Not sure if it makes sense to handle both cases in one place.

The changes currently hook into get_page_type() in xen/arch/x86/mm.c to map/unmap IOMMU pages when the page types change. This might not be the apropriate place to hook these calls.

What functionality does this patchset enable, Espen? Is this a security enhancement (isolation/containment) for PV guests with direct hardware access? For example: can access all its own memory except that which has pagetable/GDT type, and only foreign memory which is granted to it?

Is there a good reason to hide this behind a boot option?

Thanks,
Keir

#5 lore raw

[Keir Fraser]

Quoted 13 lines · Espen Skoglund
Quoted 11 lines

I've added some preliminary support for VT-d for paravirtualized guests. This must be enabled using an 'iommu_pv' boot parameter (disabled by default).

I've added some python bindigs to allow xend to assign PCI devices to IOMMU for PV guests. For HVM guests this is handled in ioemu. Not sure if it makes sense to handle both cases in one place.

The changes currently hook into get_page_type() in xen/arch/x86/mm.c to map/unmap IOMMU pages when the page types change. This might not be the apropriate place to hook these calls.

Quoted 7 lines

What functionality does this patchset enable, Espen? Is this a security enhancement (isolation/containment) for PV guests with direct hardware access? For example: can access all its own memory except that which has pagetable/GDT type, and only foreign memory which is granted to it?

Is there a good reason to hide this behind a boot option?

The patchset does, as you guessed, enable isolation for PV guests with direct hardware access. If you assign a PCI device to a guest you are guaranteed that the assigned device can't access the memory of other guests or Xen itself. The patchseet allows the device to access all its own memory which it has write access to, and memory which is granted to it.

The only reason for making it a boot option was to allow for the old behaviour (i.e., complete access) to be the default behaviour until people get more confident with the patches.

eSk

#6 lore raw
Quoted 9 lines · Espen Skoglund
Quoted 1 line

Is there a good reason to hide this behind a boot option?

The patchset does, as you guessed, enable isolation for PV guests with direct hardware access. If you assign a PCI device to a guest you are guaranteed that the assigned device can't access the memory of other guests or Xen itself. The patchseet allows the device to access all its own memory which it has write access to, and memory which is granted to it.

Quoted 3 lines

The only reason for making it a boot option was to allow for the old behaviour (i.e., complete access) to be the default behaviour until people get more confident with the patches.

Okay. Well it seems that there have been some comments to be dealt with in another iteration of these patches. But apart from that I'm happy in principle to apply these patches.

-- Keir

#7 lore raw
In reply to Espen Skoglund
Quoted 6 lines

The patchset does, as you guessed, enable isolation for PV guests with direct hardware access. If you assign a PCI device to a guest you are guaranteed that the assigned device can't access the memory of other guests or Xen itself. The patchseet allows the device to access all its own memory which it has write access to, and memory which is granted to it.

Not that I particularly think it matters, but does the patch configure the IOMMU to distinguish between read-only and read-write access to a guest's own memory or granted memory? If not, we should at least clearly document that we're being a little more permissive.

Have you got any with-and-without performance results with a decent high-throughput device (e.g. a HBA or 10Gb/s NIC)?

It would be good if you could provide a bit more detail on when the patch populates IOMMU entries, and how it keeps them in sync. For example, does the IOMMU map all the guest's memory, or just that which will soon be the subject of a DMA? How synchronous is the patch in removing mappings, e.g. due to page type changes (pagetable pages, balloon driver) or due to unmapping grants?

There's been a lot of discussion at various xen summits about different IOMMU optimizations (e.g. for IBM Summit, Power etc) and I'd like to understand exactly what tradeoffs your implementation makes. Anyhow, good stuff, thanks!

Thanks,
Ian

#8 lore raw

[Ian Pratt]

Quoted 11 lines
Quoted 6 lines

The patchset does, as you guessed, enable isolation for PV guests with direct hardware access. If you assign a PCI device to a guest you are guaranteed that the assigned device can't access the memory of other guests or Xen itself. The patchseet allows the device to access all its own memory which it has write access to, and memory which is granted to it.

Not that I particularly think it matters, but does the patch configure the IOMMU to distinguish between read-only and read-write access to a guest's own memory or granted memory? If not, we should at least clearly document that we're being a little more permissive.

The idea was indeed to distinguish between this properly. However, the current VT-d code only handles read-write or no-access. For PV guests I've made it so that page tables and such are mapped with no access in the IOMMU. This is a bit more restrictive than necessary, but it shouldn't really matter for the common usage scenarios.

Anyhow, read-only access can indeed be supported for VT-d. I just wanted to get basic PV guest support in there first. Also, I'm not familiar with AMD's IOMMU, but I would guess that it also supports read-only access.

Quoted 2 lines

Have you got any with-and-without performance results with a decent high-throughput device (e.g. a HBA or 10Gb/s NIC)?

I don't have a 10GbE NIC in my VT-d enabled machine right now, so I can't test it. We have however tried with a 10GbE NIC running in dom0 with VT-d enabled, and there was as far as I rememeber no performance hit. Of course, any performance degradation will largely depend on the networking memory footprint and the size of the IOTLB.

Quoted 6 lines

It would be good if you could provide a bit more detail on when the patch populates IOMMU entries, and how it keeps them in sync. For example, does the IOMMU map all the guest's memory, or just that which will soon be the subject of a DMA? How synchronous is the patch in removing mappings, e.g. due to page type changes (pagetable pages, balloon driver) or due to unmapping grants?

All writable memory is initially mapped in the IOMMU. Page type changes are also reflected there. In general all maps and unmaps to a domain are synced with the IOMMU. According to the feedback I got I apparently missed some places, though. Will look into this and fix it.

It's clear that performance will pretty much suck if you do frequent updates in grant tables, but the whole idea of having passthrough access for NICs is to avoid this netfront/netback data plane scheme altogether. This leaves you with grant table updates for block device access. I don't know what the expected update frequency is for that one.

It must be noted that reflecting grant table updates in the IOMMU is required for correctness. The alternative --- which is indeed possible --- is to catch DMA faults to such memory regions and somehow notify the driver to, e.g., drop packets or retry the DMA transaction once the IOMMU mapping has been established.

Quoted 4 lines

There's been a lot of discussion at various xen summits about different IOMMU optimizations (e.g. for IBM Summit, Power etc) and I'd like to understand exactly what tradeoffs your implementation makes. Anyhow, good stuff, thanks!

I can't say I know much about those other IOMMUs, but as far as I know they are quite limited in that they only support a fixed number of mappings and can not differentiate between different DMA sources (i.e., PCI devices). Someone please correct me if I'm wrong here. In short, "my" implementation don't actually do many tradeoffs. It's simply based on the VT-d implementation by the Intel folks. It assumes a more fully fledged IOMMU that can have different mappings for different devices.

eSk

#9 lore raw
Quoted 11 lines
Quoted 4 lines

Not that I particularly think it matters, but does the patch configure the IOMMU to distinguish between read-only and read-write access to a guest's own memory or granted memory? If not, we should at least clearly document that we're being a little more permissive.

The idea was indeed to distinguish between this properly. However, the current VT-d code only handles read-write or no-access. For PV guests I've made it so that page tables and such are mapped with no access in the IOMMU. This is a bit more restrictive than necessary, but it shouldn't really matter for the common usage scenarios.

Quoted 4 lines

Anyhow, read-only access can indeed be supported for VT-d. I just wanted to get basic PV guest support in there first. Also, I'm not familiar with AMD's IOMMU, but I would guess that it also supports read-only access.

OK, hopefully someone can fill in the missing bits in the VTd support.

Quoted 8 lines
Quoted 2 lines

Have you got any with-and-without performance results with a decent high-throughput device (e.g. a HBA or 10Gb/s NIC)?

I don't have a 10GbE NIC in my VT-d enabled machine right now, so I can't test it. We have however tried with a 10GbE NIC running in dom0 with VT-d enabled, and there was as far as I rememeber no performance hit. Of course, any performance degradation will largely depend on the networking memory footprint and the size of the IOTLB.

Indeed, that's why I'd like to see some measurements, both for dom0 IO, and also when dom0 is doing IO on behalf of another domain.

I'm also interested to understand what the overhead to page type change / balloon operations are. Do you synchronously invalidate the entries in the IOMMU? How slow is that?

Quoted 7 lines
Quoted 6 lines

It would be good if you could provide a bit more detail on when the patch populates IOMMU entries, and how it keeps them in sync. For example, does the IOMMU map all the guest's memory, or just that which will soon be the subject of a DMA? How synchronous is the patch in removing mappings, e.g. due to page type changes (pagetable pages, balloon driver) or due to unmapping grants?

Quoted 5 lines

All writable memory is initially mapped in the IOMMU. Page type changes are also reflected there. In general all maps and unmaps to a domain are synced with the IOMMU. According to the feedback I got I apparently missed some places, though. Will look into this and fix it.

Is "demotion" of access handled synchronously, or do you have some tricks to mitigate the synchronization?

Quoted 6 lines

It's clear that performance will pretty much suck if you do frequent updates in grant tables, but the whole idea of having passthrough access for NICs is to avoid this netfront/netback data plane scheme altogether. This leaves you with grant table updates for block device access. I don't know what the expected update frequency is for that one.

I don't entirely buy this -- I think we need to make grant map/unmaps fast too. We've discussed schemes to make this more efficient by doing the IOMMU operations at grant map time (where they can be easily batched) rather than at dma_map time. We've talked about using a kmap-style area of physical address space to cycle the mappings through to avoid having to do so many synchronous invalidates (at the expense of allowing a driver domain to be able to DMA to a page for a little longer than it strictly ought to).

Ian

#10 lore raw
Quoted 12 lines

From: Ian Pratt
Sent: 2008年5月20日 23:34

Quoted 5 lines
Quoted 5 lines

It would be good if you could provide a bit more detail on when the patch populates IOMMU entries, and how it keeps them in sync. For example, does the IOMMU map all the guest's memory, or just that which will soon be the subject of a DMA? How synchronous is the patch in removing mappings, e.g. due to page type changes

(pagetable

Quoted 4 lines
Quoted 1 line

pages, balloon driver) or due to unmapping grants?

All writable memory is initially mapped in the IOMMU. Page type changes are also reflected there. In general all maps and

Quoted 7 lines

unmaps to a

Quoted 3 lines

domain are synced with the IOMMU. According to the feedback I got I apparently missed some places, though. Will look into this and fix it.

Is "demotion" of access handled synchronously, or do you have some tricks to mitigate the synchronization?

All changes need be handled synchronously, as DMA request is not restartable with VT-d fault as async event notification. Hardware bits are designed in such way that all expected permission controls have to exist before device actually issues access request.

Quoted 5 lines
Quoted 5 lines

It's clear that performance will pretty much suck if you do frequent updates in grant tables, but the whole idea of having passthrough access for NICs is to avoid this netfront/netback data plane scheme altogether. This leaves you with grant table updates for

Quoted 8 lines

block device

Quoted 2 lines

access. I don't know what the expected update frequency is for that one.

I don't entirely buy this -- I think we need to make grant map/unmaps fast too. We've discussed schemes to make this more efficient by doing the IOMMU operations at grant map time (where they can be easily batched) rather than at dma_map time. We've talked about using a

Agree.

Quoted 6 lines

kmap-style area of physical address space to cycle the mappings through to avoid having to do so many synchronous invalidates (at the expense of
allowing a driver domain to be able to DMA to a page for a little longer
than it strictly ought to).

Could you elaborate a bit how kmap-style area helps here? The key point is whether frequency of p2m mapping can be reduced...

Thanks,
Kevin

#11 lore raw
Quoted 7 lines
Quoted 2 lines

Is "demotion" of access handled synchronously, or do you have some tricks to mitigate the synchronization?

All changes need be handled synchronously, as DMA request is not restartable with VT-d fault as async event notification. Hardware bits are designed in such way that all expected permission controls have to exist before device actually issues access request.

You are talking about 'promtion' (adding more permissions). Demotion required flushing entries in the TLB and is typically more expensive, hence the desire to 'batch' the synchronization.

Quoted 10 lines
Quoted 1 line

kmap-style area of physical address space to cycle the mappings

through

Quoted 5 lines

to avoid having to do so many synchronous invalidates (at the expense of
allowing a driver domain to be able to DMA to a page for a little longer
than it strictly ought to).

Could you elaborate a bit how kmap-style area helps here? The key point is whether frequency of p2m mapping can be reduced...

A window of guest physical address space is created that is used to create mappings to granted pages. The next available free slot is used when creating a mapping. When the end of the window is reached, flush the IOMMU. (Actually, you can do better by issuing a flush at the halfway point and then synchronizing against the flush at the end if the window, effectively double buffering).

This typically avoids the churn that would happen with grant mappings where the same guest physical address region is used to map different pages (requiring a synchronous flush).

Ian

#12 lore raw
Quoted 7 lines

From: Ian Pratt [mailto:[email protected]]
Sent: 2008年5月21日 13:05

Quoted 5 lines
Quoted 2 lines

Is "demotion" of access handled synchronously, or do you have some tricks to mitigate the synchronization?

All changes need be handled synchronously, as DMA request is not restartable with VT-d fault as async event notification.

Quoted 7 lines

Hardware bits

Quoted 2 lines

are designed in such way that all expected permission controls have to exist before device actually issues access request.

You are talking about 'promtion' (adding more permissions). Demotion required flushing entries in the TLB and is typically more expensive, hence the desire to 'batch' the synchronization.

So you're talking about TLB inside CPU? IMO, both demotion/promotion requires IOTLB flush. Even for promotion, it's not like instruction access to trigger fault for Xen to promote lazily and then restart the exection...

'batch' IOTLB flush is good direction, which requires some cooperation from guest, e.g. as long as guest driver doesn't attempt to use set of frames in changing. So to me it's more like some change in guest side to batch grant/m2p request together. Or else Xen itself doesn't know when one changed mapping will be used by guest and thus has to force flush for each change before resuming back to guest

Quoted 20 lines
Quoted 11 lines
Quoted 2 lines

kmap-style area of physical address space to cycle the mappings

through

Quoted 5 lines

to avoid having to do so many synchronous invalidates (at the expense of
allowing a driver domain to be able to DMA to a page for a little longer
than it strictly ought to).

Could you elaborate a bit how kmap-style area helps here? The key point is whether frequency of p2m mapping can be reduced...

A window of guest physical address space is created that is used to create mappings to granted pages. The next available free slot is used when creating a mapping. When the end of the window is reached, flush the IOMMU. (Actually, you can do better by issuing a flush at the halfway point and then synchronizing against the flush at the end if the
window, effectively double buffering).

Quoted 4 lines

This typically avoids the churn that would happen with grant mappings where the same guest physical address region is used to map different pages (requiring a synchronous flush).

Yep, that's a neat one to hold unflushed guest frames from being used until batch flush is done later. :-)

Thanks,
Kevin

#13 lore raw
Quoted 8 lines
Quoted 3 lines

You are talking about 'promtion' (adding more permissions). Demotion required flushing entries in the TLB and is typically more expensive, hence the desire to 'batch' the synchronization.

So you're talking about TLB inside CPU? IMO, both demotion/promotion requires IOTLB flush. Even for promotion, it's not like instruction access to trigger fault for Xen to promote lazily and then restart the exection...

The IOMMU TLB doesn't cache not_present entries, hence you don't need to do a flush when transitioning an entry from not_present to present. Some IOMMUs will also re-walk the pagetable if they find a TLB entry that is read-only and the operation is a write, but I can't recall whether VTd is like this.

Quoted 6 lines

'batch' IOTLB flush is good direction, which requires some cooperation from guest, e.g. as long as guest driver doesn't attempt to use set of frames in changing. So to me it's more like some change in guest side to batch grant/m2p request together. Or else Xen itself doesn't know when one changed mapping will be used by guest and thus has to force flush for each change before resuming back to guest

For ballooned frames, Xen should be able to put them on a 'pending' list awaiting completion of a flush (hence the flush is typically not synchronous).

Frames that transition to pagetable frames are more problematic. It's probably better to modify the guest to create a separate quicklist for pagetable frames, so they get recycled and remain out of the IOMMU until they return to the free list.

Ian

#14 lore raw
Quoted 10 lines

From: Ian Pratt [mailto:[email protected]]
Sent: 2008年5月21日 13:32

The IOMMU TLB doesn't cache not_present entries, hence you don't need to
do a flush when transitioning an entry from not_present to present. Some
IOMMUs will also re-walk the pagetable if they find a TLB entry that is read-only and the operation is a write, but I can't recall whether VTd is like this.

You're right, though VT-d spec defines a capability bit to indicate whether VT-d may cache non-present entry or not. In reality it doesn't make sense to do that.

For promotion from non-present to present, then no flush is required. But for promotion from read-only to read-write, I guess flush has to be forced. Not sure whether currently such grant entry exists to switch RO/RW permission on demand.

Quoted 10 lines
Quoted 2 lines

'batch' IOTLB flush is good direction, which requires some

cooperation

Quoted 1 line

from guest, e.g. as long as guest driver doesn't attempt to

use set of

Quoted 4 lines

frames in changing. So to me it's more like some change in guest side to batch grant/m2p request together. Or else Xen itself doesn't know when one changed mapping will be used by guest and thus has to force flush for each change before resuming back to guest

Quoted 4 lines

For ballooned frames, Xen should be able to put them on a 'pending' list
awaiting completion of a flush (hence the flush is typically not synchronous).

It seems so. Just one security concern: it's possible to have decreased frames allocated to another VM before completion of async flush. In this case, the IOMMU still caches old mapping and thus it leaks a window for mallicious domain/device to touch those frames...

But we may force a delayed completion check when a free page is allocated to a new VM or inserted to other p2m table. Then I agree upon page's specific usage, async flush is possible. :-)

Quoted 7 lines

Frames that transition to pagetable frames are more problematic. It's probably better to modify the guest to create a separate quicklist for pagetable frames, so they get recycled and remain out of the IOMMU until
they return to the free list.

So you're already talking about one more step from current implentation, to selectively insert mapping as device really requires. Create a PV iommu interface may serve this purpose more accurately.

Thanks,
Kevin

#15 lore raw
Quoted 15 lines

From: Tian, Kevin
Sent: 2008年5月21日 13:56

Quoted 8 lines

From: Ian Pratt [mailto:[email protected]]
Sent: 2008年5月21日 13:32

The IOMMU TLB doesn't cache not_present entries, hence you don't need to
do a flush when transitioning an entry from not_present to present. Some
IOMMUs will also re-walk the pagetable if they find a TLB

entry that is

Quoted 2 lines

read-only and the operation is a write, but I can't recall whether VTd is like this.

Quoted 8 lines

You're right, though VT-d spec defines a capability bit to indicate whether VT-d may cache non-present entry or not. In reality it doesn't make sense to do that.

For promotion from non-present to present, then no flush is required. But for promotion from read-only to read-write, I guess flush has to be forced. Not sure whether currently such grant entry exists to switch RO/RW permission on demand.

Forgot above, I'm just talking exact same thing as you already pointed out. :-P

Thanks,
Kevin

#16 lore raw
In reply to Tian, Kevin
Quoted 6 lines
Quoted 4 lines

For ballooned frames, Xen should be able to put them on a 'pending' list
awaiting completion of a flush (hence the flush is typically not synchronous).

It seems so. Just one security concern: it's possible to have

decreased

Quoted 2 lines

frames allocated to another VM before completion of async flush. In this case, the IOMMU still caches old mapping and thus it leaks a

window

Quoted 4 lines

for mallicious domain/device to touch those frames...

But we may force a delayed completion check when a free page is allocated to a new VM or inserted to other p2m table. Then I agree

upon

Quoted 1 line

page's specific usage, async flush is possible. :-)

Yep, that's the purpose of the 'pending' list(s): pages don't graduate to the free list until synchronized against flush completion.

Quoted 2 lines
Quoted 2 lines

Frames that transition to pagetable frames are more problematic. It's probably better to modify the guest to create a separate quicklist

for

Quoted 7 lines
Quoted 4 lines

pagetable frames, so they get recycled and remain out of the IOMMU until
they return to the free list.

So you're already talking about one more step from current implentation, to selectively insert mapping as device really requires.

Create a PV

Quoted 1 line

iommu interface may serve this purpose more accurately.

Linux 2.4 had a concept of a quicklist that was used to recycle pagetable pages rather than just returning them to the free list. It got removed in 2.6, but reinstating something similar would help Xen, particularly in the case with an IOMMU.

Ian

#17 lore raw
In reply to Espen Skoglund
Quoted 4 lines · Espen Skoglund

Anyhow, read-only access can indeed be supported for VT-d. I just wanted to get basic PV guest support in there first. Also, I'm not familiar with AMD's IOMMU, but I would guess that it also supports read-only access.

It does.

Quoted 20 lines
Quoted 6 lines

It would be good if you could provide a bit more detail on when the patch populates IOMMU entries, and how it keeps them in sync. For example, does the IOMMU map all the guest's memory, or just that which will soon be the subject of a DMA? How synchronous is the patch in removing mappings, e.g. due to page type changes (pagetable pages, balloon driver) or due to unmapping grants?

All writable memory is initially mapped in the IOMMU. Page type changes are also reflected there. In general all maps and unmaps to a domain are synced with the IOMMU. According to the feedback I got I apparently missed some places, though. Will look into this and fix it.

It's clear that performance will pretty much suck if you do frequent updates in grant tables, but the whole idea of having passthrough access for NICs is to avoid this netfront/netback data plane scheme altogether. This leaves you with grant table updates for block device access. I don't know what the expected update frequency is for that one.

Quoted 5 lines

It must be noted that reflecting grant table updates in the IOMMU is required for correctness. The alternative --- which is indeed possible --- is to catch DMA faults to such memory regions and somehow notify the driver to, e.g., drop packets or retry the DMA transaction once the IOMMU mapping has been established.

That would assume that the device can retry failed DMA's or otherwise deal with them. The majority of devices can't.

Quoted 4 lines
Quoted 4 lines

There's been a lot of discussion at various xen summits about different IOMMU optimizations (e.g. for IBM Summit, Power etc) and I'd like to understand exactly what tradeoffs your implementation makes. Anyhow, good stuff, thanks!

I think the major difference is that with Espen's patches all of the PV guest's memory is exposed to the device (i.e., it provides inter-guest protection, but no intra-guest protection). Our patches aimed at providing both inter-guest and intra-guest protection, and incurred a substantial performance hit (c.f., our OLS '07 paper on IOMMU performance). There will be a paper at USENIX '08 by Willmann et al., on different IOMMU mapping strategies which provide varying levels of inter/intra guest protection and performance hit.

Quoted 3 lines

I can't say I know much about those other IOMMUs, but as far as I know they are quite limited in that they only support a fixed number of mappings

The IBM Calgary/CalIOC2 family of IOMMUs support 4GB address spaces.

Quoted 2 lines

and can not differentiate between different DMA sources (i.e., PCI devices).

Calgary/CalIOC2 have a per-bus translation table. In practice most devices are on their own bus in these systems, so you get effectively per-device translation translation tables.

Cheers,
Muli