lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251029095846.4486-1-sarunkod@amd.com>
Date: Wed, 29 Oct 2025 15:28:46 +0530
From: Sairaj Kodilkar <sarunkod@....com>
To: <joro@...tes.org>, <suravee.suthikulpanit@....com>, <will@...nel.org>,
	<robin.murphy@....com>, <jgg@...pe.ca>, <kevin.tian@...el.com>,
	<iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
	<vasant.hegde@....com>
CC: Sairaj Kodilkar <sarunkod@....com>
Subject: [RFC PATCH] iommu/amd: Add control register in `struct iommu_hw_info_amd`

When user does IOMMU_GET_HW_INFO ioctl, read the IOMMU control
register (MMIO offset 0x0018) and return it as part of
`struct iommu_hw_info_amd`.

Userspace can use this information to determine the features
supported by the underlying host kernel.

Signed-off-by: Sairaj Kodilkar <sarunkod@....com>
---

The patch exposes the control register to the user space so that QEMU
can determine the list of features enabled by the host IOMMU driver
when there are passthrough devices. QEMU can use this information to
selectively enable the guest feature. One example of such feature is
enabling upto 2048 MSIs for passthrough devices. QEMU must not enable
this feature for passthrough devices when host IOMMU driver has not
enabled it.

The patch is based on top v6.17 (e5f0a698b34e) and patch [1] by Suravee

[1] https://lore.kernel.org/linux-iommu/20250926141901.511313-1-suravee.suthikulpanit@amd.com/

---

 drivers/iommu/amd/iommufd.c  | 3 +++
 include/uapi/linux/iommufd.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/iommu/amd/iommufd.c b/drivers/iommu/amd/iommufd.c
index 72eaaa923d04..83f34fc77ae8 100644
--- a/drivers/iommu/amd/iommufd.c
+++ b/drivers/iommu/amd/iommufd.c
@@ -12,6 +12,7 @@
 void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
 {
 	struct iommu_hw_info_amd *hwinfo;
+	struct amd_iommu *iommu = get_amd_iommu_from_dev(dev);
 
 	if (*type != IOMMU_HW_INFO_TYPE_DEFAULT &&
 	    *type != IOMMU_HW_INFO_TYPE_AMD)
@@ -26,6 +27,8 @@ void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
 
 	hwinfo->efr = amd_iommu_efr;
 	hwinfo->efr2 = amd_iommu_efr2;
+	hwinfo->control_register = readq(iommu->mmio_base
+					 + MMIO_CONTROL_OFFSET);
 
 	return hwinfo;
 }
diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
index efb52709c0a2..9435b2d877e7 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -637,6 +637,7 @@ struct iommu_hw_info_tegra241_cmdqv {
 struct iommu_hw_info_amd {
 	__aligned_u64 efr;
 	__aligned_u64 efr2;
+	__aligned_u64 control_register;
 };
 
 /**
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ