Re: [PATCH v4 3/6] KVM: arm64: Add auto DBM support for hardware dirty tracking
From: Tian Zheng
Date: Tue Jul 14 2026 - 03:46:12 EST
On 7/14/2026 3:23 PM, Marc Zyngier wrote:
On Tue, 14 Jul 2026 02:14:45 +0100,Got it, thanks for the clarification, Marc.
Tian Zheng <zhengtian10@xxxxxxxxxx> wrote:
You really can't do that. Only Leo can give his SoB, you can't forge
On 7/13/2026 7:17 PM, Leonardo Bras wrote:
On Thu, Jul 09, 2026 at 06:40:23PM +0800, Tian Zheng wrote:Hi Leo,
The DBM (Dirty Bit Modifier) attribute, introduced in ARMv8.1, enablesHello Tian,
hardware to automatically promote write-clean pages to write-dirty. This
prevents the guest from being trapped in EL2 due to missing write
permissions.
In this design, DBM is controlled by the page-table level flag
KVM_PGTABLE_S2_DBM rather than per-PTE software flags. DBM is
automatically set for writable non-device pages when the page-table has
KVM_PGTABLE_S2_DBM flag, which is determined at MMU init time based on
hardware capability.
The DBM bit is set in stage2_set_prot_attr() for initial mappings and
hugepage splitting, and directly manipulated in
kvm_pgtable_stage2_relax_perms() when removing write-protection. On
W->RO downgrade, DBM is cleared to prevent hardware from silently
upgrading RO+DBM back to W+dirty, which would bypass KVM's write
tracking.
kvm_pgtable_stage2_pte_prot() does not extract the DBM bit back into
enum kvm_pgtable_prot because DBM is a page-table policy determined by
pgt->flags, not a per-PTE property. Callers should check
pgt->flags & KVM_PGTABLE_S2_DBM instead.
This ensures DBM is consistently applied across all PTEs, including
during hugepage splitting where child PTEs inherit DBM from the parent
block entry via the pgt->flags mechanism.
Safety: DBM bit is only interpreted by hardware when VTCR_EL2.HD=1.
When HDBSS is not enabled (HD=0), ARM architecture guarantees hardware
completely ignores DBM bit in PTEs.
Co-developed-by: Eillon <yezhenyu2@xxxxxxxxxx>
Signed-off-by: Eillon <yezhenyu2@xxxxxxxxxx>
Co-developed-by: Leonardo Bras <leo.bras@xxxxxxx>
Signed-off-by: Leonardo Bras <leo.bras@xxxxxxx>
Have you added the above tags due to this patch being based on the below?
https://lore.kernel.org/all/20260629111820.1873540-2-leo.bras@xxxxxxx/
Thanks!
Leo
Yes, I added your Signed-off-by because the DBM-related code in this patch
it yourself.
is based on your implementation in:Then take the patch as is, and add to it as a separate patch. Or work
https://lore.kernel.org/all/20260629111820.1873540-2-leo.bras@xxxxxxx/
out in private with Leo whether he's happy with a Co-dev. But never do
that unilaterally.
Thanks,
M.
I'm sorry about that — I'll remove them in the next version.
Instead, I'll mention the reference in the commit message with a link to Leo's original patch:
Based on Leonardo Bras's patch:
https://lore.kernel.org/all/20260629111820.1873540-2-leo.bras@xxxxxxx/