Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3403404ybi; Mon, 10 Jun 2019 09:39:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUp+jZB4hOI1afeSpR31qRfHApmou+Wkd5wZOn2/kAm3bAcc9rIgpuRa/3TgLO27ommnuR X-Received: by 2002:a17:90a:a790:: with SMTP id f16mr22440728pjq.27.1560184780980; Mon, 10 Jun 2019 09:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560184780; cv=none; d=google.com; s=arc-20160816; b=AImFZE+jDjldwxs+AQJI88PsPtLi3ZnSf8Abejo/4VIOof2ClUD4n3X4VKwGkSyFxv +Qu+ZjeHEXyzw4ttrXR+zQ+rteSBq2pnoBywDcCSn2F2X3sCGia0pK8sVIpv2RYWQw5d WtUFPLwmm+PCxAf1ecoel6tXKUd323lpqkBVIabAkqBY+BAAm1v/s4oz4kTpgkajnUxV M0mM2B0X+0lpCB2yasMXfEple/egkqwWN1jD2ufbtCqwcz8brhVtijtyxEdla0+2gxsp hfDSX5lHuMOtEYmcWTG4wKov2D9hOyeaGJ0VPKBsQ67FiWHpeJsgcBjEK0tjGKz9vdVI O3SA== 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:dkim-signature; bh=eNbG4FRMDvCLri2Xlvltw/kdKx3VZBJXRKHPR6ne+lM=; b=i5AkB2b+lq8RfeE+D5uqL2NoU0J20NZwAtIj7HS5+T4OSy4kEZTOqF6LCiVzoIoShV LFaAn7Xek7nbhh0G97fQLlziZB3aiIIXC6Q1cMVLTIutWK3TE0JPtuBa4n8zwYT35sUb L9hck2WIPBrcYTCqzQrpf+kqtlEkK18/HvSDUCjbX/cS2qJhqBibALuRm+T6w9vDnWCs ksdimLbAPR3paFferV6X1IYzY9yCtV0ZRKeFQquQ2jXk+kl7VMN+vrX+D+IwO5hAidSA oO0oAW96BN42FXdCZ5hlkw2x2/bVdwvwvp6sxLEMkj/GUP+qLrhopGUNLKfGxRpcxnYw PeHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=BxVvqXlA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si9946329pju.69.2019.06.10.09.39.26; Mon, 10 Jun 2019 09:39:40 -0700 (PDT) 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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=BxVvqXlA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391450AbfFJQH4 (ORCPT + 99 others); Mon, 10 Jun 2019 12:07:56 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55768 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389392AbfFJQH4 (ORCPT ); Mon, 10 Jun 2019 12:07:56 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5AFwncJ187361; Mon, 10 Jun 2019 16:06:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=eNbG4FRMDvCLri2Xlvltw/kdKx3VZBJXRKHPR6ne+lM=; b=BxVvqXlANKeOX+fjB2N/PreAznVEnr3SXL9Rb6Mxkzs3hxSdPFOSuXqS4fisqD1TDdTI wAR4o3NyutIdKLIJT2yXDjPX65O9dvatarut8gqqIQkbbAUs0mgHCeh0I39OWlgS9Cp4 EdhzmYGnRQ/Be4x/298BA47lXZImNxVEK0M8pBECb32zgnksKK6B5V4nDiNqq9gK9dR1 aavCatnU6z477jCKwCuYCzHRd04IMlji/HbX2vfdnYmmmROrp8LyCd38rKcCBqzg4XFR /J6GE4MLc/eHzr65eMU09KKV5dIA5Etzo3ZQpNlm+34k0H9kx6AZQWkRREsq/sJXAOgs bg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2t05nqfsag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Jun 2019 16:06:44 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5AG4pfo091578; Mon, 10 Jun 2019 16:06:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2t04hxv15f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Jun 2019 16:06:43 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5AG6e4t023104; Mon, 10 Jun 2019 16:06:40 GMT Received: from char.us.oracle.com (/10.152.32.25) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Jun 2019 09:06:40 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 3F9206A00FC; Mon, 10 Jun 2019 12:08:03 -0400 (EDT) Date: Mon, 10 Jun 2019 12:08:03 -0400 From: Konrad Rzeszutek Wilk To: Lu Baolu Cc: David Woodhouse , Joerg Roedel , Bjorn Helgaas , Christoph Hellwig , ashok.raj@intel.com, jacob.jun.pan@intel.com, alan.cox@intel.com, kevin.tian@intel.com, mika.westerberg@linux.intel.com, Ingo Molnar , Greg Kroah-Hartman , pengfei.xu@intel.com, Marek Szyprowski , Robin Murphy , Jonathan Corbet , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Steven Rostedt , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jacob Pan Subject: Re: [PATCH v4 6/9] iommu/vt-d: Check whether device requires bounce buffer Message-ID: <20190610160802.GX28796@char.us.oracle.com> References: <20190603011620.31999-1-baolu.lu@linux.intel.com> <20190603011620.31999-7-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603011620.31999-7-baolu.lu@linux.intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9284 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906100109 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9284 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906100109 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 03, 2019 at 09:16:17AM +0800, Lu Baolu wrote: > This adds a helper to check whether a device needs to > use bounce buffer. It also provides a boot time option > to disable the bounce buffer. Users can use this to > prevent the iommu driver from using the bounce buffer > for performance gain. > > Cc: Ashok Raj > Cc: Jacob Pan > Cc: Kevin Tian > Signed-off-by: Lu Baolu > Tested-by: Xu Pengfei > Tested-by: Mika Westerberg > --- > Documentation/admin-guide/kernel-parameters.txt | 5 +++++ > drivers/iommu/intel-iommu.c | 6 ++++++ > 2 files changed, 11 insertions(+) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 138f6664b2e2..65685c6e53e4 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -1728,6 +1728,11 @@ > Note that using this option lowers the security > provided by tboot because it makes the system > vulnerable to DMA attacks. > + nobounce [Default off] > + Do not use the bounce buffer for untrusted devices like > + the Thunderbolt devices. This will treat the untrusted My brain has sometimes a hard time parsing 'Not' and 'un'. Could this be: Disable bounce buffer for unstrusted devices ..? And perhaps call it 'noswiotlb' ? Not everyone knows that SWIOTLB = bounce buffer. > + devices as the trusted ones, hence might expose security > + risks of DMA attacks. > > intel_idle.max_cstate= [KNL,HW,ACPI,X86] > 0 disables intel_idle and fall back on acpi_idle. > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 235837c50719..41439647f75d 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -371,6 +371,7 @@ static int dmar_forcedac; > static int intel_iommu_strict; > static int intel_iommu_superpage = 1; > static int iommu_identity_mapping; > +static int intel_no_bounce; intel_swiotlb_on = 1 ? > > #define IDENTMAP_ALL 1 > #define IDENTMAP_GFX 2 > @@ -384,6 +385,8 @@ EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped); > static DEFINE_SPINLOCK(device_domain_lock); > static LIST_HEAD(device_domain_list); > > +#define device_needs_bounce(d) (!intel_no_bounce && dev_is_untrusted(d)) > + > /* > * Iterate over elements in device_domain_list and call the specified > * callback @fn against each element. > @@ -466,6 +469,9 @@ static int __init intel_iommu_setup(char *str) > printk(KERN_INFO > "Intel-IOMMU: not forcing on after tboot. This could expose security risk for tboot\n"); > intel_iommu_tboot_noforce = 1; > + } else if (!strncmp(str, "nobounce", 8)) { > + pr_info("Intel-IOMMU: No bounce buffer. This could expose security risks of DMA attacks\n"); Again, Intel-IOMMU: No SWIOTLB. T.. blah blah' Asking for this as doing 'dmesg | grep SWIOTLB' will expose nicely all the SWIOTLB invocations.. > + intel_no_bounce = 1; > } > > str += strcspn(str, ","); > -- > 2.17.1 >