s390x: add migration test support
v4 cover s390x: add migration test support
Changelog from v3:
---
- Rename read_buf_end to read_buf_length (Thanks Janosch)
This series depends on my SIGP store additional status series to have access to the guarded-storage and vector related defines
("[kvm-unit-tests PATCH v3 0/2] s390x: Add tests for SIGP store adtl status").
Add migration test support for s390x.
arm and powerpc already support basic migration tests.
If a test is in the migration group, it can print "migrate" on its console. This will cause it to be migrated to a new QEMU instance. When migration is finished, the test will be able to read a newline from its standard input.
We need the following pieces for this to work under s390x:
* read support for the sclp console. This can be very basic, it doesn't even have to read anything useful, we just need to know something happened on the console.
* s390/run adjustments to call the migration helper script.
This series adds basic migration tests for s390x, which I plan to extend further.
Nico Boehr (4):
lib: s390x: add support for SCLP console read
s390x: add support for migration tests
s390x: don't run migration tests under PV
s390x: add basic migration test
lib/s390x/sclp-console.c | 79 ++++++++++++++++-- lib/s390x/sclp.h | 8 ++ s390x/Makefile | 2 + s390x/migration.c | 172 +++++++++++++++++++++++++++++++++++++++ s390x/run | 7 +- s390x/unittests.cfg | 5 ++ scripts/s390x/func.bash | 2 +- 7 files changed, 267 insertions(+), 8 deletions(-) create mode 100644 s390x/migration.c
Signature · 1 line
2.31.1
PATCH v4 1/4 lib: s390x: add support for SCLP console read
Add a basic implementation for reading from the SCLP ASCII console. The goal of this is to support migration tests on s390x. To know when the migration has been finished, we need to listen for a newline on our console.
Hence, this implementation is focused on the SCLP ASCII console of QEMU and currently won't work under e.g. LPAR.
--- lib/s390x/sclp-console.c | 79 +++++++++++++++++++++++++++++++++++++--- lib/s390x/sclp.h | 8 ++++ s390x/Makefile | 1 + 3 files changed, 82 insertions(+), 6 deletions(-)
lib/s390x/sclp-console.c +73 -6
@@ -89,6 +89,10 @@ static char lm_buff[120];static unsigned char lm_buff_off;static struct spinlock lm_buff_lock; +static char read_buf[4096 ]; +static int read_index =sizeof (read_buf) -1 ; +static int read_buf_length =0 ; +static void sclp_print_ascii (const char *str) {int len =strlen (str);
@@ -185,7 +189,7 @@ static void sclp_print_lm(const char *str)* indicating which messages the control program (we) want(s) to * send/receive. */ -static void sclp_set_write_mask (void ) +static void sclp_write_event_mask (int receive_mask,int send_mask) {WriteEventMask *sccb = (void *)_sccb;
@@ -195,18 +199,27 @@ static void sclp_set_write_mask(void) sccb->h.function_code =SCLP_FC_NORMAL_WRITE ; sccb->mask_length =sizeof (sccb_mask_t); -/* For now we don't process sclp input. */ - sccb->cp_receive_mask =0 ; -/* We send ASCII and line mode. */ - sccb->cp_send_mask =SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ; + sccb->cp_receive_mask = receive_mask; + sccb->cp_send_mask = send_mask;sclp_service_call (SCLP_CMD_WRITE_EVENT_MASK , sccb);assert (sccb->h.response_code ==SCLP_RC_NORMAL_COMPLETION ); } +static void sclp_console_enable_read (void ) +{ +sclp_write_event_mask (SCLP_EVENT_MASK_MSG_ASCII ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); +} + +static void sclp_console_disable_read (void ) +{ +sclp_write_event_mask (0 ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); +} +void sclp_console_setup (void ) { -sclp_set_write_mask (); +/* We send ASCII and line mode. */ +sclp_write_event_mask (0 ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); }void sclp_print (const char *str)
@@ -227,3 +240,57 @@ void sclp_print(const char *str)sclp_print_ascii (str);sclp_print_lm (str); } + +static int console_refill_read_buffer (void ) +{ +const int max_event_buffer_len =SCCB_SIZE - offsetof(ReadEventDataAsciiConsole , ebh); +ReadEventDataAsciiConsole *sccb = (void *)_sccb; +const int event_buffer_ascii_recv_header_len =sizeof (sccb->ebh) +sizeof (sccb->type); +int ret =-1 ; + +sclp_console_enable_read (); + +sclp_mark_busy (); +memset (sccb,0 ,SCCB_SIZE ); + sccb->h.length =PAGE_SIZE ; + sccb->h.function_code =SCLP_UNCONDITIONAL_READ ; + sccb->h.control_mask[2 ] =SCLP_CM2_VARIABLE_LENGTH_RESPONSE ; + +sclp_service_call (SCLP_CMD_READ_EVENT_DATA , sccb); + +if (sccb->h.response_code ==SCLP_RC_NO_EVENT_BUFFERS_STORED || + sccb->ebh.type !=SCLP_EVENT_ASCII_CONSOLE_DATA || + sccb->type !=SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS ) { + ret =-1 ; + goto out; + } + +assert (sccb->ebh.length <= max_event_buffer_len); +assert (sccb->ebh.length > event_buffer_ascii_recv_header_len); + + read_buf_length = sccb->ebh.length - event_buffer_ascii_recv_header_len; + +assert (read_buf_length <=sizeof (read_buf)); +memcpy (read_buf, sccb->data, read_buf_length); + + read_index =0 ; + ret =0 ; + +out: +sclp_console_disable_read (); + +return ret; +} + +int __getchar (void ) +{ +int ret; + +if (read_index >= read_buf_length) { + ret =console_refill_read_buffer (); +if (ret <0 ) +return ret; + } + +return read_buf[read_index++]; +}
lib/s390x/sclp.h +8 -0
@@ -313,6 +313,14 @@ typedef struct ReadEventData {uint32_t mask; } __attribute__((packed)) ReadEventData; +#define SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS 0 +typedef struct ReadEventDataAsciiConsole { +SCCBHeader h; +EventBufferHeader ebh; +uint8_t type; +char data[]; +} __attribute__((packed))ReadEventDataAsciiConsole ; +extern char _sccb[];void sclp_setup_int (void );void sclp_handle_ext (void );
s390x/Makefile +1 -0
@@ -75,6 +75,7 @@ cflatobjs += lib/alloc_phys.o cflatobjs += lib/alloc_page.o cflatobjs += lib/vmalloc.o cflatobjs += lib/alloc_phys.o +cflatobjs += lib/getchar.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o cflatobjs += lib/s390x/sclp.o
Signature · 1 line
2.31.1
Re: [kvm-unit-tests PATCH v4 1/4] lib: s390x: add support for SCLP console read
Quoted 11 lines · Nico Boehr
Add a basic implementation for reading from the SCLP ASCII console. The goal of this is to support migration tests on s390x. To know when the migration has been finished, we need to listen for a newline on our console.
Hence, this implementation is focused on the SCLP ASCII console of QEMU and currently won't work under e.g. LPAR.
Signed-off-by Nico Boehr <[email protected]>Reviewed-by Thomas Huth <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>---
Quoted 151 lines
lib/s390x/sclp-console.c | 79 +++++++++++++++++++++++++++++++++++++--- lib/s390x/sclp.h | 8 ++++ s390x/Makefile | 1 + 3 files changed, 82 insertions(+), 6 deletions(-)lib/s390x/sclp-console.c +73
-6@@ -89,6 +89,10 @@ static char lm_buff[120];static unsigned char lm_buff_off;static struct spinlock lm_buff_lock; +static char read_buf[4096 ]; +static int read_index =sizeof (read_buf) -1 ; +static int read_buf_length =0 ; +static void sclp_print_ascii (const char *str) {int len =strlen (str);@@ -185,7 +189,7 @@ static void sclp_print_lm(const char *str)* indicating which messages the control program (we) want(s) to * send/receive. */ -static void sclp_set_write_mask (void ) +static void sclp_write_event_mask (int receive_mask,int send_mask) {WriteEventMask *sccb = (void *)_sccb;@@ -195,18 +199,27 @@ static void sclp_set_write_mask(void) sccb->h.function_code =SCLP_FC_NORMAL_WRITE ; sccb->mask_length =sizeof (sccb_mask_t); -/* For now we don't process sclp input. */ - sccb->cp_receive_mask =0 ; -/* We send ASCII and line mode. */ - sccb->cp_send_mask =SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ; + sccb->cp_receive_mask = receive_mask; + sccb->cp_send_mask = send_mask;sclp_service_call (SCLP_CMD_WRITE_EVENT_MASK , sccb);assert (sccb->h.response_code ==SCLP_RC_NORMAL_COMPLETION ); } +static void sclp_console_enable_read (void ) +{ +sclp_write_event_mask (SCLP_EVENT_MASK_MSG_ASCII ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); +} + +static void sclp_console_disable_read (void ) +{ +sclp_write_event_mask (0 ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); +} +void sclp_console_setup (void ) { -sclp_set_write_mask (); +/* We send ASCII and line mode. */ +sclp_write_event_mask (0 ,SCLP_EVENT_MASK_MSG_ASCII |SCLP_EVENT_MASK_MSG ); }void sclp_print (const char *str)@@ -227,3 +240,57 @@ void sclp_print(const char *str)sclp_print_ascii (str);sclp_print_lm (str); } + +static int console_refill_read_buffer (void ) +{ +const int max_event_buffer_len =SCCB_SIZE - offsetof(ReadEventDataAsciiConsole , ebh); +ReadEventDataAsciiConsole *sccb = (void *)_sccb; +const int event_buffer_ascii_recv_header_len =sizeof (sccb->ebh) +sizeof (sccb->type); +int ret =-1 ; + +sclp_console_enable_read (); + +sclp_mark_busy (); +memset (sccb,0 ,SCCB_SIZE ); + sccb->h.length =PAGE_SIZE ; + sccb->h.function_code =SCLP_UNCONDITIONAL_READ ; + sccb->h.control_mask[2 ] =SCLP_CM2_VARIABLE_LENGTH_RESPONSE ; + +sclp_service_call (SCLP_CMD_READ_EVENT_DATA , sccb); + +if (sccb->h.response_code ==SCLP_RC_NO_EVENT_BUFFERS_STORED || + sccb->ebh.type !=SCLP_EVENT_ASCII_CONSOLE_DATA || + sccb->type !=SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS ) { + ret =-1 ; + goto out; + } + +assert (sccb->ebh.length <= max_event_buffer_len); +assert (sccb->ebh.length > event_buffer_ascii_recv_header_len); + + read_buf_length = sccb->ebh.length - event_buffer_ascii_recv_header_len; + +assert (read_buf_length <=sizeof (read_buf)); +memcpy (read_buf, sccb->data, read_buf_length); + + read_index =0 ; + ret =0 ; + +out: +sclp_console_disable_read (); + +return ret; +} + +int __getchar (void ) +{ +int ret; + +if (read_index >= read_buf_length) { + ret =console_refill_read_buffer (); +if (ret <0 ) +return ret; + } + +return read_buf[read_index++]; +}lib/s390x/sclp.h +8
-0@@ -313,6 +313,14 @@ typedef struct ReadEventData {uint32_t mask; } __attribute__((packed)) ReadEventData; +#define SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS 0 +typedef struct ReadEventDataAsciiConsole { +SCCBHeader h; +EventBufferHeader ebh; +uint8_t type; +char data[]; +} __attribute__((packed))ReadEventDataAsciiConsole ; +extern char _sccb[];void sclp_setup_int (void );void sclp_handle_ext (void );s390x/Makefile +1
-0@@ -75,6 +75,7 @@ cflatobjs += lib/alloc_phys.o cflatobjs += lib/alloc_page.o cflatobjs += lib/vmalloc.o cflatobjs += lib/alloc_phys.o +cflatobjs += lib/getchar.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o cflatobjs += lib/s390x/sclp.o
PATCH v4 2/4 s390x: add support for migration tests
In reply to Nico BoehrNow that we have SCLP console read support, run our tests with migration_cmd, so we can get migration support on s390x.
--- s390x/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/run +1 -1
@@ -25,7 +25,7 @@ M+=",accel=$ACCEL" command="$qemu -nodefaults -nographic $M" command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel" -command="$(timeout_cmd) $command" +command="$(migration_cmd) $(timeout_cmd) $command" # We return the exit code via stdout, not via the QEMU return code run_qemu_status $command "$@"
Signature · 1 line
2.31.1
PATCH v4 3/4 s390x: don't run migration tests under PV
In reply to Nico BoehrPV doesn't support migration, so don't run the migration tests there.
--- s390x/run | 5 +++++ scripts/s390x/func.bash | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
s390x/run +5 -0
@@ -20,6 +20,11 @@ if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$ACCEL" = " exit 2 fi +if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" = "yes" ]; then + echo "Migration isn't supported under Protected Virtualization" + exit 2 +fi + M='-machine s390-ccw-virtio' M+=",accel=$ACCEL" command="$qemu -nodefaults -nographic $M"
scripts/s390x/func.bash +1 -1
@@ -21,7 +21,7 @@ function arch_cmd_s390x() "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" # run PV test case - if [ "$ACCEL" = 'tcg' ]; then + if [ "$ACCEL" = 'tcg' ] || find_word "migration" "$groups"; then return fi kernel=${kernel%.elf}.pv.bin
Signature · 1 line
2.31.1
PATCH v4 4/4 s390x: add basic migration test
In reply to Nico BoehrAdd a basic migration test for s390x. This tests the guarded-storage registers and vector registers are preserved on migration.
--- s390x/Makefile | 1 + s390x/migration.c | 172 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 ++ 3 files changed, 178 insertions(+) create mode 100644 s390x/migration.c
s390x/Makefile +1 -0
@@ -30,6 +30,7 @@ tests += $(TEST_DIR)/spec_ex-sie.elf tests += $(TEST_DIR)/firq.elf tests += $(TEST_DIR)/epsw.elf tests += $(TEST_DIR)/adtl-status.elf +tests += $(TEST_DIR)/migration.elf pv-tests += $(TEST_DIR)/pv-diags.elf
s390x/migration.c new file +172 -0
172 lines not on this page · raw message
s390x/unittests.cfg +5 -0
@@ -171,3 +171,8 @@ file = adtl-status.elf smp = 2 accel = tcg extra_params = -cpu qemu,gs=off,vx=off + +[migration] +file = migration.elf +groups = migration +smp = 2
Signature · 1 line
2.31.1
Quoted 9 lines · On Fri, 22 Apr 2022 12:54:49 +0200 Nico Boehr <[email protected]> wrote:
Changelog from v3:
---
- Renameread_buf_endtoread_buf_length(Thanks Janosch)This series depends on my SIGP store additional status series to have access to the guarded-storage and vector related defines
("[kvm-unit-tests PATCH v3 0/2] s390x: Add tests for SIGP store adtl status").Add migration test support for s390x.
thanks, queued
Quoted 33 lines
arm and powerpc already support basic migration tests.
If a test is in the migration group, it can print "migrate" on its console. This will cause it to be migrated to a new QEMU instance. When migration is finished, the test will be able to read a newline from its standard input.
We need the following pieces for this to work under s390x:
* read support for the sclp console. This can be very basic, it doesn't even have to read anything useful, we just need to know something happened on the console.
* s390/run adjustments to call the migration helper script.This series adds basic migration tests for s390x, which I plan to extend further.
Nico Boehr (4):
lib: s390x: add support for SCLP console read
s390x: add support for migration tests
s390x: don't run migration tests under PV
s390x: add basic migration testlib/s390x/sclp-console.c | 79 ++++++++++++++++-- lib/s390x/sclp.h | 8 ++ s390x/Makefile | 2 + s390x/migration.c | 172 +++++++++++++++++++++++++++++++++++++++ s390x/run | 7 +- s390x/unittests.cfg | 5 ++ scripts/s390x/func.bash | 2 +- 7 files changed, 267 insertions(+), 8 deletions(-) create mode 100644 s390x/migration.c