public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH qemu-kvm] device assignment: default requires IOMMU
@ 2009-12-23 22:40 Chris Wright
  2009-12-24  0:45 ` Alexander Graf
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Chris Wright @ 2009-12-23 22:40 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti
  Cc: kvm, Alexander Graf, Dmitri Seletski, Sheng Yang

[ 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 <agraf@suse.de>
Cc: Dmitri Seletski <drjoms@gmail.com>
Cc: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Chris Wright <chrisw@redhat.com>
---
 hw/device-assignment.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 02d23d8..a314360 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -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

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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-23 22:40 [PATCH qemu-kvm] device assignment: default requires IOMMU Chris Wright
@ 2009-12-24  0:45 ` Alexander Graf
  2009-12-24  6:51   ` Simon Horman
  2009-12-24 11:35 ` Marcelo Tosatti
  2010-01-18 14:18 ` Alexander Graf
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Graf @ 2009-12-24  0:45 UTC (permalink / raw)
  To: Chris Wright
  Cc: Avi Kivity, Marcelo Tosatti, kvm@vger.kernel.org, Dmitri Seletski,
	Sheng Yang


Am 23.12.2009 um 23:40 schrieb Chris Wright <chrisw@sous-sol.org>:

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

Yay!

Alex

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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-24  0:45 ` Alexander Graf
@ 2009-12-24  6:51   ` Simon Horman
  2009-12-24  6:56     ` Sheng Yang
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Horman @ 2009-12-24  6:51 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Chris Wright, Avi Kivity, Marcelo Tosatti, kvm@vger.kernel.org,
	Dmitri Seletski, Sheng Yang

On Thu, Dec 24, 2009 at 01:45:34AM +0100, Alexander Graf wrote:
> 
> Am 23.12.2009 um 23:40 schrieb Chris Wright <chrisw@sous-sol.org>:
> 
> >[ 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).
> 
> Yay!

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


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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-24  6:51   ` Simon Horman
@ 2009-12-24  6:56     ` Sheng Yang
  2009-12-24  7:37       ` Muli Ben-Yehuda
  2009-12-24  7:41       ` Simon Horman
  0 siblings, 2 replies; 9+ messages in thread
From: Sheng Yang @ 2009-12-24  6:56 UTC (permalink / raw)
  To: Simon Horman
  Cc: Alexander Graf, Chris Wright, Avi Kivity, Marcelo Tosatti,
	kvm@vger.kernel.org, Dmitri Seletski

On Thursday 24 December 2009 14:51:23 Simon Horman wrote:
> On Thu, Dec 24, 2009 at 01:45:34AM +0100, Alexander Graf wrote:
> > Am 23.12.2009 um 23:40 schrieb Chris Wright <chrisw@sous-sol.org>:
> > >[ 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).
> >
> > 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?

-- 
regards
Yang, Sheng

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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-24  6:56     ` Sheng Yang
@ 2009-12-24  7:37       ` Muli Ben-Yehuda
  2009-12-24  7:41       ` Simon Horman
  1 sibling, 0 replies; 9+ messages in thread
From: Muli Ben-Yehuda @ 2009-12-24  7:37 UTC (permalink / raw)
  To: Sheng Yang
  Cc: Simon Horman, Alexander Graf, Chris Wright, Avi Kivity,
	Marcelo Tosatti, kvm@vger.kernel.org, Dmitri Seletski

On Thu, Dec 24, 2009 at 02:56:00PM +0800, Sheng Yang wrote:

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

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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-24  6:56     ` Sheng Yang
  2009-12-24  7:37       ` Muli Ben-Yehuda
@ 2009-12-24  7:41       ` Simon Horman
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Horman @ 2009-12-24  7:41 UTC (permalink / raw)
  To: Sheng Yang
  Cc: Alexander Graf, Chris Wright, Avi Kivity, Marcelo Tosatti,
	kvm@vger.kernel.org, Dmitri Seletski

On Thu, Dec 24, 2009 at 02:56:00PM +0800, Sheng Yang wrote:
> On Thursday 24 December 2009 14:51:23 Simon Horman wrote:
> > On Thu, Dec 24, 2009 at 01:45:34AM +0100, Alexander Graf wrote:
> > > Am 23.12.2009 um 23:40 schrieb Chris Wright <chrisw@sous-sol.org>:
> > > >[ 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).
> > >
> > > 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.


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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-23 22:40 [PATCH qemu-kvm] device assignment: default requires IOMMU Chris Wright
  2009-12-24  0:45 ` Alexander Graf
@ 2009-12-24 11:35 ` Marcelo Tosatti
  2010-01-18 14:18 ` Alexander Graf
  2 siblings, 0 replies; 9+ messages in thread
From: Marcelo Tosatti @ 2009-12-24 11:35 UTC (permalink / raw)
  To: Chris Wright; +Cc: Avi Kivity, kvm, Alexander Graf, Dmitri Seletski, Sheng Yang

On Wed, Dec 23, 2009 at 02:40:20PM -0800, Chris Wright wrote:
> [ 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).

Applied, thanks.


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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2009-12-23 22:40 [PATCH qemu-kvm] device assignment: default requires IOMMU Chris Wright
  2009-12-24  0:45 ` Alexander Graf
  2009-12-24 11:35 ` Marcelo Tosatti
@ 2010-01-18 14:18 ` Alexander Graf
  2010-01-18 14:20   ` Avi Kivity
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Graf @ 2010-01-18 14:18 UTC (permalink / raw)
  To: Chris Wright
  Cc: Avi Kivity, Marcelo Tosatti, kvm, Dmitri Seletski, Sheng Yang

Chris Wright wrote:
> [ 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).
>   

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


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

* Re: [PATCH qemu-kvm] device assignment: default requires IOMMU
  2010-01-18 14:18 ` Alexander Graf
@ 2010-01-18 14:20   ` Avi Kivity
  0 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2010-01-18 14:20 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Chris Wright, Marcelo Tosatti, kvm, Dmitri Seletski, Sheng Yang

On 01/18/2010 04:18 PM, Alexander Graf wrote:
> Chris Wright wrote:
>    
>> [ 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).
>>
>>      
> 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.

-- 
error compiling committee.c: too many arguments to function


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

end of thread, other threads:[~2010-01-18 14:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-23 22:40 [PATCH qemu-kvm] device assignment: default requires IOMMU Chris Wright
2009-12-24  0:45 ` Alexander Graf
2009-12-24  6:51   ` Simon Horman
2009-12-24  6:56     ` Sheng Yang
2009-12-24  7:37       ` Muli Ben-Yehuda
2009-12-24  7:41       ` Simon Horman
2009-12-24 11:35 ` Marcelo Tosatti
2010-01-18 14:18 ` Alexander Graf
2010-01-18 14:20   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox