Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2779587pxb; Tue, 24 Aug 2021 07:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/vOfnqRDwOh/QS1pff5cQH6SM1jxK+Sw7mCDcflajQ/NSeAQVXMXDdHBk+p/XpfYEb7HN X-Received: by 2002:a6b:b512:: with SMTP id e18mr32393987iof.98.1629815231031; Tue, 24 Aug 2021 07:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629815231; cv=none; d=google.com; s=arc-20160816; b=MC/jv51do3l1PCPzn9G95bNBhZedFWaj3fMrtGZ9H6n8fOpOHSEAcmthq9Fr+fJ4eE sKA1ST1of7nX+o8WBnRRR3c7MUDqktCmuMEGPhDMsFAyPnHRl3YteVBxsYosIRU81dYD dmAsz16LxP2v4MorcEjm9iYPLBwiD3wxA87ik0T9bBzKeubbAMLYUWvNQXil0kbfj+g0 pjBpDg9oTFS5n22Cxn3IprAPIX2QxUkTG9BZgxdqwFon9hTvjRjJ/0X1D1uNgGXkfLS5 BYN5sCq/u6kOWO72aXhORyFvDZdU5XqstnhjKW9CBAVnPZiF/MK7UZxKRAZfJm1a1Gnl EkWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=cLmu7zgJaXKzK4Rf3xZy8rbXQ8G9iiiCS2AqbbVSdr4=; b=WEgL8f7YnISzMof74i/a0Ye+eXo8FGP/DOYnmDWTZRVak/rqJb0j3u1WCUq/g5wErE NCoY9ONI7/+XBo5jnyW22pwkrkD9N1nmTBI8SCxrrTgLUDt1YGLyhfWdgWY3wy0v9gfQ 5Xu+19wfoyHu1gvEDZv3YiiNh39Xw/U552JQ46N52M4AzIOP/imONhLkQC9Qm2JB7DLL jwiMMbK0EuGLg380Lxq+TeMTzyGiXJE8XXTEe6sELhWhqfsQe+w0IFcNtqRYA7RX+p4H gZn9qm6Aea6MdVqMv1bs9Hqb5HvzXjecXyJ8H2LSmHGRpFGjykZBNOax9mxbsWB/Zxpi 3XbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="W/vnTArX"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si17294931jaj.101.2021.08.24.07.26.58; Tue, 24 Aug 2021 07:27:11 -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=@gmail.com header.s=20161025 header.b="W/vnTArX"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237618AbhHXO0s (ORCPT + 99 others); Tue, 24 Aug 2021 10:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235997AbhHXO0s (ORCPT ); Tue, 24 Aug 2021 10:26:48 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD80EC061757; Tue, 24 Aug 2021 07:26:03 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 61-20020a9d0d430000b02903eabfc221a9so46603102oti.0; Tue, 24 Aug 2021 07:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cLmu7zgJaXKzK4Rf3xZy8rbXQ8G9iiiCS2AqbbVSdr4=; b=W/vnTArXnkUTeAWPhVsCsNx9G1AaqqjMh7JGGCeKMkNnaOWP3sAbf+15/nLoCNmR3g q5YdGS8A1cXpAtJlYg19EzxhKY4ftiJkULVtdpcPrc3JdAsQuBkyHELZ+nm35chlenyd B1EUk7sT/qRPK4Ufw9SGcQJoAGqm8fBuCmyUjLn+ofRgVfuPflWOJHcCCZEENzbQUeyQ VmavwAVWpqeeI9XEBe9u66mgOWxsXHJm3RTYGIcz6konO25IcoN22AqYojFn8mbqHxKg qRzCfRvKs4A+5DaC8fRnZWJa7UOCRmoYWPgWVuJeEHetkAAVaEkEKj7Ut9tMesrOQeKz uFVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=cLmu7zgJaXKzK4Rf3xZy8rbXQ8G9iiiCS2AqbbVSdr4=; b=hw63h3ARUUBYommE/qzioPu6SJGj8BoEoRfp96rMxuHgPhqJixtTdKfIC5xHFIZdZm WugrFMcrjgX/IT2yNRqDQYjjYQn9G8lZW5W1jj7C/xtfBKL0UkuvBaZrC+/bpMmgrFG7 Z+bVjaAy4q6xrdEg5r8LuS8BdOYAgrS4Pv/Rf4D4DivMHfHFFeFMT+n00yWdBuN0YUWC ISlPkg6Yo6Zb6jARKU6C/8KIqq4tzEPaLsxs+/rrxbAPBFPPcj6f5AL2g9mRttC7tV/v FXstbS2d4+QD7Oc391M1of45xS2eOLhpU5CG6aIXgOocF9268Bt20ne/wMIYxBAQybYV w4Vw== X-Gm-Message-State: AOAM533ngQOaJHUrcm09VA5Y+HjWSqLsE1cDU5OdydcfYytA3lipdp6K rKmxHFWFHWYbiNMsToQve0g= X-Received: by 2002:a54:4513:: with SMTP id l19mr3045512oil.143.1629815163193; Tue, 24 Aug 2021 07:26:03 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id w23sm4515362otk.56.2021.08.24.07.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 07:26:02 -0700 (PDT) Sender: Guenter Roeck Date: Tue, 24 Aug 2021 07:26:01 -0700 From: Guenter Roeck To: Claire Chang 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" , sstabellini@kernel.org, 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 , tfiga@chromium.org, bskeggs@redhat.com, bhelgaas@google.com, chris@chris-wilson.co.uk, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, jxgao@google.com, 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, thomas.lendacky@amd.com, quic_qiancai@quicinc.com Subject: Re: [PATCH v15 10/12] swiotlb: Add restricted DMA pool initialization Message-ID: <20210824142601.GA3393158@roeck-us.net> References: <20210624155526.2775863-1-tientzu@chromium.org> <20210624155526.2775863-11-tientzu@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210624155526.2775863-11-tientzu@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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" ? Thanks, Guenter