OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1] iommu/amd/pgtbl: fix DMA faults on IOVAs mapped while the table grows
Date: Tue, 10 Nov 2026 18:53:29 +0100	[thread overview]
Message-ID: <179433320943.3571692.9638725304344595705.b4-review@b4> (raw)
In-Reply-To: <20261110164529.2794752-1-den@openvz.org>

Applying with these fixes on my side:
- "grows to 6" -> "grows up to 6"
- the second paragraph split in two: when the table grows, and what a
  faulting read and write do, as a "- " list

On Tue, 10 Nov 2026 17:45:29 +0100, Denis V. Lunev wrote:
> The v1 table starts with 3 levels and grows to 6 on the first IOVA
> dma-iommu takes from the top of the 64-bit space, once the 32-bit space
> runs out.

The table stops at amd_iommu_hpt_level. On parts whose EFR[HATS] allows
only 4 or 5 levels it never reaches 6, and the race is the same there.

> -	write_seqcount_end(&pgtable->seqcount);
> -
>  	amd_iommu_update_and_flush_device_table(domain);
> +	write_seqcount_end(&pgtable->seqcount);

- Please send a separate backport of upstream 1e75a8255f11c ("iommu/amd:
  Wait for completion instead of returning early in
  iommu_completion_wait()"). I created a task for that:
  https://virtuozzo.atlassian.net/browse/VSTOR-154424

This fix relies on domain_flush_complete() having waited for the DTE
invalidation before write_seqcount_end(). In vz10
iommu_completion_wait() still tests need_sync without iommu->lock.

If another CPU queues a completion wait on the same IOMMU right after
our invalidation, it clears need_sync. Our wait then returns before the
IOMMU has run the invalidation, and a mapper can hand out a 64-bit IOVA
while the old DTE is still cached.

The window is much smaller than the one this patch closes, but it opens
under the same heavy DMA load. The stable trees have the fix, vz10 does
not yet. It needs a small adaptation, cmd_sem_val is still an atomic64_t
here.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-10 17:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 16:45 Denis V. Lunev
2026-11-10 16:53 ` no-reply
2026-11-10 16:56   ` Denis V. Lunev
2026-11-10 17:53 ` Konstantin Khorenko [this message]
2026-11-10 17:53 ` Konstantin Khorenko

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=179433320943.3571692.9638725304344595705.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=devel@openvz.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