From: Nicolin Chen <nicolinc@nvidia•com>
To: Will Deacon <will@kernel•org>
Cc: "Joerg Roedel" <joro@8bytes•org>,
"Jean-Philippe Brucker" <jpb@kernel•org>,
"Robin Murphy" <robin.murphy@arm•com>,
"Jason Gunthorpe" <jgg@nvidia•com>,
"Pranjal Shrivastava" <praan@google•com>,
"Catalin Marinas" <catalin.marinas@arm•com>,
"Mikołaj Lenczewski" <miko.lenczewski@arm•com>,
linux-arm-kernel@lists•infradead.org, iommu@lists•linux.dev,
linux-kernel@vger•kernel.org
Subject: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
Date: Sun, 3 May 2026 06:54:12 -0700 [thread overview]
Message-ID: <20260503135413.1108138-1-nicolinc@nvidia.com> (raw)
HTTU is introduced by utilizing the Dirty Bit Modifier (DBM) in the PTE.
When kernel maps a clean but writable page, it will set PTE_READONLY and
PTE_DBM (aka PTE_WRITE) at the same time. When a write occurs, an HTTU-
capable MMU will automatically clear the PTE_RDONLY bit without software
intervention.
On the other hand, SMMU has the same HTTU feature, yet it is not enabled
in the SVA CD. As a result, SMMU will not clear the PTE_RDONLY bit while
sharing the CPU page table, resulting in unnecessary stalls.
Thus, enable CTXDESC_CD_0_TCR_HA and CTXDESC_CD_0_TCR_HD in the SVA CD.
Suggested-by: Jason Gunthorpe <jgg@nvidia•com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia•com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
index f1f8e01a7e914..1ed8a6f29dc44 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
@@ -92,6 +92,16 @@ void arm_smmu_make_sva_cd(struct arm_smmu_cd *target,
target->data[1] = cpu_to_le64(virt_to_phys(mm->pgd) &
CTXDESC_CD_1_TTB0_MASK);
+
+ /*
+ * Enable Hardware Access and Dirty updates (DBM) if supported.
+ * This is safe to enable by default, as PTE_WRITE and PTE_DBM
+ * share the same bit.
+ */
+ if (master->smmu->features & ARM_SMMU_FEAT_HA)
+ target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA);
+ if (master->smmu->features & ARM_SMMU_FEAT_HD)
+ target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HD);
} else {
target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_EPD0);
--
2.43.0
next reply other threads:[~2026-05-03 13:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 13:54 Nicolin Chen [this message]
2026-05-07 22:30 ` [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Pranjal Shrivastava
2026-05-08 12:35 ` Jason Gunthorpe
2026-05-08 13:12 ` Pranjal Shrivastava
2026-05-08 13:27 ` Jason Gunthorpe
2026-05-08 13:31 ` Robin Murphy
2026-05-08 13:57 ` Pranjal Shrivastava
2026-05-08 14:24 ` Robin Murphy
2026-05-09 7:56 ` Nicolin Chen
2026-05-11 13:22 ` Pranjal Shrivastava
2026-05-13 11:42 ` Will Deacon
2026-05-13 14:27 ` Pranjal Shrivastava
2026-05-13 14:32 ` Jason Gunthorpe
2026-05-13 17:38 ` Pranjal Shrivastava
2026-05-11 13:21 ` Pranjal Shrivastava
2026-05-19 15:23 ` Will Deacon
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=20260503135413.1108138-1-nicolinc@nvidia.com \
--to=nicolinc@nvidia$(echo .)com \
--cc=catalin.marinas@arm$(echo .)com \
--cc=iommu@lists$(echo .)linux.dev \
--cc=jgg@nvidia$(echo .)com \
--cc=joro@8bytes$(echo .)org \
--cc=jpb@kernel$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=miko.lenczewski@arm$(echo .)com \
--cc=praan@google$(echo .)com \
--cc=robin.murphy@arm$(echo .)com \
--cc=will@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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