From: sashiko-bot@kernel.org
To: "Leonardo Bras" <leo.bras@arm.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] KVM: selftests: Check dirty-ring size before enabling
Date: Wed, 24 Jun 2026 17:28:07 +0000 [thread overview]
Message-ID: <20260624172808.190341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624171656.1737580-3-leo.bras@arm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] Format string type mismatch causing undefined behavior on 64-bit big-endian architectures
- [Low] Misleading error message contradicts inclusive boundary check
- [Low] Misleading assertion failure when dirty ring capabilities are unsupported
--
commit 8555e295b2631adeaf18b3b867988e6adc58eb4c
Author: Leonardo Bras <leo.bras@arm.com>
KVM: selftests: Check dirty-ring size before enabling
This commit changes vm_enable_dirty_ring() to dynamically fetch the maximum
dirty-ring size via KVM_CAP_DIRTY_LOG_RING_ACQ_REL or KVM_CAP_DIRTY_LOG_RING.
It then validates that the requested ring size is less than or equal to this
maximum and is a power of two, printing a specific error message if the check
fails.
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
[ ... ]
> void vm_enable_dirty_ring(struct kvm_vm *vm, u32 ring_size)
> {
> - if (vm_check_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL))
> - vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING_ACQ_REL, ring_size);
> - else
> - vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
> + long cap = KVM_CAP_DIRTY_LOG_RING_ACQ_REL;
> + int max_size = vm_check_cap(vm, cap);
> +
> + if (!max_size) {
> + cap = KVM_CAP_DIRTY_LOG_RING;
> + max_size = vm_check_cap(vm, cap);
> + }
> +
[Severity: Low]
If the host KVM subsystem does not support these capabilities, max_size
will evaluate to 0.
Since the assertion below will then fail for any positive ring_size, does
this create a misleading error message about "smaller than 0 entries"
rather than indicating the feature is unsupported?
> + TEST_ASSERT(ring_size <= max_size && is_power_of_2(ring_size),
> + "Invalid dirty-ring size: Should be a power of two "
> + "smaller than %d entries\n",
[Severity: Low]
The condition checks if ring_size is less than or equal to max_size, but the
error message text specifies it must be "smaller than".
Does this mismatch make it confusing to debug failures when the requested size
is exactly equal to the maximum size?
> + max_size / sizeof(struct kvm_dirty_gfn));
[Severity: Low]
The expression max_size / sizeof(struct kvm_dirty_gfn) evaluates to a size_t,
but the format string uses %d.
Can this cause format warnings, and result in incorrectly printing 0 on
64-bit big-endian architectures since the format parsing will read the most
significant 32 bits?
> +
> + vm_enable_cap(vm, cap, ring_size);
> vm->dirty_ring_size = ring_size;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624171656.1737580-1-leo.bras@arm.com?part=2
next prev parent reply other threads:[~2026-06-24 17:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 17:16 [RFC PATCH 0/3] KVM: selftests: Improvements on dirty-ring Leonardo Bras
2026-06-24 17:16 ` [RFC PATCH 1/3] KVM: selftests: memstress: Add option to enable dirty-ring on VM creation Leonardo Bras
2026-06-24 17:16 ` [RFC PATCH 2/3] KVM: selftests: Check dirty-ring size before enabling Leonardo Bras
2026-06-24 17:28 ` sashiko-bot [this message]
2026-06-24 17:16 ` [RFC PATCH 3/3] KVM: selftests: dirty_log_perf_test: Add dirty-ring support Leonardo Bras
2026-06-24 17:29 ` sashiko-bot
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=20260624172808.190341F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=leo.bras@arm.com \
--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.