s390x: SCLP Unit test
v7 cover s390x: SCLP Unit test
This patchset contains some minor cleanup, some preparatory work and then the SCLP unit test itself.
The unit test checks 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
v6 -> v7
* renamed spx() and stpx() wrappers to set_prefix and get_prefix
* set_prefix now takes a value and get_prefix now returns a value
* put back some inline assembly for spx and stpx as a consequence
* used LC_SIZE instead of 2 * PAGE_SIZE everywhere in the unit test v5 -> v6
* fixed a bug in test_addressing
* improved comments in test_sccb_prefix
* replaced all inline assembly usages of spx and stpx with the wrappers
* added one more wrapper for test_one_sccb for read-only tests v4 -> v5
* updated usage of report()
* added SPX and STPX wrappers to the library
* improved readability
* addressed some more comments
v3 -> v4
* export sclp_setup_int instead of copying it
* add more comments
* rename some more variables to improve readability
* improve the prefix test
* improved the invalid address test
* addressed further comments received during review
v2 -> v3
* generally improved the naming of variables
* added and fixed comments
* renamed test_one_run to test_one_simple
* added some const where needed
* addresed many more small comments received during review v1 -> v2
* fix many small issues that came up during the first round of reviews
* add comments to each function
* use a static buffer for the SCCP template when used
Claudio Imbrenda (4):
s390x: export sclp_setup_int
s390x: sclp: add service call instruction wrapper
s390x: lib: add SPX and STPX instruction wrapper
s390x: SCLP unit test
s390x/Makefile | 1 + lib/s390x/asm/arch_def.h | 26 +++ lib/s390x/sclp.h | 1 + lib/s390x/sclp.c | 9 +- s390x/intercept.c | 23 +- s390x/sclp.c | 472 +++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 8 + 7 files changed, 518 insertions(+), 22 deletions(-) create mode 100644 s390x/sclp.c
Signature · 1 line
2.24.1
PATCH v7 1/4 s390x: export sclp_setup_int
Export sclp_setup_int() so that it can be used in tests.
Needed for an upcoming unit test.
--- lib/s390x/sclp.h | 1 + lib/s390x/sclp.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
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 );
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;
Signature · 1 line
2.24.1
PATCH v7 2/4 s390x: sclp: add service call instruction wrapper
In reply to Claudio ImbrendaAdd a wrapper for the service call instruction, and use it for SCLP interactions instead of using inline assembly everywhere.
--- 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
PATCH v7 3/4 s390x: lib: add SPX and STPX instruction wrapper
In reply to Claudio ImbrendaAdd a wrapper for the SET PREFIX and STORE PREFIX instructions, and use it instead of using inline assembly.
--- lib/s390x/asm/arch_def.h | 13 +++++++++++++ s390x/intercept.c | 23 ++++++++--------------- 2 files changed, 21 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 +8 -15
@@ -26,13 +26,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 +60,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); + asmvolatile (" stfl 0" : : :"memory" ); +set_prefix (old_prefix);report (pagebuf[GEN_LC_STFL ] !=0 ,"stfl to new prefix" );expect_pgm_int ();
Signature · 1 line
2.24.1
Re: [kvm-unit-tests PATCH v7 3/4] s390x: lib: add SPX and STPX instruction wrapper
Quoted 5 lines · Claudio Imbrenda
Add a wrapper for the SET PREFIX and STORE PREFIX instructions, and use it instead of using inline assembly.
Signed-off-by Claudio Imbrenda <[email protected]>Reviewed-by Thomas Huth <[email protected]>
Quoted 5 lines
s390x/intercept.c +0
-1@@ -63,14 +60,10 @@ static void test_spx(void)* some facility bits there ... at least some of them should be * set in our buffer afterwards. */ - asm volatile (
s390x/intercept.c static void test_spx(void) · line 65
Quoted 10 lines
s390x/intercept.c +3
-7-" 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); + asmvolatile (" stfl 0" : : :"memory" );
Couldn't we also use stfl from facility.h here?
And do we need to add a memory clobber to it?
Quoted 5 lines
s390x/intercept.c +1
-0+set_prefix (old_prefix);report (pagebuf[GEN_LC_STFL ] !=0 ,"stfl to new prefix" );expect_pgm_int ();
Re: [kvm-unit-tests PATCH v7 3/4] s390x: lib: add SPX and STPX instruction wrapper
Quoted 20 lines · On Mon, 13 Jan 2020 10:42:01 +0100 Janosch Frank <[email protected]> wrote:
Quoted 5 lines · Claudio Imbrenda
Add a wrapper for the SET PREFIX and STORE PREFIX instructions, and use it instead of using inline assembly.
Signed-off-by Claudio Imbrenda <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Janosch Frank <[email protected]>Quoted 11 lines
(quoted diff) +0
-0@@ -63,14 +60,10 @@ static void test_spx(void) * some facility bits there ... at least some of themshould be
s390x/intercept.c +0
-6* set in our buffer afterwards. */ - asmvolatile ( -" stpx %0\n" -" spx %1\n" -" stfl 0\n" -" spx %0\n" - : "+Q"(old_prefix)
Quoted 8 lines
s390x/intercept.c static void test_spx(void) · line 65
Quoted 5 lines
s390x/intercept.c +3
-2- : "Q"(new_prefix) - : "memory"); + old_prefix =get_prefix (); +set_prefix (new_prefix); + asmvolatile (" stfl 0" : : :"memory" );Couldn't we also use stfl from
facility.hhere?
And do we need to add a memory clobber to it?
will do both
Quoted 7 lines
Quoted 5 lines
s390x/intercept.c +1
-0+set_prefix (old_prefix);report (pagebuf[GEN_LC_STFL ] !=0 ,"stfl to new prefix" );expect_pgm_int ();
Re: [kvm-unit-tests PATCH v7 3/4] s390x: lib: add SPX and STPX instruction wrapper
In reply to Claudio ImbrendaQuoted 64 lines · Claudio Imbrenda
Add a wrapper for the SET PREFIX and STORE PREFIX instructions, and use it instead of using inline assembly.
Signed-off-by Claudio Imbrenda <[email protected]>Reviewed-by Thomas Huth <[email protected]>--- lib/s390x/asm/arch_def.h | 13 +++++++++++++ s390x/intercept.c | 23 ++++++++--------------- 2 files changed, 21 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 +4
-12@@ -26,13 +26,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 +60,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"
s390x/intercept.c static void test_spx(void) · line 69
Quoted 10 lines
s390x/intercept.c +4
-3- : "+Q"(old_prefix) - : "Q"(new_prefix) - : "memory"); + old_prefix =get_prefix (); +set_prefix (new_prefix); + asmvolatile (" stfl 0" : : :"memory" ); +set_prefix (old_prefix);report (pagebuf[GEN_LC_STFL ] !=0 ,"stfl to new prefix" );expect_pgm_int ();
Besides the comments from Janosch, looks good to me.
Signature · 3 lines
Thanks, David / dhildenb
PATCH v7 4/4 s390x: SCLP unit test
In reply to Claudio ImbrendaSCLP 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
--- s390x/Makefile | 1 + s390x/sclp.c | 472 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 8 + 3 files changed, 481 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 +472 -0
472 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
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 14 lines
s390x/sclp.c new file +14
-0+/** +* Test some bits in the instruction format that are specified to be ignored. +*/ +static void test_instbits (void ) +{ +SCCBHeader *h = (SCCBHeader *)pagebuf; +int cc; + +expect_pgm_int (); +sclp_mark_busy (); + h->length =8 ; +sclp_setup_int (); + + asm volatile(
s390x/sclp.c line 419
Quoted 10 lines
s390x/sclp.c new file +10
-0+" .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */ +" ipm %0\n" +" srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a" (__pa(pagebuf)) + : "cc", "memory"); + if (lc->pgm_int_code) { +sclp_handle_ext (); + cc =1 ; + } else if (!cc) +
I wonder if something like the following would be possible:
expect_pgm_int();
...
asm volatiole();
...sclp_wait_busy();check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
We would have to clear "sclp_busy" when we get a progam interrupt on a servc instruction - shouldn't be too hard to add to the program exception handler.
Quoted 19 lines
s390x/sclp.c new file +19
-0+report (cc ==0 ,"Instruction format ignored bits" ); +} + +/** +* Find a valid READ INFO command code; not all codes are always allowed, and +* probing should be performed in the right order. +*/ +static void find_valid_sclp_code (void ) +{ +const unsigned int commands[] = {SCLP_CMDW_READ_SCP_INFO_FORCED , +SCLP_CMDW_READ_SCP_INFO }; +SCCBHeader *h = (SCCBHeader *)pagebuf; +int i, cc; + +for (i =0 ; i <ARRAY_SIZE (commands); i++) { +sclp_mark_busy (); +memset (h,0 ,sizeof (*h)); + h->length =4096 ; +
s390x/sclp.c line 445
Quoted 10 lines
s390x/sclp.c new file +10
-0+ valid_code = commands[i]; + cc =sclp_service_call (commands[i], h); +if (cc) +break ; +if (h->response_code ==SCLP_RC_NORMAL_READ_COMPLETION ) +return ; +if (h->response_code !=SCLP_RC_INVALID_SCLP_COMMAND ) +break ; + } + valid_code =0 ;
This can be dropped because ...
s390x/sclp.c line 446
Quoted 1 line
s390x/sclp.c new file +1
-0+report_abort ("READ_SCP_INFO failed" );
... you abort here.
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 30 lines · On Mon, 13 Jan 2020 12:00:00 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 21 lines
+/**
+ * Test some bits in the instruction format that are specified to be ignored.
+ */s390x/sclp.c new file +12
-0+static void test_instbits (void ) +{ +SCCBHeader *h = (SCCBHeader *)pagebuf; +int cc; + +expect_pgm_int (); +sclp_mark_busy (); + h->length =8 ; +sclp_setup_int (); + + asmvolatile ( +" .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */
s390x/sclp.c new file +3
-0+" ipm %0\n" +" srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a"(
__pa(pagebuf))s390x/sclp.c line 419
Quoted 6 lines
s390x/sclp.c new file +6
-0+ : "cc", "memory"); +if (lc->pgm_int_code) { +sclp_handle_ext (); + cc =1 ; + }else if (!cc) +I wonder if something like the following would be possible:
Quoted 6 lines
expect_pgm_int();
...
asmvolatiole();
...sclp_wait_busy();check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
we do not expect a specification exception, if that happens it's a bug and the test should rightfully fail.
Quoted 3 lines
We would have to clear "
sclp_busy" when we get a progam interrupt on a servc instruction - shouldn't be too hard to add to the program exception handler.
Sure that could be done, but is it worth it to rework the program interrupt handler only for one unit test?
[...]
Quoted 7 lines
s390x/sclp.c line 445
Quoted 1 line
s390x/sclp.c new file +1
-0+ valid_code =0 ;This can be dropped because ...
s390x/sclp.c line 446
Quoted 1 line
s390x/sclp.c new file +1
-0+report_abort ("READ_SCP_INFO failed" );... you abort here.
will fix
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 40 lines · Claudio Imbrenda
Quoted 30 lines · On Mon, 13 Jan 2020 12:00:00 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 21 lines
+/**
+ * Test some bits in the instruction format that are specified to be ignored.
+ */s390x/sclp.c new file +12
-0+static void test_instbits (void ) +{ +SCCBHeader *h = (SCCBHeader *)pagebuf; +int cc; + +expect_pgm_int (); +sclp_mark_busy (); + h->length =8 ; +sclp_setup_int (); + + asmvolatile ( +" .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */
s390x/sclp.c new file +3
-0+" ipm %0\n" +" srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a"(
__pa(pagebuf))s390x/sclp.c line 419
Quoted 6 lines
s390x/sclp.c new file +6
-0+ : "cc", "memory"); +if (lc->pgm_int_code) { +sclp_handle_ext (); + cc =1 ; + }else if (!cc) +I wonder if something like the following would be possible:
Quoted 6 lines
expect_pgm_int();
...
asmvolatiole();
...sclp_wait_busy();check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
Quoted 2 lines
we do not expect a specification exception, if that happens it's a bug and the test should rightfully fail.
Which one do we expect? (you're not checking for a specific one, should you?)
Quoted 7 lines
Quoted 4 lines
We would have to clear "
sclp_busy" when we get a progam interrupt on a servc instruction - shouldn't be too hard to add to the program exception handler.Sure that could be done, but is it worth it to rework the program interrupt handler only for one unit test?
Good point. I don't like this particular code, but I can live with it :)
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
On Mon, 13 Jan 2020 13:48:17 +0100
David Hildenbrand <[email protected]> wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
I wonder if something like the following would be possible:
expect_pgm_int();
...
asmvolatiole();
...sclp_wait_busy();check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
Quoted 5 lines
Quoted 2 lines
we do not expect a specification exception, if that happens it's a bug and the test should rightfully fail.
Which one do we expect? (you're not checking for a specific one, should you?)
nothing, the call should succeed :)
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
We would have to clear "
sclp_busy" when we get a progam interrupt on a servc instruction - shouldn't be too hard to add to the program exception handler.Sure that could be done, but is it worth it to rework the program interrupt handler only for one unit test?
Good point. I don't like this particular code, but I can live with it :)
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 15 lines · Claudio Imbrenda
On Mon, 13 Jan 2020 13:48:17 +0100
David Hildenbrand <[email protected]> wrote:[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
I wonder if something like the following would be possible:
expect_pgm_int();
...
asmvolatiole();
...sclp_wait_busy();check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
we do not expect a specification exception, if that happens it's a bug and the test should rightfully fail.
Which one do we expect? (you're not checking for a specific one, should you?)
nothing, the call should succeed :)
:) I'm confused by the fact that you "expect_pgm_int()" but actually don't expect one ...
Please enlighten me why this isn't
+ sclp_mark_busy();
+ h->length = 8;
+ sclp_setup_int();
+
+ asm volatile(
+ " .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */ + " ipm %0\n" + " srl %0,28"
+ : "=&d" (cc) : "d" (valid_code), "a" (__pa(pagebuf))
+ : "cc", "memory");
+ if (!cc)
+ sclp_wait_busy();
+ report(cc == 0, "Instruction format ignored bits");
I feel like I am missing something important.
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
On Mon, 13 Jan 2020 14:10:10 +0100
David Hildenbrand <[email protected]> wrote:
[...]
Quoted 20 lines
:) I'm confused by the fact that you "
expect_pgm_int()" but actually don't expect one ...Please enlighten me why this isn't
s390x/sclp.c new file +6
-0+sclp_mark_busy (); + h->length =8 ; +sclp_setup_int (); + + asmvolatile ( +" .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */
s390x/sclp.c new file +7
-0+" ipm %0\n" +" srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a" (__pa(pagebuf)) + : "cc", "memory"); + if (!cc) +sclp_wait_busy (); +report (cc ==0 ,"Instruction format ignored bits" );
Quoted 1 line
I feel like I am missing something important.
because if we take an unexpected pgm interrupt:
* the interrupt handler will write stuff on the console using SCLP
* it will wait for the busy flag to be cleared before doing so
* thus it will hang.
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 32 lines · Claudio Imbrenda
On Mon, 13 Jan 2020 14:10:10 +0100
David Hildenbrand <[email protected]> wrote:[...]
Quoted 20 lines
:) I'm confused by the fact that you "
expect_pgm_int()" but actually don't expect one ...Please enlighten me why this isn't
(quoted diff) +6
-0+ sclp_mark_busy(); + h->length = 8; + sclp_setup_int(); + + asm volatile( + " .insn rre,0xb2204200,%1,%2\n" /* servc%1,%2 */
(quoted diff) +7
-0+ " ipm %0\n" + " srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a" (__pa(pagebuf)) + : "cc", "memory"); + if (!cc) + sclp_wait_busy(); + report(cc == 0, "Instruction format ignored bits");Quoted 1 line
I feel like I am missing something important.
because if we take an unexpected pgm interrupt:
* the interrupt handler will write stuff on the console using SCLP
* it will wait for the busy flag to be cleared before doing so
* thus it will hang.
Quoted 3 lines
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
I see, so the issue should hold for all SCLP checks where we don't expect an exception ... hmmm
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 34 lines · On Mon, 13 Jan 2020 15:43:28 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 33 lines · Claudio Imbrenda
On Mon, 13 Jan 2020 14:10:10 +0100
David Hildenbrand <[email protected]> wrote:[...]
Quoted 21 lines
:) I'm confused by the fact that you "
expect_pgm_int()" but actually don't expect one ...Please enlighten me why this isn't
(quoted diff) +6
-0+ sclp_mark_busy(); + h->length = 8; + sclp_setup_int(); + + asm volatile( + " .insn rre,0xb2204200,%1,%2\n" /* servc%1,%2 */
(quoted diff) +3
-0+ " ipm %0\n" + " srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a"(
__pa(pagebuf))(quoted diff) +4
-0+ : "cc", "memory"); + if (!cc) + sclp_wait_busy(); + report(cc == 0, "Instruction format ignored bits");Quoted 1 line
I feel like I am missing something important.
because if we take an unexpected pgm interrupt:
* the interrupt handler will write stuff on the console using SCLP
* it will wait for the busy flag to be cleared before doing so
* thus it will hang.
Quoted 6 lines
Quoted 3 lines
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
I see, so the issue should hold for all SCLP checks where we don't expect an exception ... hmmm
which is why my wrapper in the unit test is so complicated :)
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 37 lines · Claudio Imbrenda
Quoted 34 lines · On Mon, 13 Jan 2020 15:43:28 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 33 lines · Claudio Imbrenda
On Mon, 13 Jan 2020 14:10:10 +0100
David Hildenbrand <[email protected]> wrote:[...]
Quoted 21 lines
:) I'm confused by the fact that you "
expect_pgm_int()" but actually don't expect one ...Please enlighten me why this isn't
(quoted diff) +6
-0+ sclp_mark_busy(); + h->length = 8; + sclp_setup_int(); + + asm volatile( + " .insn rre,0xb2204200,%1,%2\n" /* servc%1,%2 */
(quoted diff) +3
-0+ " ipm %0\n" + " srl %0,28" + : "=&d" (cc) : "d" (valid_code), "a"(
__pa(pagebuf))(quoted diff) +4
-0+ : "cc", "memory"); + if (!cc) + sclp_wait_busy(); + report(cc == 0, "Instruction format ignored bits");Quoted 1 line
I feel like I am missing something important.
because if we take an unexpected pgm interrupt:
* the interrupt handler will write stuff on the console using SCLP
* it will wait for the busy flag to be cleared before doing so
* thus it will hang.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
I see, so the issue should hold for all SCLP checks where we don't expect an exception ... hmmm
which is why my wrapper in the unit test is so complicated :)
so .... if we would implement my suggestion (if we get an exception on a servc instruction, clear sclp_busy) that code would get simplified as well? :)
It would be really beneficial if we could rely on
expect_pgm_int()
...check_pgm_int_code(whatever)
if we *expect an interrupt and none of that if we don't. So if it's a matter of clearing sclp_busy on PGM exceptions, that shouldn't be too hard ... but maybe I am missing something (haven't looked again at the whole patch ...).
Signature · 3 lines
Thanks, David / dhildenb
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
On Mon, 13 Jan 2020 17:06:05 +0100
David Hildenbrand <[email protected]> wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
I see, so the issue should hold for all SCLP checks where we don't expect an exception ... hmmm
Quoted 6 lines
Quoted 2 lines
which is why my wrapper in the unit test is so complicated :)
so .... if we would implement my suggestion (if we get an exception on a servc instruction, clear
sclp_busy) that code would get simplified as well? :)
sure, as I said, that can be done. The question is if we really want to change something in the interrupt handler (shared by all s390x unit tests) just for the benefit of this one unit test.
Also consider that the changes to the interrupt handler would not necessarily be trivial. i.e. you need to check that the origin of the pgm interrupt is a SERVC instruction, and then act accordingly.
Re: [kvm-unit-tests PATCH v7 4/4] s390x: SCLP unit test
Quoted 19 lines · Claudio Imbrenda
On Mon, 13 Jan 2020 17:06:05 +0100
David Hildenbrand <[email protected]> wrote:[...]
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
this would be solved by adding special logic to the pgm interrupt handler (as we have discussed in your previous email)
I see, so the issue should hold for all SCLP checks where we don't expect an exception ... hmmm
Quoted 6 lines
Quoted 2 lines
which is why my wrapper in the unit test is so complicated :)
so .... if we would implement my suggestion (if we get an exception on a servc instruction, clear
sclp_busy) that code would get simplified as well? :)
Quoted 8 lines
sure, as I said, that can be done. The question is if we really want to change something in the interrupt handler (shared by all s390x unit tests) just for the benefit of this one unit test.
Also consider that the changes to the interrupt handler would not necessarily be trivial. i.e. you need to check that the origin of the pgm interrupt is a SERVC instruction, and then act accordingly.
I suggest something like the following:
lib/s390x/interrupt.c +8 -1
@@ -106,10 +106,17 @@ static void fixup_pgm_int(void)void handle_pgm_int (void ) { -if (!pgm_int_expected) +if (!pgm_int_expected) { +/* +* If we get a PGM interrupt while having sclp_busy=true, we +* will loop forever. Just force sclp_busy=false to make +* progress here. +*/ +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 ();
Then this test could become something like (not sure about cc handling)
s390x/sclp.c +4 -12
@@ -396,25 +396,18 @@ out:static void test_instbits (void ) {SCCBHeader *h = (SCCBHeader *)pagebuf; -int cc; -expect_pgm_int ();sclp_mark_busy (); h->length =8 ;sclp_setup_int (); asmvolatile ( -" .insn rre,0xb2204200,%1,%2\n" /* servc %1,%2 */ -" ipm %0\n" -" srl %0,28" - :"=&d" (cc) :"d" (valid_code),"a" (__pa (pagebuf)) +" .insn rre,0xb2204200,%0,%1\n" + ::"d" (valid_code),"a" (__pa (pagebuf)) :"cc" ,"memory" ); -if (lc->pgm_int_code) { -sclp_handle_ext (); - cc =1 ; - }else if (!cc) -sclp_wait_busy (); -report (cc ==0 ,"Instruction format ignored bits" ); +sclp_wait_busy (); +report (true,"Instruction format ignored bits" ); }
This works correctly. E.g., adding a "*((uint8_t *)-50ul) = 2;" after the sclp_setup_int(); - to quickly fake a PGM exception - makes the test abort correctly:
FAIL sclp-1g (0 tests)
FAIL sclp-3g (0 tests)
ABORT: sclp: Unexpected program interrupt: 5 at 0x155e8, ilen 6
Signature · 3 lines
Thanks, David / dhildenb