From: Dmytro Maluka <dmaluka@chromium.org>
To: David Woodhouse <dwmw2@infradead.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
iommu@lists.linux.dev
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org,
"Vineeth Pillai (Google)" <vineeth@bitbyteword.org>,
Aashish Sharma <aashish@aashishsharma.net>,
Grzegorz Jaszczyk <jaszczyk@chromium.org>,
Chuanxiao Dong <chuanxiao.dong@intel.com>,
Kevin Tian <kevin.tian@intel.com>,
Dmytro Maluka <dmaluka@chromium.org>
Subject: [PATCH 2/2] iommu/vt-d: Use WRITE_ONCE for setting root table entries
Date: Sun, 21 Dec 2025 02:43:02 +0100 [thread overview]
Message-ID: <20251221014302.17738-3-dmaluka@chromium.org> (raw)
In-Reply-To: <20251221014302.17738-1-dmaluka@chromium.org>
Like context table entries in the previous patch, root table entries may
also be set up at runtime, when DMA translation is already enabled (e.g.
due to a device hotplug). So to stay on the safe side, use WRITE_ONCE
when setting a root table entry, to prevent the compiler from doing
store tearing which could result in setting the present bit earlier than
the context table address bits.
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
drivers/iommu/intel/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 134302fbcd92..fe4d0d210a5f 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -374,7 +374,7 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
__iommu_flush_cache(iommu, (void *)context, CONTEXT_SIZE);
phy_addr = virt_to_phys((void *)context);
- *entry = phy_addr | 1;
+ WRITE_ONCE(*entry, phy_addr | 1);
__iommu_flush_cache(iommu, entry, sizeof(*entry));
}
return &context[devfn];
--
2.47.3
prev parent reply other threads:[~2025-12-21 1:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-21 1:43 [PATCH 0/2] iommu/vt-d: Ensure memory ordering in context & root entry updates Dmytro Maluka
2025-12-21 1:43 ` [PATCH 1/2] iommu/vt-d: Ensure memory ordering in context " Dmytro Maluka
2025-12-21 9:04 ` Baolu Lu
2025-12-21 13:11 ` Dmytro Maluka
2025-12-23 6:10 ` Baolu Lu
2025-12-27 18:06 ` Dmytro Maluka
2025-12-21 1:43 ` Dmytro Maluka [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=20251221014302.17738-3-dmaluka@chromium.org \
--to=dmaluka@chromium.org \
--cc=aashish@aashishsharma.net \
--cc=baolu.lu@linux.intel.com \
--cc=chuanxiao.dong@intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jaszczyk@chromium.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=vineeth@bitbyteword.org \
--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