Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4369181imu; Mon, 12 Nov 2018 09:54:12 -0800 (PST) X-Google-Smtp-Source: AJdET5f3cL+NYJQQXwOPQd2j5ixcxCwmlhRuF6JsRQrP3FhMWoCE0U/CN+Ms1YAZpqPz5UENYTzK X-Received: by 2002:a63:da45:: with SMTP id l5mr1654726pgj.111.1542045252204; Mon, 12 Nov 2018 09:54:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542045252; cv=none; d=google.com; s=arc-20160816; b=DP1/K9oqmqXS8Lp1t1CSrfNHQ8xeMQdufpkXaT4XowAcBALLE8spRAP3zIvmXEGljB RUBFn3RzdIKkQI/Caqu1xrS8ytC38vAAbURVKzZsulVzQFVakw6Nnau+Cozfc8mfvUdg 2Jmjcw+IPFAwty/r3B8sXvPUqT//qguY8Zjv9G9od6FGisSBdCPOZ8iMDRwkaZxyVT+3 0nYhY7ZsXo6UQvFx81IJUg2xvFNvtPNj7eJgDJCefaDhLuRNJEVdGDQjBs5jAO7drw+e ZSyb9/1T2omK+Xv4y91FeuG+c7nwD/4Wqvdoji+V8YOvV50EH0NSZSFYGxKUfoXEgjtg SjyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=NB0WRjTk9ux5aZZJj0+cOc3J/bVoGINQ4uFAPf8r6Bk=; b=ApGsPo2YRus/D4CzbzcpeW87uNUosb/WYm3BTd6Dn7u//gBbel8XGwt89EntDtSzmd XBMUYfg2kvKJEjsQVjr6nUx/QrcCY6tACho0fJOcI4bsXDpSGM3jiOj0lALyCwkxJKQV 6KsjnxX0JE19R9JV/8deDrFEZ1ckUrvYGECFkirCPFOFwai0CVG2B1lRqT0q8widhRWK KNVdahClBkMjIEejoPUOovZNehVrJjYSjq4sKzoOYnzfeSOniesjFwqJonuSS8D3y0Kn Hy2KX3rD8KWH8M1xb62gUw6rtsjVk3cJvXWRUXLw1M3QBHR3lE+QPuVaPM0vGrn3ujF6 bmmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8-v6si5374121plp.183.2018.11.12.09.53.56; Mon, 12 Nov 2018 09:54:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730197AbeKMDrp (ORCPT + 99 others); Mon, 12 Nov 2018 22:47:45 -0500 Received: from mga05.intel.com ([192.55.52.43]:18412 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbeKMDrp (ORCPT ); Mon, 12 Nov 2018 22:47:45 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 09:53:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,496,1534834800"; d="scan'208";a="273406021" Received: from araj-mobl1.jf.intel.com ([10.7.201.24]) by orsmga005.jf.intel.com with ESMTP; 12 Nov 2018 09:53:28 -0800 Date: Mon, 12 Nov 2018 09:53:28 -0800 From: "Raj, Ashok" To: Mika Westerberg Cc: iommu@lists.linux-foundation.org, Joerg Roedel , David Woodhouse , Lu Baolu , Bjorn Helgaas , "Rafael J. Wysocki" , Jacob jun Pan , Andreas Noever , Michael Jamet , Yehezkel Bernat , Lukas Wunner , Christian Kellner , Mario.Limonciello@dell.com, Anthony Wong , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4] iommu/vt-d: Do not enable ATS for external devices Message-ID: <20181112175327.GC30341@araj-mobl1.jf.intel.com> References: <20181112160628.86620-1-mika.westerberg@linux.intel.com> <20181112160628.86620-4-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181112160628.86620-4-mika.westerberg@linux.intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 12, 2018 at 07:06:27PM +0300, Mika Westerberg wrote: > Currently Linux automatically enables ATS (Address Translation Service) > for any device that supports it (and IOMMU is turned on). ATS is used to > accelerate DMA access as the device can cache translations locally so > there is no need to do full translation on IOMMU side. However, as > pointed out in [1] ATS can be used to bypass IOMMU based security > completely by simply sending PCIe read/write transaction with AT > (Address Translation) field set to "translated". > > To mitigate this modify the Intel IOMMU code so that it does not enable > ATS for any device that is marked as being external. In case this turns > out to cause performance issues we may selectively allow ATS based on > user decision but currently use big hammer and disable it completely to > be on the safe side. > > [1] https://www.repository.cam.ac.uk/handle/1810/274352 > > Signed-off-by: Mika Westerberg Reviewed-by: Ashok Raj > --- > drivers/iommu/intel-iommu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index ada786b05a59..b79788da6971 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -1473,7 +1473,8 @@ static void iommu_enable_dev_iotlb(struct device_domain_info *info) > if (info->pri_supported && !pci_reset_pri(pdev) && !pci_enable_pri(pdev, 32)) > info->pri_enabled = 1; > #endif > - if (info->ats_supported && !pci_enable_ats(pdev, VTD_PAGE_SHIFT)) { > + if (!pdev->is_external && info->ats_supported && > + !pci_enable_ats(pdev, VTD_PAGE_SHIFT)) { > info->ats_enabled = 1; > domain_update_iotlb(info->domain); > info->ats_qdep = pci_ats_queue_depth(pdev); > -- > 2.19.1 >