All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Vasant Hegde <vasant.hegde@amd.com>,
	iommu@lists.linux.dev, joro@8bytes.org
Cc: suravee.suthikulpanit@amd.com, alexander.deucher@amd.com,
	baolu.lu@linux.intel.com, Eric Wagner <ewagner12@gmail.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	stable@kernel.org
Subject: Re: [PATCH v2] iommu/amd: Enhance def_domain_type to handle untrusted device
Date: Tue, 23 Apr 2024 12:26:03 +0100	[thread overview]
Message-ID: <6552a5bb-0481-4a0c-a587-84275ab3a179@arm.com> (raw)
In-Reply-To: <20240423111725.5813-1-vasant.hegde@amd.com>

On 23/04/2024 12:17 pm, Vasant Hegde wrote:
> Previously, IOMMU core layer was forcing IOMMU_DOMAIN_DMA domain for
> untrusted device. This always took precedence over driver's
> def_domain_type(). Commit 59ddce4418da ("iommu: Reorganize
> iommu_get_default_domain_type() to respect def_domain_type()") changed
> the behaviour. Current code calls def_domain_type() but if it doesn't
> return IOMMU_DOMAIN_DMA for untrusted device it throws error. This
> results in IOMMU group (and potentially IOMMU itself) in undetermined
> state.
> 
> This patch adds untrusted check in AMD IOMMU driver code. So that it
> allows eGPUs behind Thunderbolt work again.

Sorry, but I firmly disagree with this approach - regardless of what the 
AMD driver is currently doing and how appropriate it may or may not be, 
we should not be duplicating core code policy in drivers, and we 
certainly shouldn't be doing so to bodge around a breakage in how the 
core code implements said policy.

Thanks,
Robin.

> Fine tuning amd_iommu_def_domain_type() will be done later.
> 
> Reported-by: Eric Wagner <ewagner12@gmail.com>
> Link: https://lore.kernel.org/linux-iommu/CAHudX3zLH6CsRmLE-yb+gRjhh-v4bU5_1jW_xCcxOo_oUUZKYg@mail.gmail.com
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3182
> Fixes: 59ddce4418da ("iommu: Reorganize iommu_get_default_domain_type() to respect def_domain_type()")
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: stable@kernel.org # v6.7+
> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
> ---
> Changes in v2:
>    - Added dev_is_pci() check - Thanks Lu Baolu
> 
> -Vasant
> 
>   drivers/iommu/amd/iommu.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index e692217fcb28..fb727f5b0b82 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2754,6 +2754,10 @@ static int amd_iommu_def_domain_type(struct device *dev)
>   	if (!dev_data)
>   		return 0;
>   
> +	/* Always use DMA domain for untrusted device */
> +	if (dev_is_pci(dev) && to_pci_dev(dev)->untrusted)
> +		return IOMMU_DOMAIN_DMA;
> +
>   	/*
>   	 * Do not identity map IOMMUv2 capable devices when:
>   	 *  - memory encryption is active, because some of those devices

  reply	other threads:[~2024-04-23 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 11:17 [PATCH v2] iommu/amd: Enhance def_domain_type to handle untrusted device Vasant Hegde
2024-04-23 11:26 ` Robin Murphy [this message]
2024-04-24  8:11   ` Vasant Hegde
2024-04-24 13:08     ` Jason Gunthorpe
2024-04-26 10:11 ` Joerg Roedel

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=6552a5bb-0481-4a0c-a587-84275ab3a179@arm.com \
    --to=robin.murphy@arm.com \
    --cc=alexander.deucher@amd.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=ewagner12@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=stable@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.