Re: [PATCH 17/17] PCI: Replace untrusted state with device trust

From: Aneesh Kumar K . V

Date: Mon Nov 16 2026 - 08:08:54 EST


Leon Romanovsky <leon@xxxxxxxxxx> writes:

> From: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> Convert the PCI specific untrusted to use the common device trust
> level. Adversarial means the same thing untrusted does.
>
> PCI discovery keeps the logic that set untrusted: it looks for removable
> PCI devices with arch_pci_dev_is_removable() and defaults them to an
> adversarial policy. Treat a disabled policy the same way when choosing
> the IOMMU domain. Do not record the ATS capability of such a device, as
> pci_ats_supported() rejected untrusted ones. Let the Intel write-buffer
> quirk apply, as it only adds flushing.
>

[ ... 28 lines skipped ... ]

> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 78742aeba932d..a48fb511bfe6f 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -589,16 +589,11 @@ static int iova_reserve_iommu_regions(struct device *dev,
> return ret;
> }
>
> -static bool dev_is_untrusted(struct device *dev)
> -{
> - return dev_is_pci(dev) && to_pci_dev(dev)->untrusted;
> -}
> -

[ ... 244 lines skipped ... ]

> diff --git a/include/linux/device.h b/include/linux/device.h
> index 65ea07c9ac35b..870ce14924905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -934,6 +934,11 @@ static inline bool device_iommu_mapped(struct device *dev)
> return (dev->iommu_group != NULL);
> }
>
> +static inline bool device_policy_is_adversarial(const struct device *dev)
> +{
> + return READ_ONCE(dev->trust_policy) == DEVICE_TRUST_POLICY_ADVERSARY;
> +}
> +
> /* Get the wakeup routines, which depend on struct device */
> #include <linux/pm_wakeup.h>
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index aa3765a20a96c..087c63b177c85 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -490,14 +490,6 @@ struct pci_dev {
> unsigned int shpc_managed:1; /* SHPC owned by shpchp */
> unsigned int is_thunderbolt:1; /* Thunderbolt controller */
> unsigned int is_cxl:1; /* Compute Express Link (CXL) */
> - /*
> - * Devices marked being untrusted are the ones that can potentially
> - * execute DMA attacks and similar. They are typically connected
> - * through external ports such as Thunderbolt but not limited to
> - * that. When an IOMMU is enabled they should be getting full
> - * mappings to make sure they cannot access arbitrary memory.
> - */
> - unsigned int untrusted:1;
> /*
> * Info from the platform, e.g., ACPI or device tree, may mark a
> * device as "external-facing". An external-facing device is
> @@ -616,6 +608,28 @@ static inline struct pci_dev *to_pci_dev(const struct device *dev)
> {
> return container_of(dev, struct pci_dev, dev);
> }
> +
> +static inline bool
> +pci_dev_default_is_restricted(const struct pci_dev *pdev)
> +{
> + enum device_trust_policy policy = READ_ONCE(pdev->dev.trust_policy);
> +
> + return policy == DEVICE_TRUST_POLICY_DISABLED ||
> + policy == DEVICE_TRUST_POLICY_ADVERSARY;
> +}
> +

Could you clarify how this series will work alongside device acceptance
and private-memory access?

In particular, what should callers of device_cc_accepted() use under
this model? My understanding is that trust describes the operating
policy, not TDISP acceptance or DMA access to private memory. Therefore,
neither FULL nor ADVERSARY alone indicates whether a device can access
private memory?

You also mention that once a trust level other than DISABLED is set, it
cannot be changed during the device's lifetime. If a device initially
operates in ADVERSARY mode and later attestation justifies FULL
operation, is that transition intentionally unsupported for the existing
device object? As documented, unbind/rebind and reset preserve the
committed level.

Some of these details are discussed in this thread:
https://lore.kernel.org/all/20260708143153.GH118978@xxxxxxxx/

It would help to describe how the trust framework fits together with
those separate mechanisms, including which pieces are left for follow-up
series.

-aneesh