From: Chinmay Rath <rathc@linux.ibm.com>
To: thuth@redhat.com
Cc: npiggin@gmail.com, harshpb@linux.ibm.com, lvivier@redhat.com,
linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
andrew.jones@linux.dev, sbhat@linux.ibm.com,
Chinmay Rath <rathc@linux.ibm.com>
Subject: [kvm-unit-tests RFC PATCH 6/6] powerpc: Add a panic test
Date: Tue, 2 Jun 2026 12:18:06 +0530 [thread overview]
Message-ID: <20260602064806.3101025-7-rathc@linux.ibm.com> (raw)
In-Reply-To: <20260602064806.3101025-1-rathc@linux.ibm.com>
From: Nicholas Piggin <npiggin@gmail.com>
This adds a simple panic test for pseries that works with
TCG (unlike the s390x panic tests), making it easier to test
this part of the harness code.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Chinmay Rath <rathc@linux.ibm.com>
---
lib/powerpc/asm/rtas.h | 1 +
lib/powerpc/rtas.c | 16 ++++++++++++++++
powerpc/run | 2 +-
powerpc/selftest.c | 17 ++++++++++++++++-
powerpc/unittests.cfg | 5 +++++
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/lib/powerpc/asm/rtas.h b/lib/powerpc/asm/rtas.h
index 989b21bd..fdb3c544 100644
--- a/lib/powerpc/asm/rtas.h
+++ b/lib/powerpc/asm/rtas.h
@@ -26,6 +26,7 @@ extern int rtas_call(int token, int nargs, int nret, int *outputs, ...);
extern int rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret, int *outputs, ...);
extern void rtas_power_off(void);
+extern void rtas_os_panic(void);
extern void rtas_stop_self(void);
#endif /* __ASSEMBLER__ */
diff --git a/lib/powerpc/rtas.c b/lib/powerpc/rtas.c
index 9c1e0aff..98eee24f 100644
--- a/lib/powerpc/rtas.c
+++ b/lib/powerpc/rtas.c
@@ -182,3 +182,19 @@ void rtas_power_off(void)
ret = rtas_call_unlocked(&args, token, 2, 1, NULL, -1, -1);
printf("RTAS power-off returned %d\n", ret);
}
+
+void rtas_os_panic(void)
+{
+ struct rtas_args args;
+ uint32_t token;
+ int ret;
+
+ ret = rtas_token("ibm,os-term", &token);
+ if (ret) {
+ puts("RTAS ibm,os-term not available\n");
+ return;
+ }
+
+ ret = rtas_call_unlocked(&args, token, 1, 1, NULL, "rtas_os_panic");
+ printf("RTAS ibm,os-term returned %d\n", ret);
+}
diff --git a/powerpc/run b/powerpc/run
index 06657764..718f08cb 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -57,7 +57,7 @@ fi
command="$qemu -nodefaults $A $M $B $D"
command+=" -display none -serial stdio -kernel"
-command="$(migration_cmd) $(timeout_cmd) $command"
+command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command"
# powerpc tests currently exit with rtas-poweroff, which exits with 0.
# run_test treats that as a failure exit and returns 1, so we need
diff --git a/powerpc/selftest.c b/powerpc/selftest.c
index 8d1a2c76..f6f24d6a 100644
--- a/powerpc/selftest.c
+++ b/powerpc/selftest.c
@@ -7,6 +7,7 @@
*/
#include <libcflat.h>
#include <util.h>
+#include <asm/rtas.h>
#include <asm/setup.h>
#include <asm/smp.h>
@@ -47,6 +48,17 @@ static void check_setup(int argc, char **argv)
report_abort("missing input");
}
+static void do_panic(void)
+{
+ if (machine_is_pseries()) {
+ rtas_os_panic();
+ } else {
+ /* Cause a checkstop with MSR[ME] disabled */
+ *((char *)0x10000000000) = 0;
+ }
+ report_fail("survived panic");
+}
+
int main(int argc, char **argv)
{
report_prefix_push("selftest");
@@ -60,7 +72,10 @@ int main(int argc, char **argv)
check_setup(argc-2, &argv[2]);
+ } else if (strcmp(argv[1], "panic") == 0) {
+ do_panic();
+ } else {
+ report_abort("unknown test %s", argv[1]);
}
-
return report_summary();
}
diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
index 168af206..d1395464 100644
--- a/powerpc/unittests.cfg
+++ b/powerpc/unittests.cfg
@@ -19,6 +19,11 @@ test_args = 'setup smp=2 mem=1024'
qemu_params = -m 1g
groups = selftest gitlab-ci
+[selftest-panic]
+file = selftest.elf
+extra_params = -append 'panic'
+groups = selftest panic gitlab-ci
+
[selftest-migration]
file = selftest-migration.elf
machine = pseries
--
2.53.0
prev parent reply other threads:[~2026-06-02 10:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 6:48 [kvm-unit-tests RFC PATCH 0/6] powerpc improvements Chinmay Rath
2026-06-02 6:48 ` [kvm-unit-tests RFC PATCH 1/6] powerpc: add pmu tests Chinmay Rath
2026-06-08 12:45 ` Thomas Huth
2026-06-08 13:57 ` Thomas Huth
2026-06-02 6:48 ` [kvm-unit-tests RFC PATCH 2/6] configure: Make arch_libdir a first-class entity Chinmay Rath
2026-06-02 15:54 ` Andrew Jones
2026-06-05 8:34 ` Chinmay Rath
2026-06-02 6:48 ` [kvm-unit-tests RFC PATCH 3/6] powerpc: Remove remnants of ppc64 directory and build structure Chinmay Rath
2026-06-02 6:48 ` [kvm-unit-tests RFC PATCH 4/6] powerpc: gitlab CI update Chinmay Rath
2026-06-08 12:48 ` Thomas Huth
2026-06-02 6:48 ` [kvm-unit-tests RFC PATCH 5/6] scripts/arch-run.bash: Fix run_panic() success exit status Chinmay Rath
2026-06-02 6:48 ` Chinmay Rath [this message]
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=20260602064806.3101025-7-rathc@linux.ibm.com \
--to=rathc@linux.ibm.com \
--cc=andrew.jones@linux.dev \
--cc=harshpb@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lvivier@redhat.com \
--cc=npiggin@gmail.com \
--cc=sbhat@linux.ibm.com \
--cc=thuth@redhat.com \
/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