Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1547528pxj; Wed, 19 May 2021 08:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqUEv/6R/7+R1wkuMRGw8nkYlCYw07Ob8kb4mLv6iPyDS+Zthcfp87qXMoWchZ6qc1aVvU X-Received: by 2002:a50:fb0a:: with SMTP id d10mr15094754edq.47.1621437704922; Wed, 19 May 2021 08:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621437704; cv=none; d=google.com; s=arc-20160816; b=FqoOVGsqgjNN531TBLxPgFLE5r8JwQiBgb7QuXlD3XRVVGQF59iishnj4jAgP76/VO 0gCi+mUTbaF+mQIZCYBypE/naYLJOwGsHsvMZolCLFK65l3/HaH/KG8QHyT7r43SkRPq h6ktr6OQ1yIs9Cmu+vnr7fIcDdUdCeRD2nU4wolQetnuA8VttOY+Ae/l0iMHk6yDkyw7 fdZcyi0inaUBX9J05pVDZYke0FWvtYqdWv6PVQS3XqH8mhwVcHRm0BMMCdDXZeAigV/b Zewkx5MKxK6aKCHMPeT6y5YEQR/GMVbUprjDUNtLSo5BE4qgTYYZT12rkwIe4bcZRD57 8kHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CTSTD7WHMjQLnf+yB2P/0oEkEOIVo79nGE1UI2KUH0Q=; b=sghqGPWzXKee1vW55XuHzoOj3C2x4crQApPz6WHO4aBO8c+C0u9la+AGNgwDl+P5lL idFT0H/syz1AzjbeNAACluzyOTxqlugCIFinqh/bVMlhpj6zw3NyKTINSWbd0Uf4LNlf oI2l/Wkz0cuc4qD8PbPY/kxYAujF/zXADpzyBxysTNriuubghaVZtOrfVWjrCyQxNSwV OFoZgJEx5hurZzs7s1X3lma5wJ4x5/DX5oApZzCkIJHijGp8wwDg+Y+wNO+GPm7zguoy 1cGOD1LpCH2zqd35cYJs5jUmAYzB2/S90VKEt3auvlLQ2B6JXqJAQ956hlnM+Nyvp96D Ommw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nAAUAjIf; 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 df25si13270784edb.200.2021.05.19.08.20.50; Wed, 19 May 2021 08:21:44 -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=nAAUAjIf; 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 S1346700AbhERGpz (ORCPT + 99 others); Tue, 18 May 2021 02:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346821AbhERGpv (ORCPT ); Tue, 18 May 2021 02:45:51 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33F5AC061760 for ; Mon, 17 May 2021 23:44:34 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id s19so4434768pfe.8 for ; Mon, 17 May 2021 23:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CTSTD7WHMjQLnf+yB2P/0oEkEOIVo79nGE1UI2KUH0Q=; b=nAAUAjIfoQT+ak6LjVaVetBSUMNnB6n7A11MZcPIr+b55pauAURqTYLKnD47uanmZJ 3cJyu/W7zXu7vcXxot+z5bCjTjNShkL3mMnRTemIfV7uSqDhggL5tXTfLRj2IiU5yZER EMx5ceT6GrGiYCMKZLVA9T2R6o8FKbKEjkXrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CTSTD7WHMjQLnf+yB2P/0oEkEOIVo79nGE1UI2KUH0Q=; b=RhiqsbrRaegQhyOi6UokOHnR8i9rk5MnNxC3Vl0Ivde/xVybvoulHfKESbaCEWQGxP XjO6thBIR4t6uISNoyVW33LIhR16mj12X/RNnIgIuQYJ7gt5bDxFCeFdbLWHg3wXgx8w pIF+iVQrb2qxGyoH+W0SOUoSsc4PBhUxjlfLH3wZNA0yMWpqJXtx1tKZ7Bur8Vg2jPFK +vkKeEqi1MUoGOKLd33AFAxhXZ+trxwNFHK00Dcpvc5DTi7JltjKcSwfm5hYjd1fuAJL LMZHqOee5ZcZySibVbrsH6Dtn0U4b2tkrYOWQlNG6bM1XSv8MvG0R3HjYn8LeTS/qn3w oDFQ== X-Gm-Message-State: AOAM533V0kSoEH3mZ4Fkj+M705sFOWr3al+Y7yYEBsZUa9ZGCMFpScGv x4bJMbzAt/+IgrzjhaLqN57GKw== X-Received: by 2002:aa7:8e0d:0:b029:214:a511:d88b with SMTP id c13-20020aa78e0d0000b0290214a511d88bmr3600961pfr.2.1621320273735; Mon, 17 May 2021 23:44:33 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:f284:b819:54ca:c198]) by smtp.gmail.com with UTF8SMTPSA id t22sm4382996pfl.50.2021.05.17.23.44.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 May 2021 23:44:33 -0700 (PDT) From: Claire Chang To: 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 Cc: 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, tientzu@chromium.org, 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 Subject: [PATCH v7 14/15] dt-bindings: of: Add restricted DMA pool Date: Tue, 18 May 2021 14:42:14 +0800 Message-Id: <20210518064215.2856977-15-tientzu@chromium.org> X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog In-Reply-To: <20210518064215.2856977-1-tientzu@chromium.org> References: <20210518064215.2856977-1-tientzu@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the new compatible string, restricted-dma-pool, for restricted DMA. One can specify the address and length of the restricted DMA memory region by restricted-dma-pool in the reserved-memory node. Signed-off-by: Claire Chang --- .../reserved-memory/reserved-memory.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt index e8d3096d922c..284aea659015 100644 --- a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt +++ b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt @@ -51,6 +51,23 @@ compatible (optional) - standard definition used as a shared pool of DMA buffers for a set of devices. It can be used by an operating system to instantiate the necessary pool management subsystem if necessary. + - restricted-dma-pool: This indicates a region of memory meant to be + used as a pool of restricted DMA buffers for a set of devices. The + memory region would be the only region accessible to those devices. + When using this, the no-map and reusable properties must not be set, + so the operating system can create a virtual mapping that will be used + for synchronization. The main purpose for restricted DMA is to + mitigate the lack of DMA access control on systems without an IOMMU, + which could result in the DMA accessing the system memory at + unexpected times and/or unexpected addresses, possibly leading to data + leakage or corruption. The feature on its own provides 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 way to lock down + the memory access, e.g., MPU. Note that since coherent allocation + needs remapping, one must set up another device coherent pool by + shared-dma-pool and use dma_alloc_from_dev_coherent instead for atomic + coherent allocation. - vendor specific string in the form ,[-] no-map (optional) - empty property - Indicates the operating system must not create a virtual mapping @@ -120,6 +137,11 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). compatible = "acme,multimedia-memory"; reg = <0x77000000 0x4000000>; }; + + restricted_dma_mem_reserved: restricted_dma_mem_reserved { + compatible = "restricted-dma-pool"; + reg = <0x50000000 0x400000>; + }; }; /* ... */ @@ -138,4 +160,9 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). memory-region = <&multimedia_reserved>; /* ... */ }; + + pcie_device: pcie_device@0,0 { + memory-region = <&restricted_dma_mem_reserved>; + /* ... */ + }; }; -- 2.31.1.751.gd2f1c929bd-goog