From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>, <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
<aneesh.kumar@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Gavin Shan <gshan@redhat.com>, Vikram Sethi <vsethi@nvidia.com>,
"Anshuman Khandual" <anshuman.khandual@arm.com>,
Shanker Donthineni <sdonthineni@nvidia.com>,
Mostafa Saleh <smostafa@google.com>, <rppt@kernel.org>,
Thomas Huth <thuth@redhat.com>, Marc Zyngier <maz@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>, <kas@kernel.org>,
Kohei Enju <enju.kohei@fujitsu.com>,
Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>,
Ard Biesheuvel <ardb@kernel.org>,
James Morse <james.morse@arm.com>,
Steven Price <steven.price@arm.com>,
Sang-Heon Jeon <ekffu200098@gmail.com>,
Omar Sandoval <osandov@fb.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jinjie Ruan <ruanjinjie@huawei.com>,
Sam Edwards <cfsworks@gmail.com>,
Douglas Anderson <dianders@chromium.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
Chen-Yu Tsai <wenst@chromium.org>,
Huacai Chen <chenhuacai@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Pranjal Shrivastava <praan@google.com>,
Ashish Mhetre <amhetre@nvidia.com>,
Shameer Kolothum <skolothumtho@nvidia.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <iommu@lists.linux.dev>,
<driver-core@lists.linux.dev>, Sonang Patel <sonangp@nvidia.com>,
Ankit Agrawal <ankita@nvidia.com>
Subject: [PATCH v1 5/8] iommu: Let a driver mark an IOMMU as confidential
Date: Wed, 9 Sep 2026 20:32:48 -0700 [thread overview]
Message-ID: <a2b4ecab20635c1b0defa47407af23ff901c778d.1789010941.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1789010941.git.nicolinc@nvidia.com>
An IOMMU inside a confidential VM needs private memory for its queues and
tables. Later changes also need to identify it when handling TDISP devices.
Add a confidential marker and a helper for IOMMU drivers. The helper also
marks the IOMMU device as able to access private memory. Drivers must call
it before iommu_device_register().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
include/linux/iommu.h | 10 ++++++++++
drivers/iommu/iommu.c | 20 ++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ac43b8b93f14a..bd68532e7f3be 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -822,6 +822,8 @@ struct iommu_domain_ops {
* @singleton_group: Used internally for drivers that have only one group
* @max_pasids: number of supported PASIDs
* @ready: set once iommu_device_register() has completed successfully
+ * @confidential: this instance runs inside a confidential VM. Set by the driver
+ * before any dma allocation.
*/
struct iommu_device {
struct list_head list;
@@ -831,6 +833,7 @@ struct iommu_device {
struct iommu_group *singleton_group;
u32 max_pasids;
bool ready;
+ bool confidential;
};
/**
@@ -890,6 +893,8 @@ struct dev_iommu {
int iommu_device_register(struct iommu_device *iommu,
const struct iommu_ops *ops,
struct device *hwdev);
+void iommu_device_set_confidential(struct iommu_device *iommu,
+ struct device *hwdev);
void iommu_device_unregister(struct iommu_device *iommu);
int iommu_device_sysfs_add(struct iommu_device *iommu,
struct device *parent,
@@ -1423,6 +1428,11 @@ static inline int iommu_device_register(struct iommu_device *iommu,
return -ENODEV;
}
+static inline void iommu_device_set_confidential(struct iommu_device *iommu,
+ struct device *hwdev)
+{
+}
+
static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
{
return NULL;
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index cd1bca7ede9af..feff390727d13 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -17,6 +17,7 @@
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/host1x_context_bus.h>
+#include <linux/dma-mapping.h>
#include <linux/iommu.h>
#include <linux/iommufd.h>
#include <linux/idr.h>
@@ -313,6 +314,25 @@ int iommu_device_register(struct iommu_device *iommu,
}
EXPORT_SYMBOL_GPL(iommu_device_register);
+/**
+ * iommu_device_set_confidential - Mark an IOMMU instance as confidential
+ * @iommu: the IOMMU instance
+ * @hwdev: the struct device of @iommu, whose own DMA reaches private memory
+ *
+ * Declare that @iommu runs inside a confidential VM
+ *
+ * Call this before @iommu makes any DMA allocation of its own, and not merely
+ * before iommu_device_register(). Queues and tables allocated any earlier land
+ * in shared memory that the hypervisor can read.
+ */
+void iommu_device_set_confidential(struct iommu_device *iommu,
+ struct device *hwdev)
+{
+ iommu->confidential = true;
+ dma_set_cc_private(hwdev, true);
+}
+EXPORT_SYMBOL_GPL(iommu_device_set_confidential);
+
void iommu_device_unregister(struct iommu_device *iommu)
{
for (int i = 0; i < ARRAY_SIZE(iommu_buses); i++)
--
2.43.0
next prev parent reply other threads:[~2026-09-10 3:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 3:32 [PATCH v1 0/8] iommu/arm-smmu-v3: Support guest-level Realm VSMMU (Part-1) Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 1/8] firmware: arm_rmm: Move RSI support out of arch/arm64 Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 2/8] firmware: arm_rmm: Add VSMMU commands and fields Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 3/8] dma-mapping: Let a device declare that it reaches private memory Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 4/8] dma-mapping: Keep DMA memory private for capable devices Nicolin Chen
2026-09-10 3:32 ` Nicolin Chen [this message]
2026-09-10 3:32 ` [PATCH v1 6/8] iommu: Introduce TDISP T=0 state for confidential IOMMUs Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 7/8] iommu: Park TDISP T=0 devices in the blocking domain Nicolin Chen
2026-09-10 3:32 ` [PATCH v1 8/8] iommu/arm-smmu-v3: Probe a guest-level Realm VSMMU via RSI commands Nicolin Chen
2026-09-10 4:23 ` Nicolin Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2b4ecab20635c1b0defa47407af23ff901c778d.1789010941.git.nicolinc@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=amhetre@nvidia.com \
--cc=aneesh.kumar@kernel.org \
--cc=ankita@nvidia.com \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cfsworks@gmail.com \
--cc=chenhuacai@kernel.org \
--cc=dakr@kernel.org \
--cc=dianders@chromium.org \
--cc=driver-core@lists.linux.dev \
--cc=ekffu200098@gmail.com \
--cc=enju.kohei@fujitsu.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=gshan@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=james.morse@arm.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kas@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=osandov@fb.com \
--cc=praan@google.com \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rppt@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=ryan.roberts@arm.com \
--cc=sdonthineni@nvidia.com \
--cc=skolothumtho@nvidia.com \
--cc=smostafa@google.com \
--cc=sonangp@nvidia.com \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=thuth@redhat.com \
--cc=tzimmermann@suse.de \
--cc=vsethi@nvidia.com \
--cc=wenst@chromium.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).