* [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
@ 2026-05-03 13:54 Nicolin Chen
2026-05-07 22:30 ` Pranjal Shrivastava
0 siblings, 1 reply; 9+ messages in thread
From: Nicolin Chen @ 2026-05-03 13:54 UTC (permalink / raw)
To: Will Deacon
Cc: Joerg Roedel, Jean-Philippe Brucker, Robin Murphy,
Jason Gunthorpe, Pranjal Shrivastava, Catalin Marinas,
Mikołaj Lenczewski, linux-arm-kernel, iommu, linux-kernel
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-03 13:54 [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Nicolin Chen
@ 2026-05-07 22:30 ` Pranjal Shrivastava
2026-05-08 12:35 ` Jason Gunthorpe
0 siblings, 1 reply; 9+ messages in thread
From: Pranjal Shrivastava @ 2026-05-07 22:30 UTC (permalink / raw)
To: Nicolin Chen
Cc: Will Deacon, Joerg Roedel, Jean-Philippe Brucker, Robin Murphy,
Jason Gunthorpe, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Sun, May 03, 2026 at 06:54:12AM -0700, Nicolin Chen wrote:
> 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);
IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
I think the driver maintains a clear distinction between HW capability
(FEAT_HA/HD) and feature enablement (IO_PGTABLE_QUIRK_ARM_HD).
We set IO_PGTABLE_QUIRK_ARM_HD during S1 domain finalize if
IOMMU_HWPT_ALLOC_DIRTY_TRACKING flag is passed. Hence, we should check
for that flag OR IO_PGTABLE_QUIRK_ARM_HD before enabling these in CD..
Thanks,
Praan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-07 22:30 ` Pranjal Shrivastava
@ 2026-05-08 12:35 ` Jason Gunthorpe
2026-05-08 13:12 ` Pranjal Shrivastava
0 siblings, 1 reply; 9+ messages in thread
From: Jason Gunthorpe @ 2026-05-08 12:35 UTC (permalink / raw)
To: Pranjal Shrivastava
Cc: Nicolin Chen, Will Deacon, Joerg Roedel, Jean-Philippe Brucker,
Robin Murphy, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote:
> > @@ -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);
>
> IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
SVA does not use IO_PGTABLE at all, and it directly constructs its own
CD.
No relation between those two flows.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
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
0 siblings, 2 replies; 9+ messages in thread
From: Pranjal Shrivastava @ 2026-05-08 13:12 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Nicolin Chen, Will Deacon, Joerg Roedel, Jean-Philippe Brucker,
Robin Murphy, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Fri, May 08, 2026 at 09:35:50AM -0300, Jason Gunthorpe wrote:
> On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote:
> > > @@ -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);
> >
> > IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
>
> SVA does not use IO_PGTABLE at all, and it directly constructs its own
> CD.
>
> No relation between those two flows.
I understand that but I mean we need to know if the system supports
HTTU ? Like for SMMU we use the IO_PGTABLE_QUIRK, shouldn't we be
checking if the CPU's tables support HTTU?
Are we assuming that if the SMMU IDR presents HTTU capability the MMU
would also have it? I think an unconditional enablement is risky as we
may not have system-wide HTTU support.
If we look at arm_smmu_master_sva_supported, the driver already
maintains a strict agreement between the CPU and SMMU for SVA.
It checks sanitized CPU ID registers for things like PARANGE & ASIDBITS,
and it uses system_supports_bbml2_noabort() to decide whether to enable
FEAT_BBML2.
Shouldn't we follow this exact same pattern for HTTU ?
We should probably be checking cpu_has_hw_af() (from asm/cpufeature.h)
in the SVA support check or here if we wanna enable HTTU.
Thanks,
Praan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-08 13:12 ` Pranjal Shrivastava
@ 2026-05-08 13:27 ` Jason Gunthorpe
2026-05-08 13:31 ` Robin Murphy
1 sibling, 0 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2026-05-08 13:27 UTC (permalink / raw)
To: Pranjal Shrivastava
Cc: Nicolin Chen, Will Deacon, Joerg Roedel, Jean-Philippe Brucker,
Robin Murphy, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Fri, May 08, 2026 at 01:12:56PM +0000, Pranjal Shrivastava wrote:
> Are we assuming that if the SMMU IDR presents HTTU capability the MMU
> would also have it? I think an unconditional enablement is risky as we
> may not have system-wide HTTU support.
Oh, yes! That is missing here it should not be turned on unless the
CPU side is also using it.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
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
1 sibling, 1 reply; 9+ messages in thread
From: Robin Murphy @ 2026-05-08 13:31 UTC (permalink / raw)
To: Pranjal Shrivastava, Jason Gunthorpe
Cc: Nicolin Chen, Will Deacon, Joerg Roedel, Jean-Philippe Brucker,
Catalin Marinas, Mikołaj Lenczewski, linux-arm-kernel, iommu,
linux-kernel
On 2026-05-08 2:12 pm, Pranjal Shrivastava wrote:
> On Fri, May 08, 2026 at 09:35:50AM -0300, Jason Gunthorpe wrote:
>> On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote:
>>>> @@ -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);
>>>
>>> IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
>>
>> SVA does not use IO_PGTABLE at all, and it directly constructs its own
>> CD.
>>
>> No relation between those two flows.
>
> I understand that but I mean we need to know if the system supports
> HTTU ? Like for SMMU we use the IO_PGTABLE_QUIRK, shouldn't we be
> checking if the CPU's tables support HTTU?
>
> Are we assuming that if the SMMU IDR presents HTTU capability the MMU
> would also have it? I think an unconditional enablement is risky as we
> may not have system-wide HTTU support.
>
> If we look at arm_smmu_master_sva_supported, the driver already
> maintains a strict agreement between the CPU and SMMU for SVA.
> It checks sanitized CPU ID registers for things like PARANGE & ASIDBITS,
> and it uses system_supports_bbml2_noabort() to decide whether to enable
> FEAT_BBML2.
>
> Shouldn't we follow this exact same pattern for HTTU ?
> We should probably be checking cpu_has_hw_af() (from asm/cpufeature.h)
> in the SVA support check or here if we wanna enable HTTU.
It might make sense to depend on CONFIG_ARM64_HW_AFDBM - when that is
enabled, then IIRC we already expect to cope with some CPUs not
supporting hardware updates, so it should still be fine for an SMMU to
make them even if no CPU does. However, if it's disabled then I'm not
sure if missing access flag faults (if SMMU HA silently sets them) might
be an issue - for dirty, we'd just never put down the Writeable-Clean
permission so enabling SMMU HD wouldn't do anything anyway.
Thanks,
Robin.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-08 13:31 ` Robin Murphy
@ 2026-05-08 13:57 ` Pranjal Shrivastava
2026-05-08 14:24 ` Robin Murphy
0 siblings, 1 reply; 9+ messages in thread
From: Pranjal Shrivastava @ 2026-05-08 13:57 UTC (permalink / raw)
To: Robin Murphy
Cc: Jason Gunthorpe, Nicolin Chen, Will Deacon, Joerg Roedel,
Jean-Philippe Brucker, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Fri, May 08, 2026 at 02:31:11PM +0100, Robin Murphy wrote:
> On 2026-05-08 2:12 pm, Pranjal Shrivastava wrote:
> > On Fri, May 08, 2026 at 09:35:50AM -0300, Jason Gunthorpe wrote:
> > > On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote:
> > > > > @@ -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);
> > > >
> > > > IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
> > >
> > > SVA does not use IO_PGTABLE at all, and it directly constructs its own
> > > CD.
> > >
> > > No relation between those two flows.
> >
> > I understand that but I mean we need to know if the system supports
> > HTTU ? Like for SMMU we use the IO_PGTABLE_QUIRK, shouldn't we be
> > checking if the CPU's tables support HTTU?
> >
> > Are we assuming that if the SMMU IDR presents HTTU capability the MMU
> > would also have it? I think an unconditional enablement is risky as we
> > may not have system-wide HTTU support.
> >
> > If we look at arm_smmu_master_sva_supported, the driver already
> > maintains a strict agreement between the CPU and SMMU for SVA.
> > It checks sanitized CPU ID registers for things like PARANGE & ASIDBITS,
> > and it uses system_supports_bbml2_noabort() to decide whether to enable
> > FEAT_BBML2.
> >
> > Shouldn't we follow this exact same pattern for HTTU ?
> > We should probably be checking cpu_has_hw_af() (from asm/cpufeature.h)
> > in the SVA support check or here if we wanna enable HTTU.
>
> It might make sense to depend on CONFIG_ARM64_HW_AFDBM - when that is
> enabled, then IIRC we already expect to cope with some CPUs not supporting
> hardware updates, so it should still be fine for an SMMU to make them even
> if no CPU does. However, if it's disabled then I'm not sure if missing
> access flag faults (if SMMU HA silently sets them) might be an issue - for
> dirty, we'd just never put down the Writeable-Clean permission so enabling
> SMMU HD wouldn't do anything anyway.
I see, so IIUC, you mean if IS_ENABLED(CONFIG_ARM64_HW_AFDBM) but CPU
doesn't enable HTTU, it is perfectly safe to let the SMMU do HTT updates,
Since the fault handlers are already expecting HW-triggered updates?
Which means our check would be something like:
if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) {
if (smmu->features & FEAT_HA)
...
}
instead of cpu_has_hw_af()?
Thanks,
Praan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-08 13:57 ` Pranjal Shrivastava
@ 2026-05-08 14:24 ` Robin Murphy
2026-05-09 7:56 ` Nicolin Chen
0 siblings, 1 reply; 9+ messages in thread
From: Robin Murphy @ 2026-05-08 14:24 UTC (permalink / raw)
To: Pranjal Shrivastava
Cc: Jason Gunthorpe, Nicolin Chen, Will Deacon, Joerg Roedel,
Jean-Philippe Brucker, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On 2026-05-08 2:57 pm, Pranjal Shrivastava wrote:
> On Fri, May 08, 2026 at 02:31:11PM +0100, Robin Murphy wrote:
>> On 2026-05-08 2:12 pm, Pranjal Shrivastava wrote:
>>> On Fri, May 08, 2026 at 09:35:50AM -0300, Jason Gunthorpe wrote:
>>>> On Thu, May 07, 2026 at 10:30:14PM +0000, Pranjal Shrivastava wrote:
>>>>>> @@ -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);
>>>>>
>>>>> IIUC, we should be setting these if IO_PGTABLE_QUIRK_ARM_HD is present?
>>>>
>>>> SVA does not use IO_PGTABLE at all, and it directly constructs its own
>>>> CD.
>>>>
>>>> No relation between those two flows.
>>>
>>> I understand that but I mean we need to know if the system supports
>>> HTTU ? Like for SMMU we use the IO_PGTABLE_QUIRK, shouldn't we be
>>> checking if the CPU's tables support HTTU?
>>>
>>> Are we assuming that if the SMMU IDR presents HTTU capability the MMU
>>> would also have it? I think an unconditional enablement is risky as we
>>> may not have system-wide HTTU support.
>>>
>>> If we look at arm_smmu_master_sva_supported, the driver already
>>> maintains a strict agreement between the CPU and SMMU for SVA.
>>> It checks sanitized CPU ID registers for things like PARANGE & ASIDBITS,
>>> and it uses system_supports_bbml2_noabort() to decide whether to enable
>>> FEAT_BBML2.
>>>
>>> Shouldn't we follow this exact same pattern for HTTU ?
>>> We should probably be checking cpu_has_hw_af() (from asm/cpufeature.h)
>>> in the SVA support check or here if we wanna enable HTTU.
>>
>> It might make sense to depend on CONFIG_ARM64_HW_AFDBM - when that is
>> enabled, then IIRC we already expect to cope with some CPUs not supporting
>> hardware updates, so it should still be fine for an SMMU to make them even
>> if no CPU does. However, if it's disabled then I'm not sure if missing
>> access flag faults (if SMMU HA silently sets them) might be an issue - for
>> dirty, we'd just never put down the Writeable-Clean permission so enabling
>> SMMU HD wouldn't do anything anyway.
>
> I see, so IIUC, you mean if IS_ENABLED(CONFIG_ARM64_HW_AFDBM) but CPU
> doesn't enable HTTU, it is perfectly safe to let the SMMU do HTT updates,
> Since the fault handlers are already expecting HW-triggered updates?
>
> Which means our check would be something like:
>
> if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) {
> if (smmu->features & FEAT_HA)
> ...
> }
>
> instead of cpu_has_hw_af()?
Hmm, looking closer, cpu_has_hw_af() is the thing which actually
influences mm behaviour (via arch_has_hw_pte_young and
arch_wants_old_prefaulted_pte), and that can still be false at runtime
if ARM64_HW_AFDBM is enabled but any CPU doesn't support HAFDBS, so
perhaps you were right the first time :)
Although AFAICS from __cpu_setup(), ARM64_HW_AFDBM will still
unconditionally enable TCR_EL1.HA on CPUs which do support it, so maybe
it is OK anyway?
Cheers,
Robin.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits
2026-05-08 14:24 ` Robin Murphy
@ 2026-05-09 7:56 ` Nicolin Chen
0 siblings, 0 replies; 9+ messages in thread
From: Nicolin Chen @ 2026-05-09 7:56 UTC (permalink / raw)
To: Robin Murphy
Cc: Pranjal Shrivastava, Jason Gunthorpe, Will Deacon, Joerg Roedel,
Jean-Philippe Brucker, Catalin Marinas, Mikołaj Lenczewski,
linux-arm-kernel, iommu, linux-kernel
On Fri, May 08, 2026 at 03:24:32PM +0100, Robin Murphy wrote:
> On 2026-05-08 2:57 pm, Pranjal Shrivastava wrote:
> > I see, so IIUC, you mean if IS_ENABLED(CONFIG_ARM64_HW_AFDBM) but CPU
> > doesn't enable HTTU, it is perfectly safe to let the SMMU do HTT updates,
> > Since the fault handlers are already expecting HW-triggered updates?
> >
> > Which means our check would be something like:
> >
> > if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) {
> > if (smmu->features & FEAT_HA)
> > ...
> > }
> >
> > instead of cpu_has_hw_af()?
>
> Hmm, looking closer, cpu_has_hw_af() is the thing which actually influences
> mm behaviour (via arch_has_hw_pte_young and arch_wants_old_prefaulted_pte),
> and that can still be false at runtime if ARM64_HW_AFDBM is enabled but any
> CPU doesn't support HAFDBS, so perhaps you were right the first time :)
IIUIC, v2 should be:
+ /*
+ * Enable Hardware Access and Dirty updates (DBM) if supported by
+ * both the SMMU and the CPU. It is unsafe to enable SMMU's HTTU,
+ * if the CPU does not support it as it bypasses mm page aging.
+ */
+ if (cpu_has_hw_af()) {
+ 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);
+ }
Thanks
Nicolin
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-05-09 7:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 13:54 [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Nicolin Chen
2026-05-07 22:30 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox