From: Leonardo Bras <leo.bras@arm.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
David Matlack <dmatlack@google.com>,
Yosry Ahmed <yosry@kernel.org>, Marc Zyngier <maz@kernel.org>,
Fuad Tabba <fuad.tabba@linux.dev>,
Oliver Upton <oupton@kernel.org>,
Leonardo Bras <leo.bras@arm.com>,
Ackerley Tng <ackerleytng@google.com>,
Josh Hilke <jrhilke@google.com>,
Wu Fei <wu.fei9@sanechips.com.cn>,
Steffen Eiden <seiden@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/5] KVM: selftests: Introduce kvm_get_dirty_ring_cap()
Date: Fri, 9 Oct 2026 14:00:48 +0100 [thread overview]
Message-ID: <20261009130054.3312154-5-leo.bras@arm.com> (raw)
In-Reply-To: <20261009130054.3312154-2-leo.bras@arm.com>
In a preparation to introduce dirty-ring support in dirty_log_perf_test,
add a helper to detect the Dirty-ring capability and replace the checking
of individual capabilities in the dirty_log_test.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Leonardo Bras <leo.bras@arm.com>
---
tools/testing/selftests/kvm/include/kvm_util.h | 11 +++++++++++
tools/testing/selftests/kvm/dirty_log_test.c | 3 +--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index 5a7a455b5387..a89758e66a68 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -300,20 +300,31 @@ static inline int get_kvm_param_integer(const char *param)
return kvm_get_module_param_integer("kvm", param);
}
unsigned int kvm_check_cap(long cap);
static inline bool kvm_has_cap(long cap)
{
return kvm_check_cap(cap);
}
+static inline long kvm_get_dirty_ring_cap(void)
+{
+ if (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING_ACQ_REL))
+ return KVM_CAP_DIRTY_LOG_RING_ACQ_REL;
+
+ if (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING))
+ return KVM_CAP_DIRTY_LOG_RING;
+
+ return 0;
+}
+
/*
* Use the "inner", double-underscore macro when reporting errors from within
* other macros so that the name of ioctl() and not its literal numeric value
* is printed on error. The "outer" macro is strongly preferred when reporting
* errors "directly", i.e. without an additional layer of macros, as it reduces
* the probability of passing in the wrong string.
*/
#define __KVM_IOCTL_ERROR(_name, _ret) __KVM_SYSCALL_ERROR(_name, _ret)
#define KVM_IOCTL_ERROR(_ioctl, _ret) __KVM_IOCTL_ERROR(#_ioctl, _ret)
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index af5eb0334a74..558a71d631da 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -284,22 +284,21 @@ static void default_after_vcpu_run(struct kvm_vcpu *vcpu)
TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC,
"Invalid guest sync status: exit_reason=%s",
exit_reason_str(run->exit_reason));
vcpu_handle_sync_stop();
}
static bool dirty_ring_supported(void)
{
- return (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING) ||
- kvm_has_cap(KVM_CAP_DIRTY_LOG_RING_ACQ_REL));
+ return kvm_get_dirty_ring_cap();
}
static void dirty_ring_create_vm_done(struct kvm_vm *vm)
{
u64 pages;
u32 limit;
/*
* We rely on vcpu exit due to full dirty ring state. Adjust
* the ring buffer size to ensure we're able to reach the
--
2.55.0
next prev parent reply other threads:[~2026-10-09 13:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 13:00 [PATCH v2 0/5] KVM: selftests: Add support for dirty-ring on dirty_log_perf_test Leonardo Bras
2026-10-09 13:00 ` [PATCH v2 1/5] KVM: selftests: memstress: Add struct memstress_params, make memstress_create_vm() use it Leonardo Bras
2026-10-09 13:00 ` [PATCH v2 2/5] KVM: selftests: memstress: Add option to enable dirty-ring on VM creation Leonardo Bras
2026-10-09 13:00 ` Leonardo Bras [this message]
2026-10-09 13:00 ` [PATCH v2 4/5] KVM: selftests: Check dirty-ring size before enabling Leonardo Bras
2026-10-09 13:00 ` [PATCH v2 5/5] KVM: selftests: dirty_log_perf_test: Add dirty-ring support 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=20261009130054.3312154-5-leo.bras@arm.com \
--to=leo.bras@arm.com \
--cc=ackerleytng@google.com \
--cc=dmatlack@google.com \
--cc=fuad.tabba@linux.dev \
--cc=imbrenda@linux.ibm.com \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=seiden@linux.ibm.com \
--cc=shuah@kernel.org \
--cc=wu.fei9@sanechips.com.cn \
--cc=yosry@kernel.org \
/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
all inboxes | Powered by JetHome®