s390x updates
Hi Paolo,
The following changes since commit f2606a873e805f9aff4c4879ec75e65d7e30af73:
Makefile: Compile the kvm-unit-tests with -fno-strict-aliasing (2020-01-22 16:29:43 +0100)
are available in the Git repository at:
https://github.com/davidhildenbrand/kvm-unit-tests.git tags/s390x-2020-01-30
for you to fetch changes up to 1cbda07c1cc63589686048866ee24459c38c42f5:
s390x: SCLP unit test (2020-01-24 09:47:00 +0100)
----------------------------------------------------------------
Add new SCLP unit test
----------------------------------------------------------------
Claudio Imbrenda (6):
s390x: export sclp_setup_int
s390x: sclp: add service call instruction wrapper
s390x: lib: fix stfl wrapper asm
s390x: lib: add SPX and STPX instruction wrapper
s390x: lib: fix program interrupt handler if sclp_busy was set
s390x: SCLP unit testlib/s390x/asm/arch_def.h | 26 +++ lib/s390x/asm/facility.h | 2 +- lib/s390x/interrupt.c | 5 +- lib/s390x/sclp.c | 9 +- lib/s390x/sclp.h | 1 + s390x/Makefile | 1 + s390x/intercept.c | 24 +-- s390x/sclp.c | 479 +++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 8 + 9 files changed, 531 insertions(+), 24 deletions(-) create mode 100644 s390x/sclp.c
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 1/6] s390x: export sclp_setup_int
From: Claudio Imbrenda <[email protected]>
Export sclp_setup_int() so that it can be used in tests.
Needed for an upcoming unit test.
Message-Id: <[email protected]>
--- lib/s390x/sclp.c | 2 +- lib/s390x/sclp.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
lib/s390x/sclp.c +1 -1
@@ -45,7 +45,7 @@ static void mem_init(phys_addr_t mem_end)page_alloc_ops_enable (); } -static void sclp_setup_int (void ) +void sclp_setup_int (void ) {uint64_t mask;
lib/s390x/sclp.h +1 -0
@@ -265,6 +265,7 @@ typedef struct ReadEventData { } __attribute__((packed)) ReadEventData;extern char _sccb[]; +void sclp_setup_int (void );void sclp_handle_ext (void );void sclp_wait_busy (void );void sclp_mark_busy (void );
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 2/6] s390x: sclp: add service call instruction wrapper
In reply to David HildenbrandFrom: Claudio Imbrenda <[email protected]>
Add a wrapper for the service call instruction, and use it for SCLP interactions instead of using inline assembly everywhere.
Message-Id: <[email protected]>
--- lib/s390x/asm/arch_def.h | 13 +++++++++++++ lib/s390x/sclp.c | 7 +------ 2 files changed, 14 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +13 -0
@@ -271,4 +271,17 @@ static inline int stsi(void *addr, int fc, int sel1, int sel2) return cc; } +static inline int servc (uint32_t command,unsigned long sccb) +{ +int cc; + + asmvolatile ( +" .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */ +" ipm %0\n" +" srl %0,28" + :"=&d" (cc) :"d" (command),"a" (sccb) + :"cc" ,"memory" ); +return cc; +} +#endif
lib/s390x/sclp.c +1 -6
@@ -116,12 +116,7 @@ int sclp_service_call(unsigned int command, void *sccb)int cc;sclp_setup_int (); - 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" ); + cc =servc (command,__pa (sccb));sclp_wait_busy ();if (cc ==3 )return -1 ;
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 3/6] s390x: lib: fix stfl wrapper asm
In reply to David HildenbrandFrom: Claudio Imbrenda <[email protected]>
the stfl wrapper in lib/s390x/asm/facility.h was lacking the "memory" clobber in the inline asm.
Message-Id: <[email protected]>
--- lib/s390x/asm/facility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/s390x/asm/facility.h +1 -1
@@ -24,7 +24,7 @@ static inline bool test_facility(int nr)static inline void stfl (void ) { - asmvolatile (" stfl 0(0)\n" ); + asmvolatile (" stfl 0(0)\n" : : :"memory" ); }static inline void stfle (uint8_t *fac,unsigned int len)
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 4/6] s390x: lib: add SPX and STPX instruction wrapper
In reply to David HildenbrandFrom: Claudio Imbrenda <[email protected]>
Add a wrapper for the SET PREFIX and STORE PREFIX instructions, and use it instead of using inline assembly.
Message-Id: <[email protected]>
--- lib/s390x/asm/arch_def.h | 13 +++++++++++++ s390x/intercept.c | 24 +++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-)
lib/s390x/asm/arch_def.h +13 -0
@@ -284,4 +284,17 @@ static inline int servc(uint32_t command, unsigned long sccb) return cc; } +static inline void set_prefix (uint32_t new_prefix) +{ + asmvolatile (" spx %0" : :"Q" (new_prefix) :"memory" ); +} + +static inline uint32_t get_prefix (void ) +{ +uint32_t current_prefix; + + asmvolatile (" stpx %0" :"=Q" (current_prefix)); +return current_prefix; +} +#endif
s390x/intercept.c +9 -15
@@ -13,6 +13,7 @@#include <asm/asm-offsets.h> #include <asm/interrupt.h> #include <asm/page.h> +#include <asm/facility.h> static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2)));
@@ -26,13 +27,10 @@ static void test_stpx(void)uint32_t new_prefix = (uint32_t )(intptr_t )pagebuf;/* Can we successfully change the prefix? */ - asmvolatile ( -" stpx %0\n" -" spx %2\n" -" stpx %1\n" -" spx %0\n" - :"+Q" (old_prefix),"+Q" (tst_prefix) - :"Q" (new_prefix)); + old_prefix =get_prefix (); +set_prefix (new_prefix); + tst_prefix =get_prefix (); +set_prefix (old_prefix);report (old_prefix ==0 && tst_prefix == new_prefix,"store prefix" );expect_pgm_int ();
@@ -63,14 +61,10 @@ static void test_spx(void)* some facility bits there ... at least some of them should be * set in our buffer afterwards. */ - asmvolatile ( -" stpx %0\n" -" spx %1\n" -" stfl 0\n" -" spx %0\n" - :"+Q" (old_prefix) - :"Q" (new_prefix) - :"memory" ); + old_prefix =get_prefix (); +set_prefix (new_prefix); +stfl (); +set_prefix (old_prefix);report (pagebuf[GEN_LC_STFL ] !=0 ,"stfl to new prefix" );expect_pgm_int ();
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 5/6] s390x: lib: fix program interrupt handler if sclp_busy was set
In reply to David HildenbrandFrom: Claudio Imbrenda <[email protected]>
Fix the program interrupt handler for the case where sclp_busy is set.
The interrupt handler will attempt to write an error message on the console using the SCLP, and will wait for sclp_busy to become false before doing so. If an exception happenes between setting the flag and the SCLP call, or if the call itself raises an exception, we need to clear the flag so we can successfully print the error message.
Message-Id: <[email protected]>
--- lib/s390x/interrupt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/s390x/interrupt.c +4 -1
@@ -106,10 +106,13 @@ static void fixup_pgm_int(void)void handle_pgm_int (void ) { -if (!pgm_int_expected) +if (!pgm_int_expected) { +/* Force sclp_busy to false, otherwise we will loop forever */ +sclp_handle_ext ();report_abort ("Unexpected program interrupt: %d at %#lx, ilen %d\n" , lc->pgm_int_code, lc->pgm_old_psw.addr, lc->pgm_int_id); + } pgm_int_expected = false;fixup_pgm_int ();
Signature · 1 line
2.24.1
[kvm-unit-tests PULL 6/6] s390x: SCLP unit test
In reply to David HildenbrandFrom: Claudio Imbrenda <[email protected]>
SCLP unit test. Testing the following:
* Correctly ignoring instruction bits that should be ignored
* Privileged instruction check
* Check for addressing exceptions
* Specification exceptions:
- SCCB size less than 8
- SCCB unaligned
- SCCB overlaps prefix or lowcore
- SCCB address higher than 2GB
* Return codes for
- Invalid command
- SCCB too short (but at least 8)
- SCCB page boundary violation
Message-Id: <[email protected]>
--- s390x/Makefile | 1 + s390x/sclp.c | 479 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 8 + 3 files changed, 488 insertions(+) create mode 100644 s390x/sclp.c
s390x/Makefile +1 -0
@@ -16,6 +16,7 @@ tests += $(TEST_DIR)/diag288.elf tests += $(TEST_DIR)/stsi.elf tests += $(TEST_DIR)/skrf.elf tests += $(TEST_DIR)/smp.elf +tests += $(TEST_DIR)/sclp.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) all: directories test_cases test_cases_binary
s390x/sclp.c new file +479 -0
479 lines not on this page · raw message
s390x/unittests.cfg +8 -0
@@ -75,3 +75,11 @@ file = stsi.elf [smp] file = smp.elf extra_params =-smp 2 + +[sclp-1g] +file = sclp.elf +extra_params = -m 1G + +[sclp-3g] +file = sclp.elf +extra_params = -m 3G
Signature · 1 line
2.24.1
Paolo Bonzini
maintainerQuoted 26 lines · David Hildenbrand
Hi Paolo,
The following changes since commit
f2606a873e805f9aff4c4879ec75e65d7e30af73:
Makefile: Compile the kvm-unit-tests with -fno-strict-aliasing (2020-01-22 16:29:43 +0100)are available in the Git repository at:
https://github.com/davidhildenbrand/kvm-unit-tests.git tags/s390x-2020-01-30
for you to fetch changes up to
1cbda07c1cc63589686048866ee24459c38c42f5:s390x: SCLP unit test (2020-01-24 09:47:00 +0100)
----------------------------------------------------------------
Add new SCLP unit test----------------------------------------------------------------
Claudio Imbrenda (6):s390x: export sclp_setup_int s390x: sclp: add service call instruction wrapper s390x: lib: fix stfl wrapper asm s390x: lib: add SPX and STPX instruction wrapper s390x: lib: fix program interrupt handler if sclp_busy was set s390x: SCLP unit test
Quoted 12 lines
lib/s390x/asm/arch_def.h | 26 +++ lib/s390x/asm/facility.h | 2 +- lib/s390x/interrupt.c | 5 +- lib/s390x/sclp.c | 9 +- lib/s390x/sclp.h | 1 + s390x/Makefile | 1 + s390x/intercept.c | 24 +-- s390x/sclp.c | 479 +++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 8 + 9 files changed, 531 insertions(+), 24 deletions(-) create mode 100644 s390x/sclp.c
Pulled, thanks.
Paolo