Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Leonardo Bras <leo.bras@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Leonardo Bras <leo.bras@arm.com>,
	kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Subject: Re: [PATCH v3 02/11] arm64/cpufeature: Add system-wide FEAT_HACDBS detection
Date: Mon,  3 Aug 2026 14:50:10 +0100	[thread overview]
Message-ID: <anCckqI9pXVRAHIF@LeoBrasDK> (raw)
In-Reply-To: <20260729110212.3183A1F000E9@smtp.kernel.org>

]On Wed, Jul 29, 2026 at 11:02:11AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Critical] Missing KVM ID register filtering exposes FEAT_HACDBS to guests, preventing VMMs from hiding the feature and breaking VM migration.
> - [Low] The new capability HACDBS is not alphabetically sorted in the cpucaps list.
> --
> 
> --- Patch [2]: [PATCH v3 02/11] arm64/cpufeature: Add system-wide FEAT_HACDBS detection ---
> commit 79552fba5f033b2becee395a64d0ccf3fbde7b1a
> Author: Leonardo Bras <leo.bras@arm.com>
> 
> arm64/cpufeature: Add system-wide FEAT_HACDBS detection
> 
> This commit adds system-wide CPU feature detection for FEAT_HACDBS
> (Hardware dirty bit Cleaning). It updates the cpufeature structures
> and cpucaps list to track the feature across the system.
> 
> > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> > index aa327eebaf1ca..62f56bbd0a65c 100644
> > --- a/arch/arm64/kernel/cpufeature.c
> > +++ b/arch/arm64/kernel/cpufeature.c
> > @@ -523,6 +523,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr3[] = {
> >  static const struct arm64_ftr_bits ftr_id_aa64mmfr4[] = {
> >  	S_ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_E2H0_SHIFT, 4, 0),
> >  	ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_NV_frac_SHIFT, 4, 0),
> > +	ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR4_EL1_HACDBS_SHIFT, 4, 0),
> 
> [Severity: Critical]
> Does exposing this feature here break VM live migration for KVM?
> 
> By adding HACDBS to the host's sanitised ID register, it is subsequently
> read by KVM to form the guest's ID register limit.
> 
> Looking at arch/arm64/kvm/sys_regs.c:__kvm_read_sanitised_id_reg(), there is
> no case handling SYS_ID_AA64MMFR4_EL1, which means the host's HACDBS value
> unconditionally leaks into the guest's limit.
> 
> Furthermore, looking at sys_reg_descs in arch/arm64/kvm/sys_regs.c:
> 
> 	ID_WRITABLE(ID_AA64MMFR4_EL1, ID_AA64MMFR4_EL1_NV_frac),
> 
> The writable mask for ID_AA64MMFR4_EL1 does not include HACDBS. Because KVM
> strictly enforces that non-writable fields must match the destination host's
> limit, a VMM attempting to restore a saved VM state will fail if the source
> and destination hosts have different HACDBS support.
> 
> Could this be addressed by either masking HACDBS from the guest view or
> making the field writable by the VMM?

IIUC, this means the value is being leaked to guest, which means the guest 
could try to use it to clean an L2 guest's dirty-bits. 

In general usage, it should not happen as this feature is limited to VHE,
and requires the kernel to write to HACDBS*_EL2 registers, which should not 
be directly done by the guest. In any case, I guess it's fair to mask 
that out so guest does not believe it has access to that feature.
 
> 
> >  	ARM64_FTR_END,
> >  };
> 
> [ ... ]
> 
> > diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
> > index a87706c9d160e..bd2c0bb98da61 100644
> > --- a/arch/arm64/tools/cpucaps
> > +++ b/arch/arm64/tools/cpucaps
> > @@ -72,6 +72,7 @@ HAS_XNX
> >  HAS_HDBSS
> >  HAFT
> >  HW_DBM
> > +HACDBS
> 
> [Severity: Low]
> This isn't a bug, but HACDBS is inserted out of alphabetical order here.
> 
> Does this violate the "# Internal CPU capabilities constants, keep this list
> sorted" comment at the top of the arch/arm64/tools/cpucaps file?

Okay, will do.

Thanks!
Leo

  reply	other threads:[~2026-08-03 13:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 10:45 [PATCH v3 00/11] KVM Dirty-bit cleaning hw accelerator (HACDBS) Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 01/11] KVM: arm64: HDBSS bits Leonardo Bras
2026-07-29 10:55   ` sashiko-bot
2026-08-03 13:13     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 02/11] arm64/cpufeature: Add system-wide FEAT_HACDBS detection Leonardo Bras
2026-07-29 11:02   ` sashiko-bot
2026-08-03 13:50     ` Leonardo Bras [this message]
2026-07-29 10:45 ` [PATCH v3 03/11] arm64/sysreg: Add HACDBS consumer and base registers Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 04/11] KVM: arm64: dirty_bit: Add base FEAT_HACDBS cleaning routine Leonardo Bras
2026-07-29 10:57   ` sashiko-bot
2026-08-03 14:47     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 05/11] kvm: Add arch-generic interface for hw-accelerated dirty-bitmap cleaning Leonardo Bras
2026-07-29 11:00   ` sashiko-bot
2026-08-03 15:16     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 06/11] KVM: arm64: Add hardware-accelerated dirty-bitmap cleaning routine Leonardo Bras
2026-07-29 11:18   ` sashiko-bot
2026-08-03 15:35     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 07/11] KVM: arm64: Dirty-bitmap: avoid splitting previously split blocks Leonardo Bras
2026-07-29 11:08   ` sashiko-bot
2026-08-03 15:54     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 08/11] kvm/dirty_ring: Introduce get_memslot and move helpers to header Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 09/11] kvm/dirty_ring: Add arch-generic interface for hw-accelerated dirty-ring cleaning Leonardo Bras
2026-07-29 11:14   ` sashiko-bot
2026-08-03 16:04     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 10/11] KVM: arm64: Add hardware-accelerated dirty-ring cleaning routine Leonardo Bras
2026-07-29 11:21   ` sashiko-bot
2026-08-03 16:07     ` Leonardo Bras
2026-07-29 10:45 ` [PATCH v3 11/11] KVM: arm64: Enable KVM_HW_DIRTY_BIT Leonardo Bras
2026-07-29 11:29   ` sashiko-bot
2026-08-03 16:38     ` Leonardo Bras

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=anCckqI9pXVRAHIF@LeoBrasDK \
    --to=leo.bras@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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