[Skiboot] [PATCH] test/sreset_world: Kind of like Hello World, but from the SRESET vector.
Stewart Smith
stewart at linux.vnet.ibm.com
Mon Mar 6 17:25:06 AEDT 2017
A regression test for the mambo implementation of OPAL_SIGNAL_SYSTEM_RESET.
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
test/sreset_world/Makefile.check | 38 ++++++++
test/sreset_world/run_mambo_p9_sreset.sh | 70 ++++++++++++++
test/sreset_world/run_mambo_sreset.sh | 72 +++++++++++++++
test/sreset_world/run_sreset_world.tcl | 6 ++
test/sreset_world/sreset_kernel/sreset_kernel.S | 112 +++++++++++++++++++++++
test/sreset_world/sreset_kernel/sreset_kernel.ld | 29 ++++++
6 files changed, 327 insertions(+)
create mode 100644 test/sreset_world/Makefile.check
create mode 100755 test/sreset_world/run_mambo_p9_sreset.sh
create mode 100755 test/sreset_world/run_mambo_sreset.sh
create mode 100644 test/sreset_world/run_sreset_world.tcl
create mode 100644 test/sreset_world/sreset_kernel/sreset_kernel.S
create mode 100644 test/sreset_world/sreset_kernel/sreset_kernel.ld
diff --git a/test/sreset_world/Makefile.check b/test/sreset_world/Makefile.check
new file mode 100644
index 000000000000..2386b9ebde2f
--- /dev/null
+++ b/test/sreset_world/Makefile.check
@@ -0,0 +1,38 @@
+SRESET_WORLD_TEST := test/sreset_world/sreset_kernel/sreset_kernel
+
+.PHONY: sreset_world-tests
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-mambo)
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-smt-p9-mambo)
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-mambo)
+sreset_world-tests: $(SRESET_WORLD_TEST:%=%-check-p9-mambo)
+
+boot-tests: sreset_world-tests
+check: sreset_world-tests
+
+$(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_TEST:%=%-check-mambo): %-check-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/sreset_world/run_mambo_sreset.sh, $@)
+
+$(SRESET_WORLD_TEST:%=%-check-p9-mambo): %-check-p9-mambo: % skiboot.lid
+ $(call Q , BOOT TEST , ./test/sreset_world/run_mambo_p9_sreset.sh, $@)
+
+test/sreset_world/sreset_kernel/sreset_kernel.o: test/sreset_world/sreset_kernel/sreset_kernel.S test/sreset_world/sreset_kernel/sreset_kernel.ld
+ $(call Q,CC, $(CC) -m64 -c -MMD -o $@ $< ,$@)
+
+sreset_kernel_LDFLAGS=-m64 -Wl,--build-id=none -T test/sreset_world/sreset_kernel/sreset_kernel.ld -ffreestanding -nostdlib -Ttext=0x0
+
+-include $(wildcard test/sreset_world/sreset_kernel/*.d)
+
+test/sreset_world/sreset_kernel/sreset_kernel: test/sreset_world/sreset_kernel/sreset_kernel.o
+ $(call Q,LD, $(CC) $(sreset_kernel_LDFLAGS) -o $@ $^ , $@)
+
+clean: sreset_world-test-clean
+
+sreset_world-test-clean:
+ $(RM) -f test/sreset_world/sreset_kernel/sreset_kernel
+ $(RM) -f test/sreset_world/sreset_kernel/sreset_kernel.[od]
diff --git a/test/sreset_world/run_mambo_p9_sreset.sh b/test/sreset_world/run_mambo_p9_sreset.sh
new file mode 100755
index 000000000000..a161424d4dab
--- /dev/null
+++ b/test/sreset_world/run_mambo_p9_sreset.sh
@@ -0,0 +1,70 @@
+#!/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/$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
+
+export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel
+
+# Currently getting some core dumps from mambo, so disable them!
+OLD_ULIMIT_C=`ulimit -c`
+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 }
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+efo { send_user "\nUnexpected EOF\n"; exit 1 }
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\n"; exit 1}
+eof { send_user "\nUnexpected EOF\n"; 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
+
+ulimit -c $OLD_ULIMIT_C
+
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/test/sreset_world/run_mambo_sreset.sh b/test/sreset_world/run_mambo_sreset.sh
new file mode 100755
index 000000000000..167b5b594f81
--- /dev/null
+++ b/test/sreset_world/run_mambo_sreset.sh
@@ -0,0 +1,72 @@
+#!/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
+
+
+export SKIBOOT_ZIMAGE=`pwd`/test/sreset_world/sreset_kernel/sreset_kernel
+
+# Currently getting some core dumps from mambo, so disable them!
+OLD_ULIMIT_C=`ulimit -c`
+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 }
+"Hello World!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for Hello SRESET\n"; exit 1 }
+efo { send_user "\nUnexpected EOF\n"; exit 1 }
+"Hello SRESET!"
+}
+expect {
+timeout { send_user "\nTimeout waiting for shutdown\n"; exit 1}
+eof { send_user "\nUnexpected EOF\n"; 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
+
+ulimit -c $OLD_ULIMIT_C
+
+rm -f -- "$t"
+trap - EXIT
+exit 0;
diff --git a/test/sreset_world/run_sreset_world.tcl b/test/sreset_world/run_sreset_world.tcl
new file mode 100644
index 000000000000..d399a0dafaba
--- /dev/null
+++ b/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 0x300000 skiboot-sreset_world.dump
+exit
diff --git a/test/sreset_world/sreset_kernel/sreset_kernel.S b/test/sreset_world/sreset_kernel/sreset_kernel.S
new file mode 100644
index 000000000000..732d2f75db17
--- /dev/null
+++ b/test/sreset_world/sreset_kernel/sreset_kernel.S
@@ -0,0 +1,112 @@
+/* Copyright 2013-2017 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ Test the SRESET OPAL call in Mambo by
+ having a bit of fun printing 'Hello World' from the SRESET vector.
+*/
+
+ . = 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
+ addi %r7, %r8, sreset_code
+ 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 /* ptr to length of string */
+ addi %r5, %r8, str /* ptr to string start */
+ mr %r2, %r13
+ mtctr %r14
+ bctrl
+
+ li %r0, 145 /* OPAL_SIGNAL_SYSTEM_RESET */
+ li %r3, -1 /* All 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
+ li %r5, str2
+ 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:
+
diff --git a/test/sreset_world/sreset_kernel/sreset_kernel.ld b/test/sreset_world/sreset_kernel/sreset_kernel.ld
new file mode 100644
index 000000000000..d9bbc92857b2
--- /dev/null
+++ b/test/sreset_world/sreset_kernel/sreset_kernel.ld
@@ -0,0 +1,29 @@
+ENTRY(_start)
+SECTIONS
+{
+ .text :
+ {
+ _start = .;
+ *(.text)
+ }
+
+ . = ALIGN(4096);
+ .data :
+ {
+ *(.rodata*)
+ *(.data*)
+ *(.sdata*)
+ *(.got2)
+ }
+
+ . = ALIGN(4096);
+ .bss :
+ {
+ _edata = .;
+ __bss_start = .;
+ *(.sbss)
+ *(.bss)
+ *(COMMON)
+ _end = . ;
+ }
+}
--
2.9.3
More information about the Skiboot
mailing list