s390x: basic test infrastructure
v2 cover s390x: basic test infrastructure
This adds the very basic infrastructure for s390x.
For now, only a basic self test is provided. This one will also run under TCG.
Tested on KVM (on top of z/VM) and TCG.
The following, previously sent patches are required:
- [PATCH kvm-unit-tests] Makefile: drop "-lpthread -lrt"
- [kvm-unit-tests PATCH v2 0/3] provide asm-generic spinlock
Parts taken from a prototype by Thomas Huth.
v1 -> v2:
- enable AFP-register control, so GCC can use FPs and we can drop -msoft-float
- moved #include's into header guards
- beautified the selftest checks
- moved S390X section befor X86 section in MAINTAINERS file
- added a simple division test, that test if the FP unit is enabled and working (necesessary so GCC can use all FP registers)
David Hildenbrand (6):
s390x: initial infrastructure
s390x: basic self test
s390x: copy sclp.h and sclp-ascii.c from QEMU
s390x: compile sclp-ascii.c
s390x: wire up sclp console output
MAINTAINERS: add s390x maintainers
MAINTAINERS | 7 +++ configure | 2 +- lib/s390x/asm/barrier.h | 16 +++++++ lib/s390x/asm/io.h | 18 ++++++++ lib/s390x/asm/page.h | 16 +++++++ lib/s390x/asm/spinlock.h | 16 +++++++ lib/s390x/asm/stack.h | 21 +++++++++ lib/s390x/io.c | 49 +++++++++++++++++++++ lib/s390x/sclp-ascii.c | 68 +++++++++++++++++++++++++++++ lib/s390x/sclp.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++ lib/s390x/stack.c | 28 ++++++++++++ s390x/Makefile | 34 +++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++ s390x/selftest.c | 41 ++++++++++++++++++ s390x/unittests.cfg | 24 +++++++++++ 17 files changed, 589 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/asm/barrier.h create mode 100644 lib/s390x/asm/io.h create mode 100644 lib/s390x/asm/page.h create mode 100644 lib/s390x/asm/spinlock.h create mode 100644 lib/s390x/asm/stack.h create mode 100644 lib/s390x/io.c create mode 100644 lib/s390x/sclp-ascii.c create mode 100644 lib/s390x/sclp.h create mode 100644 lib/s390x/stack.c create mode 100644 s390x/Makefile create mode 100644 s390x/cstart64.S create mode 100644 s390x/flat.lds create mode 100755 s390x/run create mode 100644 s390x/selftest.c create mode 100644 s390x/unittests.cfg
Signature · 1 line
2.9.3
PATCH v2 1/6 s390x: initial infrastructure
This adds the very basic infrastructure for s390x. As we compile for z900, also QEMU tcg can be used.
To cross compile:
$./configure --arch=s390x --cross-prefix=/usr/bin/s390x-linux-gnu-
$ make
Please note that for now, nothing will be compiled, as there is no test to compile. A basic self test will be added in the following patches.
smp and stack unwinding is not supported yet. sclp console output will be added in the following patches.
Parts based on a prototype by Thomas Huth.
--- configure | 2 +- lib/s390x/asm/barrier.h | 16 ++++++++++++++ lib/s390x/asm/io.h | 18 ++++++++++++++++ lib/s390x/asm/page.h | 16 ++++++++++++++ lib/s390x/asm/spinlock.h | 16 ++++++++++++++ lib/s390x/asm/stack.h | 21 ++++++++++++++++++ lib/s390x/io.c | 48 +++++++++++++++++++++++++++++++++++++++++ lib/s390x/stack.c | 28 ++++++++++++++++++++++++ s390x/Makefile | 31 +++++++++++++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 19 ++++++++++++++++ 13 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/asm/barrier.h create mode 100644 lib/s390x/asm/io.h create mode 100644 lib/s390x/asm/page.h create mode 100644 lib/s390x/asm/spinlock.h create mode 100644 lib/s390x/asm/stack.h create mode 100644 lib/s390x/io.c create mode 100644 lib/s390x/stack.c create mode 100644 s390x/Makefile create mode 100644 s390x/cstart64.S create mode 100644 s390x/flat.lds create mode 100755 s390x/run create mode 100644 s390x/unittests.cfg
configure +1 -1
@@ -7,7 +7,7 @@ objcopy=objcopy objdump=objdump ar=ar addr2line=addr2line -arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` +arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/;s/s390x.*/s390x/'` host=$arch cross_prefix= endian=""
lib/s390x/asm/barrier.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#ifndef _ASM_S390X_BARRIER_H_ +#define _ASM_S390X_BARRIER_H_ + +#include <asm-generic/barrier.h> + +#endif
lib/s390x/asm/io.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#ifndef _ASMS390X_IO_H_ +#define _ASMS390X_IO_H_ + +#define __iomem + +#include <asm-generic/io.h> + +#endif
lib/s390x/asm/page.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#ifndef _ASMS390X_PAGE_H_ +#define _ASMS390X_PAGE_H_ + +#include <asm-generic/page.h> + +#endif
lib/s390x/asm/spinlock.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#ifndef __ASMS390X_SPINLOCK_H +#define __ASMS390X_SPINLOCK_H + +#include <asm-generic/spinlock.h> + +#endif
lib/s390x/asm/stack.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#ifndef _ASMS390X_STACK_H_ +#define _ASMS390X_STACK_H_ + +#ifndef _STACK_H_ +#error Do not directly include <asm/stack.h>. Just use <stack.h>. +#endif + +#define HAVE_ARCH_BACKTRACE_FRAME +#define HAVE_ARCH_BACKTRACE + +#endif
lib/s390x/io.c new file +48 -0
48 lines not on this page · raw message
lib/s390x/stack.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* s390x stack implementation +* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#include <libcflat.h> +#include <stack.h> + +int backtrace_frame (const void *frame,const void **return_addrs,int max_depth) +{ +printf ("TODO: Implement backtrace_frame(%p, %p, %d) function!\n" , + frame, return_addrs, max_depth); +return 0 ; +} + +int backtrace (const void **return_addrs,int max_depth) +{ +printf ("TODO: Implement backtrace(%p, %d) function!\n" , + return_addrs, max_depth); +return 0 ; +}
s390x/Makefile new file +31 -0
@@ -0,0 +1,31 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestanding +CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -march=z900 +LDFLAGS += -nostdlib + +# We want to keep intermediate files +.PRECIOUS: %.o + +cflatobjs += lib/util.o +cflatobjs += lib/alloc.o +cflatobjs += lib/s390x/io.o +cflatobjs += lib/s390x/stack.o + +cstart.o = $(TEST_DIR)/cstart64.o + +FLATLIBS = $(libcflat) +%.elf: %.o $(FLATLIBS) s390x/flat.lds $(cstart.o) + $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) lib/auxinfo.c -DPROGNAME=\"$@\" + $(CC) $(LDFLAGS) -o $@ -T s390x/flat.lds -Ttext=0x10000 \ + $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o) + $(RM) $(@:.elf=.aux.o) + +arch_clean: + $(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/.*.d lib/s390x/.*.d
s390x/cstart64.S new file +44 -0
44 lines not on this page · raw message
s390x/flat.lds new file +42 -0
42 lines not on this page · raw message
s390x/run new file +56 -0
56 lines not on this page · raw message
s390x/unittests.cfg new file +19 -0
@@ -0,0 +1,19 @@ +############################################################################## +# unittest configuration +# +# [unittest_name] +# file = <name>.elf # Name of the elf file to be used. +# extra_params = -append <params...> # Additional parameters used. +# groups = <group_name1> <group_name2> ... # Used to identify test cases +# # with run_tests -g ... +# # Specify group_name=nodefault +# # to have test not run by default +# accel = kvm|tcg # Optionally specify if test must run with +# # kvm or tcg. If not specified, then kvm will +# # be used when available. +# timeout = <duration> # Optionally specify a timeout. +# check = <path>=<value> # check a file for a particular value before running +# # a test. The check line can contain multiple files +# # to check separated by a space but each check +# # parameter needs to be of the form <path>=<value> +##############################################################################
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v2 1/6] s390x: initial infrastructure
Quoted 50 lines · David Hildenbrand
This adds the very basic infrastructure for s390x. As we compile for z900, also QEMU tcg can be used.
To cross compile:
$./configure --arch=s390x --cross-prefix=/usr/bin/s390x-linux-gnu-
$ makePlease note that for now, nothing will be compiled, as there is no test to compile. A basic self test will be added in the following patches.
smp and stack unwinding is not supported yet. sclp console output will be added in the following patches.
Parts based on a prototype by Thomas Huth.
Signed-off-by David Hildenbrand <[email protected]>--- configure | 2 +- lib/s390x/asm/barrier.h | 16 ++++++++++++++ lib/s390x/asm/io.h | 18 ++++++++++++++++ lib/s390x/asm/page.h | 16 ++++++++++++++ lib/s390x/asm/spinlock.h | 16 ++++++++++++++ lib/s390x/asm/stack.h | 21 ++++++++++++++++++ lib/s390x/io.c | 48 +++++++++++++++++++++++++++++++++++++++++ lib/s390x/stack.c | 28 ++++++++++++++++++++++++ s390x/Makefile | 31 +++++++++++++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 19 ++++++++++++++++ 13 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/asm/barrier.h create mode 100644 lib/s390x/asm/io.h create mode 100644 lib/s390x/asm/page.h create mode 100644 lib/s390x/asm/spinlock.h create mode 100644 lib/s390x/asm/stack.h create mode 100644 lib/s390x/io.c create mode 100644 lib/s390x/stack.c create mode 100644 s390x/Makefile create mode 100644 s390x/cstart64.S create mode 100644 s390x/flat.lds create mode 100755 s390x/run create mode 100644 s390x/unittests.cfgconfigure +0
-0
configure objcopy=objcopy · line 13
Quoted 8 lines
configure +1
-1@@ -7,7 +7,7 @@ objcopy=objcopy objdump=objdump ar=ar addr2line=addr2line -arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` +arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/;s/s390x.*/s390x/'` host=$arch cross_prefix= endian=""
I think we likely do not need this hunk on s390x, since we do not got something like ppc64le there...?
[...]
Quoted 30 lines
s390x/run new file +24
-0@@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +if [ -z "$STANDALONE" ]; then + if [ ! -f config.mak ]; then + echo "run ./configure && make first. See ./configure -h" + exit 2 + fi + source config.mak + source scripts/arch-run.bash +fi + +if [ -c /dev/kvm ]; then + if [ "$HOST" = "s390x" ] && [ "$ARCH" = "s390x" ]; then + kvm_available=yes + fi +fi + +if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then + echo "KVM is needed, but not available on this host" + exit 2 +fi + +if [ -z "$ACCEL" ]; then + if [ "$kvm_available" = "yes" ]; then
s390x/run line 34
Quoted 10 lines
s390x/run new file +10
-0+ ACCEL="kvm" + else + ACCEL="tcg" + fi +fi + +qemu=$(search_qemu_binary) + +M='-machine s390-ccw-virtio' +M+=",accel=$ACCEL"
I'd maybe put the two above lines into one line only:
M="-M s390-ccw-virtio,accel=$ACCEL"
Quoted 12 lines
s390x/run new file +12
-0+command="$qemu -nodefaults -nographic $M" +command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" +[ -f "$ENV" ] && command+=" -initrd $ENV" +command+=" -kernel" +command="$(timeout_cmd) $command" +echo $command "$@" + +# We return the exit code via stdout, not via the QEMU return code +lines=$(run_qemu $command "$@") +ret=$? +echo "$lines" +if [ $ret -eq 1 ]; then
s390x/run line 56
Quoted 10 lines
s390x/run new file +10
-0+ testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') + if [ "$testret" ]; then + if [ $testret -eq 1 ]; then + ret=0 + else + ret=$testret + fi + fi +fi +exit $ret
Apart from the two nits, patch looks fine to me, so feel free to add my:
Re: [kvm-unit-tests PATCH v2 1/6] s390x: initial infrastructure
Quoted 46 lines · Thomas Huth
Quoted 45 lines · David Hildenbrand
This adds the very basic infrastructure for s390x. As we compile for z900, also QEMU tcg can be used.
To cross compile:
$./configure --arch=s390x --cross-prefix=/usr/bin/s390x-linux-gnu-
$ makePlease note that for now, nothing will be compiled, as there is no test to compile. A basic self test will be added in the following patches.
smp and stack unwinding is not supported yet. sclp console output will be added in the following patches.
Parts based on a prototype by Thomas Huth.
Signed-off-by David Hildenbrand <[email protected]>--- configure | 2 +- lib/s390x/asm/barrier.h | 16 ++++++++++++++ lib/s390x/asm/io.h | 18 ++++++++++++++++ lib/s390x/asm/page.h | 16 ++++++++++++++ lib/s390x/asm/spinlock.h | 16 ++++++++++++++ lib/s390x/asm/stack.h | 21 ++++++++++++++++++ lib/s390x/io.c | 48 +++++++++++++++++++++++++++++++++++++++++ lib/s390x/stack.c | 28 ++++++++++++++++++++++++ s390x/Makefile | 31 +++++++++++++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 19 ++++++++++++++++ 13 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 lib/s390x/asm/barrier.h create mode 100644 lib/s390x/asm/io.h create mode 100644 lib/s390x/asm/page.h create mode 100644 lib/s390x/asm/spinlock.h create mode 100644 lib/s390x/asm/stack.h create mode 100644 lib/s390x/io.c create mode 100644 lib/s390x/stack.c create mode 100644 s390x/Makefile create mode 100644 s390x/cstart64.S create mode 100644 s390x/flat.lds create mode 100755 s390x/run create mode 100644 s390x/unittests.cfg
Quoted 16 lines
configure objcopy=objcopy · line 13
Quoted 13 lines
configure +1
-1@@ -7,7 +7,7 @@ objcopy=objcopy objdump=objdump ar=ar addr2line=addr2line -arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` +arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/;s/s390x.*/s390x/'` host=$arch cross_prefix= endian=""I think we likely do not need this hunk on s390x, since we do not got something like ppc64le there...?
Correct, uname -m should return "s390x" only, will drop it.
Quoted 45 lines
[...]
Quoted 30 lines
s390x/run new file +24
-0@@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +if [ -z "$STANDALONE" ]; then + if [ ! -f config.mak ]; then + echo "run ./configure && make first. See ./configure -h" + exit 2 + fi + source config.mak + source scripts/arch-run.bash +fi + +if [ -c /dev/kvm ]; then + if [ "$HOST" = "s390x" ] && [ "$ARCH" = "s390x" ]; then + kvm_available=yes + fi +fi + +if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then + echo "KVM is needed, but not available on this host" + exit 2 +fi + +if [ -z "$ACCEL" ]; then + if [ "$kvm_available" = "yes" ]; thens390x/run line 34
Quoted 10 lines
s390x/run new file +10
-0+ ACCEL="kvm" + else + ACCEL="tcg" + fi +fi + +qemu=$(search_qemu_binary) + +M='-machine s390-ccw-virtio' +M+=",accel=$ACCEL"I'd maybe put the two above lines into one line only:
Quoted 1 line
M="-M s390-ccw-virtio,accel=$ACCEL"
This is similar to powerpc/run, so I'll leave it like that for now.
Quoted 26 lines
Quoted 13 lines
s390x/run new file +12
-0+command="$qemu -nodefaults -nographic $M" +command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" +[ -f "$ENV" ] && command+=" -initrd $ENV" +command+=" -kernel" +command="$(timeout_cmd) $command" +echo $command "$@" + +# We return the exit code via stdout, not via the QEMU return code +lines=$(run_qemu $command "$@") +ret=$? +echo "$lines" +if [ $ret -eq 1 ]; thens390x/run line 56
Quoted 10 lines
s390x/run new file +10
-0+ testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') + if [ "$testret" ]; then + if [ $testret -eq 1 ]; then + ret=0 + else + ret=$testret + fi + fi +fi +exit $retApart from the two nits, patch looks fine to me, so feel free to add my:
Quoted 2 lines
Reviewed-by Thomas Huth <[email protected]>
Thanks!
Signature · 3 lines
Thanks, David
PATCH v2 2/6 s390x: basic self test
In reply to David HildenbrandTest if the general infrastructure is working. The test will fail until we have proper sclp console output.
--- s390x/Makefile | 2 ++ s390x/selftest.c | 41 +++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 +++++ 3 files changed, 48 insertions(+) create mode 100644 s390x/selftest.c
s390x/Makefile +2 -0
@@ -1,3 +1,5 @@ +tests = $(TEST_DIR)/selftest.elf + all: test_cases test_cases: $(tests)
s390x/selftest.c new file +41 -0
41 lines not on this page · raw message
s390x/unittests.cfg +5 -0
@@ -17,3 +17,8 @@ # # to check separated by a space but each check # # parameter needs to be of the form <path>=<value> ############################################################################## + +[selftest-setup] +file = selftest.elf +groups = selftest +extra_params = -append 'test 123'
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v2 2/6] s390x: basic self test
Quoted 40 lines · David Hildenbrand
Test if the general infrastructure is working. The test will fail until we have proper sclp console output.
Signed-off-by David Hildenbrand <[email protected]>--- s390x/Makefile | 2 ++ s390x/selftest.c | 41 +++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 +++++ 3 files changed, 48 insertions(+) create mode 100644 s390x/selftest.cs390x/Makefile +2
-0@@ -1,3 +1,5 @@ +tests = $(TEST_DIR)/selftest.elf + all: test_cases test_cases: $(tests)s390x/selftest.c new file +13
-0@@ -0,0 +1,41 @@ +/* +* Copyright (c) 2017 Red Hat Inc +* +* Authors: +* Thomas Huth <[email protected]> +* David Hildenbrand <[email protected]> +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU Library General Public License version 2. +*/ +#include <libcflat.h> +#include <util.h> +
s390x/selftest.c line 23
Quoted 10 lines
s390x/selftest.c new file +10
-0+static void test_fp (void ) +{ +double a =3.0 ; +double b =2.0 ; +double c; + + asmvolatile ( +" ddb %1, %2\n" +" std %1, %0\n" + :"=m" (c) :"f" (a),"m" (b) : );
You could omit the final ":" here.
s390x/selftest.c line 25
Quoted 2 lines
s390x/selftest.c new file +2
-0+ +report ("3.0/2.0 == 1.5" , c ==1.5 );
The indentation of the last parameter looks weird when only looking at this function.
s390x/selftest.c line 36
Quoted 11 lines
s390x/selftest.c new file +11
-0+} + +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +report ("true" , true); +report ("argc == 3" , argc ==3 ); +report ("argv[0] == PROGNAME" , !strcmp (argv[0 ],"s390x/selftest.elf" )); +report ("argv[1] == test" , !strcmp (argv[1 ],"test" )); +report ("argv[2] == 123" , !strcmp (argv[2 ],"123" ));
I think I'd also prefer if you could remove the indentation of the second parameters here.
Also not sure whether we should really use the argv[1] and argv[2] test here? ... that way, you hardly can run this test manually (without unittests.cfg) ... I think it would be nicer if we'd had something like in arm/selftest.c here one day ... but ok, for a start, it's likely ok.
Quoted 10 lines
s390x/selftest.c new file +4
-0+test_fp (); + +return report_summary (); +}s390x/unittests.cfg +0
-0
s390x/unittests.cfg line 24
Quoted 8 lines
s390x/unittests.cfg +5
-0@@ -17,3 +17,8 @@ # # to check separated by a space but each check # # parameter needs to be of the form <path>=<value> ############################################################################## + +[selftest-setup] +file = selftest.elf +groups = selftest +extra_params = -append 'test 123'
Thomas
Re: [kvm-unit-tests PATCH v2 2/6] s390x: basic self test
Quoted 7 lines
s390x/selftest.c line 23
Quoted 5 lines
s390x/selftest.c new file +4
-0+ asmvolatile ( +" ddb %1, %2\n" +" std %1, %0\n" + :"=m" (c) :"f" (a),"m" (b) : );You could omit the final ":" here.
Yes, will drop it!
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + report("3.0/2.0 == 1.5", c == 1.5);The indentation of the last parameter looks weird when only looking at this function.
Quoted 14 lines
s390x/selftest.c line 36
Quoted 11 lines
s390x/selftest.c new file +11
-0+} + +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +report ("true" , true); +report ("argc == 3" , argc ==3 ); +report ("argv[0] == PROGNAME" , !strcmp (argv[0 ],"s390x/selftest.elf" )); +report ("argv[1] == test" , !strcmp (argv[1 ],"test" )); +report ("argv[2] == 123" , !strcmp (argv[2 ],"123" ));I think I'd also prefer if you could remove the indentation of the second parameters here.
Me too, added it because Radim proposed it. Will simply drop the indentation.
Quoted 4 lines
Also not sure whether we should really use the argv[1] and argv[2] test here? ... that way, you hardly can run this test manually (without unittests.cfg) ... I think it would be nicer if we'd had something like in
arm/selftest.chere one day ... but ok, for a start, it's likely ok.
Mixed feelings, for now I think this should be fine.
Testing frameworks will run it via unittests.cfg
The handful of people that actually execute the test manually either now about this or should be able to figure out what is going on here.
So I agree, that we could change this later, once everything has been running fine for a while.
Quoted 13 lines
Quoted 13 lines
s390x/selftest.c new file +4
-0+test_fp (); + +return report_summary (); +}s390x/unittests.cfg +0
-0@@ -17,3 +17,8 @@ # # to check separated by a space but each check # # parameter needs to be of the form <path>=<value> ##############################################################################
Quoted 9 lines
s390x/unittests.cfg line 24
Quoted 6 lines
s390x/unittests.cfg +5
-0+ +[selftest-setup] +file = selftest.elf +groups = selftest +extra_params = -append 'test 123'Thomas
Thanks!
Signature · 3 lines
Thanks, David
PATCH v2 3/6 s390x: copy sclp.h and sclp-ascii.c from QEMU
In reply to David HildenbrandThe s390x-ccw pcbios already has what we need to print to the sclp console. Let's copy the files and adjust them to our needs later.
--- lib/s390x/sclp-ascii.c | 82 +++++++++++++++++++++++++++++++++++++ lib/s390x/sclp.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 lib/s390x/sclp-ascii.c create mode 100644 lib/s390x/sclp.h
lib/s390x/sclp-ascii.c new file +82 -0
@@ -0,0 +1,82 @@ +/* +* SCLP ASCII access driver +* +* Copyright (c) 2013 Alexander Graf <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at +* your option) any later version. See the COPYING file in the top-level +* directory. +*/ + +#include "s390-ccw.h" +#include "sclp.h" + +static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096))); + +/* Perform service call. Return 0 on success, non-zero otherwise. */ +static int sclp_service_call (unsigned int command,void *sccb) +{ +int cc; + + asmvolatile ( +" .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */ +" ipm %0\n" +" srl %0,28" + :"=&d" (cc) :"d" (command),"a" (__pa (sccb)) + :"cc" ,"memory" ); +consume_sclp_int (); +if (cc ==3 ) +return -EIO ; +if (cc ==2 ) +return -EBUSY ; +return 0 ; +} + +static void sclp_set_write_mask (void ) +{ +WriteEventMask *sccb = (void *)_sccb; + + sccb->h.length =sizeof (WriteEventMask); + sccb->mask_length =sizeof (unsigned int ); + sccb->receive_mask =SCLP_EVENT_MASK_MSG_ASCII ; + sccb->cp_receive_mask =SCLP_EVENT_MASK_MSG_ASCII ; + sccb->send_mask =SCLP_EVENT_MASK_MSG_ASCII ; + sccb->cp_send_mask =SCLP_EVENT_MASK_MSG_ASCII ; + +sclp_service_call (SCLP_CMD_WRITE_EVENT_MASK , sccb); +} + +void sclp_setup (void ) +{ +sclp_set_write_mask (); +} + +static int _strlen (const char *str) +{ +int i; +for (i =0 ; *str; i++) + str++; +return i; +} + +static void _memcpy (char *dest,const char *src,int len) +{ +int i; +for (i =0 ; i < len; i++) + dest[i] = src[i]; +} + +void sclp_print (const char *str) +{ +int len =_strlen (str); +WriteEventData *sccb = (void *)_sccb; + + sccb->h.length =sizeof (WriteEventData) + len; + sccb->h.function_code =SCLP_FC_NORMAL_WRITE ; + sccb->ebh.length =sizeof (EventBufferHeader) + len; + sccb->ebh.type =SCLP_EVENT_ASCII_CONSOLE_DATA ; + sccb->ebh.flags =0 ; +_memcpy (sccb->data, str, len); + +sclp_service_call (SCLP_CMD_WRITE_EVENT_DATA , sccb); +}
lib/s390x/sclp.h new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v2 3/6] s390x: copy sclp.h and sclp-ascii.c from QEMU
lib/s390x/sclp-ascii.c
Quoted 16 lines · David Hildenbrand
The s390x-ccw pcbios already has what we need to print to the sclp console. Let's copy the files and adjust them to our needs later.
Signed-off-by David Hildenbrand <[email protected]>--- lib/s390x/sclp-ascii.c | 82 +++++++++++++++++++++++++++++++++++++ lib/s390x/sclp.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 lib/s390x/sclp-ascii.c create mode 100644 lib/s390x/sclp.hlib/s390x/sclp-ascii.c new file +0
-0
Looks like the file has been renamed to sclp.c in recent QEMU master ... maybe we should use that name here, too?
Thomas
Re: [kvm-unit-tests PATCH v2 3/6] s390x: copy sclp.h and sclp-ascii.c from QEMU
Quoted 12 lines · Thomas Huth
Quoted 11 lines · David Hildenbrand
The s390x-ccw pcbios already has what we need to print to the sclp console. Let's copy the files and adjust them to our needs later.
Signed-off-by David Hildenbrand <[email protected]>--- lib/s390x/sclp-ascii.c | 82 +++++++++++++++++++++++++++++++++++++ lib/s390x/sclp.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 lib/s390x/sclp-ascii.c create mode 100644 lib/s390x/sclp.h
Quoted 9 lines
lib/s390x/sclp-ascii.c
Quoted 5 lines
lib/s390x/sclp-ascii.c new file +0
-0Looks like the file has been renamed to
sclp.cin recent QEMU master ... maybe we should use that name here, too?
At the time I copied it, it was called sclp-ascii.c, so this should be fine I think. Also, if we ever add new code related to sclp, we will rather put it into a new file, which could then become sclp.c
Quoted 2 lines
Thomas
Thanks
Signature · 3 lines
Thanks, David
PATCH v2 4/6 s390x: compile sclp-ascii.c
In reply to David HildenbrandWe can reuse strlen and memcpy. __pa(x) is already defined in page.h We don't have (and need) defines for error values and consuming sclp irqs is not required, as we won't be passing control to some other OS.
--- lib/s390x/sclp-ascii.c | 28 +++++++--------------------- lib/s390x/sclp.h | 2 -- s390x/Makefile | 1 + 3 files changed, 8 insertions(+), 23 deletions(-)
lib/s390x/sclp-ascii.c +7 -21
@@ -8,7 +8,9 @@* directory. */ -#include "s390-ccw.h" +#include <libcflat.h> +#include <string.h> +#include <asm/page.h> #include "sclp.h" static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
@@ -24,11 +26,10 @@ static int sclp_service_call(unsigned int command, void *sccb)" srl %0,28" : "=&d" (cc) : "d" (command), "a" (__pa(sccb)) : "cc", "memory"); - consume_sclp_int(); if (cc == 3) -return -EIO ; +return -1 ;if (cc ==2 ) -return -EBUSY ; +return -1 ;return 0 ; }
@@ -51,24 +52,9 @@ void sclp_setup(void)sclp_set_write_mask (); } -static int _strlen (const char *str) -{ -int i; -for (i =0 ; *str; i++) - str++; -return i; -} - -static void _memcpy (char *dest,const char *src,int len) -{ -int i; -for (i =0 ; i < len; i++) - dest[i] = src[i]; -} -void sclp_print (const char *str) { -int len =_strlen (str); +int len =strlen (str);WriteEventData *sccb = (void *)_sccb; sccb->h.length =sizeof (WriteEventData) + len;
@@ -76,7 +62,7 @@ void sclp_print(const char *str) sccb->ebh.length =sizeof (EventBufferHeader) + len; sccb->ebh.type =SCLP_EVENT_ASCII_CONSOLE_DATA ; sccb->ebh.flags =0 ; -_memcpy (sccb->data, str, len); +memcpy (sccb->data, str, len);sclp_service_call (SCLP_CMD_WRITE_EVENT_DATA , sccb); }
lib/s390x/sclp.h +0 -2
@@ -102,6 +102,4 @@ typedef struct ReadEventData {uint32_t mask; } __attribute__((packed)) ReadEventData; -#define __pa (x) (x) -#endif /* SCLP_H */
s390x/Makefile +1 -0
@@ -19,6 +19,7 @@ cflatobjs += lib/util.o cflatobjs += lib/alloc.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o +cflatobjs += lib/s390x/sclp-ascii.o cstart.o = $(TEST_DIR)/cstart64.o
Signature · 1 line
2.9.3
PATCH v2 5/6 s390x: wire up sclp console output
In reply to David HildenbrandNow the basics should be working and therefore the self test should pass.
--- lib/s390x/io.c | 5 +++-- lib/s390x/sclp.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-)
lib/s390x/io.c +3 -2
@@ -12,6 +12,7 @@*/ #include <libcflat.h> #include <asm/spinlock.h> +#include "sclp.h" extern void setup_args_progname (const char *args);extern char ipl_args[];
@@ -21,8 +22,7 @@ static struct spinlock lock;void puts (const char *s) {spin_lock (&lock); -/* FIXME */ - (void )s; +sclp_print (s);spin_unlock (&lock); }
@@ -39,6 +39,7 @@ static void sigp_stop()void setup () {setup_args_progname (ipl_args); +sclp_setup (); }void exit (int code)
lib/s390x/sclp.h +3 -0
@@ -102,4 +102,7 @@ typedef struct ReadEventData {uint32_t mask; } __attribute__((packed)) ReadEventData; +void sclp_setup (void ); +void sclp_print (const char *str); +#endif /* SCLP_H */
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v2 5/6] s390x: wire up sclp console output
Quoted 44 lines · David Hildenbrand
Now the basics should be working and therefore the self test should pass.
Signed-off-by David Hildenbrand <[email protected]>--- lib/s390x/io.c | 5 +++-- lib/s390x/sclp.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-)lib/s390x/io.c +3
-2@@ -12,6 +12,7 @@*/ #include <libcflat.h> #include <asm/spinlock.h> +#include "sclp.h" extern void setup_args_progname (const char *args);extern char ipl_args[];@@ -21,8 +22,7 @@ static struct spinlock lock;void puts (const char *s) {spin_lock (&lock); -/* FIXME */ - (void )s; +sclp_print (s);spin_unlock (&lock); }@@ -39,6 +39,7 @@ static void sigp_stop()void setup () {setup_args_progname (ipl_args); +sclp_setup (); }void exit (int code)lib/s390x/sclp.h +0
-0
lib/s390x/sclp.h typedef struct ReadEventData { · line 108
Quoted 7 lines
lib/s390x/sclp.h +3
-0@@ -102,4 +102,7 @@ typedef struct ReadEventData {uint32_t mask; } __attribute__((packed)) ReadEventData; +void sclp_setup (void ); +void sclp_print (const char *str); +#endif /* SCLP_H */
PATCH v2 6/6 MAINTAINERS: add s390x maintainers
In reply to David HildenbrandAdd Thomas and myself as maintainers for now.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -76,6 +76,13 @@ F: powerpc/* F: lib/powerpc/* F: lib/ppc64/* +S390X +M: Thomas Huth <[email protected]> +M: David Hildenbrand <[email protected]> +L: [email protected] +F: s390x/* +F: lib/s390x/* + X86 M: Paolo Bonzini <[email protected]> M: Radim Krčmář <[email protected]>
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v2 6/6] MAINTAINERS: add s390x maintainers
Quoted 16 lines · David Hildenbrand
Add Thomas and myself as maintainers for now.
Signed-off-by David Hildenbrand <[email protected]>--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)MAINTAINERS +0
-0@@ -76,6 +76,13 @@ F: powerpc/* F: lib/powerpc/* F: lib/ppc64/*
MAINTAINERS F: powerpc/* · line 88
Quoted 10 lines
MAINTAINERS +7
-0+S390X +M: Thomas Huth <[email protected]> +M: David Hildenbrand <[email protected]> +L: [email protected] +F: s390x/* +F: lib/s390x/* + X86 M: Paolo Bonzini <[email protected]> M: Radim Krčmář <[email protected]>