s390x: basic test infrastructure
v3 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.
Parts taken from a prototype by Thomas Huth.
v2 -> v3:
- Fixed it up to allow for out-of-tree builds, added it to .travis.yml
- Selftest: removed parameter intendation, dropped a ":" from inline asm
David Hildenbrand (7):
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
.travis.yml: add s390x
MAINTAINERS: add s390x maintainers
.travis.yml | 5 +++ MAINTAINERS | 7 +++ 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 | 37 ++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++ s390x/selftest.c | 41 ++++++++++++++++++ s390x/unittests.cfg | 24 +++++++++++ 17 files changed, 596 insertions(+) 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 v3 1/7 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.
--- 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 | 34 +++++++++++++++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 19 ++++++++++++++++ 12 files changed, 358 insertions(+) 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
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 +34 -0
@@ -0,0 +1,34 @@ +all: directories test_cases + +test_cases: $(tests) + +CFLAGS += -std=gnu99 +CFLAGS += -ffreestanding +CFLAGS += -Wextra +CFLAGS += -I $(SRCDIR)/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 + +OBJDIRS += lib/s390x + +cstart.o = $(TEST_DIR)/cstart64.o + +FLATLIBS = $(libcflat) +%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(cstart.o) + $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \ + $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\" + $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/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
PATCH v3 2/7 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: directories 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 v3 2/7] s390x: basic self test
Quoted 10 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.c
PATCH v3 3/7 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 v3 3/7] s390x: copy sclp.h and sclp-ascii.c from QEMU
Quoted 10 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
PATCH v3 4/7 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 OBJDIRS += lib/s390x
Signature · 1 line
2.9.3
Re: [kvm-unit-tests PATCH v3 4/7] s390x: compile sclp-ascii.c
Quoted 10 lines · David Hildenbrand
We can reuse strlen and memcpy.
__pa(x)is already defined inpage.hWe 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.Signed-off-by David Hildenbrand <[email protected]>--- lib/s390x/sclp-ascii.c | 28 +++++++--------------------- lib/s390x/sclp.h | 2 -- s390x/Makefile | 1 + 3 files changed, 8 insertions(+), 23 deletions(-)
PATCH v3 5/7 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 v3 6/7 .travis.yml: add s390x
In reply to David HildenbrandLet's also add the brand new s390x version.
--- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+)
.travis.yml +5 -0
@@ -11,6 +11,7 @@ addons: - gcc-arm-linux-gnueabihf - gcc-aarch64-linux-gnu - gcc-powerpc64le-linux-gnu + - gcc-s390x-linux-gnu # Run dependencies - qemu-system git:
@@ -33,6 +34,10 @@ env: BUILD_DIR="." - CONFIG="--arch=ppc64 --endian=little --cross-prefix=powerpc64le-linux-gnu-" BUILD_DIR="ppc64le-buildir" + - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-" + BUILD_DIR="." + - CONFIG="--arch=s390x --cross-prefix=s390x-linux-gnu-" + BUILD_DIR="s390x-builddir" before_script: - mkdir -p $BUILD_DIR && cd $BUILD_DIR
Signature · 1 line
2.9.3
PATCH v3 7/7 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
Paolo Bonzini
maintainerQuoted 46 lines · David Hildenbrand
This adds the very basic infrastructure for s390x.
For now, only a basic self test is provided. This one will also run under TCG.
Parts taken from a prototype by Thomas Huth.
v2 -> v3:
- Fixed it up to allow for out-of-tree builds, added it to .travis.yml
- Selftest: removed parameter intendation, dropped a ":" from inline asmDavid Hildenbrand (7):
s390x: initial infrastructure
s390x: basic self test
s390x: copysclp.handsclp-ascii.cfrom QEMU
s390x: compilesclp-ascii.c
s390x: wire up sclp console output
.travis.yml: add s390x
MAINTAINERS: add s390x maintainers.travis.yml | 5 +++ MAINTAINERS | 7 +++ 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 | 37 ++++++++++++++++ s390x/cstart64.S | 44 +++++++++++++++++++ s390x/flat.lds | 42 ++++++++++++++++++ s390x/run | 56 ++++++++++++++++++++++++ s390x/selftest.c | 41 ++++++++++++++++++ s390x/unittests.cfg | 24 +++++++++++ 17 files changed, 596 insertions(+) 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
Quoted 9 lines
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
Thanks, didn't have time to test it today. Will push tomorrow.
Paolo