Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp671860pxj; Fri, 11 Jun 2021 08:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws/oFzgMcU10BHLlTUeLm+WY1QD7OfmD/qsStnqp/QRzMoW8GDtblj6zU2CEYbspNMYlmk X-Received: by 2002:a05:6402:26d3:: with SMTP id x19mr4642290edd.234.1623425694416; Fri, 11 Jun 2021 08:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623425694; cv=none; d=google.com; s=arc-20160816; b=kv1cFizTcjakHCPbYYsDXo40gwsF2Rntw8vBleW6RpTi2YxXZ9859FtDZYx2E/eVT1 E2+okiQdM4jHT2Rb0xdMn9cD039xhMGbPPT7jOXBmLAgnEJToEXafw2+9X2y5zOPSJI+ KWDx2NEcRzbX0SpvwzRw1uZxtrnVPDOui0QllhZWXeQlxU8yODTWYksCxYH+Fmt6Y3DE 6AwWHqy2LDJQJKZVN5i/vxb2gcq8+V3npI+dBZtCcPHsff5iCDzaedpXcCUiynQMXaxB Mp8b+cAYFozLJdbrmU+T0bJaBj6fAOfV6PMwdKNtFzvBLYzVdmf1i94tPfL/72rS4Gyu ABhg== 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=HrrVVnSjpUoKFrAoTS1Nmvf9GKdgWVrBB899NO9QKoYUHQxTcfbEyTrUObqRrIJbtO IwqBN3vNamV5bodlSFYB09pGvaiIFtzcr/YqzuC5R+EddxV5oFQ+GUsGOh45OULFLIVY /jXPuLUBQSPo2skHCY1ReTXRDdzxP2+hBu91OJ31IP6lUWXxl5q6pQg0Ss/T+jjIbuVh z2TBBcGwblJ1rpQ1XcsEOi7/sguFcEPYG45otaWSVKayK5DJCFfCaq2kQLQwdJ+wLVwB PN6Bi5jtGshPVmzPK44x6TYUYT+4U29+NJ97o0rjRmhCdyCPcyJ1L59TiRoXDqSembE2 ebYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="RsUtJuQ/"; 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 h14si5622533edr.9.2021.06.11.08.34.30; Fri, 11 Jun 2021 08:34: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="RsUtJuQ/"; 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 S231815AbhFKPce (ORCPT + 99 others); Fri, 11 Jun 2021 11:32:34 -0400 Received: from mail-pj1-f47.google.com ([209.85.216.47]:44869 "EHLO mail-pj1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbhFKPcV (ORCPT ); Fri, 11 Jun 2021 11:32:21 -0400 Received: by mail-pj1-f47.google.com with SMTP id h12-20020a17090aa88cb029016400fd8ad8so6189406pjq.3 for ; Fri, 11 Jun 2021 08:30:08 -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=RsUtJuQ/xhbMtMc9XuxV/0qNZvgSrMkqrnyRrOyme9H1qYO1hZTedsVrCqpq2htHSN ZlwkSxjdIBM3PkDZK/6KVtHrZLtJJw6srF6HFJmL1NXvYoRqj5+Sdh8htaj0wdQKo+0g e5vmju65RPaMyCngcRLDKqjt2q5GFgsBLXP+0= 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=dAx4X4l6b7Zoe+zp07HbPomXb0BS2pb0FkaTmsP65BwWtwJeAQ1GScdFSwzxSr3uSz hqBIDSFzq6GvRHKjhGBFHW/pTiWX1SxIlzCecsFx4e9/SnSlFJ/9yMfyHkz80rfxyeQM +4dGjQ3r3ziI3/7llVEImLInuYNAIzpSmqdw12rkZsVPJQYyMTs2JtRq6vMa0/HNB16L gmVK9b6YbjH5T8GpwwNaU8kIeBFwQRK/61Fsz+IzBq7qSX9yVuv9So0pyLK50T8uUUEE 5gjS7aP6rhKQo6NXBtQv+4rRt21tKCzM1kFSlhkaGOtwv/GtSQ3XjsLzrH7ObH5Cled9 A47A== X-Gm-Message-State: AOAM531i8mElnchWj7YgJLcPPylubueclXXdvpjHGdWhWOzy9VQyyMIE SIHS9SJlw1Zx/ilPYnYNBnQh2g== X-Received: by 2002:a17:90a:e2c1:: with SMTP id fr1mr5051480pjb.83.1623425348249; Fri, 11 Jun 2021 08:29:08 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:33c8:8e01:1161:6797]) by smtp.gmail.com with UTF8SMTPSA id fw16sm10709535pjb.30.2021.06.11.08.29.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Jun 2021 08:29:07 -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 v9 13/14] dt-bindings: of: Add restricted DMA pool Date: Fri, 11 Jun 2021 23:26:58 +0800 Message-Id: <20210611152659.2142983-14-tientzu@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611152659.2142983-1-tientzu@chromium.org> References: <20210611152659.2142983-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