From: Leonardo Bras <leo.bras@arm.com>
To: sashiko-reviews@lists.linux.dev
Cc: Leonardo Bras <leo.bras@arm.com>,
Oliver Upton <oupton@kernel.org>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH v3 09/11] kvm/dirty_ring: Add arch-generic interface for hw-accelerated dirty-ring cleaning
Date: Mon, 3 Aug 2026 17:04:05 +0100 [thread overview]
Message-ID: <anC79Slpmwl0yePC@LeoBrasDK> (raw)
In-Reply-To: <20260729111451.EB5EE1F00A3D@smtp.kernel.org>
On Wed, Jul 29, 2026 at 11:14:51AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> - [Low] The monolithic `#ifndef CONFIG_HAVE_KVM_HW_DIRTY_BIT` guard causes a build failure for architectures that implement only one of the hardware-accelerated dirty logging hooks.
> - [Low] The undocumented API contract of `kvm_arch_dirty_ring_clear` silently shifts the responsibility of updating KVM dirty ring state to the architecture hook.
> - [Low] Missing forward declaration for `struct kvm_dirty_ring` in `include/linux/kvm_dirty_bit.h`.
> --
>
> --- Patch [9]: [PATCH v3 09/11] kvm/dirty_ring: Add arch-generic interface for hw-accelerated dirty-ring cleaning ---
> commit 54695fde1ebfc7f27e678570e500f9d9eb6ecff5
> Author: Leonardo Bras <leo.bras@arm.com>
>
> kvm/dirty_ring: Add arch-generic interface for hw-accelerated dirty-ring cleaning
>
> Introduce kvm_arch_dirty_ring_clear() to allow architecture-specific
> hardware-accelerated dirty-ring routines. The call is added to
> kvm_dirty_ring_reset() and falls back to a software version if not
> implemented or if an error is detected.
>
> > diff --git a/include/linux/kvm_dirty_bit.h b/include/linux/kvm_dirty_bit.h
> > index fa4f6b67b6235..8492979d694e7 100644
> > --- a/include/linux/kvm_dirty_bit.h
> > +++ b/include/linux/kvm_dirty_bit.h
> > @@ -18,6 +18,13 @@ static inline int kvm_arch_dirty_log_clear(struct kvm *kvm,
> > return -ENXIO;
> > }
> >
> > +static inline int kvm_arch_dirty_ring_clear(struct kvm *kvm,
> > + struct kvm_dirty_ring *ring,
>
> [Severity: Low]
> Does this struct need a forward declaration?
>
> If this header is included before include/linux/kvm_dirty_ring.h, might this
> cause a compiler warning for struct kvm_dirty_ring being declared inside a
> parameter list?
It's included in proper order
>
> > + int *nr_entries_reset)
> > +{
> > + return -ENXIO;
> > +}
> > +
> > #else /* CONFIG_HAVE_KVM_HW_DIRTY_BIT */
>
> [Severity: Low]
> Could this monolithic config guard cause a build failure if an architecture
> enables CONFIG_HAVE_KVM_HW_DIRTY_BIT to provide kvm_arch_dirty_log_clear(),
> but does not implement kvm_arch_dirty_ring_clear()?
>
It's a package, you have to provide both.
If not, provide a return -ENXIO inlined function such as above.
> Because the fallback for kvm_arch_dirty_ring_clear() is excluded when the
> config is enabled, omitting it in the arch-specific header would leave it
> undeclared.
>
> >
> > #include <asm/kvm_dirty_bit.h>
> > diff --git a/virt/kvm/dirty_ring.c b/virt/kvm/dirty_ring.c
> > index 807c45fb1fc7b..3fa62894f3d24 100644
> > --- a/virt/kvm/dirty_ring.c
> > +++ b/virt/kvm/dirty_ring.c
>
> [ ... ]
>
> > @@ -133,6 +134,9 @@ int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring,
> > */
> > lockdep_assert_held(&kvm->slots_lock);
> >
> > + if (kvm_arch_dirty_ring_clear(kvm, ring, nr_entries_reset) >= 0)
> > + goto out;
> > +
>
> [Severity: Low]
> Does this bypass implicitly require the arch-specific hook to manually update
> the internal state of the dirty ring?
>
> If an architecture implements kvm_arch_dirty_ring_clear() and returns success,
> this goto skips the generic software loop. The arch hook would need to
> manually increment ring->reset_index, update *nr_entries_reset, and call
> kvm_dirty_gfn_set_invalid() for each processed entry to avoid corrupting the
> ring state. Is this API contract expected to be documented here?
Yes, since it skips everything else in the function, it's required to do
the dirty-ring management as well.
Okay, will keep in mind that this file has the comments about this and log
being NULL from before.
Leo
next prev parent reply other threads:[~2026-08-03 16:04 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
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 [this message]
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=anC79Slpmwl0yePC@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.