stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree
@ 2015-05-02 17:59 gregkh
  2015-05-02 18:24 ` Woodhouse, David
  0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2015-05-02 17:59 UTC (permalink / raw)
  To: David.Woodhouse, gregkh; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    iommu/vt-d: Allow RMRR on graphics devices too

to the 3.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iommu-vt-d-allow-rmrr-on-graphics-devices-too.patch
and it can be found in the queue-3.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 18436afdc11a00ac881990b454cfb2eae81d6003 Mon Sep 17 00:00:00 2001
From: David Woodhouse <David.Woodhouse@intel.com>
Date: Wed, 25 Mar 2015 15:05:47 +0000
Subject: iommu/vt-d: Allow RMRR on graphics devices too

From: David Woodhouse <David.Woodhouse@intel.com>

commit 18436afdc11a00ac881990b454cfb2eae81d6003 upstream.

Commit c875d2c1 ("iommu/vt-d: Exclude devices using RMRRs from IOMMU API
domains") prevents certain options for devices with RMRRs. This even
prevents those devices from getting a 1:1 mapping with 'iommu=pt',
because we don't have the code to handle *preserving* the RMRR regions
when moving the device between domains.

There's already an exclusion for USB devices, because we know the only
reason for RMRRs there is a misguided desire to keep legacy
keyboard/mouse emulation running in some theoretical OS which doesn't
have support for USB in its own right... but which *does* enable the
IOMMU.

Add an exclusion for graphics devices too, so that 'iommu=pt' works
there. We should be able to successfully assign graphics devices to
guests too, as long as the initial handling of stolen memory is
reconfigured appropriately. This has certainly worked in the past.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/iommu/intel-iommu.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -50,6 +50,7 @@
 #define CONTEXT_SIZE		VTD_PAGE_SIZE
 
 #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
+#define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
 #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
 #define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
 
@@ -2561,6 +2562,10 @@ static bool device_has_rmrr(struct devic
  * In both cases we assume that PCI USB devices with RMRRs have them largely
  * for historical reasons and that the RMRR space is not actively used post
  * boot.  This exclusion may change if vendors begin to abuse it.
+ *
+ * The same exception is made for graphics devices, with the requirement that
+ * any use of the RMRR regions will be torn down before assigning the device
+ * to a guest.
  */
 static bool device_is_rmrr_locked(struct device *dev)
 {
@@ -2570,7 +2575,7 @@ static bool device_is_rmrr_locked(struct
 	if (dev_is_pci(dev)) {
 		struct pci_dev *pdev = to_pci_dev(dev);
 
-		if ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB)
+		if (IS_USB_DEVICE(pdev) || IS_GFX_DEVICE(pdev))
 			return false;
 	}
 


Patches currently in stable-queue which might be from David.Woodhouse@intel.com are

queue-3.19/iommu-vt-d-allow-rmrr-on-graphics-devices-too.patch

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

* Re: Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree
  2015-05-02 17:59 Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree gregkh
@ 2015-05-02 18:24 ` Woodhouse, David
  2015-05-02 18:46   ` gregkh
  2015-06-02  6:31   ` gregkh
  0 siblings, 2 replies; 5+ messages in thread
From: Woodhouse, David @ 2015-05-02 18:24 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org; +Cc: stable@vger.kernel.org


[-- Attachment #1.1: Type: text/plain, Size: 916 bytes --]

On Sat, 2015-05-02 at 19:59 +0200, gregkh@linuxfoundation.org wrote:
> This is a note to let you know that I've just added the patch titled
> 
>     iommu/vt-d: Allow RMRR on graphics devices too
> 
> to the 3.19-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable
> -queue.git;a=summary
> 
> The filename of the patch is:
>      iommu-vt-d-allow-rmrr-on-graphics-devices-too.patch
> and it can be found in the queue-3.19 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable 
> tree,
> please let <stable@vger.kernel.org> know about it.

Actually, please wait. You're going to want this too...


-- 
                  Sent with Evolution's ActiveSync support.

David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


[-- Attachment #1.2: Attached message - Re: Intel-iommu panic on kernel v4.1-rc1 --]
[-- Type: message/rfc822, Size: 8320 bytes --]

[-- Attachment #1.2.1.1: Type: text/plain, Size: 2214 bytes --]

On Mon, 2015-04-27 at 15:27 +0800, sl4ever@gmail.com wrote:
> commit 18436afdc11a00ac881990b454cfb2eae81d6003 iommu/vt-d: Allow 
> RMRR on graphics devices too
> 
> cause kernel panic with Z77+vt-d and kernel parameters: 
> intel_iommu=igfx_off iommu=pt
> the panic path is:
> dev_prepare_static_identity_mapping()
>   domain_add_dev_info()
>     dmar_insert_dev_info()
>       find_domain()
>         info = dev->archdata.iommu; 
>         if (info) 
> ->            return info->domain;
> 
> igfx_off cause <igfx@0:2.0>.archdata.iommu assigned to
>  DUMMY_DEVICE_DOMAIN_INFO. 
> Above patch cause iommu_should_identity_map() return 1, and attempt 
> to setup identity mapping for igfx.

Can you try this please?

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 68d43be..2ffe589 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -696,6 +696,11 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu
        return &context[devfn];
 }
 
+static int iommu_dummy(struct device *dev)
+{
+       return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
+}
+
 static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
 {
        struct dmar_drhd_unit *drhd = NULL;
@@ -705,6 +710,9 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
        u16 segment = 0;
        int i;
 
+       if (iommu_dummy(dev))
+               return NULL;
+
        if (dev_is_pci(dev)) {
                pdev = to_pci_dev(dev);
                segment = pci_domain_nr(pdev->bus);
@@ -2969,11 +2977,6 @@ static inline struct dmar_domain *get_valid_domain_for_dev(struct device *dev)
        return __get_valid_domain_for_dev(dev);
 }
 
-static int iommu_dummy(struct device *dev)
-{
-       return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
-}
-
 /* Check if the dev needs to go through non-identity map and unmap process.*/
 static int iommu_no_mapping(struct device *dev)
 {

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

[-- Attachment #1.2.1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3437 bytes --]

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3437 bytes --]

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

* Re: Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree
  2015-05-02 18:24 ` Woodhouse, David
@ 2015-05-02 18:46   ` gregkh
  2015-06-02  6:31   ` gregkh
  1 sibling, 0 replies; 5+ messages in thread
From: gregkh @ 2015-05-02 18:46 UTC (permalink / raw)
  To: Woodhouse, David; +Cc: stable@vger.kernel.org

On Sat, May 02, 2015 at 06:24:22PM +0000, Woodhouse, David wrote:
> On Sat, 2015-05-02 at 19:59 +0200, gregkh@linuxfoundation.org wrote:
> > This is a note to let you know that I've just added the patch titled
> > 
> >     iommu/vt-d: Allow RMRR on graphics devices too
> > 
> > to the 3.19-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable
> > -queue.git;a=summary
> > 
> > The filename of the patch is:
> >      iommu-vt-d-allow-rmrr-on-graphics-devices-too.patch
> > and it can be found in the queue-3.19 subdirectory.
> > 
> > If you, or anyone else, feels it should not be added to the stable 
> > tree,
> > please let <stable@vger.kernel.org> know about it.
> 
> Actually, please wait. You're going to want this too...

Ok, I'll drop it for now until this gets into Linus's tree.

thanks,

greg k-h

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

* Re: Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree
  2015-05-02 18:24 ` Woodhouse, David
  2015-05-02 18:46   ` gregkh
@ 2015-06-02  6:31   ` gregkh
  2015-06-02  7:08     ` Woodhouse, David
  1 sibling, 1 reply; 5+ messages in thread
From: gregkh @ 2015-06-02  6:31 UTC (permalink / raw)
  To: Woodhouse, David; +Cc: stable@vger.kernel.org

On Sat, May 02, 2015 at 06:24:22PM +0000, Woodhouse, David wrote:
> On Sat, 2015-05-02 at 19:59 +0200, gregkh@linuxfoundation.org wrote:
> > This is a note to let you know that I've just added the patch titled
> > 
> >     iommu/vt-d: Allow RMRR on graphics devices too
> > 
> > to the 3.19-stable tree which can be found at:
> >     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable
> > -queue.git;a=summary
> > 
> > The filename of the patch is:
> >      iommu-vt-d-allow-rmrr-on-graphics-devices-too.patch
> > and it can be found in the queue-3.19 subdirectory.
> > 
> > If you, or anyone else, feels it should not be added to the stable 
> > tree,
> > please let <stable@vger.kernel.org> know about it.
> 
> Actually, please wait. You're going to want this too...
> 
> 
> -- 
>                   Sent with Evolution's ActiveSync support.
> 
> David Woodhouse                            Open Source Technology Centre
> David.Woodhouse@intel.com                              Intel Corporation
> 

> Date: Mon, 27 Apr 2015 22:18:10 +0100
> From: David Woodhouse <David.Woodhouse@intel.com>
> To: "sl4ever@gmail.com" <sl4ever@gmail.com>
> Cc: iommu@lists.linux-foundation.org
> Subject: Re: Intel-iommu panic on kernel v4.1-rc1
> 
> On Mon, 2015-04-27 at 15:27 +0800, sl4ever@gmail.com wrote:
> > commit 18436afdc11a00ac881990b454cfb2eae81d6003 iommu/vt-d: Allow 
> > RMRR on graphics devices too
> > 
> > cause kernel panic with Z77+vt-d and kernel parameters: 
> > intel_iommu=igfx_off iommu=pt
> > the panic path is:
> > dev_prepare_static_identity_mapping()
> >   domain_add_dev_info()
> >     dmar_insert_dev_info()
> >       find_domain()
> >         info = dev->archdata.iommu; 
> >         if (info) 
> > ->            return info->domain;
> > 
> > igfx_off cause <igfx@0:2.0>.archdata.iommu assigned to
> >  DUMMY_DEVICE_DOMAIN_INFO. 
> > Above patch cause iommu_should_identity_map() return 1, and attempt 
> > to setup identity mapping for igfx.
> 
> Can you try this please?
> 
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 68d43be..2ffe589 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -696,6 +696,11 @@ static inline struct context_entry *iommu_context_addr(struct intel_iommu *iommu
>         return &context[devfn];
>  }
>  
> +static int iommu_dummy(struct device *dev)
> +{
> +       return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
> +}
> +
>  static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
>  {
>         struct dmar_drhd_unit *drhd = NULL;
> @@ -705,6 +710,9 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
>         u16 segment = 0;
>         int i;
>  
> +       if (iommu_dummy(dev))
> +               return NULL;
> +
>         if (dev_is_pci(dev)) {
>                 pdev = to_pci_dev(dev);
>                 segment = pci_domain_nr(pdev->bus);
> @@ -2969,11 +2977,6 @@ static inline struct dmar_domain *get_valid_domain_for_dev(struct device *dev)
>         return __get_valid_domain_for_dev(dev);
>  }
>  
> -static int iommu_dummy(struct device *dev)
> -{
> -       return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
> -}
> -
>  /* Check if the dev needs to go through non-identity map and unmap process.*/
>  static int iommu_no_mapping(struct device *dev)
>  {
> 

Did this patch ever end up in Linus's tree?  I can't seem to find it...

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

* Re: Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree
  2015-06-02  6:31   ` gregkh
@ 2015-06-02  7:08     ` Woodhouse, David
  0 siblings, 0 replies; 5+ messages in thread
From: Woodhouse, David @ 2015-06-02  7:08 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org; +Cc: stable@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

On Tue, 2015-06-02 at 15:31 +0900, gregkh@linuxfoundation.org wrote:
> 
> Did this patch ever end up in Linus's tree?  I can't seem to find
> it...

Er, no. It's 4ed6a540fab in my linux-iommu.git tree; I need to send a
pull request but have been somewhat distracted. Thanks for the reminder.

-- 
                  Sent with Evolution's ActiveSync support.

David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation





[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3437 bytes --]

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

end of thread, other threads:[~2015-06-02  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-02 17:59 Patch "iommu/vt-d: Allow RMRR on graphics devices too" has been added to the 3.19-stable tree gregkh
2015-05-02 18:24 ` Woodhouse, David
2015-05-02 18:46   ` gregkh
2015-06-02  6:31   ` gregkh
2015-06-02  7:08     ` Woodhouse, David

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