From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C80C133858F for ; Mon, 1 Dec 2025 17:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610218; cv=none; b=K7zEfa89KWT/3l8/u5jrgiTb5KLYYHmrxXQCGrHPYZN7wkDp18HSpdfPPOXKqKkoQeHu+quYDi8lUgo4hviOSXGCoUvX1x5XSDpuWpdVmhHtQmoe/s5RDzjWJ1NPV36Sk1JhLV6pV5SvxE6sQLIXGrOUtK+/MeGJpZ1IrDed81Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610218; c=relaxed/simple; bh=ch1iG4+rbAwhyHGFHyNeUh174auZewU/c2vFBb8DVF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ER27toMHINWjiInBxnYPedM5t3JfUJvhw8/5xNr+11JtwSzIqjdpd6i1hTGmCmx3kcdj5fwv8wPuFE8oizBfNb84ZL9wqGhtlBiJnIv/xnKY5EWC7foPHt+R2//rBtcNCbeR3jkeVeysvK9vsS+BMOq3xXIQ3Gz/roufx5yf9v4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=ekutGR0M; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ekutGR0M" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 66C02201551D; Mon, 1 Dec 2025 09:30:15 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 66C02201551D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610215; bh=HsIcBiKk6OaLkg7+LF8HSq/9kvaT/CtZxs5ppRMC5DU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekutGR0MQpcrKN5c27xT/f/M2vYEjOGl5Fu2wJprZNQm6PazP/ZZxv3pw4vybXXMM zIh1BEQ2QblsDwe/rFygpazh+qUZduCTkT6oX47iLQmCmwdeeuFTQ/tioX4yWNHECw 06lHBnUWfmui84tQziipU8F5tiy+a7loK3oTPyO8= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 1/8] iommu: Make iommu_device_register_bus available beyond selftest Date: Mon, 1 Dec 2025 09:30:05 -0800 Message-Id: <20251201173012.18371-2-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bus type specific registeration can be used beyond selfttest mock IOMMU driver, move it outside CONFIG_IOMMUFD_TEST. Signed-off-by: Jacob Pan --- drivers/iommu/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 59244c744eab..0df914a04064 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -298,7 +298,6 @@ void iommu_device_unregister(struct iommu_device *iommu) } EXPORT_SYMBOL_GPL(iommu_device_unregister); =20 -#if IS_ENABLED(CONFIG_IOMMUFD_TEST) void iommu_device_unregister_bus(struct iommu_device *iommu, const struct bus_type *bus, struct notifier_block *nb) @@ -347,6 +346,7 @@ int iommu_device_register_bus(struct iommu_device *iomm= u, } EXPORT_SYMBOL_GPL(iommu_device_register_bus); =20 +#if IS_ENABLED(CONFIG_IOMMUFD_TEST) int iommu_mock_device_add(struct device *dev, struct iommu_device *iommu) { int rc; --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4877A3358DD for ; Mon, 1 Dec 2025 17:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610219; cv=none; b=C8mKialEf6FLIHHbBX5bSVBYo8yLTfNDmRSO3Lx/ImEHP9ksm/uwZrytXlSS1gIuRGxh2TnhiN9oGxAl9mFVvFmhYt6sXqXeUzY7gVbmhB9mBXH5yrcHHwtah5MiJrfUuEoimz/sY2NJGzZfQNe8/nMImdjt3K2IG5lpg3rj1Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610219; c=relaxed/simple; bh=bImSNgi4dZkdOMPK57Dv6OP6ggJxli6qP7lZJCYcKMs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LkMq+Z+PAwzXkk/XINxJVCJdz87hOuVYiEZNRbeTJ2505dslaOSIxiQ05vZ7HXUHMKXb8eq6Q5Ixer4ztaKKjRf7IGl7Vicz3r/iU7EOneT/l0XdgtTal61eEi9mVTZ8MMzkjgpH0dH/1LYq6Y0TD9ESeHfG6mA3+ib11cuN860= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=PRBuLpQD; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="PRBuLpQD" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 4B8B3201C97E; Mon, 1 Dec 2025 09:30:16 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4B8B3201C97E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610216; bh=o0BfdJb6BWCVT/mCZ8zsVVH2PslD3N+9Dsx1+f0fKdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PRBuLpQD0ljwyecFTBLZRNz3dNOuNyGwNQmCIJXq5x+GaseE3KWgewZopsSHrib7y dACPGaB25Gf5E4kr9I46UQ7tLntpzGhn8bXxvkg/rUc9RWqy4t54alT8MCUt0z46ZZ eeRr/4lwGvZXfU01muMvA42GB8Wnm5CX9OxVhG2s= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 2/8] iommu: Add a helper to check if any iommu device is registered Date: Mon, 1 Dec 2025 09:30:06 -0800 Message-Id: <20251201173012.18371-3-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dummy IOMMU driver for No-IOMMU mode should only be active when no real IOMMU devices are present in the system. Introduce a helper to check this condition, ensuring that the dummy driver does not interfere when hardware-backed IOMMU support is available. Signed-off-by: Jacob Pan --- drivers/iommu/iommu.c | 10 ++++++++++ include/linux/iommu.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0df914a04064..958f612bf176 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2895,6 +2895,16 @@ static const struct iommu_device *iommu_from_fwnode(= const struct fwnode_handle * return ret; } =20 +bool iommu_is_registered(void) +{ + bool registered; + + spin_lock(&iommu_device_lock); + registered =3D !list_empty(&iommu_device_list); + spin_unlock(&iommu_device_lock); + return registered; +} + const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *= fwnode) { const struct iommu_device *iommu =3D iommu_from_fwnode(fwnode); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c30d12e16473..4191ae7312dd 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -933,6 +933,7 @@ extern void iommu_put_resv_regions(struct device *dev, = struct list_head *list); extern void iommu_set_default_passthrough(bool cmd_line); extern void iommu_set_default_translated(bool cmd_line); extern bool iommu_default_passthrough(void); +extern bool iommu_is_registered(void); extern struct iommu_resv_region * iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot, enum iommu_resv_type type, gfp_t gfp); --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56FED337BB4 for ; Mon, 1 Dec 2025 17:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610220; cv=none; b=Kx/j6ceKZmq89Fc9nc10XMSjfEsPT27fNvWu8d3CVCmm2Q6F/ZwUUJezUmTrDh+p1LJxcMZ+Qz6yGzhMHZdEYTvZy3JJwmGwIBfwn14+Z0PQEJ00G+GJ4Al6S6mzTItJP2NYWtRjYk4+OtXnLOJcqQExP/16AULJUzWnQnilJmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610220; c=relaxed/simple; bh=3JJCDxdlqwr5kvJp+p2EObs2W/VAt1Sh4v9N178dMhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Trn19n8L9VYGGnMXoWAIZ7i4PobsVpnbdnyFZZjHbbL51WPS271BCUntA5LB+WZzkjzz6so6lHbJ2rHTi1D34UG9ukvFR/Os8lIn4KueqvSddt29FxoT0lm+gySBNUYsBlxJKzrukrQILO6xMbNLRa7OQpdoOc6TORqxKlM6xfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=REUAiGH/; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="REUAiGH/" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 0F00D2065961; Mon, 1 Dec 2025 09:30:16 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0F00D2065961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610217; bh=RWBe9UylVU+tcKbDr2C5pnuePxMqB34k4+OTgKl9wQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=REUAiGH/5rj727FKcmHRSHw59fGQeGkT8/eWGrNKYklCDF+9gftTPUL/uDJUIp2He MBsKKcugZXpR3iwcG6soIgzVbhoVzRxuq+gOSYvalIFauuLaukJv0QI4W6iuAf5+BD x+GzLia9I5dkPy3RjJvP8RQemP1fW9guBMIh2oUQ= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 3/8] iommufd: Add a mock page table format for noiommu mode Date: Mon, 1 Dec 2025 09:30:07 -0800 Message-Id: <20251201173012.18371-4-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dummy IOMMU driver for No-IOMMU mode needs a page table to store IOVA to physical address mappings. Instead of inventing a new format, reuse the generic IOMMU page table (iommupt) provided mock format where its implementation modeled after AMD IOMMU v1 format, but generalized for software-only use. Signed-off-by: Jacob Pan --- drivers/iommu/generic_pt/fmt/Makefile | 1 + drivers/iommu/generic_pt/fmt/iommu_noiommu.c | 10 ++++++++++ include/linux/generic_pt/iommu.h | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 drivers/iommu/generic_pt/fmt/iommu_noiommu.c diff --git a/drivers/iommu/generic_pt/fmt/Makefile b/drivers/iommu/generic_= pt/fmt/Makefile index 5a3379107999..59ea791c6383 100644 --- a/drivers/iommu/generic_pt/fmt/Makefile +++ b/drivers/iommu/generic_pt/fmt/Makefile @@ -2,6 +2,7 @@ =20 iommu_pt_fmt-$(CONFIG_IOMMU_PT_AMDV1) +=3D amdv1 iommu_pt_fmt-$(CONFIG_IOMMUFD_TEST) +=3D mock +iommu_pt_fmt-$(CONFIG_NOIOMMU_MODE_IOMMU) +=3D noiommu =20 iommu_pt_fmt-$(CONFIG_IOMMU_PT_X86_64) +=3D x86_64 =20 diff --git a/drivers/iommu/generic_pt/fmt/iommu_noiommu.c b/drivers/iommu/g= eneric_pt/fmt/iommu_noiommu.c new file mode 100644 index 000000000000..4991dff60b59 --- /dev/null +++ b/drivers/iommu/generic_pt/fmt/iommu_noiommu.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES + * Copyright (c) 2025, Microsoft Corporation. + */ +#define PT_FMT amdv1 +#define PT_FMT_VARIANT noiommu +#define PT_SUPPORTED_FEATURES 0 + +#include "iommu_template.h" diff --git a/include/linux/generic_pt/iommu.h b/include/linux/generic_pt/io= mmu.h index fde7ccf007c5..d7f70eaeb37f 100644 --- a/include/linux/generic_pt/iommu.h +++ b/include/linux/generic_pt/iommu.h @@ -255,6 +255,11 @@ IOMMU_FORMAT(amdv1, amdpt); struct pt_iommu_amdv1_mock_hw_info; IOMMU_PROTOTYPES(amdv1_mock); =20 +#define pt_iommu_amdv1_noiommu pt_iommu_amdv1 +#define pt_iommu_amdv1_noiommu_cfg pt_iommu_amdv1_cfg +struct pt_iommu_amdv1_noiommu_hw_info; +IOMMU_PROTOTYPES(amdv1_noiommu); + struct pt_iommu_x86_64_cfg { struct pt_iommu_cfg common; }; --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1366338582 for ; Mon, 1 Dec 2025 17:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610221; cv=none; b=pIcECGBCCTl84u9Dmy8IzXB5FoMUx2YyW0/+b61+al5FOXpvlIQe+MSkw2h67i204QOBEKUjctccfrg1Msc+kfeJwk3xJqv3fhkvw8Lx1ojXlTzpToLy1eAp62AOhuGEqUdZjfK5ibM+06SCmxQPDXRBMb42ikN2d6biLgrme54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610221; c=relaxed/simple; bh=ZvmATApHccUp68CQ/saVJ9hiW70Tyo+WzC7+4XAfl9E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=M6nGWI7hA+1SaGaKW0blrahiJK1hCQkr2C5k7dqTDNDNVFkJQABllkSpoViIepGrGBbAW5xCKc97wWYi+84Fiz9XQSNmz/lOLcNFVZqVRLtLp4tvsuAfWWHV3eLT7vtAUCStRw4j5xP/lUyW8r15Qa0eFQOVBewwmp9Qqx2agoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=DToxhsNP; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="DToxhsNP" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id C8387206595C; Mon, 1 Dec 2025 09:30:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C8387206595C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610218; bh=TVQKRGF9FbbhmjAA0nq52YgUFuaZHHjhE8pX0uhFLuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DToxhsNPtD/BY4H0tcP6MClzlNBTrQTaLImoU90tWzOYo8PbnqBhkBMg27VUAnVYj 49R21v0CbCTOmegHiUAS8+iHL+9CmWAnIYufCrSYnEA7gsIRKJBvoggBThssqF29qg n/Gv9xBoZ3yUIwQ6npUAHOeXuDBedmYnYERmn9IY= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 4/8] iommu: Add a dummy driver for noiommu mode Date: Mon, 1 Dec 2025 09:30:08 -0800 Message-Id: <20251201173012.18371-5-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Introduce a dummy IOMMU driver that enables VFIO character devices (cdevs) to operate under No-IOMMU mode using IOMMUFD. Similar to VFIO=E2=80=99s existing No-IOMMU mode, this requires userspace t= o set the enable_unsafe_noiommu module parameter, allowing DMA only with physical addresses. Unlike the traditional VFIO No-IOMMU mode, this option supports IOMMUFD IOAS UAPIs (e.g., map and unmap) by leveraging mock page tables provided by the generic IOMMU page table layer. In this model, IOVAs exposed to userspace are not used for DMA. Instead, they serve as keys to retrieve corresponding physical addresses from the mock IO page tables. Memory pinning is still performed the same way as if there is a physical IOMMU. For in-kernel DMA, DMA APIs will use direct mode only since this driver provides identity domain only. Signed-off-by: Jacob Pan --- drivers/iommu/Kconfig | 25 +++++ drivers/iommu/Makefile | 1 + drivers/iommu/noiommu.c | 204 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 drivers/iommu/noiommu.c diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index c9ae3221cd6f..9b3423180d16 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -359,6 +359,31 @@ config HYPERV_IOMMU Stub IOMMU driver to handle IRQs to support Hyper-V Linux guest and root partitions. =20 +config NOIOMMU_MODE_IOMMU + bool "Dummy IOMMU driver to support noiommu mode for IOMMUFD" + depends on PCI + depends on VFIO_NOIOMMU && VFIO_DEVICE_CDEV + depends on IOMMUFD_DRIVER + depends on IOMMU_PT + depends on GENERIC_PT + depends on IOMMU_PT_AMDV1 + select IOMMU_API + help + This option introduces a dummy IOMMU driver that enables VFIO cdevs + to operate under no-IOMMU mode using IOMMUFD. Similar to VFIO=E2=80=99s + existing no-IOMMU mode, this requires userspace to set the + enable_unsafe_noiommu module parameter, allowing DMA only with physical + addresses. Unlike the traditional VFIO no-IOMMU mode, this option + supports IOMMUFD IOAS UAPIs such as map and unmap by leveraging mock + page tables provided by the generic IOMMU page table layer. The IOVAs + exposed to userspace are not used for DMA; instead, they serve as keys + to retrieve corresponding physical addresses from these mock tables. + Memory pinning is still performed to ensure that physical pages remain + resident during DMA operations. + VFIO group based No-IOMMU mode is mutually exclusive with this option. + + If unsure, say N here. + config VIRTIO_IOMMU tristate "Virtio IOMMU driver" depends on VIRTIO diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index b17ef9818759..226041e928fa 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_FSL_PAMU) +=3D fsl_pamu.o fsl_pamu_domain.o obj-$(CONFIG_S390_IOMMU) +=3D s390-iommu.o obj-$(CONFIG_HYPERV_IOMMU) +=3D hyperv-iommu.o obj-$(CONFIG_VIRTIO_IOMMU) +=3D virtio-iommu.o +obj-$(CONFIG_NOIOMMU_MODE_IOMMU) +=3D noiommu.o obj-$(CONFIG_IOMMU_SVA) +=3D iommu-sva.o obj-$(CONFIG_IOMMU_IOPF) +=3D io-pgfault.o obj-$(CONFIG_SPRD_IOMMU) +=3D sprd-iommu.o diff --git a/drivers/iommu/noiommu.c b/drivers/iommu/noiommu.c new file mode 100644 index 000000000000..06125a190686 --- /dev/null +++ b/drivers/iommu/noiommu.c @@ -0,0 +1,204 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2025, Microsoft Corporation. + */ + +#define pr_fmt(fmt) "NOIOMMU: " fmt +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iommu-priv.h" + +struct noiommu_dev { + struct iommu_device iommu; + struct device *dev; +}; + +struct noiommu_domain { + union { + struct iommu_domain domain; + struct pt_iommu iommu; + struct pt_iommu_amdv1 amdv1; + }; +}; + +static struct iommu_ops noiommu_ops; + +struct noiommu_dev noiommu_dev =3D { + .iommu =3D { + .ops =3D &noiommu_ops, + }, +}; + +static void noiommu_release_device(struct device *dev) +{ +} + +static struct iommu_device *noiommu_probe_device(struct device *dev) +{ + /* Support VFIO PCI devices only */ + if (!dev_is_pci(dev)) + return ERR_PTR(-ENODEV); + + return &noiommu_dev.iommu; +} + +static int noiommu_attach_dev(struct iommu_domain *domain, struct device *= dev) +{ + return 0; +} + +static void noiommu_domain_free(struct iommu_domain *domain) +{ + kfree(domain); +} + +static const struct iommu_domain_ops noiommu_amdv1_ops =3D { + IOMMU_PT_DOMAIN_OPS(amdv1), + .free =3D noiommu_domain_free, + .attach_dev =3D noiommu_attach_dev, +}; + +static struct iommu_domain * +noiommu_domain_alloc_paging_flags(struct device *dev, u32 flags, + const struct iommu_user_data *user_data) +{ + struct noiommu_domain *noiommu_dom; + struct pt_iommu_amdv1_cfg cfg =3D {}; + int rc; + + if (user_data) + return ERR_PTR(-EOPNOTSUPP); + + if (vfio_noiommu_enabled() =3D=3D false) { + pr_info("Must enable unsafe_noiommu_mode\n"); + return ERR_PTR(-ENODEV); + } + + cfg.common.hw_max_vasz_lg2 =3D 64; + cfg.common.hw_max_oasz_lg2 =3D 52; + cfg.common.features =3D BIT(PT_FEAT_AMDV1_FORCE_COHERENCE); + cfg.starting_level =3D 2; + + noiommu_dom =3D kzalloc(sizeof(*noiommu_dom), GFP_KERNEL); + if (!noiommu_dom) + return ERR_PTR(-ENOMEM); + + noiommu_dom->amdv1.iommu.nid =3D NUMA_NO_NODE; + noiommu_dom->domain.ops =3D &noiommu_amdv1_ops; + + /* Use mock page table which is based on AMDV1 */ + rc =3D pt_iommu_amdv1_noiommu_init(&noiommu_dom->amdv1, &cfg, GFP_KERNEL); + if (rc) { + kfree(noiommu_dom); + return ERR_PTR(rc); + } + + return &noiommu_dom->domain; +} + +static int noiommu_domain_nop_attach(struct iommu_domain *domain, + struct device *dev) +{ + return 0; +} + +static const struct iommu_domain_ops noiommu_nop_ops =3D { + .attach_dev =3D noiommu_domain_nop_attach, +}; + +static struct iommu_domain noiommu_identity_domain =3D { + .type =3D IOMMU_DOMAIN_IDENTITY, + .ops =3D &noiommu_nop_ops, +}; + +static struct iommu_domain noiommu_blocking_domain =3D { + .type =3D IOMMU_DOMAIN_BLOCKED, + .ops =3D &noiommu_nop_ops, +}; + +static bool noiommu_capable(struct device *dev, enum iommu_cap cap) +{ + switch (cap) { + /* Fake cache coherency support to allow iommufd-dev bind */ + case IOMMU_CAP_CACHE_COHERENCY: + return true; + default: + return false; + } +} + +static struct iommu_ops noiommu_ops =3D { + .default_domain =3D &noiommu_identity_domain, + .blocked_domain =3D &noiommu_blocking_domain, + .capable =3D noiommu_capable, + .domain_alloc_paging_flags =3D noiommu_domain_alloc_paging_flags, + .probe_device =3D noiommu_probe_device, + .release_device =3D noiommu_release_device, + .device_group =3D generic_device_group, + .owner =3D THIS_MODULE, + .default_domain_ops =3D &(const struct iommu_domain_ops) { + .attach_dev =3D noiommu_attach_dev, + .free =3D noiommu_domain_free, + } +}; + +struct notifier_block noiommu_bus_nb =3D { + /* data */ +}; + +static int iommu_noiommu_dev_add(struct device *dev, struct iommu_device *= iommu) +{ + return iommu_fwspec_init(dev, iommu->fwnode); +} + +static int __init noiommu_init(void) +{ + struct pci_dev *pdev =3D NULL; + + if (iommu_is_registered()) { + pr_info("IOMMU devices already registered, skipping No-IOMMU driver\n"); + return 0; + } + pr_debug("Initializing No-IOMMU driver\n"); + iommu_device_sysfs_add(&noiommu_dev.iommu, noiommu_dev.dev, NULL, + "%s", "noiommu"); + + if (iommu_device_register_bus(&noiommu_dev.iommu, &noiommu_ops, + &pci_bus_type, &noiommu_bus_nb)) + return -ENODEV; + + for_each_pci_dev(pdev) { + if (iommu_noiommu_dev_add(&pdev->dev, &noiommu_dev.iommu)) { + dev_err(&pdev->dev, "Failed to add no-IOMMU fwspec \n"); + continue; + } + iommu_probe_device(&pdev->dev); + dev_dbg(&pdev->dev, "Probed PCI device for no IOMMU\n"); + } + + return 0; +} +early_initcall(noiommu_init); + +static void __exit noiommu_exit(void) +{ + pr_debug("Exiting No-IOMMU driver\n"); + + /* No hardware resources to clean up */ + iommu_device_unregister(&noiommu_dev.iommu); + +} + +module_init(noiommu_init); +module_exit(noiommu_exit); + +MODULE_DESCRIPTION("No-IOMMU driver for PCI devices without hardware IOMMU= "); +MODULE_AUTHOR("Anonymous"); +MODULE_LICENSE("GPL v2"); \ No newline at end of file --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E3193385A0 for ; Mon, 1 Dec 2025 17:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610221; cv=none; b=J+GlVv4Ce/kaYpAtI2BejmAV1QwmwizxQKMUVhvKUmOqW8SIjRcf8FLIhwg4Mz5+u2gvByHNf9oZIdrDozr77KcMjJQy7X8W59Ey1ZaaiB4Sj4+gaHfuoSLKrS3IYyk8+HYSOYRd0NWba9s7C4kAWiQ/rpc9vOmPWl9+DZtYC6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610221; c=relaxed/simple; bh=FbNOAZU0TKAhX3Wq3/ciyXKedKyMzpckcHTC9mx8Wp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CoKU0PyA+tWTSl7Vpe+GlhVc6OiFDVAjIWBHB41g0auHfD+90Fn4bXPXr1QqktKV/ZkUQcV89J3QjHMQ+S6nC9xUqOwSbMd4mBeBJbZbXG6EFCEuM+Z+Hiux208OtE/YaJ8ElH9sOdbsHgj3DpMw9oaEj0paMqJ31jDMwqUKMCY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=l0Lls3Vo; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="l0Lls3Vo" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id E468C2065978; Mon, 1 Dec 2025 09:30:18 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E468C2065978 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610219; bh=dvomxELmbgUsVVEk5BX3KOjzWISlwhy4c5KxjdUoepY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0Lls3Vobt5W4SfRM6e8SjngoYYyvFQuVmVu4ogoL88V42/44vZXNPP/65MDRlgcI znWFTkAxZusrhnLmyAuky2fsdo8EBxRqr3n6Ze4EnPhEwl4PNxq7drsmiHXYi8uZPv DeAwqKbgngXEfj3p5sLds8JlssDXZ3ry1TSa7Yqo= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 5/8] vfio: IOMMUFD relax requirement for noiommu mode Date: Mon, 1 Dec 2025 09:30:09 -0800 Message-Id: <20251201173012.18371-6-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" noiommu device only has auto domain, does not need to attach to other ioas. Signed-off-by: Jacob Pan --- drivers/vfio/vfio_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 38c8e9350a60..805d30b0b82f 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -317,9 +317,7 @@ static int __vfio_register_dev(struct vfio_device *devi= ce, =20 if (WARN_ON(IS_ENABLED(CONFIG_IOMMUFD) && (!device->ops->bind_iommufd || - !device->ops->unbind_iommufd || - !device->ops->attach_ioas || - !device->ops->detach_ioas))) + !device->ops->unbind_iommufd))) return -EINVAL; =20 /* --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 066F8338907 for ; Mon, 1 Dec 2025 17:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610223; cv=none; b=jwsKRRJcBsM5/jw4U4ICWwrIqiTop7oYitxAtBacdHUG8SHQGnF2hfOa05elVNwbz7XP+bQtBdTFpW3BQxLNhnUEokEWS9NMmsSdtpDQek0MXVCMhrNgKgD0dzhnswQmtdUEFHykcUwMp/2KeQFgPQebJ+DnoS9XAJfee28xd2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610223; c=relaxed/simple; bh=7WcQI7ptM3Pq4VBxQhJMksQCk8jUX2k/LFJwgO0ZI8g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W3GatVrbaq5iQCke9R9shoUiT2B/70veiXX8FiMw8ppl2O11XdB7CoGRXvwmAjy//gwv0FsihaD22uGteeU+K9BTKYH4MBHpHa2O8NeebUHf2ejGUukGTBCI40uF07MNBg+C2oCa1+bTdRdxJ2kVSxWiuUgaX0mw+0E1UkxUf6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=qkIUwc96; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="qkIUwc96" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 8FB07206C15D; Mon, 1 Dec 2025 09:30:19 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8FB07206C15D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610219; bh=8qKnjYD9ftt2lodJmR4nVyYNpscAUqYpv2zFFnUYyL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkIUwc96rAqyfB5xWtP7o6lALu4plaSikYejniWaA9eDCcWvkgzBntnW0kBR6eYKY zx4lByQPvVpxVMZ38aRcKCbdpHUnRrE95YQsWfYMUL9kcUJSeOz6rMVEfgBDvlUAjb eQ34AG11T5Q24bcyjpXSfCF+pLLnPhzrx3lzR2C8= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 6/8] vfio: Rename and remove compat from noiommu set function Date: Mon, 1 Dec 2025 09:30:10 -0800 Message-Id: <20251201173012.18371-7-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With the dummy iommu driver, noiommu mode can be supported beyond vfio_compat mode under IOMMUFD. Rename it accordingly. Signed-off-by: Jacob Pan --- drivers/iommu/iommufd/vfio_compat.c | 6 +++--- drivers/vfio/group.c | 2 +- include/linux/iommufd.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/vfio_compat.c b/drivers/iommu/iommufd/vf= io_compat.c index a258ee2f4579..82630fe024a6 100644 --- a/drivers/iommu/iommufd/vfio_compat.c +++ b/drivers/iommu/iommufd/vfio_compat.c @@ -47,12 +47,12 @@ int iommufd_vfio_compat_ioas_get_id(struct iommufd_ctx = *ictx, u32 *out_ioas_id) EXPORT_SYMBOL_NS_GPL(iommufd_vfio_compat_ioas_get_id, "IOMMUFD_VFIO"); =20 /** - * iommufd_vfio_compat_set_no_iommu - Called when a no-iommu device is att= ached + * iommufd_vfio_set_no_iommu - Called when a no-iommu device is attached * @ictx: Context to operate on * * This allows selecting the VFIO_NOIOMMU_IOMMU and blocks normal types. */ -int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx) +int iommufd_vfio_set_no_iommu(struct iommufd_ctx *ictx) { int ret; =20 @@ -66,7 +66,7 @@ int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *= ictx) xa_unlock(&ictx->objects); return ret; } -EXPORT_SYMBOL_NS_GPL(iommufd_vfio_compat_set_no_iommu, "IOMMUFD_VFIO"); +EXPORT_SYMBOL_NS_GPL(iommufd_vfio_set_no_iommu, "IOMMUFD_VFIO"); =20 /** * iommufd_vfio_compat_ioas_create - Ensure the compat IOAS is created diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c index c376a6279de0..39fada00ef50 100644 --- a/drivers/vfio/group.c +++ b/drivers/vfio/group.c @@ -134,7 +134,7 @@ static int vfio_group_ioctl_set_container(struct vfio_g= roup *group, if (!IS_ERR(iommufd)) { if (IS_ENABLED(CONFIG_VFIO_NOIOMMU) && group->type =3D=3D VFIO_NO_IOMMU) - ret =3D iommufd_vfio_compat_set_no_iommu(iommufd); + ret =3D iommufd_vfio_set_no_iommu(iommufd); else ret =3D iommufd_vfio_compat_ioas_create(iommufd); =20 diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 6e7efe83bc5d..fb3bc387b78e 100644 --- a/include/linux/iommufd.h +++ b/include/linux/iommufd.h @@ -212,7 +212,7 @@ int iommufd_access_rw(struct iommufd_access *access, un= signed long iova, void *data, size_t len, unsigned int flags); int iommufd_vfio_compat_ioas_get_id(struct iommufd_ctx *ictx, u32 *out_ioa= s_id); int iommufd_vfio_compat_ioas_create(struct iommufd_ctx *ictx); -int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx); +int iommufd_vfio_set_no_iommu(struct iommufd_ctx *ictx); #else /* !CONFIG_IOMMUFD */ static inline struct iommufd_ctx *iommufd_ctx_from_file(struct file *file) { @@ -250,7 +250,7 @@ static inline int iommufd_vfio_compat_ioas_create(struc= t iommufd_ctx *ictx) return -EOPNOTSUPP; } =20 -static inline int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ict= x) +static inline int iommufd_vfio_set_no_iommu(struct iommufd_ctx *ictx) { return -EOPNOTSUPP; } --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F199F338912 for ; Mon, 1 Dec 2025 17:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610224; cv=none; b=NApYRaBzrq0QE1uAGD5JeKbRNmF6DPe9YmC8cCdbW0DJS1Bntgx+KAL8lZXQwQVzr6GVKX4NlQoKhAsDoe+lp75xTVprw2HfR9tk7IUJ1wuXJbsbTZfSSyBPZaJEuUkl/uYiRLaGnVoAugd/kL6wbGqUUbLk9L+OCwyNGm0mXz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610224; c=relaxed/simple; bh=M6PxvYcbQtgTVqxhyqWxq+FI4fpOdSGHx0xHT84Gkeo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XXq7YmbkpfXmCg+9yff7eVIstE9nRStG3+noU+IN2MIgEt7wN7OAFUbHT9j1DWINimWm+chbcmlVuql/HQlQvMCT2F3zH62nJGC4FRIbScWwL4EcSj8qA+zZklaxxn9R8oyBkqpmcv/tSHKayyq6Fw0qORil9ZhA59T20Wq4cJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=q3VXhqsP; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="q3VXhqsP" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 030D3206C15E; Mon, 1 Dec 2025 09:30:20 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 030D3206C15E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610221; bh=E9A85AITF9dX4jFtoh0xUotyG6bSXPomrnJpYCVxT5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3VXhqsPfdF6SpPPZ3bHxy2kO5zlbOIkxmzRhJyFXMatXEbZLoy7byDGnrb/v05Vd pDQYNDDNPGdTvlG5tGYiQGNMlPvsOR6E+1Rq9C3BCxZ+iYqQgypEIKWOVXtMqKsQ79 F2Yqzn2qplBtjpmMKCQRAw6MHL1RU2RO1vi8yFZg= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 7/8] iommu: Enable cdev noiommu mode under iommufd Date: Mon, 1 Dec 2025 09:30:11 -0800 Message-Id: <20251201173012.18371-8-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With an IOAS capable dummy IOMMU driver in place for noiommu mode, devices under noiommu mode can now bind with IOMMUFD and performe subsequent operations such as open, attach, and IOAS map/unmap. No IOMMU cdevs are explicitly named with noiommu prefix. e.g. /dev/vfio/ |-- 7 |-- devices | `-- noiommu-vfio0 `-- vfio Signed-off-by: Jacob Pan --- drivers/iommu/iommufd/hw_pagetable.c | 8 ++++++ drivers/vfio/Kconfig | 3 +-- drivers/vfio/device_cdev.c | 6 +++++ drivers/vfio/vfio.h | 38 +++++++++++++++++++++++++++- drivers/vfio/vfio_main.c | 16 +++++++++--- include/linux/vfio.h | 2 ++ 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/h= w_pagetable.c index fe789c2dc0c9..8bf76b2002b4 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -345,6 +345,14 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) struct iommufd_device *idev; int rc; =20 + /* + * For devices operating in no-IOMMU mode, permit only the automatic + * domain HWPT where auto domain uses generic iommupt to provide mock + * page tables. + */ + if (ucmd->ictx->no_iommu_mode) + return -EOPNOTSUPP; + if (cmd->__reserved) return -EOPNOTSUPP; if ((cmd->data_type =3D=3D IOMMU_HWPT_DATA_NONE && cmd->data_len) || diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index ceae52fd7586..7a06a4a9dabe 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -22,8 +22,7 @@ config VFIO_DEVICE_CDEV The VFIO device cdev is another way for userspace to get device access. Userspace gets device fd by opening device cdev under /dev/vfio/devices/vfioX, and then bind the device fd with an iommufd - to set up secure DMA context for device access. This interface does - not support noiommu. + to set up secure DMA context for device access. =20 If you don't know what to do here, say N. =20 diff --git a/drivers/vfio/device_cdev.c b/drivers/vfio/device_cdev.c index 480cac3a0c27..50724e3653ef 100644 --- a/drivers/vfio/device_cdev.c +++ b/drivers/vfio/device_cdev.c @@ -132,6 +132,12 @@ long vfio_df_ioctl_bind_iommufd(struct vfio_device_fil= e *df, goto out_unlock; } =20 + if (device->noiommu) { + ret =3D iommufd_vfio_set_no_iommu(df->iommufd); + if (ret) + goto out_unlock; + } + /* * Before the device open, get the KVM pointer currently * associated with the device file (if there is) and obtain diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index 50128da18bca..4c36de62a5f2 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -118,6 +118,19 @@ static inline bool vfio_device_is_noiommu(struct vfio_= device *vdev) return IS_ENABLED(CONFIG_VFIO_NOIOMMU) && vdev->group->type =3D=3D VFIO_NO_IOMMU; } + +static inline bool vfio_cdev_is_noiommu(struct vfio_device *vdev) +{ + return IS_ENABLED(CONFIG_NOIOMMU_MODE_IOMMU) && vfio_noiommu_enabled(); +} + +static inline int vfio_device_set_no_iommu(struct vfio_device *vdev) +{ + if (vfio_device_is_noiommu(vdev) || vfio_cdev_is_noiommu(vdev)) + vdev->noiommu =3D true; + + return 0; +} #else struct vfio_group; =20 @@ -193,6 +206,25 @@ static inline bool vfio_device_is_noiommu(struct vfio_= device *vdev) { return false; } + +static inline int vfio_device_set_no_iommu(struct vfio_device *vdev) +{ + struct iommu_group *iommu_group; + + /* Do not support group device noiommu mode simultaneously */ + if (iommu_group_get(vdev->dev)) { + vdev->noiommu =3D false; + iommu_group_put(iommu_group); + return -EINVAL; + } + + if (!IS_ENABLED(CONFIG_VFIO_NOIOMMU) || !vfio_noiommu) + return -EINVAL; + + vdev->noiommu =3D true; + + return 0; +} #endif /* CONFIG_VFIO_GROUP */ =20 #if IS_ENABLED(CONFIG_VFIO_CONTAINER) @@ -359,7 +391,11 @@ void vfio_init_device_cdev(struct vfio_device *device); =20 static inline int vfio_device_add(struct vfio_device *device) { - /* cdev does not support noiommu device */ + /* + * cdev does not support noiommu device for VFIO_NOIOMMU group type. + * However, under IOMMUFD with dummy iommu driver, noiommu mode is + * also supported for cdev devices. + */ if (vfio_device_is_noiommu(device)) return device_add(&device->device); vfio_init_device_cdev(device); diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 805d30b0b82f..c8aefa13bda3 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -60,6 +60,10 @@ bool vfio_noiommu __read_mostly; module_param_named(enable_unsafe_noiommu_mode, vfio_noiommu, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(enable_unsafe_noiommu_mode, "Enable UNSAFE, no-IOMMU mode= . This mode provides no device isolation, no DMA translation, no host kern= el protection, cannot be used for device assignment to virtual machines, re= quires RAWIO permissions, and will taint the kernel. If you do not know wh= at this is for, step away. (default: false)"); +bool vfio_noiommu_enabled(void) +{ + return vfio_noiommu; +} #endif =20 static DEFINE_XARRAY(vfio_device_set_xa); @@ -327,13 +331,19 @@ static int __vfio_register_dev(struct vfio_device *de= vice, if (!device->dev_set) vfio_assign_device_set(device, device); =20 - ret =3D dev_set_name(&device->device, "vfio%d", device->index); + ret =3D vfio_device_set_group(device, type); if (ret) return ret; =20 - ret =3D vfio_device_set_group(device, type); + ret =3D vfio_device_set_no_iommu(device); if (ret) - return ret; + goto err_out; + + /* Just to be safe, expose to user explicitly noiommu cdev node */ + ret =3D dev_set_name(&device->device, "%svfio%d", + device->noiommu ? "noiommu-" : "", device->index); + if (ret) + goto err_out; =20 /* * VFIO always sets IOMMU_CACHE because we offer no way for userspace to diff --git a/include/linux/vfio.h b/include/linux/vfio.h index eb563f538dee..944e74dc3da0 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -71,6 +71,7 @@ struct vfio_device { u8 iommufd_attached:1; #endif u8 cdev_opened:1; + u8 noiommu:1; #ifdef CONFIG_DEBUG_FS /* * debug_root is a static property of the vfio_device @@ -331,6 +332,7 @@ static inline bool vfio_file_has_dev(struct file *file,= struct vfio_device *devi return false; } #endif +bool vfio_noiommu_enabled(void); bool vfio_file_is_valid(struct file *file); bool vfio_file_enforced_coherent(struct file *file); void vfio_file_set_kvm(struct file *file, struct kvm *kvm); --=20 2.34.1 From nobody Mon Dec 1 20:54:53 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37015338F38 for ; Mon, 1 Dec 2025 17:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610225; cv=none; b=sNnZSy32KSiUBVfEtwTsRcSsYQBN479KDuLKQTgeCGE17xKAiwFfbl+BoEkY4hksvwZ0XDO4OPZlhCv5xE9vcWRXps3vGPA8EtROsUBp6tGL74qX3Nd0v01vsOKDmSOoztxM3wiyxYHNCL+7HYxJrujOS+/pEA340NC8D7eO5c8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764610225; c=relaxed/simple; bh=W4zrwr45dXYYcO7iKO41qJJddSemH0Ip/g+WpAV5llE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JoAJ89aG8CYJYn0JhitLXEfz6QBQXh2vZ8QfKbr5E45BUeMLVvTHRXJN45F4byAi/3qOFnGs2TgiWmGH3gGjI3KwtqwfNFP/pn2hIRE5s4lgzjsrVdMB3xrXTYf4DeuGzeKpgGAeYo4XoTlQqnRTA8vQ9loq9NKCQzaM2ImOc6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=YhQ4xPen; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="YhQ4xPen" Received: from DESKTOP-0403QTC.corp.microsoft.com (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id 08E3D20A10E4; Mon, 1 Dec 2025 09:30:21 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 08E3D20A10E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1764610222; bh=1Rfy6S/Akn9qX5xzf1fS1wP+nHDcp2JwJ+OdzpXMGjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhQ4xPenb1H0DuHYv7ki2rFRe3PrZgIrYf66XUJtCywQVqnP/q253mm1lzI5wT0wj t234UrrFz5aStnvZ9uowT6ftE5e3Bw+7i/GF9veo1fCUVTz53Tf5ntWVzna0puZ0tD 8T9Y5lnFA3AG5t8A7pFkbw3RWgNas1jCrN/PRzW0= From: Jacob Pan To: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , "Tian, Kevin" , "Liu, Yi L" Cc: skhawaja@google.com, pasha.tatashin@soleen.com, Jacob Pan , Zhang Yu , Jean Philippe-Brucker , David Matlack Subject: [RFC 8/8] iommufd: Add an ioctl IOMMU_IOAS_GET_PA to query PA from IOVA Date: Mon, 1 Dec 2025 09:30:12 -0800 Message-Id: <20251201173012.18371-9-jacob.pan@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> References: <20251201173012.18371-1-jacob.pan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To support no-IOMMU mode where userspace drivers perform unsafe DMA using physical addresses, introduce an new API to retrieve the physical address of a user-allocated DMA buffer that has been mapped to an IOVA via IOAS. The mapping is backed by mock I/O page tables maintained by generic IOMMUPT framework. Link: https://lore.kernel.org/linux-iommu/20250603175403.GA407344@nvidia.co= m/ Suggested-by: Jason Gunthorpe Signed-off-by: Jacob Pan --- drivers/iommu/iommufd/io_pagetable.c | 44 +++++++++++++++++++++++++ drivers/iommu/iommufd/ioas.c | 24 ++++++++++++++ drivers/iommu/iommufd/iommufd_private.h | 3 ++ drivers/iommu/iommufd/main.c | 3 ++ include/uapi/linux/iommufd.h | 25 ++++++++++++++ 5 files changed, 99 insertions(+) diff --git a/drivers/iommu/iommufd/io_pagetable.c b/drivers/iommu/iommufd/i= o_pagetable.c index c0360c450880..134a16acb44f 100644 --- a/drivers/iommu/iommufd/io_pagetable.c +++ b/drivers/iommu/iommufd/io_pagetable.c @@ -813,6 +813,50 @@ int iopt_unmap_iova(struct io_pagetable *iopt, unsigne= d long iova, return iopt_unmap_iova_range(iopt, iova, iova_last, unmapped); } =20 +int iopt_get_phys(struct io_pagetable *iopt, unsigned long iova, + phys_addr_t *paddr, u64 *length) +{ + unsigned long area_iova; + struct iopt_area *area; + unsigned long offset; + int rc =3D 0; + + down_read(&iopt->iova_rwsem); + area =3D iopt_area_iter_first(iopt, iova, iova); + if (!area || !area->pages) { + pr_warn("%s: No area for iova 0x%lx\n", __func__, iova); + rc =3D -ENOENT; + goto unlock_exit; + } + + if (!area->storage_domain) { + pr_warn("%s: area has no storage_domain\n", __func__); + rc =3D -EINVAL; + goto unlock_exit; + } + + area_iova =3D iopt_area_iova(area); + offset =3D iova - area_iova; + *paddr =3D iommu_iova_to_phys(area->storage_domain, iova); + if (!*paddr) { + pr_warn("%s: No paddr for iova 0x%lx\n", __func__, iova); + rc =3D -EINVAL; + goto unlock_exit; + } + /* + * TBD: we can return contiguous IOVA length so that userspace can + * keep searching for next physical address. + * e.g. + * iopt_area_length(area) - offset; + */ + *length =3D PAGE_SIZE; + +unlock_exit: + up_read(&iopt->iova_rwsem); + + return rc; +} + int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped) { int rc; diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c index 1542c5fd10a8..c11c5fce955a 100644 --- a/drivers/iommu/iommufd/ioas.c +++ b/drivers/iommu/iommufd/ioas.c @@ -377,6 +377,30 @@ int iommufd_ioas_unmap(struct iommufd_ucmd *ucmd) return rc; } =20 +int iommufd_ioas_get_pa(struct iommufd_ucmd *ucmd) +{ + struct iommu_ioas_get_pa *cmd =3D ucmd->cmd; + struct iommufd_ioas *ioas; + int rc; + + ioas =3D iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); + if (IS_ERR(ioas)) + return PTR_ERR(ioas); + + rc =3D iopt_get_phys(&ioas->iopt, cmd->iova, &cmd->phys, &cmd->length); + if (rc) { + pr_err("%s: Failed to get PA for IOVA 0x%llx length 0x%llx: %d\n", + __func__, cmd->iova, cmd->length, rc); + goto out_put; + } + + rc =3D iommufd_ucmd_respond(ucmd, sizeof(*cmd)); +out_put: + iommufd_put_object(ucmd->ictx, &ioas->obj); + + return rc; +} + static void iommufd_release_all_iova_rwsem(struct iommufd_ctx *ictx, struct xarray *ioas_list) { diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommuf= d/iommufd_private.h index 627f9b78483a..f74a0aea70bf 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -117,6 +117,8 @@ int iopt_map_pages(struct io_pagetable *iopt, struct li= st_head *pages_list, int iopt_unmap_iova(struct io_pagetable *iopt, unsigned long iova, unsigned long length, unsigned long *unmapped); int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped); +int iopt_get_phys(struct io_pagetable *iopt, unsigned long iova, + phys_addr_t *paddr, u64 *length); =20 int iopt_read_and_clear_dirty_data(struct io_pagetable *iopt, struct iommu_domain *domain, @@ -345,6 +347,7 @@ int iommufd_ioas_map_file(struct iommufd_ucmd *ucmd); int iommufd_ioas_change_process(struct iommufd_ucmd *ucmd); int iommufd_ioas_copy(struct iommufd_ucmd *ucmd); int iommufd_ioas_unmap(struct iommufd_ucmd *ucmd); +int iommufd_ioas_get_pa(struct iommufd_ucmd *ucmd); int iommufd_ioas_option(struct iommufd_ucmd *ucmd); int iommufd_option_rlimit_mode(struct iommu_option *cmd, struct iommufd_ctx *ictx); diff --git a/drivers/iommu/iommufd/main.c b/drivers/iommu/iommufd/main.c index ce775fbbae94..37e785d0e40d 100644 --- a/drivers/iommu/iommufd/main.c +++ b/drivers/iommu/iommufd/main.c @@ -432,6 +432,7 @@ union ucmd_buffer { struct iommu_veventq_alloc veventq; struct iommu_vfio_ioas vfio_ioas; struct iommu_viommu_alloc viommu; + struct iommu_ioas_get_pa get_pa; #ifdef CONFIG_IOMMUFD_TEST struct iommu_test_cmd test; #endif @@ -484,6 +485,8 @@ static const struct iommufd_ioctl_op iommufd_ioctl_ops[= ] =3D { struct iommu_ioas_map_file, iova), IOCTL_OP(IOMMU_IOAS_UNMAP, iommufd_ioas_unmap, struct iommu_ioas_unmap, length), + IOCTL_OP(IOMMU_IOAS_GET_PA, iommufd_ioas_get_pa, struct iommu_ioas_get_pa, + phys), IOCTL_OP(IOMMU_OPTION, iommufd_option, struct iommu_option, val64), IOCTL_OP(IOMMU_VDEVICE_ALLOC, iommufd_vdevice_alloc_ioctl, struct iommu_vdevice_alloc, virt_id), diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index c218c89e0e2e..915cb128f220 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -57,6 +57,7 @@ enum { IOMMUFD_CMD_IOAS_CHANGE_PROCESS =3D 0x92, IOMMUFD_CMD_VEVENTQ_ALLOC =3D 0x93, IOMMUFD_CMD_HW_QUEUE_ALLOC =3D 0x94, + IOMMUFD_CMD_IOAS_GET_PA =3D 0x95, }; =20 /** @@ -219,6 +220,30 @@ struct iommu_ioas_map { }; #define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP) =20 +/** + * struct iommu_ioas_get_pa - ioctl(IOMMU_IOAS_GET_PA) + * @size: sizeof(struct iommu_ioas_get_pa) + * @flags: TBD + * @ioas_id: IOAS ID to query IOVA to PA mapping from + * @__reserved: Must be 0 + * @iova: IOVA to query + * @length: Number of bytes contiguous physical address starting from phys + * @phys: Output physical address the IOVA maps to + * + * Query the physical address backing an IOVA range. The entire range must= be + * mapped already. For noiommu devices doing unsafe DMA only. + */ +struct iommu_ioas_get_pa { + __u32 size; + __u32 flags; + __u32 ioas_id; + __u32 __reserved; + __aligned_u64 iova; + __aligned_u64 length; + __aligned_u64 phys; +}; +#define IOMMU_IOAS_GET_PA _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_GET_PA) + /** * struct iommu_ioas_map_file - ioctl(IOMMU_IOAS_MAP_FILE) * @size: sizeof(struct iommu_ioas_map_file) --=20 2.34.1