Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp978549pxb; Thu, 26 Aug 2021 20:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlswO2Hf/rGVxzfwLf0mg+Ya4O/0AmhauXJPiIHgg46XHABD1BUKq+DRiFiIjfPYgUOf/B X-Received: by 2002:a05:6602:200f:: with SMTP id y15mr5579582iod.64.1630036768227; Thu, 26 Aug 2021 20:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630036768; cv=none; d=google.com; s=arc-20160816; b=XM4+65c4p+IGixcg2VBWNFzh4xmha1roib0fy4Q87Byj5RWVyv+DZQq4cnP56upF19 3ZbqNPxTofa7y6Hhk66tqRLKtm61dR+OvZcadNyYrGjWM8vCTFjB+uXwpStyHjc5bTZd afuoB4V/fFsvEV/BEiMHQ+9bm+E8wUBIFajKaK2Ofuq+UIEiRILWPw4/HoOjlbAVBJfH EXc0Yfy2a+2CQ1XvZtuAneyC7wej+rDrscyySTLxY5vcc3SJc53vVM5kOaltLAmNNMdI 034tgx4efgI2DeQcBKVfwXKP/rL8Ewuc/KMncmLtL2aNgK3FbiNMbsUCAgVy3WV4KUFA PCYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aO31d1ja5MAKunYUAZZRLdfg9N4l+qmRykC9m1jC/pQ=; b=tbiU8EQW4yF6i+C/2fGn6C23drSkXbN+Po3TxWXFFh2zB9w8NXCQpmjgVmtRf8Q7PA stV/y0bIsMIOsysLAQIYiBeE0FRatCCQ6dRDcilV3UDC+0LXNX4xIn/5BbngTNdgCRjS xmmcDMo6lp7sGYspaBkAv7ykh9EAO0PL0XQTkBb7JYhvko+vZYzAWGr6LAswAiTNs7Zw e3IaZswzBlL5uh3YoTa+1oq05FXdFKZMZsoFBb8aGuuHY0YZlY5CA5L3zqKfMWDVkFoy JQYMpwkxKmwCfWLFpY1ynoYOVK0Dwi28YJrTHIDs29az1qp84wVziiIQmo/H2Tn3UoEg KYYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LHO3ECTK; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si4346734jaa.116.2021.08.26.20.59.16; Thu, 26 Aug 2021 20:59:28 -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=@chromium.org header.s=google header.b=LHO3ECTK; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244191AbhH0D6M (ORCPT + 99 others); Thu, 26 Aug 2021 23:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244177AbhH0D6L (ORCPT ); Thu, 26 Aug 2021 23:58:11 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76267C061757 for ; Thu, 26 Aug 2021 20:57:22 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id b200so6810669iof.13 for ; Thu, 26 Aug 2021 20:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aO31d1ja5MAKunYUAZZRLdfg9N4l+qmRykC9m1jC/pQ=; b=LHO3ECTKxrFvHrNircCd8rdZ+1fd28Cmb0yeGOAFZz7tvi23JfdsoKQlBQ/osBU2PS uSjlHhkxT55kRAddmfXWJAAOEApdxidxxDW04W+WXtBEpgeVUzkf4uqWPWAg7OHZiZJx 7DqmkAUptTsy2yC8hMD6ce5SkESGfwW9yU/Tw= 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=aO31d1ja5MAKunYUAZZRLdfg9N4l+qmRykC9m1jC/pQ=; b=EBAEoMHgvmtN8Q/Ba4JRmg1qGBgSZN9Fv4HdEilMoDujwv0TzfWKjQzfGsjgnHY90A C4EvM5+wYJ6eeEVSke3c1mKJcuVvU9yVlmhK5+DzZZl9nQvkYIx9y3x07tEUDMuprGU9 QtdjhsAD98sXl3+Luhe31WPVgyPnQJS4UtxqNw+xmFcqVoWtzqZtI8t77v8MvOizIzLl GQ5j1SerL19c9iiy2IEEM+DGMzncW/91hxJChJ6T4hujqJE47sfafELntMzoLHIZ2VAg drUU6MJw7AMgK3rfmawKHQBD8MlDI/1wR0ZRoMnU1QIfA6JZoG6DP93ClwP/I4DM0kwK itKA== X-Gm-Message-State: AOAM530wxQNDNNutcIPa0fXwshxCzhK4zUDGBhsYPXBnnN8LWp3vSX8/ nNF+joveDiAfouHDXihrkQsPL5tszcYbdA== X-Received: by 2002:a5e:a81a:: with SMTP id c26mr5790746ioa.15.1630036641606; Thu, 26 Aug 2021 20:57:21 -0700 (PDT) Received: from mail-il1-f177.google.com (mail-il1-f177.google.com. [209.85.166.177]) by smtp.gmail.com with ESMTPSA id k14sm2784394ili.19.2021.08.26.20.57.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 20:57:21 -0700 (PDT) Received: by mail-il1-f177.google.com with SMTP id r6so5696388ilt.13 for ; Thu, 26 Aug 2021 20:57:21 -0700 (PDT) X-Received: by 2002:a5d:9ada:: with SMTP id x26mr5606315ion.50.1630036221774; Thu, 26 Aug 2021 20:50:21 -0700 (PDT) MIME-Version: 1.0 References: <20210624155526.2775863-1-tientzu@chromium.org> <20210624155526.2775863-11-tientzu@chromium.org> <20210824142601.GA3393158@roeck-us.net> In-Reply-To: <20210824142601.GA3393158@roeck-us.net> From: Claire Chang Date: Fri, 27 Aug 2021 11:50:10 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v15 10/12] swiotlb: Add restricted DMA pool initialization To: Guenter Roeck Cc: Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Christoph Hellwig , Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , Stefano Stabellini , Robin Murphy , grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , Tomasz Figa , bskeggs@redhat.com, Bjorn Helgaas , chris@chris-wilson.co.uk, Daniel Vetter , airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, Jianxiong Gao , joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com, Tom Lendacky , Qian Cai Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 24, 2021 at 10:26 PM Guenter Roeck wrote: > > Hi Claire, > > On Thu, Jun 24, 2021 at 11:55:24PM +0800, Claire Chang wrote: > > Add the initialization function to create restricted DMA pools from > > matching reserved-memory nodes. > > > > Regardless of swiotlb setting, the restricted DMA pool is preferred if > > available. > > > > The restricted DMA pools provide a basic level of protection against the > > DMA overwriting buffer contents at unexpected times. However, to protect > > against general data leakage and system memory corruption, the system > > needs to provide a way to lock down the memory access, e.g., MPU. > > > > Signed-off-by: Claire Chang > > Reviewed-by: Christoph Hellwig > > Tested-by: Stefano Stabellini > > Tested-by: Will Deacon > > --- > > include/linux/swiotlb.h | 3 +- > > kernel/dma/Kconfig | 14 ++++++++ > > kernel/dma/swiotlb.c | 76 +++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 92 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 3b9454d1e498..39284ff2a6cd 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -73,7 +73,8 @@ extern enum swiotlb_force swiotlb_force; > > * range check to see if the memory was in fact allocated by this > > * API. > > * @nslabs: The number of IO TLB blocks (in groups of 64) between @start and > > - * @end. This is command line adjustable via setup_io_tlb_npages. > > + * @end. For default swiotlb, this is command line adjustable via > > + * setup_io_tlb_npages. > > * @used: The number of used IO TLB block. > > * @list: The free list describing the number of free entries available > > * from each index. > > diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig > > index 77b405508743..3e961dc39634 100644 > > --- a/kernel/dma/Kconfig > > +++ b/kernel/dma/Kconfig > > @@ -80,6 +80,20 @@ config SWIOTLB > > bool > > select NEED_DMA_MAP_STATE > > > > +config DMA_RESTRICTED_POOL > > + bool "DMA Restricted Pool" > > + depends on OF && OF_RESERVED_MEM > > + select SWIOTLB > > This makes SWIOTLB user configurable, which in turn results in > > mips64-linux-ld: arch/mips/kernel/setup.o: in function `arch_mem_init': > setup.c:(.init.text+0x19c8): undefined reference to `plat_swiotlb_setup' > make[1]: *** [Makefile:1280: vmlinux] Error 1 > > when building mips:allmodconfig. > > Should this possibly be "depends on SWIOTLB" ? Patch is sent here: https://lkml.org/lkml/2021/8/26/932 > > Thanks, > Guenter Thanks, Claire