From: Jason Gunthorpe <jgg@ziepe.ca>
To: Vasant Hegde <vasant.hegde@amd.com>
Cc: iommu@lists.linux.dev, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, suravee.suthikulpanit@amd.com,
Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
stable@vger.kernel.org, Joao Martins <joao.m.martins@oracle.com>
Subject: Re: [PATCH] iommu/amd/pgtbl: Fix possible race while increase page table level
Date: Mon, 22 Sep 2025 10:02:19 -0300 [thread overview]
Message-ID: <20250922130219.GX1326709@ziepe.ca> (raw)
In-Reply-To: <c09b3679-00f9-43e8-a620-1a6051cc6db3@amd.com>
On Mon, Sep 22, 2025 at 03:35:07PM +0530, Vasant Hegde wrote:
> > IMHO unless someone is actually hitting this I'd leave it and focus on
> > merging iomupt which fully fixes this without adding any locks to the
> > fast path.
>
> Unfortunately yes. We had customer reporting this issue.
If a customer is actually hitting this then you definately need to
solve the whole problem including the mmap race.
I guess adding a lock makes it easer to deal with, but this:
+ write_seqcount_begin(&pgtable->seqcount);
pgtable->root = pte;
pgtable->mode += 1;
+ write_seqcount_end(&pgtable->seqcount);
+
amd_iommu_update_and_flush_device_table(domain);
Is out of order.
The DTE has to be updated and caches flushed *before* writing the new
information to the pgtable for other threads to observe.
You can look at what I did, but broadly you have to feed the new top
as a function argument through to set_dte:
static void set_dte_entry(struct amd_iommu *iommu,
- struct iommu_dev_data *dev_data)
+ struct iommu_dev_data *dev_data,
+ phys_addr_t top_paddr, unsigned int top_level)
{
u16 domid;
So the above can be ordered correctly.
You may also want to think about just disabling this optimization,
always start with a 6 level table.
Jason
prev parent reply other threads:[~2025-09-22 13:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 12:14 [PATCH] iommu/amd/pgtbl: Fix possible race while increase page table level Vasant Hegde
2025-09-13 6:10 ` Jörg Rödel
2025-09-13 6:18 ` Vasant Hegde
2025-09-18 14:17 ` Jason Gunthorpe
2025-09-22 10:05 ` Vasant Hegde
2025-09-22 13:02 ` Jason Gunthorpe [this message]
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=20250922130219.GX1326709@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=alejandro.j.jimenez@oracle.com \
--cc=iommu@lists.linux.dev \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@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