linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Mostafa Saleh <smostafa@google.com>,
	Sairaj Kodilkar <sarunkod@amd.com>,
	suravee.suthikulpanit@amd.com
Cc: Nicolin Chen <nicolinc@nvidia.com>,
	will@kernel.org, robin.murphy@arm.com, joro@8bytes.org,
	linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, skolothumtho@nvidia.com,
	praan@google.com, xueshuai@linux.alibaba.com
Subject: Re: [PATCH rc v4 3/4] iommu/arm-smmu-v3: Mark STE EATS safe when computing the update sequence
Date: Fri, 2 Jan 2026 14:51:08 -0400	[thread overview]
Message-ID: <20260102185108.GD125162@nvidia.com> (raw)
In-Reply-To: <aVgM9ZNOmK6MdaNa@google.com>

On Fri, Jan 02, 2026 at 06:22:45PM +0000, Mostafa Saleh wrote:

> Looking at the code in arm-smmu-v3-iommufd and iommufd/device.c, it
> seems ATS enable will only change at attach.
> Looking into arm_smmu_attach_commit(), I see the ATC is invalidated
> after the STE is installed, which means that userspace can transiently
> observe the old domain ATC. I think that's fine at the moment because
> when binding to a VFIO driver, it will attach to an empty domain.

Yeah, it is a bit confusing..

The PCI ATS flag in the config space must exclusively be controlled by
the IOMMU driver. We must not allow the PCI device to turn on ATS
while the IOMMU driver is not synchronized and able to issue flushes,
otherwise we can have cache inconsistencies.

This goes both ways, we can't allow the hypervisor to turn on ATS
unless the VM is aware and is issuing flushes for its S1, and we can't
have the VM turn on ATS unless the hypervisor is aware and issuing
flushes for its S2.

Thus, for a VM the vPCI config space for ATS is ignored by HW, and the
VM controls ATS ONLY through the vSTE EATS bit.

Only once the VM enables EATS do we get to turn on the PCI config
space ATS.

All the detail I explains before holds because all the ATS switching
logic in the drvier is designed to ensure no invalidations are lost,
regardless of what two domains are being switched between. At worst
you get a transient moment during switching when the ATC hold a page
that is either new/old domain - but that is resolved before the domain
switch completes.

AMD folks, this whole explanation in this thread applies to the AMD
driver too, it currently has wrong ATS for virtualization, and fixing
it means make it work like ARM.. It will need to be fixed to complete
the VIOMMU work.

Jason

  reply	other threads:[~2026-01-02 18:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17  4:25 [PATCH rc v4 0/4] iommu/arm-smmu-v3: Fix hitless STE update in nesting cases Nicolin Chen
2025-12-17  4:25 ` [PATCH rc v4 1/4] iommu/arm-smmu-v3: Add update_safe bits to fix STE update sequence Nicolin Chen
2025-12-18 16:40   ` Mostafa Saleh
2025-12-19  6:05     ` Nicolin Chen
2025-12-17  4:26 ` [PATCH rc v4 2/4] iommu/arm-smmu-v3: Mark STE MEV safe when computing the " Nicolin Chen
2025-12-18 16:40   ` Mostafa Saleh
2025-12-17  4:26 ` [PATCH rc v4 3/4] iommu/arm-smmu-v3: Mark STE EATS " Nicolin Chen
2025-12-18 16:42   ` Mostafa Saleh
2025-12-18 17:32     ` Nicolin Chen
2025-12-18 18:01       ` Jason Gunthorpe
2026-01-02 18:22         ` Mostafa Saleh
2026-01-02 18:51           ` Jason Gunthorpe [this message]
2025-12-17  4:26 ` [PATCH rc v4 4/4] iommu/arm-smmu-v3-test: Add nested s1bypass/s1dssbypass coverage Nicolin Chen
2025-12-18 16:47   ` Mostafa Saleh
2025-12-18 17:35     ` Nicolin Chen

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=20260102185108.GD125162@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=praan@google.com \
    --cc=robin.murphy@arm.com \
    --cc=sarunkod@amd.com \
    --cc=skolothumtho@nvidia.com \
    --cc=smostafa@google.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    --cc=xueshuai@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).