accel/tcg: Test unaligned stores to s390x low-address-protected lowcore
v2 cover accel/tcg: Test unaligned stores to s390x low-address-protected lowcore
Hi,
This is a follow-up series for [1].
The fix has been committed.
I asked Christian what might be a good alternative for the mmio-debug-exit device for testing, and he suggested to look into shutdown/panic actions.
Patch 1 adds a new panic action.
Patch 2 tests unaligned stores to s390x low-address-protected lowcore; it performs a shutdown on success and panic on failure.
Best regards,
Ilya
[1] https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg01876.html
Ilya Leoshkevich (2):
qapi: Add exit-failure PanicAction tests/tcg/s390x: Test unaligned accesses to lowcore
include/sysemu/sysemu.h | 2 +- qapi/run-state.json | 4 +++- qemu-options.hx | 2 +- softmmu/main.c | 6 ++++-- softmmu/runstate.c | 17 +++++++++++++---- tests/tcg/s390x/Makefile.softmmu-target | 9 +++++++++ tests/tcg/s390x/unaligned-lowcore.S | 19 +++++++++++++++++++ 7 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 tests/tcg/s390x/Makefile.softmmu-target create mode 100644 tests/tcg/s390x/unaligned-lowcore.S
Signature · 1 line
2.35.3
PATCH v2 1/2 qapi: Add exit-failure PanicAction
Currently QEMU exits with code 0 on both panic an shutdown. For tests it is useful to return 1 on panic, so that it counts as a test failure.
Introduce a new exit-failure PanicAction that makes main() return EXIT_FAILURE. Tests can use -action panic=exit-failure option to activate this behavior.
--- include/sysemu/sysemu.h | 2 +- qapi/run-state.json | 4 +++- qemu-options.hx | 2 +- softmmu/main.c | 6 ++++-- softmmu/runstate.c | 17 +++++++++++++---- 5 files changed, 22 insertions(+), 9 deletions(-)
include/sysemu/sysemu.h +1 -1
@@ -103,7 +103,7 @@ void qemu_boot_set(const char *boot_order, Error **errp);bool defaults_enabled (void );void qemu_init (int argc,char **argv,char **envp); -void qemu_main_loop (void ); +int qemu_main_loop (void );void qemu_cleanup (void );extern QemuOptsList qemu_legacy_drive_opts;
qapi/run-state.json +3 -1
@@ -364,10 +364,12 @@ # # @shutdown: Shutdown the VM and exit, according to the shutdown action # +# @exit-failure: Shutdown the VM and exit with nonzero status +# # Since: 6.0 ## { 'enum': 'PanicAction', - 'data': [ 'pause', 'shutdown', 'none' ] } + 'data': [ 'pause', 'shutdown', 'exit-failure', 'none' ] } ## # @watchdog-set-action:
qemu-options.hx +1 -1
@@ -4239,7 +4239,7 @@ DEF("action", HAS_ARG, QEMU_OPTION_action, " action when guest reboots [default=reset]\n" "-action shutdown=poweroff|pause\n" " action when guest shuts down [default=poweroff]\n" - "-action panic=pause|shutdown|none\n" + "-action panic=pause|shutdown|exit-failure|none\n" " action when guest panics [default=shutdown]\n" "-action watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none\n" " action when watchdog fires [default=reset]\n",
softmmu/main.c +4 -2
@@ -32,11 +32,13 @@int qemu_main (int argc,char **argv,char **envp) { +int status; +qemu_init (argc, argv, envp); -qemu_main_loop (); + status =qemu_main_loop ();qemu_cleanup (); -return 0 ; +return status; }#ifndef CONFIG_COCOA
softmmu/runstate.c +13 -4
@@ -482,7 +482,8 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , !!info, info);vm_stop (RUN_STATE_GUEST_PANICKED ); - }else if (panic_action ==PANIC_ACTION_SHUTDOWN ) { + }else if (panic_action ==PANIC_ACTION_SHUTDOWN || + panic_action ==PANIC_ACTION_EXIT_FAILURE ) {qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_POWEROFF , !!info, info);vm_stop (RUN_STATE_GUEST_PANICKED );
@@ -662,7 +663,7 @@ void qemu_system_debug_request(void)qemu_notify_event (); } -static bool main_loop_should_exit (void ) +static bool main_loop_should_exit (int *status) {RunState r;ShutdownCause request;
@@ -680,6 +681,10 @@ static bool main_loop_should_exit(void)if (shutdown_action ==SHUTDOWN_ACTION_PAUSE ) {vm_stop (RUN_STATE_SHUTDOWN ); }else { +if (request ==SHUTDOWN_CAUSE_GUEST_PANIC && + panic_action ==PANIC_ACTION_EXIT_FAILURE ) { + *status =EXIT_FAILURE ; + }return true; } }
@@ -715,12 +720,14 @@ static bool main_loop_should_exit(void)return false; } -void qemu_main_loop (void ) +int qemu_main_loop (void ) { +int status =EXIT_SUCCESS ;#ifdef CONFIG_PROFILER int64_t ti;#endif -while (!main_loop_should_exit ()) { + +while (!main_loop_should_exit (&status)) {#ifdef CONFIG_PROFILER ti =profile_getclock ();#endif
@@ -729,6 +736,8 @@ void qemu_main_loop(void) dev_time +=profile_getclock () - ti;#endif } + +return status; }void qemu_add_exit_notifier (Notifier *notify)
Signature · 1 line
2.35.3
PATCH v2 2/2 tests/tcg/s390x: Test unaligned accesses to lowcore
In reply to Ilya LeoshkevichAdd a small test to avoid regressions.
--- tests/tcg/s390x/Makefile.softmmu-target | 9 +++++++++ tests/tcg/s390x/unaligned-lowcore.S | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/tcg/s390x/Makefile.softmmu-target create mode 100644 tests/tcg/s390x/unaligned-lowcore.S
tests/tcg/s390x/Makefile.softmmu-target new file +9 -0
@@ -0,0 +1,9 @@ +S390X_SRC=$(SRC_PATH)/tests/tcg/s390x +VPATH+=$(S390X_SRC) +QEMU_OPTS=-action panic=exit-failure -kernel + +%: %.S + $(CC) -march=z13 -m64 -nostartfiles -static -Wl,-Ttext=0 \ + -Wl,--build-id=none $< -o $@ + +TESTS += unaligned-lowcore
tests/tcg/s390x/unaligned-lowcore.S new file +19 -0
@@ -0,0 +1,19 @@ + .org 0x1D0 /* program new PSW */ + .quad 0x2000000000000, 0 /* disabled wait */ + .org 0x200 /* lowcore padding */ + + .globl _start +_start: + lctlg %c0,%c0,_c0 + vst %v0,_unaligned + lpswe quiesce_psw + + .align 8 +quiesce_psw: + .quad 0x2000000000000,0xfff /* see is_special_wait_psw() */ +_c0: + .quad 0x10060000 /* lowcore protection, AFP, VX */ + + .byte 0 +_unaligned: + .octa 0
Signature · 1 line
2.35.3
Re: [PATCH v2 1/2] qapi: Add exit-failure PanicAction
In reply to Ilya LeoshkevichQuoted 9 lines · Ilya Leoshkevich
Currently QEMU exits with code 0 on both panic an shutdown. For tests it is useful to return 1 on panic, so that it counts as a test failure.
Introduce a new exit-failure PanicAction that makes
main()returnEXIT_FAILURE. Tests can use -action panic=exit-failure option to activate this behavior.Signed-off-by Ilya Leoshkevich <[email protected]>
I like it.
r~
Quoted 132 lines
--- include/sysemu/sysemu.h | 2 +- qapi/run-state.json | 4 +++- qemu-options.hx | 2 +- softmmu/main.c | 6 ++++-- softmmu/runstate.c | 17 +++++++++++++---- 5 files changed, 22 insertions(+), 9 deletions(-)include/sysemu/sysemu.h +1
-1@@ -103,7 +103,7 @@ void qemu_boot_set(const char *boot_order, Error **errp);bool defaults_enabled (void );void qemu_init (int argc,char **argv,char **envp); -void qemu_main_loop (void ); +int qemu_main_loop (void );void qemu_cleanup (void );extern QemuOptsList qemu_legacy_drive_opts;qapi/run-state.json +3
-1@@ -364,10 +364,12 @@ # # @shutdown: Shutdown the VM and exit, according to the shutdown action # +# @exit-failure: Shutdown the VM and exit with nonzero status +# # Since: 6.0 ## { 'enum': 'PanicAction', - 'data': [ 'pause', 'shutdown', 'none' ] } + 'data': [ 'pause', 'shutdown', 'exit-failure', 'none' ] } ## # @watchdog-set-action:qemu-options.hx +1
-1@@ -4239,7 +4239,7 @@ DEF("action", HAS_ARG, QEMU_OPTION_action, " action when guest reboots [default=reset]\n" "-action shutdown=poweroff|pause\n" " action when guest shuts down [default=poweroff]\n" - "-action panic=pause|shutdown|none\n" + "-action panic=pause|shutdown|exit-failure|none\n" " action when guest panics [default=shutdown]\n" "-action watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none\n" " action when watchdog fires [default=reset]\n",softmmu/main.c +4
-2@@ -32,11 +32,13 @@int qemu_main (int argc,char **argv,char **envp) { +int status; +qemu_init (argc, argv, envp); -qemu_main_loop (); + status =qemu_main_loop ();qemu_cleanup (); -return 0 ; +return status; }#ifndef CONFIG_COCOA softmmu/runstate.c +13
-4@@ -482,7 +482,8 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_PAUSE , !!info, info);vm_stop (RUN_STATE_GUEST_PANICKED ); - }else if (panic_action ==PANIC_ACTION_SHUTDOWN ) { + }else if (panic_action ==PANIC_ACTION_SHUTDOWN || + panic_action ==PANIC_ACTION_EXIT_FAILURE ) {qapi_event_send_guest_panicked (GUEST_PANIC_ACTION_POWEROFF , !!info, info);vm_stop (RUN_STATE_GUEST_PANICKED );@@ -662,7 +663,7 @@ void qemu_system_debug_request(void)qemu_notify_event (); } -static bool main_loop_should_exit (void ) +static bool main_loop_should_exit (int *status) {RunState r;ShutdownCause request;@@ -680,6 +681,10 @@ static bool main_loop_should_exit(void)if (shutdown_action ==SHUTDOWN_ACTION_PAUSE ) {vm_stop (RUN_STATE_SHUTDOWN ); }else { +if (request ==SHUTDOWN_CAUSE_GUEST_PANIC && + panic_action ==PANIC_ACTION_EXIT_FAILURE ) { + *status =EXIT_FAILURE ; + }return true; } }@@ -715,12 +720,14 @@ static bool main_loop_should_exit(void)return false; } -void qemu_main_loop (void ) +int qemu_main_loop (void ) { +int status =EXIT_SUCCESS ;#ifdef CONFIG_PROFILER int64_t ti;#endif -while (!main_loop_should_exit ()) { + +while (!main_loop_should_exit (&status)) {#ifdef CONFIG_PROFILER ti =profile_getclock ();#endif @@ -729,6 +736,8 @@ void qemu_main_loop(void) dev_time +=profile_getclock () - ti;#endif } + +return status; }void qemu_add_exit_notifier (Notifier *notify)
Re: [PATCH v2 2/2] tests/tcg/s390x: Test unaligned accesses to lowcore
In reply to Ilya LeoshkevichQuoted 3 lines · Ilya Leoshkevich
Add a small test to avoid regressions.
Signed-off-by Ilya Leoshkevich <[email protected]>
r~
Quoted 47 lines
--- tests/tcg/s390x/Makefile.softmmu-target | 9 +++++++++ tests/tcg/s390x/unaligned-lowcore.S | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+)create mode 100644 tests/tcg/s390x/Makefile.softmmu-target create mode 100644
tests/tcg/s390x/unaligned-lowcore.Stests/tcg/s390x/Makefile.softmmu-target new file +9
-0@@ -0,0 +1,9 @@ +S390X_SRC=$(SRC_PATH)/tests/tcg/s390x +VPATH+=$(S390X_SRC) +QEMU_OPTS=-action panic=exit-failure -kernel + +%: %.S + $(CC) -march=z13 -m64 -nostartfiles -static -Wl,-Ttext=0 \ + -Wl,--build-id=none $< -o $@ + +TESTS += unaligned-lowcoretests/tcg/s390x/unaligned-lowcore.S new file +19
-0@@ -0,0 +1,19 @@ + .org 0x1D0 /* program new PSW */ + .quad 0x2000000000000, 0 /* disabled wait */ + .org 0x200 /* lowcore padding */ + + .globl _start +_start: + lctlg %c0,%c0,_c0 + vst %v0,_unaligned + lpswe quiesce_psw + + .align 8 +quiesce_psw: + .quad 0x2000000000000,0xfff /* see is_special_wait_psw() */ +_c0: + .quad 0x10060000 /* lowcore protection, AFP, VX */ + + .byte 0 +_unaligned: + .octa 0
Re: [PATCH v2 1/2] qapi: Add exit-failure PanicAction
In reply to Ilya LeoshkevichQuoted 7 lines · Ilya Leoshkevich
Currently QEMU exits with code 0 on both panic an shutdown. For tests it is useful to return 1 on panic, so that it counts as a test failure.
Introduce a new exit-failure PanicAction that makes
main()returnEXIT_FAILURE. Tests can use -action panic=exit-failure option to activate this behavior.
Roughly what I proposed, nice.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 10 lines · Ilya Leoshkevich
Hi,
This is a follow-up series for [1].
The fix has been committed.
I asked Christian what might be a good alternative for the mmio-debug-exit device for testing, and he suggested to look into shutdown/panic actions.
Quoted 6 lines
Patch 1 adds a new panic action.
Patch 2 tests unaligned stores to s390x low-address-protected lowcore; it performs a shutdown on success and panic on failure.Best regards,
Ilya
Queued to testing/next, thanks.
Signature · 1 line
Alex Bennée
Re: [PATCH v2 1/2] qapi: Add exit-failure PanicAction
In reply to Ilya LeoshkevichQuoted 13 lines · Ilya Leoshkevich
Currently QEMU exits with code 0 on both panic an shutdown. For tests it is useful to return 1 on panic, so that it counts as a test failure.
Introduce a new exit-failure PanicAction that makes
main()returnEXIT_FAILURE. Tests can use -action panic=exit-failure option to activate this behavior.Signed-off-by Ilya Leoshkevich <[email protected]>---
+++
b/qapi/run-state.json
qapi/run-state.json line 367
Quoted 4 lines
qapi/run-state.json +1
-0@@ -364,10 +364,12 @@ # # @shutdown: Shutdown the VM and exit, according to the shutdown action # +# @exit-failure: Shutdown the VM and exit with nonzero status
Missing a '(since 7.1)' tag. Otherwise a nice addition.
Quoted 6 lines
qapi/run-state.json +2
-1+# # Since: 6.0 ## { 'enum': 'PanicAction', - 'data': [ 'pause', 'shutdown', 'none' ] } + 'data': [ 'pause', 'shutdown', 'exit-failure', 'none' ] }
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org