s390x: basic test infrastructure
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.
The following, previously sent patches are required:
- [PATCH kvm-unit-tests] Makefile: drop "-lpthread -lrt"
- [kvm-unit-tests PATCH v1 0/3] provide asm-generic spinlock
- [kvm-unit-tests PATCH v1] lib: fix compilation warning
Parts taken from a prototype by Thomas Huth.
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 | 17 ++++++++ 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 | 35 +++++++++++++++ s390x/cstart64.S | 39 +++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++ s390x/selftest.c | 31 ++++++++++++++ s390x/unittests.cfg | 24 +++++++++++ 17 files changed, 574 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 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 | 17 +++++++++++++++ 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 | 32 +++++++++++++++++++++++++++ s390x/cstart64.S | 39 +++++++++++++++++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 19 ++++++++++++++++ 13 files changed, 351 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. +*/ +#include <asm-generic/barrier.h> + +#ifndef _ASM_S390X_BARRIER_H_ +#define _ASM_S390X_BARRIER_H_ + +#endif
lib/s390x/asm/io.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* 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. +*/ +#include <asm-generic/page.h> + +#ifndef _ASMS390X_PAGE_H_ +#define _ASMS390X_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. +*/ +#include <asm-generic/spinlock.h> + +#ifndef __ASMS390X_SPINLOCK_H +#define __ASMS390X_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 +32 -0
@@ -0,0 +1,32 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestanding +CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -msoft-float +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 +39 -0
@@ -0,0 +1,39 @@ +/* + * s390x startup code + * + * 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. + */ +.section .init + +/* entry point - for KVM + TCG we directly start in 64 bit mode */ + .globl start +start: + /* setup stack */ + larl %r15, stacktop + /* setup initial PSW mask */ + larl %r1, initital_psw + lpswe 0(%r1) +init_psw_cont: + /* call setup() */ + brasl %r14, setup + /* forward test parameter */ + larl %r2, __argc + llgf %r2, 0(%r2) + larl %r3, __argv + /* call to main() */ + brasl %r14, main + /* forward exit code */ + lgr %r3, %r2 + /* call exit() */ + j exit + + .align 8 +initital_psw: + .quad 0x0000000180000000, init_psw_cont
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 v1 1/6] s390x: initial infrastructure
Nice to see somebody doing this for s390x.
On 05/12/2017 12:58 PM, David Hildenbrand wrote:
[...]
Quoted 6 lines
s390x/Makefile new file +0
-0
s390x/Makefile line 10
Quoted 10 lines
s390x/Makefile new file +10
-0@@ -0,0 +1,32 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestanding +CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -msoft-float
If you enable the AFP register control bit in your startup code, you can probably avoid the soft-float thing.
Re: [kvm-unit-tests PATCH v1 1/6] s390x: initial infrastructure
Quoted 18 lines · Christian Borntraeger
Nice to see somebody doing this for s390x.
On 05/12/2017 12:58 PM, David Hildenbrand wrote:
[...]Quoted 12 lines
s390x/Makefile new file +6
-0@@ -0,0 +1,32 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestanding
Quoted 9 lines
s390x/Makefile line 10
Quoted 4 lines
s390x/Makefile new file +4
-0+CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -msoft-floatIf you enable the AFP register control bit in your startup code, you can probably avoid the soft-float thing.
Looks like we can drop that completely.
a) no floating point operations are used either way.
b) adding a very basic division results in
static void test_fp(void)
{
double a, b;
b = 6.5;
a = 2.0;
b = b / a;
report("test fp", b == 3.25);
}(compiled with -O0)
s390x/selftest.o: In function `test_fp':/home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:21: undefined reference to __divdf3' /home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:23: undefined reference to __eqdf2'
So we would need a soft float lib (as we're using -nostdlib)
c) dropping -msoft-float
A DDB (DIVIDE long BFP) is generated. That seems to work under TCG without any exception. I assume the check for AFP-register control is missing. I assume, that test would not pass under KVM.
For now I will simply drop -msoft-float.
Thanks!
Signature · 3 lines
Thanks, David
Re: [kvm-unit-tests PATCH v1 1/6] s390x: initial infrastructure
Quoted 57 lines · David Hildenbrand
Quoted 18 lines · Christian Borntraeger
Nice to see somebody doing this for s390x.
On 05/12/2017 12:58 PM, David Hildenbrand wrote:
[...]Quoted 12 lines
s390x/Makefile new file +6
-0@@ -0,0 +1,32 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestandingQuoted 9 lines
s390x/Makefile line 10
Quoted 4 lines
s390x/Makefile new file +4
-0+CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -msoft-floatIf you enable the AFP register control bit in your startup code, you can probably avoid the soft-float thing.
Looks like we can drop that completely.
a) no floating point operations are used either way.
b) adding a very basic division results in
static void
test_fp(void){ double a, b; b = 6.5; a = 2.0; b = b / a; report("test fp", b == 3.25); }(compiled with -O0)
s390x/selftest.o: In function `test_fp':/home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:21: undefined reference to__divdf3' /home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:23: undefined reference to__eqdf2'So we would need a soft float lib (as we're using -nostdlib)
Quoted 8 lines
c) dropping -msoft-float
A DDB (DIVIDE long BFP) is generated. That seems to work under TCG without any exception. I assume the check for AFP-register control is missing. I assume, that test would not pass under KVM.
For now I will simply drop -msoft-float.
This will allow gcc to spill/fill into floating point registers, which are not all available without afp-register control. It will probably work because the gr->fpr move will not be used for -march=z900, but I suggest to not rely on that.
Re: [kvm-unit-tests PATCH v1 1/6] s390x: initial infrastructure
Quoted 65 lines · Christian Borntraeger
Quoted 64 lines · David Hildenbrand
Quoted 18 lines · Christian Borntraeger
Nice to see somebody doing this for s390x.
On 05/12/2017 12:58 PM, David Hildenbrand wrote:
[...]Quoted 12 lines
s390x/Makefile new file +6
-0@@ -0,0 +1,32 @@ +all: test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestandingQuoted 9 lines
s390x/Makefile line 10
Quoted 4 lines
s390x/Makefile new file +4
-0+CFLAGS += -Wextra +CFLAGS += -I lib +CFLAGS += -O2 +CFLAGS += -msoft-floatIf you enable the AFP register control bit in your startup code, you can probably avoid the soft-float thing.
Looks like we can drop that completely.
a) no floating point operations are used either way.
b) adding a very basic division results in
static void
test_fp(void){ double a, b; b = 6.5; a = 2.0; b = b / a; report("test fp", b == 3.25); }(compiled with -O0)
s390x/selftest.o: In function `test_fp':/home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:21: undefined reference to__divdf3' /home/dhildenb/git/kvm-unit-tests/s390x/selftest.c:23: undefined reference to__eqdf2'So we would need a soft float lib (as we're using -nostdlib)
c) dropping -msoft-float
A DDB (DIVIDE long BFP) is generated. That seems to work under TCG without any exception. I assume the check for AFP-register control is missing. I assume, that test would not pass under KVM.
Quoted 7 lines
Quoted 1 line
For now I will simply drop -msoft-float.
This will allow gcc to spill/fill into floating point registers, which are not all available without afp-register control. It will probably work because the
gr->fprmove will not be used for -march=z900, but I suggest to not rely on that.
Good point, so enabling AFP sounds right. And that should be valid on any z/Architecture system (base feature set).
Thanks!
Signature · 3 lines
Thanks, David
PATCH 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 | 31 +++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 +++++ 3 files changed, 38 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 +31 -0
@@ -0,0 +1,31 @@ +/* +* 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> + +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +if (argc !=3 ) +report_abort ("Wrong number of arguments" ); + +if (strcmp (argv[0 ],"s390x/selftest.elf" ) !=0 ) +report_abort ("wrong program name" ); +if (strcmp (argv[1 ],"test" ) !=0 ) +report_abort ("wrong parameter value" ); +if (strcmp (argv[2 ],"123" ) !=0 ) +report_abort ("wrong parameter value" ); + +report ("test true" , true,0 ); + +return report_summary (); +}
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 v1 2/6] s390x: basic self test
2017-05-12 12:58+0200, David Hildenbrand:
Quoted 7 lines
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/selftest.c line 9
Quoted 9 lines
s390x/selftest.c +9
-0@@ -0,0 +1,31 @@ +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +if (argc !=3 ) +report_abort ("Wrong number of arguments" ); + +if (strcmp (argv[0 ],"s390x/selftest.elf" ) !=0 ) +report_abort ("wrong program name" );
This is going to fail when executed as a standalone test (argv[0] would be a temp file name). No point in checking, IMO.
s390x/selftest.c line 28
Quoted 6 lines
s390x/selftest.c +6
-0+if (strcmp (argv[1 ],"test" ) !=0 ) +report_abort ("wrong parameter value" ); +if (strcmp (argv[2 ],"123" ) !=0 ) +report_abort ("wrong parameter value" ); + +report ("test true" , true,0 );
^
It seems you'll be doing v2 -- please remove this zero in it.
(I'll prepare patch that check format of report in order to have
automatic notifications in the future. :])
Thanks.
Re: [kvm-unit-tests PATCH v1 2/6] s390x: basic self test
Quoted 4 lines · Radim Krčmář
2017-05-12 12:58+0200, David Hildenbrand:
Quoted 3 lines
Test if the general infrastructure is working. The test will fail until we have proper sclp console output.
Quoted 16 lines
s390x/selftest.c line 9
Quoted 13 lines
Signed-off-by David Hildenbrand <[email protected]>---
s390x/selftest.c +9
-0@@ -0,0 +1,31 @@ +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +if (argc !=3 ) +report_abort ("Wrong number of arguments" ); + +if (strcmp (argv[0 ],"s390x/selftest.elf" ) !=0 ) +report_abort ("wrong program name" );This is going to fail when executed as a standalone test (argv[0] would be a temp file name). No point in checking, IMO.
That name is determined during compile time, so it shouldn't change, or am i wrong? But if you prefer, I can drop it.
Quoted 9 lines
s390x/selftest.c line 28
Quoted 7 lines
s390x/selftest.c +6
-0+if (strcmp (argv[1 ],"test" ) !=0 ) +report_abort ("wrong parameter value" ); +if (strcmp (argv[2 ],"123" ) !=0 ) +report_abort ("wrong parameter value" ); + +report ("test true" , true,0 );^It seems you'll be doing v2 -- please remove this zero in it.
Thanks, if that would throw an error during compile time like printf, it would be perfect.
Yes, I'll resend!
Quoted 6 lines
(I'll prepare patch that check format of report in order to have
automatic notifications in the future. :])Thanks.
Signature · 3 lines
Thanks, David
Re: [kvm-unit-tests PATCH v1 2/6] s390x: basic self test
2017-05-16 21:16+0200, David Hildenbrand:
Quoted 22 lines · Radim Krčmář
Quoted 4 lines
2017-05-12 12:58+0200, David Hildenbrand:
Quoted 3 lines
Test if the general infrastructure is working. The test will fail until we have proper sclp console output.
Quoted 16 lines
s390x/selftest.c line 9
Quoted 13 lines
Signed-off-by David Hildenbrand <[email protected]>---
s390x/selftest.c +9
-0@@ -0,0 +1,31 @@ +int main (int argc,char **argv) +{ +report_prefix_push ("selftest" ); + +if (argc !=3 ) +report_abort ("Wrong number of arguments" ); + +if (strcmp (argv[0 ],"s390x/selftest.elf" ) !=0 ) +report_abort ("wrong program name" );This is going to fail when executed as a standalone test (argv[0] would be a temp file name). No point in checking, IMO.
Quoted 2 lines
That name is determined during compile time, so it shouldn't change, or am i wrong? But if you prefer, I can drop it.
You are right, only x86 uses the actual kernel file name, sorry.
Quoted 9 lines
Quoted 8 lines
s390x/selftest.c line 28
Quoted 6 lines
s390x/selftest.c +6
-0+if (strcmp (argv[1 ],"test" ) !=0 ) +report_abort ("wrong parameter value" ); +if (strcmp (argv[2 ],"123" ) !=0 ) +report_abort ("wrong parameter value" ); + +report ("test true" , true,0 );^It seems you'll be doing v2 -- please remove this zero in it.
Quoted 4 lines
Thanks, if that would throw an error during compile time like printf, it would be perfect.
Yes, I'll resend!
Thinking more about it, the test would look better if we used report() instead of if()+report_abort() and a final report, something like:
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"));This is also a nitpick and I'll gladly accept the original version. :)
Re: [kvm-unit-tests PATCH v1 2/6] s390x: basic self test
Quoted 15 lines
Quoted 10 lines
Quoted 9 lines
s390x/selftest.c line 28
Quoted 7 lines
s390x/selftest.c new file +6
-0+if (strcmp (argv[1 ],"test" ) !=0 ) +report_abort ("wrong parameter value" ); +if (strcmp (argv[2 ],"123" ) !=0 ) +report_abort ("wrong parameter value" ); + +report ("test true" , true,0 );^It seems you'll be doing v2 -- please remove this zero in it.
Quoted 4 lines
Thanks, if that would throw an error during compile time like printf, it would be perfect.
Yes, I'll resend!
Quoted 9 lines
Thinking more about it, the test would look better if we used
report()instead of if()+report_abort() and a final report, something like: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"));This is also a nitpick and I'll gladly accept the original version. :)
Thanks - I'll add that change and send a new version out tomorrow.
Signature · 3 lines
Thanks, David
PATCH 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
PATCH 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
@@ -20,6 +20,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 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
PATCH 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
@@ -82,3 +82,10 @@ M: Radim Krčmář <[email protected]> L: [email protected] F: x86/* F: lib/x86/* + +S390X +M: Thomas Huth <[email protected]> +M: David Hildenbrand <[email protected]> +L: [email protected] +F: s390x/* +F: lib/s390x/*
Signature · 1 line
2.9.3