Skip to contentSkip to conversation

device assignment: default requires IOMMU

PATCH Applied Chris Wright 7 participants 9 messages Dec 23, 2009 – Jan 18, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device assignment: default requires IOMMU

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is simply broken.

And, of course, disabling the IOMMU requirement using the old:

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Cc Alexander Graf <[email protected]>
Cc Dmitri Seletski <[email protected]>
Cc Sheng Yang <[email protected]>
---
 hw/device-assignment.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
hw/device-assignment.c +9 -8
index 02d23d8..a314360 100644
@@ -816,14 +816,15 @@ static int assign_device(AssignedDevice *dev)
     assigned_dev_data.devfn = dev->h_devfn;
 
 #ifdef KVM_CAP_IOMMU
-    /* We always enable the IOMMU if present
-     * (or when not disabled on the command line)
-     */
-    r = kvm_check_extension(kvm_state, KVM_CAP_IOMMU);
-    if (!r)
-        dev->use_iommu = 0;
-    if (dev->use_iommu)
-	assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU;
+    /* We always enable the IOMMU unless disabled on the command line */
+    if (dev->use_iommu) {
+        if (!kvm_check_extension(kvm_state, KVM_CAP_IOMMU)) {
+            fprintf(stderr, "No IOMMU found.  Unable to assign device \"%s\"\n",
+                    dev->dev.qdev.id);
+             return -ENODEV;
+        }
+        assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU;
+    }
 #else
     dev->use_iommu = 0;
 #endif
#1 lore raw

Am 23.12.2009 um 23:40 schrieb Chris Wright <[email protected]>:

Quoted 18 lines

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is simply broken.

And, of course, disabling the IOMMU requirement using the old:

Quoted 8 lines

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Yay!

Alex

#2 lore raw
Quoted 25 lines · Alexander Graf

Am 23.12.2009 um 23:40 schrieb Chris Wright <[email protected]>:

Quoted 22 lines

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current
logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is
simply broken.

And, of course, disabling the IOMMU requirement using the old:

-pcidevice host=[addr],dma=none

Quoted 8 lines
Quoted 6 lines

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Yay!

Sounds good to me. Though I am curious to know the reasoning behind the current logic.

#3 lore raw
Quoted 28 lines · On Thursday 24 December 2009 14:51:23 Simon Horman wrote:
Quoted 27 lines · Alexander Graf

Am 23.12.2009 um 23:40 schrieb Chris Wright <[email protected]>:

Quoted 26 lines

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current
logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is
simply broken.

And, of course, disabling the IOMMU requirement using the old:

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

will do what it always did (not require an IOMMU, and fail to work properly).

Yay!

Sounds good to me. Though I am curious to know the reasoning behind the current logic.

Sounds pretty good. :)

I think maybe it due to we are interested in implementing PV DMA?

Signature · 2 lines
regards
Yang, Sheng
#4 lore raw
Quoted 11 lines · Sheng Yang
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

And, of course, disabling the IOMMU requirement using the old:

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yay!

Sounds good to me. Though I am curious to know the reasoning behind the current logic.

Sounds pretty good. :)

I think maybe it due to we are interested in implementing PV DMA?

Yes, we are. The current defaults came from the desire to support both pvdma and also 1-1 host mappings. There were patches floating around for both. Having said that, I fully agree with this change---the default should be to require IOMMU. Anything else is "highly experimental".

Cheers,
Muli

#5 lore raw
In reply to Sheng Yang
Quoted 32 lines · Sheng Yang
Quoted 31 lines · On Thursday 24 December 2009 14:51:23 Simon Horman wrote:
Quoted 30 lines · Alexander Graf

Am 23.12.2009 um 23:40 schrieb Chris Wright <[email protected]>:

Quoted 28 lines

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current
logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is
simply broken.

And, of course, disabling the IOMMU requirement using the old:

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yay!

Sounds good to me. Though I am curious to know the reasoning behind the current logic.

Sounds pretty good. :)

I think maybe it due to we are interested in implementing PV DMA?

Ok, that would explain it.

#6 lore raw
In reply to Chris Wright
Quoted 18 lines · Chris Wright

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is simply broken.

And, of course, disabling the IOMMU requirement using the old:

Quoted 8 lines

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Applied, thanks.

#7 lore raw
In reply to Chris Wright
Quoted 18 lines · Chris Wright

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is simply broken.

And, of course, disabling the IOMMU requirement using the old:

Quoted 9 lines

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Avi,

could you please cherry-pick this into 0.12-stable?
I don't feel too eager getting 500 bug reports from people who try out device passthrough with disabled or no IOMMU.

Alex

#8 lore raw
Quoted 30 lines · Alexander Graf
Quoted 18 lines · Chris Wright

[ resend, fixing email header, sorry for duplicate ]

The default mode for device assignment is to rely on an IOMMU for proper translations and a functioning device in the guest. The current logic makes this requirement advisory, and simply disables the request for IOMMU if one is not found on the host. This makes for a confused user when the device assignment appears to work, but the device in the guest is not functioning (I've seen about a half-dozen reports with this failure mode).

Change the logic such that the default requires the IOMMU. Period. If the host does not have an IOMMU, device assignment will fail.

This is a user visible change, however I think the current situation is simply broken.

And, of course, disabling the IOMMU requirement using the old:

Quoted 10 lines

-pcidevice host=[addr],dma=none

or the newer:

-device pci-assign,host=[addr],iommu=0

will do what it always did (not require an IOMMU, and fail to work properly).

Quoted 7 lines

Avi,

could you please cherry-pick this into 0.12-stable?
I don't feel too eager getting 500 bug reports from people who try out device passthrough with disabled or no IOMMU.

Makes sense. Marcelo is committing this week, though.

Signature · 1 line
error compiling committee.c: too many arguments to function