aboutsummaryrefslogtreecommitdiffstats
path: root/roms/skiboot/test
diff options
context:
space:
mode:
Diffstat (limited to 'roms/skiboot/test')
-rw-r--r--roms/skiboot/test/Makefile.check26
-rw-r--r--roms/skiboot/test/dt_common.c59
-rw-r--r--roms/skiboot/test/hello_world/Makefile.check69
-rw-r--r--roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S48
-rw-r--r--roms/skiboot/test/hello_world/run_hello_world.tcl5
-rwxr-xr-xroms/skiboot/test/hello_world/run_mambo_hello_world.sh64
-rwxr-xr-xroms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh64
-rwxr-xr-xroms/skiboot/test/hello_world/run_qemu_hello_world.sh65
-rwxr-xr-xroms/skiboot/test/make-boot-coverage-report.sh35
-rwxr-xr-xroms/skiboot/test/run.sh16
-rw-r--r--roms/skiboot/test/run_boot_test.tcl16
-rwxr-xr-xroms/skiboot/test/run_mambo_boot_test.sh71
-rwxr-xr-xroms/skiboot/test/run_qemu_boot_test.sh74
-rw-r--r--roms/skiboot/test/sreset_world/Makefile.check48
-rwxr-xr-xroms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh76
-rwxr-xr-xroms/skiboot/test/sreset_world/run_mambo_sreset.sh76
-rw-r--r--roms/skiboot/test/sreset_world/run_sreset_world.tcl6
-rw-r--r--roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S99
18 files changed, 917 insertions, 0 deletions
diff --git a/roms/skiboot/test/Makefile.check b/roms/skiboot/test/Makefile.check
new file mode 100644
index 000000000..c2137252b
--- /dev/null
+++ b/roms/skiboot/test/Makefile.check
@@ -0,0 +1,26 @@
+check: boot-check boot-smt-check qemu-boot-check
+
+boot-check: skiboot.lid
+ $(call Q, BOOT TEST , ./test/run_mambo_boot_test.sh, $@)
+
+boot-smt-check: skiboot.lid
+ $(call Q, BOOT TEST , THREADS=2 ./test/run_mambo_boot_test.sh, $@)
+
+qemu-boot-check: skiboot.lid
+ $(call Q, BOOT TEST , ./test/run_qemu_boot_test.sh , $@)
+
+OP_BUILD_BOOT_CHECK=op-build-v1.0 op-build-v1.1 op-build-v1.2 op-build-v1.2.1
+
+boot-check-%: skiboot.lid skiboot.map
+ $(call Q, BOOT TEST , SKIBOOT_MEM_DUMP=skiboot-$(@:boot-check-%=%).dump SKIBOOT_ZIMAGE=`pwd`/opal-ci/images/$(@:boot-check-%=%)/zImage.epapr ./test/run_mambo_boot_test.sh, $@)
+
+boot-tests: boot-check $(OP_BUILD_BOOT_CHECK:%=boot-check-%)
+
+boot-coverage-report: boot-tests extract-gcov skiboot.map all-boot-hardware
+ $(call Q, BOOT TEST , CROSS=$(CROSS) BOOT_TESTS="hello_world boot_test ${OP_BUILD_BOOT_CHECK} ${FSP_GCOV_MACHINES}" ./test/make-boot-coverage-report.sh, $@)
+
+boot-fsp-hardware-%: skiboot.lid skiboot.map
+ $(call Q, BOOT TEST , ./external/boot-tests/boot_test.sh -v -p -b fsp -t $(@:boot-fsp-hardware-%=%) -1 skiboot.lid, $@)
+ ./external/boot-tests/extract_gcov.sh $(@:boot-fsp-hardware-%=%)
+
+all-boot-hardware: $(FSP_GCOV_MACHINES:%=boot-fsp-hardware-%)
diff --git a/roms/skiboot/test/dt_common.c b/roms/skiboot/test/dt_common.c
new file mode 100644
index 000000000..98032c496
--- /dev/null
+++ b/roms/skiboot/test/dt_common.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/* Copyright 2015-2017 IBM Corp. */
+
+#include <skiboot.h>
+#include <stdlib.h>
+
+#include "../include/device.h"
+
+/* dump_dt() is used in hdata/test/hdata_to_dt.c and core/test/run-device.c
+ * this file is directly #included in both
+ */
+
+static void indent_num(unsigned indent)
+{
+ unsigned int i;
+
+ for (i = 0; i < indent; i++)
+ putc(' ', stdout);
+}
+
+static void dump_val(unsigned indent, const void *prop, size_t size)
+{
+ size_t i;
+ int width = 78 - indent;
+
+ for (i = 0; i < size; i++) {
+ printf("%02x", ((unsigned char *)prop)[i]);
+ width -= 2;
+ if(width < 2) {
+ printf("\n");
+ indent_num(indent);
+ width = 80 - indent;
+ }
+ }
+}
+
+void dump_dt(const struct dt_node *root, unsigned indent, bool show_props);
+
+void dump_dt(const struct dt_node *root, unsigned indent, bool show_props)
+{
+ const struct dt_node *i;
+ const struct dt_property *p;
+
+ indent_num(indent);
+ printf("node: %s\n", root->name);
+
+ if (show_props) {
+ list_for_each(&root->properties, p, list) {
+ indent_num(indent);
+ printf("prop: %s size: %zu val: ", p->name, p->len);
+ dump_val(indent, p->prop, p->len);
+ printf("\n");
+ }
+ }
+
+ list_for_each(&root->children, i, list)
+ dump_dt(i, indent + 2, show_props);
+}
+
diff --git a/roms/skiboot/test/hello_world/Makefile.check b/roms/skiboot/test/hello_world/Makefile.check
new file mode 100644
index 000000000..0390cf662
--- /dev/null
+++ b/roms/skiboot/test/hello_world/Makefile.check
@@ -0,0 +1,69 @@
+HELLO_WORLD_TEST := test/hello_world/hello_kernel/hello_kernel
+HELLO_WORLD_STB_TEST := test/hello_world/hello_kernel/hello_kernel.stb
+
+.PHONY: hello_world-tests
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-smt-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-smt-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_TEST:%=%-check-qemu)
+
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-mambo)
+hello_world-tests: $(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo)
+
+boot-tests: hello_world-tests
+check: hello_world-tests
+
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+hello_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+hello_kernel_CFLAGS += -mbig-endian -m64
+
+$(HELLO_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/hello_world/run_mambo_hello_world.sh , $@)
+
+$(HELLO_WORLD_TEST:%=%-check-smt-p9-mambo): %-check-smt-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/hello_world/run_mambo_p9_hello_world.sh , $@)
+
+$(HELLO_WORLD_TEST:%=%-check-mambo): %-check-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_mambo_hello_world.sh, $@)
+
+$(HELLO_WORLD_TEST:%=%-check-p9-mambo): %-check-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_mambo_p9_hello_world.sh, $@)
+
+# and now, with secure and trusted boot:
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-mambo): %-check-stb-smt-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/hello_world/run_mambo_hello_world.sh , $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo): %-check-stb-smt-p9-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/hello_world/run_mambo_p9_hello_world.sh , $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-mambo): %-check-stb-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 ./test/hello_world/run_mambo_hello_world.sh, $@)
+
+$(HELLO_WORLD_STB_TEST:%=%-check-stb-p9-mambo): %-check-stb-p9-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 ./test/hello_world/run_mambo_p9_hello_world.sh, $@)
+
+# qemu
+
+$(HELLO_WORLD_TEST:%=%-check-qemu): %-check-qemu: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/hello_world/run_qemu_hello_world.sh, $@)
+
+test/hello_world/hello_kernel/hello_kernel.o: test/hello_world/hello_kernel/hello_kernel.S
+ $(call Q,CC, $(CC) $(hello_kernel_CFLAGS) -c -o $@ $< ,$@)
+
+test/hello_world/hello_kernel/hello_kernel: test/hello_world/hello_kernel/hello_kernel.o
+ $(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
+
+test/hello_world/hello_kernel/hello_kernel.stb: test/hello_world/hello_kernel/hello_kernel libstb/create-container
+ $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
+
+clean: hello_world-test-clean
+
+hello_world-test-clean:
+ $(RM) test/hello_world/hello_kernel/hello_kernel
+ $(RM) test/hello_world/hello_kernel/hello_kernel.o
diff --git a/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S b/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S
new file mode 100644
index 000000000..4f774c179
--- /dev/null
+++ b/roms/skiboot/test/hello_world/hello_kernel/hello_kernel.S
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/*
+ * hello_kernel.S!
+ *
+ * Because skiboot has its own stack, we don't even need that!
+ * All we need to do is make an OPAL call to write to the console.
+ *
+ * Copyright 2014-2016 IBM Corp.
+ */
+
+ . = 0x0
+ .globl _start
+_start:
+/*
+ * Save some values passed in from skiboot into registers that are
+ * non-volatile over OPAL calls.
+ * r8 is the OPAL base
+ * r9 is the OPAL entry point point
+ */
+ mr %r13, %r8
+ mr %r14, %r9
+
+ bl here
+here: mflr %r8 /* work out where we are running */
+
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ addi %r4, %r8, len - here /* ptr to length of string */
+ addi %r5, %r8, str - here /* ptr to string start */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ li %r0, 5 /* OPAL_CEC_POWER_DOWN */
+ li %r3, 0 /* normal shutdown */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ /* We shouldn't get here but if we do, just wait here */
+ b .
+
+len:
+ .long 0x00
+ .long (strend - str)
+str:
+ .string "Hello World!\n"
+strend:
diff --git a/roms/skiboot/test/hello_world/run_hello_world.tcl b/roms/skiboot/test/hello_world/run_hello_world.tcl
new file mode 100644
index 000000000..bbd916c39
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_hello_world.tcl
@@ -0,0 +1,5 @@
+source ../../external/mambo/skiboot.tcl
+
+mysim go
+mysim memory fwrite 0x30000000 0x500000 skiboot-hello_world.dump
+exit
diff --git a/roms/skiboot/test/hello_world/run_mambo_hello_world.sh b/roms/skiboot/test/hello_world/run_mambo_hello_world.sh
new file mode 100755
index 000000000..a9f5b8ad9
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_mambo_hello_world.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+
+if [ -z "$MAMBO_PATH" ]; then
+ MAMBO_PATH=/opt/ibm/systemsim-p8/
+fi
+
+if [ -z "$MAMBO_BINARY" ]; then
+ MAMBO_BINARY="/run/pegasus/power8"
+fi
+
+if [ ! -x "$MAMBO_PATH/$MAMBO_BINARY" ]; then
+ echo "Could not find executable MAMBO_BINARY ($MAMBO_PATH/$MAMBO_BINARY). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $MAMBO_PATH/$MAMBO_BINARY -n -f ../../test/hello_world/run_hello_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh b/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh
new file mode 100755
index 000000000..e9eee8c39
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_mambo_p9_hello_world.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+if [ -z "$P9MAMBO_PATH" ]; then
+ P9MAMBO_PATH=/opt/ibm/systemsim-p9/
+fi
+
+if [ -z "$P9MAMBO_BINARY" ]; then
+ P9MAMBO_BINARY="/run/p9/power9"
+fi
+
+if [ ! -x "$P9MAMBO_PATH/$P9MAMBO_BINARY" ]; then
+ echo "Could not find executable P9MAMBO_BINARY ($P9MAMBO_PATH/$P9MAMBO_BINARY). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel.stb
+ export SKIBOOT_CVC_CODE=$(pwd)/external/mambo/cvc.bin
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $P9MAMBO_PATH/$P9MAMBO_BINARY -n -f ../../test/hello_world/run_hello_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/hello_world/run_qemu_hello_world.sh b/roms/skiboot/test/hello_world/run_qemu_hello_world.sh
new file mode 100755
index 000000000..9ca35d382
--- /dev/null
+++ b/roms/skiboot/test/hello_world/run_qemu_hello_world.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+QEMU_ARGS="-M powernv -nodefaults -device ipmi-bmc-sim,id=bmc0 -serial none"
+QEMU_ARGS+=" -device isa-serial,chardev=s1 -chardev stdio,id=s1,signal=off"
+
+if [ -z "$QEMU_BIN" ]; then
+ QEMU_BIN="qemu-system-ppc64"
+fi
+
+if [ ! $(command -v $QEMU_BIN) ]; then
+ echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+
+export SKIBOOT_ZIMAGE=$(pwd)/test/hello_world/hello_kernel/hello_kernel
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+(
+cat <<EOF | expect
+set timeout 30
+spawn $QEMU_BIN -bios skiboot.lid $QEMU_ARGS -kernel $SKIBOOT_ZIMAGE -nographic
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Could not load OPAL firmware" { send_user "\nSkiboot is too large for this Qemu, skipping\n"; exit 4; }
+"Machine Check Stop" { exit 1;}
+"Hello World!"
+}
+close
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r -eq 4 ]; then
+ echo "Qemu is too old and can't load a skiboot.lid this big"
+ rm $T
+ exit 0
+fi
+
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+
+exit 0;
diff --git a/roms/skiboot/test/make-boot-coverage-report.sh b/roms/skiboot/test/make-boot-coverage-report.sh
new file mode 100755
index 000000000..210880ee6
--- /dev/null
+++ b/roms/skiboot/test/make-boot-coverage-report.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# We cheat and do this in a shell script so I don't go Makefile crazy.
+
+SKIBOOT_GCOV_ADDR=$(perl -e "printf '0x%x', 0x30000000 + 0x$(grep gcov_info_list skiboot.map|cut -f 1 -d ' ')")
+
+LCOV_INFO_FILES=""
+
+function process_dump {
+ ./extract-gcov $1 $SKIBOOT_GCOV_ADDR
+ lcov -q -b . -d . -c -o $2 --gcov-tool ${CROSS}gcov
+ LCOV_INFO_FILES="$LCOV_INFO_FILES -a $2"
+ find .|grep '\.gcda$'|xargs rm -f
+}
+
+
+find .|grep '\.gcda$'|xargs rm -f
+
+for i in $BOOT_TESTS; do
+ if [ -f ./external/mambo/skiboot-$i.dump ]; then
+ process_dump ./external/mambo/skiboot-$i.dump skiboot-$i.info
+ fi
+ if [ -f ./skiboot-$i.dump ]; then
+ process_dump ./skiboot-$i.dump skiboot-$i.info
+ fi
+done
+
+if [ -z "$LCOV_INFO_FILES" ]; then
+ echo "ERROR: no lcov files found"
+ exit 1;
+fi
+
+lcov -q -b . -d . --gcov-tool ${CROSS}gcov -o skiboot-boot.info $LCOV_INFO_FILES
+
+genhtml -o boot-coverage-report skiboot-boot.info
diff --git a/roms/skiboot/test/run.sh b/roms/skiboot/test/run.sh
new file mode 100755
index 000000000..e159bd30c
--- /dev/null
+++ b/roms/skiboot/test/run.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+$* 2>&1 > $t
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+rm -f -- "$t"
+trap - EXIT
+exit 0
diff --git a/roms/skiboot/test/run_boot_test.tcl b/roms/skiboot/test/run_boot_test.tcl
new file mode 100644
index 000000000..9aa708de2
--- /dev/null
+++ b/roms/skiboot/test/run_boot_test.tcl
@@ -0,0 +1,16 @@
+source ../../external/mambo/skiboot.tcl
+
+proc console_trigger {response args} {
+ array set triginfo $args
+ set sim $triginfo(sim)
+ $sim trigger clear console $triginfo(match)
+
+ puts "console trigger: putting $response to console"
+ $sim console create input in string $response
+}
+
+mysim trigger set console "Welcome to Petitboot" { console_trigger "x" }
+mysim trigger set console "# " { console_trigger "halt\n" }
+mysim go
+mysim memory fwrite 0x30000000 0x500000 $env(SKIBOOT_MEM_DUMP)
+exit
diff --git a/roms/skiboot/test/run_mambo_boot_test.sh b/roms/skiboot/test/run_mambo_boot_test.sh
new file mode 100755
index 000000000..d08d93f9c
--- /dev/null
+++ b/roms/skiboot/test/run_mambo_boot_test.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+
+if [ -z "$MAMBO_PATH" ]; then
+ MAMBO_PATH=/opt/ibm/systemsim-p8/
+fi
+
+if [ -z "$MAMBO_BINARY" ]; then
+ MAMBO_BINARY="/run/pegasus/power8"
+fi
+
+if [ ! -x "$MAMBO_PATH/$MAMBO_BINARY" ]; then
+ echo 'Could not find executable MAMBO_BINARY. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -z "$SKIBOOT_ZIMAGE" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/zImage.epapr
+fi
+
+if [ ! -f "$SKIBOOT_ZIMAGE" ]; then
+ echo "No $SKIBOOT_ZIMAGE, skipping boot test";
+ exit 0;
+fi
+
+if [ -z "$SKIBOOT_MEM_DUMP" ]; then
+ export SKIBOOT_MEM_DUMP=skiboot-boot_test.dump
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 600
+spawn $MAMBO_PATH/$MAMBO_BINARY -n -f ../../test/run_boot_test.tcl
+expect {
+timeout { send_user "\nTimeout waiting for petitboot\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Machine Check Stop" { exit 1; }
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0
diff --git a/roms/skiboot/test/run_qemu_boot_test.sh b/roms/skiboot/test/run_qemu_boot_test.sh
new file mode 100755
index 000000000..791a75086
--- /dev/null
+++ b/roms/skiboot/test/run_qemu_boot_test.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+QEMU_ARGS="-M powernv -nodefaults -device ipmi-bmc-sim,id=bmc0 -serial none"
+QEMU_ARGS+=" -device isa-serial,chardev=s1 -chardev stdio,id=s1,signal=off"
+
+if [ -z "$QEMU_BIN" ]; then
+ QEMU_BIN="qemu-system-ppc64"
+fi
+
+if [ ! $(command -v $QEMU_BIN) ]; then
+ echo "Could not find executable QEMU_BIN ($QEMU_BIN). Skipping hello_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping hello_world test';
+ exit 0;
+fi
+
+if [ -z "$SKIBOOT_ZIMAGE" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/zImage.epapr
+fi
+
+if [ ! -f "$SKIBOOT_ZIMAGE" ]; then
+ echo "No $SKIBOOT_ZIMAGE, skipping boot test";
+ exit 0;
+fi
+
+T=$(mktemp --tmpdir skiboot_qemu_boot_test.XXXXXXXXXX)
+
+( cat <<EOF | expect
+set timeout 600
+spawn $QEMU_BIN $QEMU_ARGS -bios skiboot.lid -kernel $SKIBOOT_ZIMAGE
+expect {
+timeout { send_user "\nTimeout waiting for petitboot\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n;" exit 1 }
+"Could not load OPAL firmware" { send_user "\nSkiboot is too large for this Qemu, skipping\n"; exit 4; }
+"Machine Check Stop" { exit 1; }
+"Trying to write privileged spr 338" { send_user "\nUpgrade Qemu: needs PCR register\n"; exit 3 }
+"Welcome to Petitboot"
+}
+close
+wait
+exit 0
+EOF
+) 2>&1 > $T
+E=$?
+
+if [ $E -eq 4 ]; then
+ echo "Qemu is too old and can't load a skiboot.lid this big"
+ rm $T
+ exit 0
+fi
+
+if [ $E -eq 3 ]; then
+ echo "WARNING: Qemu test not run; upgrade QEMU to one that supports PCR register";
+ rm $T
+ exit 0;
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+if [ $E -eq 0 ]; then
+ rm $T
+else
+ echo "Boot Test FAILED. Results in $T";
+fi
+
+echo
+exit $E;
diff --git a/roms/skiboot/test/sreset_world/Makefile.check b/roms/skiboot/test/sreset_world/Makefile.check
new file mode 100644
index 000000000..ec9fd2747
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/Makefile.check
@@ -0,0 +1,48 @@
+SRESET_WORLD_TEST := test/sreset_world/sreset_kernel/sreset_kernel
+SRESET_WORLD_STB_TEST := test/sreset_world/sreset_kernel/sreset_kernel.stb
+
+.PHONY: sreset_world-tests
+# We only do the SMT tests as we don't do OPAL re-entry
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-mambo)
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-p9-mambo)
+
+sreset_world-tests: $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-mambo)
+sreset_world-tests: $(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo)
+
+boot-tests: sreset_world-tests
+check: sreset_world-tests
+
+cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(cc-name),clang)
+sreset_kernel_CFLAGS = --target=powerpc64-linux-gnu
+endif
+sreset_kernel_CFLAGS += -mbig-endian -m64
+
+$(SRESET_WORLD_TEST:%=%-check-smt-mambo): %-check-smt-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/sreset_world/run_mambo_sreset.sh , $@)
+
+$(SRESET_WORLD_TEST:%=%-check-smt-p9-mambo): %-check-smt-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , THREADS=2 ./test/sreset_world/run_mambo_p9_sreset.sh , $@)
+
+$(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-mambo): %-check-stb-smt-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/sreset_world/run_mambo_sreset.sh , $@)
+
+$(SRESET_WORLD_STB_TEST:%=%-check-stb-smt-p9-mambo): %-check-stb-smt-p9-mambo: % skiboot.lid.stb
+ $(call Q , BOOT TEST , SKIBOOT_ENABLE_MAMBO_STB=1 THREADS=2 ./test/sreset_world/run_mambo_p9_sreset.sh , $@)
+
+test/sreset_world/sreset_kernel/sreset_kernel.o: test/sreset_world/sreset_kernel/sreset_kernel.S
+ $(call Q,CC, $(CC) $(sreset_kernel_CFLAGS) -c -o $@ $< ,$@)
+
+test/sreset_world/sreset_kernel/sreset_kernel: test/sreset_world/sreset_kernel/sreset_kernel.o
+ $(call Q,LD, $(LD) -EB -m elf64ppc -N -o $@ $^ , $@)
+
+test/sreset_world/sreset_kernel/sreset_kernel.stb: test/sreset_world/sreset_kernel/sreset_kernel libstb/create-container
+ $(call Q,STB-DEVELOPMENT-SIGNED-CONTAINER,$(SRC)/libstb/sign-with-local-keys.sh $< $@ $(SRC)/libstb/keys/,$@)
+
+
+clean: sreset_world-test-clean
+
+sreset_world-test-clean:
+ $(RM) test/sreset_world/sreset_kernel/sreset_kernel
+ $(RM) test/sreset_world/sreset_kernel/sreset_kernel.o
diff --git a/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh b/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh
new file mode 100755
index 000000000..1f6524000
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_mambo_p9_sreset.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+if [ -z "$P9MAMBO_PATH" ]; then
+ P9MAMBO_PATH=/opt/ibm/systemsim-p9/
+fi
+
+if [ -z "$P9MAMBO_BINARY" ]; then
+ P9MAMBO_BINARY="/run/p9/power9"
+fi
+
+if [ ! -x "$P9MAMBO_PATH/$P9MAMBO_BINARY" ]; then
+ echo "Could not find executable P9MAMBO_BINARY ($P9MAMBO_PATH/$P9MAMBO_BINARY). Skipping sreset_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
+ export SKIBOOT_CVC_CODE=$(pwd)/external/mambo/cvc.bin
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $P9MAMBO_PATH/$P9MAMBO_BINARY -n -f ../../test/sreset_world/run_sreset_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\n"; exit 1}
+eof { send_user "\nUnexpected EOF\n"; exit 1}
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/sreset_world/run_mambo_sreset.sh b/roms/skiboot/test/sreset_world/run_mambo_sreset.sh
new file mode 100755
index 000000000..298a582f8
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_mambo_sreset.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+
+if [ -z "$MAMBO_PATH" ]; then
+ MAMBO_PATH=/opt/ibm/systemsim-p8/
+fi
+
+if [ -z "$MAMBO_BINARY" ]; then
+ MAMBO_BINARY="/run/pegasus/power8"
+fi
+
+if [ ! -x "$MAMBO_PATH/$MAMBO_BINARY" ]; then
+ echo "Could not find executable MAMBO_BINARY ($MAMBO_PATH/$MAMBO_BINARY). Skipping sreset_world test";
+ exit 0;
+fi
+
+if [ -n "$KERNEL" ]; then
+ echo 'Please rebuild skiboot without KERNEL set. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ ! $(command -v expect) ]; then
+ echo 'Could not find expect binary. Skipping sreset_world test';
+ exit 0;
+fi
+
+if [ -n "$SKIBOOT_ENABLE_MAMBO_STB" ]; then
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel.stb
+else
+ export SKIBOOT_ZIMAGE=$(pwd)/test/sreset_world/sreset_kernel/sreset_kernel
+fi
+
+# Currently getting some core dumps from mambo, so disable them!
+ulimit -c 0
+
+t=$(mktemp) || exit 1
+
+trap "rm -f -- '$t'" EXIT
+
+( cd external/mambo;
+cat <<EOF | expect
+set timeout 30
+spawn $MAMBO_PATH/$MAMBO_BINARY -n -f ../../test/sreset_world/run_sreset_world.tcl
+expect {
+timeout { send_user "\nTimeout waiting for hello world\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+eof { send_user "\nUnexpected EOF\n"; exit 1 }
+"Machine Check Stop" { exit 1;}
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\n"; exit 1}
+eof { send_user "\nUnexpected EOF\n"; exit 1}
+"Machine Check Stop" { exit 1;}
+"Execution stopped: Sim Support exit requested stop"
+}
+wait
+exit 0
+EOF
+) 2>&1 > $t
+
+r=$?
+if [ $r != 0 ]; then
+ cat $t
+ exit $r
+fi
+
+if [ -n "$V" ] ; then cat "$t" ; fi
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/roms/skiboot/test/sreset_world/run_sreset_world.tcl b/roms/skiboot/test/sreset_world/run_sreset_world.tcl
new file mode 100644
index 000000000..38da0d235
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/run_sreset_world.tcl
@@ -0,0 +1,6 @@
+source ../../external/mambo/skiboot.tcl
+source ../../external/mambo/mambo_utils.tcl
+
+mysim go
+mysim memory fwrite 0x30000000 0x500000 skiboot-sreset_world.dump
+exit
diff --git a/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S b/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S
new file mode 100644
index 000000000..08960d589
--- /dev/null
+++ b/roms/skiboot/test/sreset_world/sreset_kernel/sreset_kernel.S
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+/*
+ * Test the SRESET OPAL call in Mambo by
+ * having a bit of fun printing 'Hello World' from the SRESET vector.
+ *
+ * Copyright 2013-2017 IBM Corp.
+ */
+
+ . = 0x0
+ .globl _start
+_start:
+/*
+ * Save some values passed in from skiboot into registers that are
+ * non-volatile over OPAL calls.
+ * r8 is the OPAL base
+ * r9 is the OPAL entry point point
+ */
+ mr %r13, %r8
+ mr %r14, %r9
+
+ bl here
+here: mflr %r8 /* work out where we are running */
+ subi %r8, %r8, here - _start
+ /* Stash OPAL base and entry point somewhere SRESET can find it */
+ li %r6, 0xe0
+ std %r13, 0(%r6)
+ std %r14, 8(%r6)
+ std %r8, 16(%r6)
+ addi %r6, %r8, sreset_code_end - _start
+ addi %r7, %r8, sreset_code - _start
+ li %r10, 0x100
+c:
+ lwa %r9, 0(%r7)
+ stw %r9, 0(%r10)
+ addi %r7,%r7,4
+ addi %r10,%r10,4
+ cmpd %r7,%r6
+ bne c
+ sync
+ icbi 0,%r0
+ sync
+ isync
+
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ addi %r4, %r8, len - _start /* ptr to length of string */
+ addi %r5, %r8, str - _start /* ptr to string start */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ li %r0, 145 /* OPAL_SIGNAL_SYSTEM_RESET */
+ li %r3, -2 /* All *OTHER* CPUs */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ /* We shouldn't get here but if we do, just wait here */
+ b .
+
+sreset_code:
+ li %r6, 0xe0
+ ld %r13, 0(%r6)
+ ld %r14, 8(%r6)
+ ld %r8, 16(%r6) /* "here" */
+ li %r0, 1 /* OPAL_CONSOLE_WRITE */
+ li %r3, 0 /* terminal 0 */
+ li %r4, len2 - _start
+ li %r5, str2 - _start
+ add %r4, %r8, %r4
+ add %r5, %r8, %r5
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+ li %r0, 5 /* OPAL_CEC_POWER_DOWN */
+ li %r3, 0 /* normal shutdown */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ /* We shouldn't get here but if we do, just wait here */
+ b .
+
+sreset_code_end:
+
+len:
+ .long 0x00
+ .long (strend - str)
+str:
+ .string "Hello World!\n"
+strend:
+
+len2:
+ .long 0x00
+ .long (str2end - str2)
+str2:
+ .string "Hello SRESET!\n"
+str2end:
+