Re: [PATCH RFC 1/9] iommu: Introduce external attach domain type

From: Mostafa Saleh

Date: Wed Oct 21 2026 - 07:00:45 EST


On Fri, Sep 25, 2026 at 12:07:34PM -0700, Jacob Pan wrote:
> Add IOMMU_DOMAIN_EXTERNAL for externally managed domains that move or
> attach devices to another VM address space provisioned by an external
> owner, such as a type 1 hypervisor.
>
> This is not a paging domain and is not sysfs-selectable as a default
> domain type. It requires external owner context, such as a vIOMMU.
>

Can't we use a IOMMU_DOMAIN_BLOCKED domain for that, AFAIU, the host never
inserts any mapping?

Thanks,
Mostafa

> PV IOMMU drivers are expected to use it when moving a device to a guest
> VM with an already-created S2 IOPT.
>
> Assisted-by: GPT-5.6 Sol
> Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/iommu/iommu.c | 2 ++
> include/linux/iommu.h | 9 +++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index cd1bca7ede9a..d0bd3ef00379 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -220,6 +220,8 @@ static const char *iommu_domain_type_str(unsigned int t)
> return "Translated";
> case IOMMU_DOMAIN_PLATFORM:
> return "Platform";
> + case IOMMU_DOMAIN_EXTERNAL:
> + return "External";
> default:
> return "Unknown";
> }
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index ac43b8b93f14..ede77b90f0fd 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -188,6 +188,7 @@ enum iommu_domain_cookie_type {
>
> #define __IOMMU_DOMAIN_NESTED (1U << 6) /* User-managed address space nested
> on a stage-2 translation */
> +#define __IOMMU_DOMAIN_EXTERNAL (1U << 7) /* Externally managed translation */
>
> #define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ
> /*
> @@ -207,6 +208,13 @@ enum iommu_domain_cookie_type {
> * represented by mm_struct's.
> * IOMMU_DOMAIN_PLATFORM - Legacy domain for drivers that do their own
> * dma_api stuff. Do not use in new drivers.
> + * IOMMU_DOMAIN_EXTERNAL - Externally managed domain for moving/attaching
> + * devices to another VM address space
> + * provisioned by the external owner, such as
> + * a type 1 hypervisor. This is not a
> + * sysfs-selectable default domain type; it
> + * requires external owner context such as a
> + * vIOMMU.
> */
> #define IOMMU_DOMAIN_BLOCKED (0U)
> #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT)
> @@ -219,6 +227,7 @@ enum iommu_domain_cookie_type {
> #define IOMMU_DOMAIN_SVA (__IOMMU_DOMAIN_SVA)
> #define IOMMU_DOMAIN_PLATFORM (__IOMMU_DOMAIN_PLATFORM)
> #define IOMMU_DOMAIN_NESTED (__IOMMU_DOMAIN_NESTED)
> +#define IOMMU_DOMAIN_EXTERNAL (__IOMMU_DOMAIN_EXTERNAL)
>
> struct iommu_domain {
> unsigned type;
> --
> 2.43.0
>
>