From: Jason Gunthorpe <jgg@ziepe.ca>
To: Vasant Hegde <vashegde@amd.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
joro@8bytes.org, will@kernel.org, ewagner12@gmail.com,
suravee.suthikulpanit@amd.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, regressions@lists.linux.dev
Subject: Re: [PATCH] iommu: Fix def_domain_type interaction with untrusted devices
Date: Thu, 18 Apr 2024 09:02:24 -0300 [thread overview]
Message-ID: <20240418120224.GY223006@ziepe.ca> (raw)
In-Reply-To: <b014b871-1be0-4316-a72c-d699b8872604@amd.com>
On Thu, Apr 18, 2024 at 05:14:59PM +0530, Vasant Hegde wrote:
> We return IDENTITY only if SNP and memory encryption is not enabled and device
> is SVA capable. Upstream has below code (v6.9-rc4)
>
> if (pdev_pasid_supported(dev_data) &&
> !cc_platform_has(CC_ATTR_MEM_ENCRYPT) &&
> !amd_iommu_snp_en) {
> return IOMMU_DOMAIN_IDENTITY;
> }
>
>
> and during boot, we will enforce Paging domain when Encryption/SNP is enabled.
It is very confusing considering the comment says identity isn't supported:
* Do not identity map IOMMUv2 capable devices when:
* - memory encryption is active, because some of those devices
* (AMD GPUs) don't have the encryption bit in their DMA-mask
* and require remapping.
* - SNP is enabled, because it prohibits DTE[Mode]=0.
*/
Then it goes on to return IDENTITY anyhow.
If the HW cannot identity map it needs to return DMA for those cases:
/* SNP is enabled, because it prohibits DTE[Mode]=0, IDENTITY is not
* supported */
if (amd_snp_en)
return IOMMU_DOMAIN_DMA;
/* memory encryption is active, because some of those devices
* (AMD GPUs) don't have the encryption bit in their DMA-mask
* and require remapping. IDENTITY is not supported.
*/
if (cc_platform_has(CC_ATTR_MEM_ENCRYPT))
return IOMMU_DOMAIN_DMA;
> So far the policy was core layer to handle untrusted device which got changed
> and hence we hit this bug.
Well I would say the AMD driver changed to mis-use def_domain for
policy and that causes problems.
> I don't see any issue with enforcing these checks inside AMD driver.. If we go
> with this approach then IMO core should just adhere to what driver returned
> rather than failing. Having policy decision at two level is inviting trouble
> like this one.
Again, no policy in drivers.
def_domain should return only the HW capability. If it returns
IDENTITY then the driver must fail attaches of PAGING.
You should send a patch fixing this function and remove the PASID test
entirely for now.
Jason
next prev parent reply other threads:[~2024-04-18 12:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 13:00 [PATCH] iommu: Fix def_domain_type interaction with untrusted devices Robin Murphy
2024-04-16 14:33 ` Greg KH
2024-04-16 15:29 ` Jason Gunthorpe
2024-04-17 5:23 ` Vasant Hegde
2024-04-17 16:06 ` Jason Gunthorpe
2024-04-18 11:44 ` Vasant Hegde
2024-04-18 12:02 ` Jason Gunthorpe [this message]
2024-04-23 11:26 ` Robin Murphy
2024-04-24 13:04 ` Jason Gunthorpe
2024-04-24 14:05 ` Baolu Lu
2024-04-24 14:18 ` Baolu Lu
2024-04-24 14:37 ` Jason Gunthorpe
2024-04-25 1:41 ` Baolu Lu
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=20240418120224.GY223006@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=ewagner12@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=regressions@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vashegde@amd.com \
--cc=will@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox