Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp336168pxv; Thu, 24 Jun 2021 08:59:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBHDhc3BVS7+h4M3g/9xqojpEgB4p5T03/0lQRALLAVQGsNSu3je8coAsxxS3MCmgYHo9d X-Received: by 2002:a05:6402:2885:: with SMTP id eg5mr8257171edb.73.1624550394780; Thu, 24 Jun 2021 08:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624550394; cv=none; d=google.com; s=arc-20160816; b=NjhPdVphx5MZJPZZxyDXgOhfZA6l6d3I6FW+aJ53zE1QHcSkv+IAwcNWvxK+/8Uvo1 luvNElOJeFxadrujwkdcX0SkzwzMALWkDRWdB/x1SRoOEuuV9Q7fs3GsUKLmiJZjkLsW or/Ey8oZuSMZ5qBMmRTW99PuUECUXNygYk/n+rjfdz2Nf7cXrJXh/XvcmUrL6Tq03t8q 0SCxMRQh/dn6UqyzhQxRN3FhHPWASO6mdJXOvIGXn2iM1z8SBmeeRRlxNuMjzlin9HtQ J7+6cBQ+hAV2+U3pV/ALWLCdCYpC1G1RWh4kMSZOhQfsZ5EINST7zZAlXuTJHdO2D4Us /04w== 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=YPdZA059qJtBhHo92L+QtxB+I/HHPOi+M+A9tEqXqKY=; b=xH3s8Xun4snxld8QtwfS7M5pJBUMLCyqUFch3kpEUgM1zQgmH4i+aL1RXB3cYRvO1O gsbaB+XW5G6VDXB1gNRj1R49UMs7Z4V/H9OUkDQpGfmzOAt1DoEMOPaKTBTtu5Fox0Dq ch5j8127uaobif27OCXtFg5FzWuESyIm+gEAKrqm78P17mriCsVa35/y9e5ihw9KN4Wu Kl9ZnCTBXYUu93zzQqhoi0Tmvs8v8PRoHmEcJriF8ovt6ilCDEa4vuUeBk+y4ZzFR8uy VBzYj4AbU1xHjy2miJiqByd54piu1GZVb92ISYMm529QYFGfkVUPDEloQaCzAxsoAykJ ZbkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PjlqqBPl; 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 hw7si3179218ejc.405.2021.06.24.08.59.31; Thu, 24 Jun 2021 08:59:54 -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=PjlqqBPl; 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 S232561AbhFXP7r (ORCPT + 99 others); Thu, 24 Jun 2021 11:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbhFXP7j (ORCPT ); Thu, 24 Jun 2021 11:59:39 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 437C1C061767 for ; Thu, 24 Jun 2021 08:57:19 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id b5-20020a17090a9905b029016fc06f6c5bso3753467pjp.5 for ; Thu, 24 Jun 2021 08:57:19 -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=YPdZA059qJtBhHo92L+QtxB+I/HHPOi+M+A9tEqXqKY=; b=PjlqqBPlZ7HlVzWQ/NG7jUEmdRoSGdDyyhsicywtHJWmlQpajkDrqtejX1sn/5F2sS SwwO3EzEcXtbM4jLQSoe8mUbP22ohS6knOWK2YU5Q+OvqR8ORZOMLvrptba985Ay6g72 468Ys8fEwAI9IAi2Nx5OeG0lVcTQ7r4EAMUuk= 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=YPdZA059qJtBhHo92L+QtxB+I/HHPOi+M+A9tEqXqKY=; b=hL6fPl1gUjZBS2avWsA47H4O6ya1ASFY6uB1SeeU/UKYhRNzYtS53xTNrN/zUBBjBX xAV+Hzs/c5kIJ799lRTzpR3BgubSap7sEz1V1Aq070HpmNMj1/jHvTXvsxTyt310tGDJ bPCEt5+d4QKNw5+Wsh7Fqmx7zvJYHCBmagtYEOkrX4esMPQOTa8WdmZUiOZE/icpESBS 953P3Gdie+16xXerS3hVJgNKeurVZ6sgR3djHCEZo8Ir9l/jUihHRE57sd84Kgp3rxmz YoUuIbiIdZI32n0VG/+EbnN7gQ6oAQhEJ6tvUEzllzRQTCkpdBIFZgeZG3FJMLg9TMsm DAyA== X-Gm-Message-State: AOAM531GzRsel3ptTJ+lxjxhhsAlKTgCv/wZPe2NOMufdiQtz2lOS8p3 KMu14VXNJsOzrPVcH4sOHYBVMQ== X-Received: by 2002:a17:90b:1d06:: with SMTP id on6mr5855940pjb.149.1624550238780; Thu, 24 Jun 2021 08:57:18 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:165a:99ec:42d5:d8b]) by smtp.gmail.com with UTF8SMTPSA id s4sm2950901pjn.31.2021.06.24.08.57.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 08:57:18 -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, thomas.lendacky@amd.com, quic_qiancai@quicinc.com Subject: [PATCH v15 11/12] dt-bindings: of: Add restricted DMA pool Date: Thu, 24 Jun 2021 23:55:25 +0800 Message-Id: <20210624155526.2775863-12-tientzu@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210624155526.2775863-1-tientzu@chromium.org> References: <20210624155526.2775863-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 Tested-by: Stefano Stabellini Tested-by: Will Deacon --- .../reserved-memory/reserved-memory.txt | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt index e8d3096d922c..39b5f4c5a511 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 @@ -85,10 +102,11 @@ memory-region-names (optional) - a list of names, one for each corresponding Example ------- -This example defines 3 contiguous regions are defined for Linux kernel: +This example defines 4 contiguous regions for Linux kernel: one default of all device drivers (named linux,cma@72000000 and 64MiB in size), -one dedicated to the framebuffer device (named framebuffer@78000000, 8MiB), and -one for multimedia processing (named multimedia-memory@77000000, 64MiB). +one dedicated to the framebuffer device (named framebuffer@78000000, 8MiB), +one for multimedia processing (named multimedia-memory@77000000, 64MiB), and +one for restricted dma pool (named restricted_dma_reserved@0x50000000, 64MiB). / { #address-cells = <1>; @@ -120,6 +138,11 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). compatible = "acme,multimedia-memory"; reg = <0x77000000 0x4000000>; }; + + restricted_dma_reserved: restricted_dma_reserved { + compatible = "restricted-dma-pool"; + reg = <0x50000000 0x4000000>; + }; }; /* ... */ @@ -138,4 +161,11 @@ one for multimedia processing (named multimedia-memory@77000000, 64MiB). memory-region = <&multimedia_reserved>; /* ... */ }; + + pcie_device: pcie_device@0,0 { + reg = <0x83010000 0x0 0x00000000 0x0 0x00100000 + 0x83010000 0x0 0x00100000 0x0 0x00100000>; + memory-region = <&restricted_dma_reserved>; + /* ... */ + }; }; -- 2.32.0.288.g62a8d224e6-goog