From: Lu Baolu <baolu.lu@linux.intel.com>
To: Rajat Jain <rajatja@google.com>,
David Woodhouse <dwmw2@infradead.org>,
Joerg Roedel <joro@8bytes.org>,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
Mika Westerberg <mika.westerberg@intel.com>,
Ashok Raj <ashok.raj@intel.com>,
lalithambika.krishnakumar@intel.com
Cc: baolu.lu@linux.intel.com, rajatxjain@gmail.com,
pmalani@google.com, bleung@google.com, levinale@google.com,
zsm@google.com, mnissler@google.com, tbroch@google.com
Subject: Re: [PATCH] iommu/vt-d: Don't apply gfx quirks to untrusted devices
Date: Tue, 2 Jun 2020 15:15:12 +0800 [thread overview]
Message-ID: <ad238863-bef8-99bf-38c7-5839af1647e5@linux.intel.com> (raw)
In-Reply-To: <20200602054517.191244-1-rajatja@google.com>
On 2020/6/2 13:45, Rajat Jain wrote:
> Currently, an external malicious PCI device can masquerade the VID:PID
> of faulty gfx devices, and thus apply iommu quirks to effectively
> disable the IOMMU restrictions for itself.
>
> Thus we need to ensure that the device we are applying quirks to, is
> indeed an internal trusted device.
>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> Signed-off-by: Rajat Jain <rajatja@google.com>
> ---
> drivers/iommu/intel-iommu.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index ef0a5246700e5..f2a480168a02f 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -6214,6 +6214,11 @@ const struct iommu_ops intel_iommu_ops = {
>
> static void quirk_iommu_igfx(struct pci_dev *dev)
> {
> + if (dev->untrusted) {
> + pci_warn(dev, "skipping iommu quirk for untrusted gfx dev\n");
> + return;
> + }
> +
> pci_info(dev, "Disabling IOMMU for graphics on this chipset\n");
> dmar_map_gfx = 0;
> }
> @@ -6255,6 +6260,11 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx);
>
> static void quirk_iommu_rwbf(struct pci_dev *dev)
> {
> + if (dev->untrusted) {
> + pci_warn(dev, "skipping iommu quirk for untrusted dev\n");
> + return;
> + }
> +
> /*
> * Mobile 4 Series Chipset neglects to set RWBF capability,
> * but needs it. Same seems to hold for the desktop versions.
> @@ -6285,6 +6295,11 @@ static void quirk_calpella_no_shadow_gtt(struct pci_dev *dev)
> {
> unsigned short ggc;
>
> + if (dev->untrusted) {
> + pci_warn(dev, "skipping iommu quirk for untrusted gfx dev\n");
> + return;
> + }
> +
> if (pci_read_config_word(dev, GGC, &ggc))
> return;
>
> @@ -6318,6 +6333,13 @@ static void __init check_tylersburg_isoch(void)
> pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x3a3e, NULL);
> if (!pdev)
> return;
> +
> + if (pdev->untrusted) {
> + pci_warn(pdev, "skipping iommu quirk due to untrusted dev\n");
> + pci_dev_put(pdev);
> + return;
> + }
> +
> pci_dev_put(pdev);
>
> /* System Management Registers. Might be hidden, in which case
> @@ -6327,6 +6349,12 @@ static void __init check_tylersburg_isoch(void)
> if (!pdev)
> return;
>
> + if (pdev->untrusted) {
> + pci_warn(pdev, "skipping iommu quirk due to untrusted dev\n");
> + pci_dev_put(pdev);
> + return;
> + }
> +
> if (pci_read_config_dword(pdev, 0x188, &vtisochctrl)) {
> pci_dev_put(pdev);
> return;
>
next prev parent reply other threads:[~2020-06-02 7:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 5:45 [PATCH] iommu/vt-d: Don't apply gfx quirks to untrusted devices Rajat Jain
2020-06-02 7:15 ` Lu Baolu [this message]
2020-06-02 9:50 ` Mika Westerberg
2020-06-02 18:43 ` Rajat Jain
2020-06-02 20:19 ` Raj, Ashok
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad238863-bef8-99bf-38c7-5839af1647e5@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=bleung@google.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=lalithambika.krishnakumar@intel.com \
--cc=levinale@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@intel.com \
--cc=mnissler@google.com \
--cc=pmalani@google.com \
--cc=rajatja@google.com \
--cc=rajatxjain@gmail.com \
--cc=tbroch@google.com \
--cc=zsm@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox