From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
kvm-ppc@vger.kernel.org
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <david@davidgow.net>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH v2] kvm powerpc/book3s-apiv2: Add suite initialization to skip GSB tests without APIv2 support
Date: Wed, 17 Jun 2026 18:08:18 +0530 [thread overview]
Message-ID: <20260617123820.467601-1-vaibhav@linux.ibm.com> (raw)
The guest state buffer (GSB) test suite currently fails on systems that
do not support the PAPR APIv2 nested virtualization. This happens because
the tests attempt to use APIv2-specific functionality without first
checking if the host supports it. This was recently reported [1] when
test-guest-state-buffer kunit tests were being run on Qemu without enabling
Qemu capability 'cap-nested-papr' which enabled APIv2 nested virtualization
for PPC64 Pseries Qemu machine.
Add a suite_init callback that checks for APIv2 support by calling
plpar_guest_get_capabilities(). If the host does not support APIv2
(indicated by H_SUCCESS not being returned), mark the kunit_suite as
skipped. This prevents test failures on systems without APIv2 support while
still allowing the tests to run on capable systems.
This patch uses the ability to skip entire kunit_suite which is proposed at
[2].
[1] https://lore.kernel.org/all/20260603064225.GC18149@sol/
[2] https://lore.kernel.org/all/20260617121535.462459-1-vaibhav@linux.ibm.com/
Reported-by: Eric Biggers <ebiggers@kernel.org>
Closes: https://lore.kernel.org/all/20260603064225.GC18149@sol
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Assisted-by: Bob:Claude-3.7-Sonnet Bob-Shell
---
Change-log
=========
V1->V2:
* Updated the init_gs_test_suite() to use 'kunit_mark_skipped()' for
kunit_suite.
* Addressed sashiko-bot's review comment regarding unconditional execution
of hcall on non-PSeries systems like PowerNV [Sashiko]
---
arch/powerpc/kvm/test-guest-state-buffer.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/powerpc/kvm/test-guest-state-buffer.c b/arch/powerpc/kvm/test-guest-state-buffer.c
index 5ccca306997a..232c00493a25 100644
--- a/arch/powerpc/kvm/test-guest-state-buffer.c
+++ b/arch/powerpc/kvm/test-guest-state-buffer.c
@@ -521,6 +521,21 @@ static void test_gs_hostwide_counters(struct kunit *test)
kvmppc_gsb_free(gsb);
}
+static int init_gs_test_suite(struct kunit_suite *suite)
+{
+ long rc = H_NOT_AVAILABLE;
+ unsigned long host_capabilities = 0;
+
+ /* Enable test suite only if APIv2 is supported */
+ if (kvmhv_on_pseries())
+ rc = plpar_guest_get_capabilities(0, &host_capabilities);
+
+ if (rc)
+ kunit_mark_skipped(suite, "Unsupported hypervisor");
+
+ return 0;
+}
+
static struct kunit_case guest_state_buffer_testcases[] = {
KUNIT_CASE(test_creating_buffer),
KUNIT_CASE(test_adding_element),
@@ -535,6 +550,7 @@ static struct kunit_case guest_state_buffer_testcases[] = {
static struct kunit_suite guest_state_buffer_test_suite = {
.name = "guest_state_buffer_test",
.test_cases = guest_state_buffer_testcases,
+ .suite_init = init_gs_test_suite,
};
kunit_test_suites(&guest_state_buffer_test_suite);
--
2.54.0
reply other threads:[~2026-06-17 12:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260617123820.467601-1-vaibhav@linux.ibm.com \
--to=vaibhav@linux.ibm.com \
--cc=brendan.higgins@linux.dev \
--cc=david@davidgow.net \
--cc=ebiggers@kernel.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
/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