Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3684021pxj; Tue, 15 Jun 2021 06:31:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIiQOPCun0vMBB5mTCuNV4Bcw/sf7C7hG9CPbqXE0m0k/XPBwadr6OalWLoKq700Tkpa3N X-Received: by 2002:a17:906:7fc5:: with SMTP id r5mr21524948ejs.474.1623763893813; Tue, 15 Jun 2021 06:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623763893; cv=none; d=google.com; s=arc-20160816; b=NKP1Kfb8YicPUMrPOhLpoqu+IxYjpYiHK3+0zWgJ9NP6QzWC/XURXN5WcT7mVv1KAc J26rzKk5VQSsnWbwO3b0YDS1zGs3RwrN7uez7l8EX0vfAG1c3oN9moqVaa9qG0r1/wLS Z5B7rHD3JClF+oEx0QZehOpfcLjJJUZL10r+4CS+lM9neYFAjnrRdvdN4gEglszX0B8H RtWZMmi//6p7Hk6JQrGg/LNkAHNrPcgwJ0R8E/Ump6kg/zXjToMNQu1nT2NyKN9VT+D6 TJLvZXLnPmZEAjsTxrnix5Lj/oaN17b369M1lsczoKBF5l3rtcjCNFcpAT/xLYkpvLtL +3AQ== 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=GymVnULBeJ03m5EPo7c7VEX7DSqoBwMT6L2fMWoeeEc=; b=cUFrh7gyXgPsE/Pkmn9DKFE8ODkrKu7iZ8dxlGIQd3M904/wao6bZn/HIcDfIPlOlR QW71gqUZsMRi0W4z+9rZKo5VTqGfm2S0ADOYFTBYdbqBfm3uNfphQqJVGOR62w5bnQxq PCiQ5yQ2Q4NIVMYwRAMTMDd0zJYHhVZOWNFzADBGsSGBuLA43GkFA1ycw6idY49DJY9u 3GAgJrM/HfJA93C0/b9a0+Itc+c2MMvKpytZ3hIxZWiEyE61qYUvqHh17oh3WDkph4Eu 39w1O8yuL8N2Ev98GhzkMwK33jW1nEmFmdi/wGIRjHY9A5hGwKqzE72uBPpq3aF8UV+a ZtMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WOU8IVzg; 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 l21si14101474eja.295.2021.06.15.06.31.09; Tue, 15 Jun 2021 06:31:33 -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=WOU8IVzg; 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 S231522AbhFONbU (ORCPT + 99 others); Tue, 15 Jun 2021 09:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbhFONbE (ORCPT ); Tue, 15 Jun 2021 09:31:04 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBDDC061574 for ; Tue, 15 Jun 2021 06:29:00 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id k5so11788430pjj.1 for ; Tue, 15 Jun 2021 06:29:00 -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=GymVnULBeJ03m5EPo7c7VEX7DSqoBwMT6L2fMWoeeEc=; b=WOU8IVzg+iYvk6N5b67KD5CKh5Wgn355zu5PCMe6mPVyyUQjES9RmEtfXkhuQMaXmA hHjDKIazD9xu9BtywBAgsYVdsMG3DqbHBxwCuAdZqvctaQSD9keTHyqXNfZ2Km99muyW YJc+kW7TLNcpm9kWU0l/wPI+emgUC6NSvuBJc= 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=GymVnULBeJ03m5EPo7c7VEX7DSqoBwMT6L2fMWoeeEc=; b=RKcoNL1iAVugAfPsOXfHiSG1UqN6PJfXxmGVXP/jlAbH84jfShjcY31SMQtSVM+Ca7 1Hu+pSlV5dFoej8ZQt3tLuBp7eQME1s8z82BzR+B5JCMt9IhcFj4yCGWu4NZFzWU9/pG 0ubJjIDrj5sfBjA0qZ3Rdf2dibXge/HHFl4J/2/itTup+paLvdnAspRvlyBtUSmX6D2X /pMqaGi2EH0OY1s+aXgO0BF++Fqywh4ryOQ6H6iaAsNHdpLql3IK6vMtVGstnwESwBMN 8Iyt/DRo8k0GP+ENaYoiIUa9O+/Aqh64iZWmebvGNmH/fT6OttSQo1O4sb7qh2gy2voo jakg== X-Gm-Message-State: AOAM531R4aXtA45TJ0Iwbp4MV6w2ab/4/wrM+QeE/8EKs3PoElOk45hY j40Ym2AxkW6VaUMicC7q1ouSXg== X-Received: by 2002:a17:90a:a116:: with SMTP id s22mr24962655pjp.218.1623763739540; Tue, 15 Jun 2021 06:28:59 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:1846:5274:e444:139e]) by smtp.gmail.com with UTF8SMTPSA id y205sm15379907pfb.53.2021.06.15.06.28.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 06:28:59 -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 v10 11/12] dt-bindings: of: Add restricted DMA pool Date: Tue, 15 Jun 2021 21:27:10 +0800 Message-Id: <20210615132711.553451-12-tientzu@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210615132711.553451-1-tientzu@chromium.org> References: <20210615132711.553451-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 | 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..46804f24df05 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_mem_reserved>; + /* ... */ + }; }; -- 2.32.0.272.g935e593368-goog