public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Leonardo Bras <leo.bras@arm.com>
Cc: Tian Zheng <zhengtian10@huawei.com>,
	oliver.upton@linux.dev, catalin.marinas@arm.com, corbet@lwn.net,
	pbonzini@redhat.com, will@kernel.org,
	linux-kernel@vger.kernel.org, yuzenghui@huawei.com,
	wangzhou1@hisilicon.com, yezhenyu2@huawei.com,
	xiexiangyou@huawei.com, zhengchuan@huawei.com,
	linuxarm@huawei.com, joey.gouly@arm.com, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-doc@vger.kernel.org, suzuki.poulose@arm.com
Subject: Re: [PATCH v2 2/5] KVM: arm64: Support set the DBM attr during memory abort
Date: Thu, 29 Jan 2026 18:48:51 +0000	[thread overview]
Message-ID: <867bt0b6gc.wl-maz@kernel.org> (raw)
In-Reply-To: <aXuSsVKtXBcffzo2@devkitleo>

On Thu, 29 Jan 2026 17:02:41 +0000,
Leonardo Bras <leo.bras@arm.com> wrote:
> 
> On Fri, Nov 21, 2025 at 05:23:39PM +0800, Tian Zheng wrote:
> > From: eillon <yezhenyu2@huawei.com>
> > 
> > Add DBM support to automatically promote write-clean pages to
> > write-dirty, preventing users from being trapped in EL2 due to
> > missing write permissions.
> > 
> > Since the DBM attribute was introduced in ARMv8.1 and remains
> > optional in later architecture revisions, including ARMv9.5.
> > 
> > Support set the DBM attr during user_mem_abort().
> > 
> > Signed-off-by: eillon <yezhenyu2@huawei.com>
> > Signed-off-by: Tian Zheng <zhengtian10@huawei.com>
> > ---
> >  arch/arm64/include/asm/kvm_pgtable.h | 4 ++++
> >  arch/arm64/kvm/hyp/pgtable.c         | 6 ++++++
> >  2 files changed, 10 insertions(+)
> > 
> > diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
> > index 2888b5d03757..2fa24953d1a6 100644
> > --- a/arch/arm64/include/asm/kvm_pgtable.h
> > +++ b/arch/arm64/include/asm/kvm_pgtable.h
> > @@ -91,6 +91,8 @@ typedef u64 kvm_pte_t;
> > 
> >  #define KVM_PTE_LEAF_ATTR_HI_S2_XN	BIT(54)
> > 
> > +#define KVM_PTE_LEAF_ATTR_HI_S2_DBM	BIT(51)
> > +
> >  #define KVM_PTE_LEAF_ATTR_HI_S1_GP	BIT(50)
> > 
> >  #define KVM_PTE_LEAF_ATTR_S2_PERMS	(KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \
> > @@ -245,6 +247,7 @@ enum kvm_pgtable_stage2_flags {
> >   * @KVM_PGTABLE_PROT_R:		Read permission.
> >   * @KVM_PGTABLE_PROT_DEVICE:	Device attributes.
> >   * @KVM_PGTABLE_PROT_NORMAL_NC:	Normal noncacheable attributes.
> > + * @KVM_PGTABLE_PROT_DBM:	Dirty bit management attribute.
> >   * @KVM_PGTABLE_PROT_SW0:	Software bit 0.
> >   * @KVM_PGTABLE_PROT_SW1:	Software bit 1.
> >   * @KVM_PGTABLE_PROT_SW2:	Software bit 2.
> > @@ -257,6 +260,7 @@ enum kvm_pgtable_prot {
> > 
> >  	KVM_PGTABLE_PROT_DEVICE			= BIT(3),
> >  	KVM_PGTABLE_PROT_NORMAL_NC		= BIT(4),
> > +	KVM_PGTABLE_PROT_DBM			= BIT(5),
> > 
> >  	KVM_PGTABLE_PROT_SW0			= BIT(55),
> >  	KVM_PGTABLE_PROT_SW1			= BIT(56),
> > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
> > index c351b4abd5db..ce41c6924ebe 100644
> > --- a/arch/arm64/kvm/hyp/pgtable.c
> > +++ b/arch/arm64/kvm/hyp/pgtable.c
> > @@ -694,6 +694,9 @@ static int stage2_set_prot_attr(struct kvm_pgtable *pgt, enum kvm_pgtable_prot p
> >  	if (prot & KVM_PGTABLE_PROT_W)
> >  		attr |= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W;
> > 
> > +	if (prot & KVM_PGTABLE_PROT_DBM)
> > +		attr |= KVM_PTE_LEAF_ATTR_HI_S2_DBM;
> > +
> >  	if (!kvm_lpa2_is_enabled())
> >  		attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S2_SH, sh);
> > 
> > @@ -1303,6 +1306,9 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr,
> >  	if (prot & KVM_PGTABLE_PROT_W)
> >  		set |= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W;
> > 
> > +	if (prot & KVM_PGTABLE_PROT_DBM)
> > +		set |= KVM_PTE_LEAF_ATTR_HI_S2_DBM;
> > +
> >  	if (prot & KVM_PGTABLE_PROT_X)
> >  		clr |= KVM_PTE_LEAF_ATTR_HI_S2_XN;
> > 
> 
> 
> Hi Tian,
> 
> I was re-reading this series while planning the other feature I am working 
> on top of this one.
> 
> This patch, IMHO, is unrelated to the HDBSS feature.
> I get that HDBSS feature needs this bit being set in the page descriptor
> but it was not introduced in this feature.
> 
> It was actually introduced in HAFDBS.
> 
> So maybe it's worth to split this series in:
> - Enable HAFDBS for KVM, and

TBH, just enabling the dirty bit at S2 is pretty pointless for KVM. It
would require scanning the S2 PTs looking for a dirty bit, and
transfer that to whatever userspace is using, be it dirty bitmap or
ring.

It has been tried before, and it was absolutely disgusting. So let's
not enable this standalone, this is a dead end. It only makes sense
with HDBSS (that's why we have this extension the first place).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2026-01-29 18:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  9:23 [PATCH v2 0/5] Support the FEAT_HDBSS introduced in Armv9.5 Tian Zheng
2025-11-21  9:23 ` [PATCH v2 1/5] arm64/sysreg: Add HDBSS related register information Tian Zheng
2025-11-22 12:40   ` Marc Zyngier
2025-11-27 11:48     ` Tian Zheng
2025-12-02  6:51     ` Tian Zheng
2026-01-22 15:12     ` Leonardo Bras
2026-01-22 15:16       ` Leonardo Bras
2026-01-23 10:15       ` Marc Zyngier
2026-01-26  2:21       ` Tian Zheng
2026-01-26 11:50         ` Leonardo Bras
2025-11-21  9:23 ` [PATCH v2 2/5] KVM: arm64: Support set the DBM attr during memory abort Tian Zheng
2025-11-22 12:54   ` Marc Zyngier
2025-11-27 12:19     ` Tian Zheng
2026-01-29 17:02   ` Leonardo Bras
2026-01-29 18:48     ` Marc Zyngier [this message]
2025-11-21  9:23 ` [PATCH v2 3/5] KVM: arm64: Add support for FEAT_HDBSS Tian Zheng
2025-11-22 13:25   ` Marc Zyngier
2025-11-27 13:24     ` Tian Zheng
2025-11-21  9:23 ` [PATCH v2 4/5] KVM: arm64: Enable HDBSS support and handle HDBSSF events Tian Zheng
2025-11-22 16:17   ` Marc Zyngier
2025-11-28  9:21     ` Tian Zheng
2025-12-17 13:39   ` Robert Hoo
2025-12-24  6:15     ` Tian Zheng
2025-12-28 13:21       ` Robert Hoo
2026-01-09  7:52         ` Tian Zheng
2025-11-21  9:23 ` [PATCH v2 5/5] KVM: arm64: Document HDBSS ioctl Tian Zheng
2025-11-21  9:54 ` [PATCH v2 0/5] Support the FEAT_HDBSS introduced in Armv9.5 Marc Zyngier
2025-11-21 10:21   ` z00939249
2025-11-22 16:23     ` Marc Zyngier

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=867bt0b6gc.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=leo.bras@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=suzuki.poulose@arm.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=will@kernel.org \
    --cc=xiexiangyou@huawei.com \
    --cc=yezhenyu2@huawei.com \
    --cc=yuzenghui@huawei.com \
    --cc=zhengchuan@huawei.com \
    --cc=zhengtian10@huawei.com \
    /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