All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] semihosting: proper QEMU exit on semihosted exit syscall
@ 2022-06-21 12:59 Luc Michel
  2022-06-21 12:59 ` [PATCH v2 1/7] softmmu: add qemu_[set|get]_exit_status functions Luc Michel
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Luc Michel @ 2022-06-21 12:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Luc Michel, Richard Henderson, Peter Maydell,
	Philippe Mathieu-Daudé,
	Paolo Bonzini, Alex Bennée, Eric Blake, Markus Armbruster,
	Laurent Vivier, Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo,
	Chris Wulff, Marek Vasut, Max Filippov

v2:
  - fix linux-user compilation. Declare semihosting_exit_request "static
    inline G_NORETURN" on CONFIG_USER_ONLY side. Use
    g_assert_not_reached() to enforce the G_NORETURN since this function
    is unused in linux-user mode.
  - do not call gdb_exit() in semihosting_exit_request() as it is called in
    qemu_cleanup().
  - pass qemu_get_exit_status() to gdb_exit() in qemu_cleanup() instead
    of 0.

Hi,

This series implements a clean way for semihosted exit syscalls to
terminate QEMU with a given return code.

Until now, exit syscalls implementations consisted in calling exit()
with the wanted return code. The problem with this approach is that
other CPUs are not properly stopped, leading to possible crashes in
MTTCG mode, especially when at_exit callbacks have been registered. This
can be the case e.g., when plugins are in use. Plugins can register
at_exit callbacks. Those will be called on the CPU thread the exit
syscall is comming from, while other CPUs can continue to run and thus
call other plugin callbacks.

The semihosting_exit_request function provides a mean to cleanly
terminate QEMU. It introduces an new exit reason
(SHUTDOWN_CAUSE_GUEST_SEMI_EXIT) used in this case. The CPU is stopped
and returns to the main CPU loop so that no more instruction get
executed (the semihosting_exit_request is declared G_NORETURN).

All targets are converted to use this new function.

Thanks,
Luc

Luc Michel (7):
  softmmu: add qemu_[set|get]_exit_status functions
  semihosting: add the semihosting_exit_request function
  semihosting/arm-compat-semi: use semihosting_exit_request
  target/m68k: use semihosting_exit_request on semihosted exit syscall
  target/mips: use semihosting_exit_request on semihosted exit syscall
  target/nios2: use semihosting_exit_request on semihosted exit syscall
  target/xtensa: use semihosting_exit_request on semihosted exit syscall

 qapi/run-state.json                |  4 +++-
 include/semihosting/semihost.h     |  5 +++++
 include/sysemu/sysemu.h            |  2 ++
 semihosting/arm-compat-semi.c      |  3 +--
 semihosting/config.c               | 16 ++++++++++++++++
 softmmu/main.c                     |  2 +-
 softmmu/runstate.c                 | 13 ++++++++++++-
 target/m68k/m68k-semi.c            |  4 ++--
 target/mips/tcg/sysemu/mips-semi.c |  2 +-
 target/nios2/nios2-semi.c          |  4 ++--
 target/xtensa/xtensa-semi.c        |  2 +-
 11 files changed, 46 insertions(+), 11 deletions(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-06-23  7:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 12:59 [PATCH v2 0/7] semihosting: proper QEMU exit on semihosted exit syscall Luc Michel
2022-06-21 12:59 ` [PATCH v2 1/7] softmmu: add qemu_[set|get]_exit_status functions Luc Michel
2022-06-21 13:22   ` Laurent Vivier
2022-06-21 12:59 ` [PATCH v2 2/7] semihosting: add the semihosting_exit_request function Luc Michel
2022-06-21 13:33   ` Laurent Vivier
2022-06-22 16:19   ` Eric Blake
2022-06-22 19:09   ` Peter Maydell
2022-06-23  7:16     ` Luc Michel
2022-06-21 12:59 ` [PATCH v2 3/7] semihosting/arm-compat-semi: use semihosting_exit_request Luc Michel
2022-06-21 13:34   ` Laurent Vivier
2022-06-21 12:59 ` [PATCH v2 4/7] target/m68k: use semihosting_exit_request on semihosted exit syscall Luc Michel
2022-06-21 13:37   ` Laurent Vivier
2022-06-21 12:59 ` [PATCH v2 5/7] target/mips: " Luc Michel
2022-06-21 13:35   ` Laurent Vivier
2022-06-21 12:59 ` [PATCH v2 6/7] target/nios2: " Luc Michel
2022-06-21 13:35   ` Laurent Vivier
2022-06-21 12:59 ` [PATCH v2 7/7] target/xtensa: " Luc Michel
2022-06-21 13:36   ` Laurent Vivier
2022-06-21 14:37 ` [PATCH v2 0/7] semihosting: proper QEMU exit " Richard Henderson
2022-06-22  7:11   ` Luc Michel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.