Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2088669pxj; Sat, 19 Jun 2021 02:34:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTIhMv+ZrmWU+Sf/yHQJ6X1HgpW35HVJpvkO8Oy1r6w2sKh/2vfFM7EYSf2pNMbUVjXNRT X-Received: by 2002:a17:907:7848:: with SMTP id lb8mr15404358ejc.494.1624095260124; Sat, 19 Jun 2021 02:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624095260; cv=none; d=google.com; s=arc-20160816; b=f8kEXROCnCICxxmscxg1x5TsQ1cmsUf5oogaCJ7WGW1n5Ys5IFpIVJinhnsv/V30te Cg0qHgUp+64KCny/OzDT+MWLaSMb0+3d2mOayafTFnmmXoP+vnEQ+OKKy5h7qnB2sL/P V60+msTh/zucbS72cNTTTFhz487jXajy+48056zgT/bVsiVdQiKjQ2049iXdGzHbnaa8 fsHAxgUwMcXmpioNiAOhOzi7Pc01S0K8zGMw63KkVgVlAbmkcwmLn5le9Y8qAdTSzwt5 1cxESspyHCkpLROlps9I3crthXVsIIGcRMmocWD2MI6vv/g9vcetCBXzzs25n61C1HRx QTPQ== 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=j7wGQD4twf/mjHBJ6jHWcT59jU96e+Iceg7cfAn1f6MePrWrjYEfCF74mi9+YZTxzp Tx9PlbyqY58Npho0dQQY/b1M9H5jZOZy1jMZPiz6r5jmGR7rEt+6Tpcpx5JfdlJhmd+L RXCVLIji2YzPNajG5nPDtkOs831R7EV3E4dk8dk/++IzMVYMMrpUHo/Q1ilhT1bfCOgo 0vS4fV3i5ttT+tTAN3OhQPBsccbwquVaAJ1nPn4MFmYBMyAz8nGWWuIaF5fNamL4Dh3q XuHCvM9WMFV9IbvtBC49wmdIEW8BX1lfcVYYkSVfBSmSwhMn2YZHLKmjIY/c0E8F8TbM ZJQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wu0eLHFq; 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 c11si1559134edy.282.2021.06.19.02.33.58; Sat, 19 Jun 2021 02:34:20 -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=Wu0eLHFq; 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 S235750AbhFSDpJ (ORCPT + 99 others); Fri, 18 Jun 2021 23:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235809AbhFSDon (ORCPT ); Fri, 18 Jun 2021 23:44:43 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51CEFC0617AE for ; Fri, 18 Jun 2021 20:42:33 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id q192so2652601pfc.7 for ; Fri, 18 Jun 2021 20:42:33 -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=Wu0eLHFq0Y/87UVuH2wG2UQKehneEtjyPBVQdTP1lnkewLoZWvPjWvbDIzh+Arzpty 6/gTzGLkVnr6kmY9LH3UOa/5MBfVIDw2V2Pk6DizW41XnS2UTJ+egFCFXcGunjOko5uu NFfdBa59v19TyyGjeObnddQmZaP9dKr5Tb8k0= 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=ni99fC+rqpp0CikK4npQ6+VYpaRfMjhAA7lPChOvx1ANYI1QqAz1HO6ATRG0BmtFEh 1rvt1aOyB1bcOwq+nLryxfMzqtEFPY+hG+zD9cGVA3OVwACCgLtLZTaO1EZF2i5a/8vk 9UzXOQLaw7h2pMxFPXbtY8ad+u4ZtmqmxmBJnAvVLw06OCPYHCh/xRDE5KHD7s4lM18O DBynYfZbnZBf6zXQhw2UQ6LQXVtmWdkdT4xU8kHvOIyfYiNfjpJOG8l0XL2Ezjrx9Mw0 7iK2jomyZ+ndSRsu2sLzw5X0Y4qCVXOVx/Cs8Y6ROtj9te7gMyghnVE0Sq8xWjaAhRAG W1Mw== X-Gm-Message-State: AOAM530vLn87Cay2OIu821YFv3NUbzHljZq4QIx94RSG1iBP86M+Jvyq tFI811f6O5V0P1hHkL/thSZlDg== X-Received: by 2002:a63:6644:: with SMTP id a65mr12953547pgc.431.1624074152888; Fri, 18 Jun 2021 20:42:32 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:4a46:e208:29e8:e076]) by smtp.gmail.com with UTF8SMTPSA id h8sm10337503pgr.43.2021.06.18.20.42.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Jun 2021 20:42:32 -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 Subject: [PATCH v14 11/12] dt-bindings: of: Add restricted DMA pool Date: Sat, 19 Jun 2021 11:40:42 +0800 Message-Id: <20210619034043.199220-12-tientzu@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210619034043.199220-1-tientzu@chromium.org> References: <20210619034043.199220-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