Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1503863ybg; Tue, 2 Jun 2020 11:45:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFNwrzuE7+DmRb75Iz6Q0kkGJnuLS4iyWMBw5A4p+x9lntU3idqQH1N619ds2A+Pe/6znt X-Received: by 2002:a17:906:a44:: with SMTP id x4mr14485939ejf.237.1591123552250; Tue, 02 Jun 2020 11:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591123552; cv=none; d=google.com; s=arc-20160816; b=s50blDwL/LfHUyJT8JnKzGN28Hsx/6KmnS7oY9aKVpwYx6H9/60HsBl3/KyZkozEEv Vf2i+UuuX3wFFxKp3UNtfhRorXQfpZ1dvG3LZtN/LvA9b63er0/TJnzVoRzTPQXIFCp6 8+unX1NCRF6hXjZ8kX96VnfrdJQCdBGKQme0X8+gxo0qkTtFu5UcvJntQSOMVvD7xJkn RRc9EZ9mZLVUnxNkOVBFLIXuyMGQIPPzKYckcTQ0Fhr5WoTxon/dlQDLoDRKYlnGQJo3 FtZOIMDFeavYGKkoz/zvtPy42hv2iTqtbQqy6ItpSivtfCtzXpKS9LlJIO+EZslOvjaE Yweg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AyaUVVMDE+TUTFKilCRtJ50WF2xa5EmGs9v2imFUYZE=; b=n6ZA68cGJ1wZYZY96DjNmj5B+BkzNtOpvc8FS4IKAivBwsSmd3ZOFe+3DBJF/QCw2d xZ+H83sqCnSaKQN14iZanx6eNT+xdTbpi78nqhXsm7kOlRsiFuxqgw1j9UvVEZOkpLVg 6bAlkajwPOlUau9CnSJH9/inWiizWgspBYnWNh1gHRPw/P9Yh0OHNVUkSApn676KdZ+k NN/dPB/stRsZkhl9BiUW0THcKskyKHoXLHNa+g6kzBpgwQrrwYZyaG/SN91weyDCjJjA GFHx8WhyO0k7bis9q9qvq91GzCAb7mF5L38OPuAVCAsSbGN1FPLx6aWlxMYGKXVEKL5w kmrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W+ulR6nk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn1si2373616ejc.638.2020.06.02.11.45.28; Tue, 02 Jun 2020 11:45:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W+ulR6nk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgFBSnj (ORCPT + 99 others); Tue, 2 Jun 2020 14:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbgFBSnj (ORCPT ); Tue, 2 Jun 2020 14:43:39 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3BDC08C5C0 for ; Tue, 2 Jun 2020 11:43:38 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id e4so13877331ljn.4 for ; Tue, 02 Jun 2020 11:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AyaUVVMDE+TUTFKilCRtJ50WF2xa5EmGs9v2imFUYZE=; b=W+ulR6nkqAsZTIpa1G4Pxucwbit4Oys2/blbskVzp8WkjQqfpqKDlaCFcVnCknocql va5Ciki+HmjDFygrDozP9yzV/CFlQcHVqBdRWzViY5I+doh2oJ1x+uwhYMD8GA1oUWFa Lj813cY7RL48tm96YBDZR8DOwlAvoVXxU0URTUPSErtHXw+7CPWh7MW3e9znMLt/zmR1 YtwuDN0fC7M6JfUodoVjFWYbEDJjPhf+VHVJN1rBb6KgMaIMSq1/dqY8P5E7DOTSeYJI 5fZyvPWgyCosKxTCmgmBbzWDMp49vrZJsil42rKpOSTzkxFX97TwShsTvr221Ez1oxce OeWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AyaUVVMDE+TUTFKilCRtJ50WF2xa5EmGs9v2imFUYZE=; b=j9iLUksFcM0ShKcIk3tbzcchol1mz8sjRQ5NeuwIxVxzlNRaWBzjw6voAXjL7CyuEZ S3pXk+lsZ356/gyCP4sq2vzWQwprQ8ZnYn0t9DizJoWEitU+p3ioDQEdzvJ8ACVLsxjq wfoGAUINB3UvRqL7aplclOm0ixBYhhjlY7RrCqSjs6jmbCtXMJlw/Mi8sbzrT1wrV8ww +d8lVm689OrtXz+JWxw/PwHL+RdDS43c07bUsZ8MMGMv0gRQXFQ/JvxtX/LazwdJEs/M 0qz8MU0KHlnbCo/tb9C5S828FB7pNMUs56SLv3lsiIy88qdweATP6Xfm3N2Vn0aRNviy fAXQ== X-Gm-Message-State: AOAM531GWS7ItrEPAv/lPW/7DO1+f5n5NXcLJPOvnn1fYWHk417hShQC 0vhkK8Fu/RqVeGGkAQEuf6ZKjTT9TsnN7f3Fr9G3Xg== X-Received: by 2002:a2e:8944:: with SMTP id b4mr202192ljk.247.1591123416673; Tue, 02 Jun 2020 11:43:36 -0700 (PDT) MIME-Version: 1.0 References: <20200602054517.191244-1-rajatja@google.com> <20200602095003.GI247495@lahna.fi.intel.com> In-Reply-To: <20200602095003.GI247495@lahna.fi.intel.com> From: Rajat Jain Date: Tue, 2 Jun 2020 18:43:00 +0000 Message-ID: Subject: Re: [PATCH] iommu/vt-d: Don't apply gfx quirks to untrusted devices To: Mika Westerberg Cc: David Woodhouse , Lu Baolu , Joerg Roedel , iommu@lists.linux-foundation.org, Linux Kernel Mailing List , Ashok Raj , "Krishnakumar, Lalithambika" , Rajat Jain , Prashant Malani , Benson Leung , Alex Levin , Zubin Mithra , Mattias Nissler , Todd Broch Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi MIka, Thanks for taking a look. On Tue, Jun 2, 2020 at 2:50 AM Mika Westerberg wrote: > > On Mon, Jun 01, 2020 at 10:45:17PM -0700, 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. > > > > Signed-off-by: Rajat Jain > > --- > > 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"); > > I think you should be consistent with other messages. For example iommu > should be spelled IOMMU as done below. > > Also this is visible to users so maybe put bit more information there: > > pci_warn(dev, "Will not apply IOMMU quirk for untrusted graphics device\n"); > > Ditto for all the other places. Also is "untrusted" good word here? If > an ordinary user sees this will it trigger some sort of panic reaction. > Perhaps we should call it "potentially untrusted" or something like > that? Fixed it, posted new patch at https://lkml.org/lkml/2020/6/2/822 Thanks, Rajat > > > + return; > > + } > > + > > pci_info(dev, "Disabling IOMMU for graphics on this chipset\n"); > > dmar_map_gfx = 0;