Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp95765ybg; Tue, 2 Jun 2020 17:35:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuNTifPoPkookDMbISKhIChqkTE4lOqUuNq1eHRIVCeHowIrx1KU29enWU5wXIWtUgUFvG X-Received: by 2002:a05:6402:22a5:: with SMTP id cx5mr30298525edb.246.1591144505398; Tue, 02 Jun 2020 17:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591144505; cv=none; d=google.com; s=arc-20160816; b=xP7XUbBXjUWOIIgVww+tVJP936+r+hAwTA+FZu83OT+5CADUajnvXrMj26lU14Gemp WtXk4u30638m4F4mpPncIRRF2yeYyIRo/a1nUj19kOnm/sPnHJAcwBZrob3MMtmV+dCR 0AAgm2R5QPJuK0qiVaqbrs0IE27CH+OErGV9DGbUFurBTiDaQPz4VeTR25y1ABO0HGqd XX2+/VVyGcZhUyJOOfUcxpi5RotKgfapCsjpSgswgbwcvYyE8YkjSXOWuAIBPV3Q2d2g oRr8/0/9HUy5/R/lc3KAwV0tw8mfMNAAWOpCrFUhveremL56NrFYK3mk8F8ze3Nz7i29 ckfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Qnzjt+g4cB//ahJdxLx9hz0hNZU/fqEnBmDtd0LYOjI=; b=phxZlTOJImXna4cX3TdEvI9mHIL2AiL+o/A/F8zjpnfK1LJXm61Z6Rr3D0C6AACCqB 1pgVaY0GSZkf+4StIY37X38kaNohc1XZq6wyLyfyAGY1jFOh2B3A3XJQhS35+VYQH0JA cXtmBFb16CBGKk/gTyR2zE7pEuV/LahErlPIU1eqcKndEbEmHaffSZ4kY2Bfs28H6DsZ hcndz8YVuduRiFYH3SvPqQIYas0LDtD0YowdWIWnnakx1l9DbHxJCbNYv858Oh1RXS+P 7MpIASvICRMMEdp2rOCx4gxEjhhdtQmqNCz0wNXNffecW0mjQaQKDQEhR3nSFyi+kUgI 1V+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=a2C7Mgmf; 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 i12si204448edq.423.2020.06.02.17.34.38; Tue, 02 Jun 2020 17:35:05 -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=a2C7Mgmf; 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 S1728187AbgFCAck (ORCPT + 99 others); Tue, 2 Jun 2020 20:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgFCAcj (ORCPT ); Tue, 2 Jun 2020 20:32:39 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C740DC08C5C0 for ; Tue, 2 Jun 2020 17:32:39 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o8so474963pgm.7 for ; Tue, 02 Jun 2020 17:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Qnzjt+g4cB//ahJdxLx9hz0hNZU/fqEnBmDtd0LYOjI=; b=a2C7MgmflNZhuX60tQc+uDBp8E6Awdh6dSwcT+NDEXWcaHr/WWC05JVeSUc7C7RsLJ hXQGv1iFTHu42sDAEMWcfgy1fqDYWGp+Feyl8E6t4/q7PBCVzhoeDOKBZaQDvmIkIbY5 RwlHH0xf8NGNR1/oPvBwUt5llOgKsYTUrBFfWF4ZY2mFdyFM/i3fHCbJ2+GrJLVnMzKh wj+93IGgiwqCbuhdFulNMhR8rPmYpXJdPSH9YEOVrLqivLPmyO9PU18fdei+UcJQAT7h QBZyjY06AmQ1zHUTVToguV8ZZP+7/LF3YiCKKBP/+vkQ8HElOFTLtkHJBTTvTNH5H/zO e3bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Qnzjt+g4cB//ahJdxLx9hz0hNZU/fqEnBmDtd0LYOjI=; b=mBJGiOtlj5EWngRszTzqlYdMdpxmODQANsv2OcZ3wHu0jAROCWYi46uXpCmzZwbEgH tIS/l5Zp0niRRWyDlUtfHzq0L6o0ofj40z7MbP4VrWVkM2U7CCY0tDQ4OZb84v8dte2Y YSeZ9aQRqmJr1SrqUMCDSTFH1oStVdzxjOYwgMH4UBD4RArS+ZKi5V/itBBjLdfiU8yY CiOkMKKZ7d4GJtN7lPLOsIRuY1OvoP810+cm+Lai6OtP+5f/5FsFD5Ldi/wkT8MfvfLA IKRflfgOqVPFE+xi7oIVxkWCf3lxAwsrGvg1/5rRI/SuXGfmwcuBlte6eqmayC9zdzce 7ztw== X-Gm-Message-State: AOAM533w8Vk03XFRGZyzhQ8wCHs4h3n4Dsyl+qnx5wlZ613K/z+NVuDO 8Gd7TAvESipbcdCc7T6qsNoiKQ== X-Received: by 2002:a63:1a01:: with SMTP id a1mr24703646pga.87.1591144358699; Tue, 02 Jun 2020 17:32:38 -0700 (PDT) Received: from google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id y10sm138263pgi.54.2020.06.02.17.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 17:32:37 -0700 (PDT) Date: Tue, 2 Jun 2020 17:32:32 -0700 From: Prashant Malani To: Rajat Jain Cc: Rajat Jain , David Woodhouse , Lu Baolu , Joerg Roedel , iommu@lists.linux-foundation.org, Linux Kernel Mailing List , Mika Westerberg , Ashok Raj , lalithambika.krishnakumar@intel.com, bleung@google.com, levinale@google.com, zsm@google.com, mnissler@google.com, tbroch@google.com Subject: Re: [PATCH v3] iommu/vt-d: Don't apply gfx quirks to untrusted devices Message-ID: <20200603003232.GC109930@google.com> References: <20200602232602.156049-1-rajatja@google.com> <20200602234912.GB109930@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Trimming text) On Wed, Jun 03, 2020 at 12:23:48AM +0000, Rajat Jain wrote: > On Tue, Jun 2, 2020 at 4:49 PM Prashant Malani wrote: > > > > Hi Rajat, > > Hi Prashant, thanks for taking a look. > > > > > On Tue, Jun 02, 2020 at 04:26:02PM -0700, Rajat Jain wrote: > > > +static bool risky_device(struct pci_dev *pdev) > > > +{ > > > + if (pdev->untrusted) { > > > + pci_warn(pdev, > > > + "Skipping IOMMU quirk for dev (%04X:%04X) on untrusted" > > > + " PCI link. Please check with your BIOS/Platform" > > > + " vendor about this\n", pdev->vendor, pdev->device); > > > + return true; > > > + } > > > + return false; > > minor suggestion: Perhaps you could use a guard clause here? It would save you > > a level of indentation, and possibly allow better string splitting > > (e.g keeping "untrusted PCI" together). So something like: > > > > if (!pdev->untrusted) > > return false; > > I personally have found double negation expressions always confusing, > even if negation is part of the variable. (For e.g. I have found I > need to be always stop and convince myself that: > > "if (!pdev->untrusted)" > > > conceptually implies > > "if (pdev->trusted)". > > > So I tend to keep negations to minimum. In this case, it doesn't buy > us much either, so I'd prefer to keep it the same unless there are > more opinions on this. OTOH I don't mind changing it too if you feel > strongly about this. Ordinarily, I'd agree with you regarding double-negatives. However, in this case the condition phrasing is so brief ("not untrusted") that I'd argue the indentation savings outweigh possible interpretation issues. That said, I don't have a strong opinion here, so will defer to the maintainer's preference. Best, > > Thanks, > > Rajat > > > > > > pci_warn(...); > > > > I also hear the column limit warning is now for 100 chars [1], though > > I'm not sure how it's being handled in this file. > > > > Best regards, > > > > -Prashant > > > > [1]: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/Documentation/process/coding-style.rst?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144 > > > > > +} > > > + > > > const struct iommu_ops intel_iommu_ops = { > > > .capable = intel_iommu_capable, > > > .domain_alloc = intel_iommu_domain_alloc, > > > @@ -6214,6 +6231,9 @@ const struct iommu_ops intel_iommu_ops = { > > > > > > static void quirk_iommu_igfx(struct pci_dev *dev) > > > { > > > + if (risky_device(dev)) > > > + return; > > > + > > > pci_info(dev, "Disabling IOMMU for graphics on this chipset\n"); > > > dmar_map_gfx = 0; > > > } > > > @@ -6255,6 +6275,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx); > > > > > > static void quirk_iommu_rwbf(struct pci_dev *dev) > > > { > > > + if (risky_device(dev)) > > > + return; > > > + > > > /* > > > * Mobile 4 Series Chipset neglects to set RWBF capability, > > > * but needs it. Same seems to hold for the desktop versions. > > > @@ -6285,6 +6308,9 @@ static void quirk_calpella_no_shadow_gtt(struct pci_dev *dev) > > > { > > > unsigned short ggc; > > > > > > + if (risky_device(dev)) > > > + return; > > > + > > > if (pci_read_config_word(dev, GGC, &ggc)) > > > return; > > > > > > @@ -6318,6 +6344,12 @@ static void __init check_tylersburg_isoch(void) > > > pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x3a3e, NULL); > > > if (!pdev) > > > return; > > > + > > > + if (risky_device(pdev)) { > > > + pci_dev_put(pdev); > > > + return; > > > + } > > > + > > > pci_dev_put(pdev); > > > > > > /* System Management Registers. Might be hidden, in which case > > > @@ -6327,6 +6359,11 @@ static void __init check_tylersburg_isoch(void) > > > if (!pdev) > > > return; > > > > > > + if (risky_device(pdev)) { > > > + pci_dev_put(pdev); > > > + return; > > > + } > > > + > > > if (pci_read_config_dword(pdev, 0x188, &vtisochctrl)) { > > > pci_dev_put(pdev); > > > return; > > > -- > > > 2.27.0.rc2.251.g90737beb825-goog > > >