@@ -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 /* __ASSEMBLY__ */
@@ -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);
+}
@@ -56,7 +56,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_qemu treats that as a failure exit and returns 1, so we need
@@ -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");
@@ -57,9 +69,11 @@ int main(int argc, char **argv)
report_prefix_push(argv[1]);
if (strcmp(argv[1], "setup") == 0) {
-
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();
@@ -18,6 +18,11 @@ smp = 2
extra_params = -m 1g -append 'setup smp=2 mem=1024'
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
This adds a simple panic test for pseries and powernv 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> --- lib/powerpc/asm/rtas.h | 1 + lib/powerpc/rtas.c | 16 ++++++++++++++++ powerpc/run | 2 +- powerpc/selftest.c | 18 ++++++++++++++++-- powerpc/unittests.cfg | 5 +++++ 5 files changed, 39 insertions(+), 3 deletions(-)