All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/24] accel/tcg: share raise_excp across TCG targets
@ 2026-09-28  5:20 Yonggang Luo
  2026-09-28  5:20 ` [PATCH v2 01/24] accel/tcg: move helper_exit_atomic next to cpu_loop_exit_atomic Yonggang Luo
                   ` (23 more replies)
  0 siblings, 24 replies; 34+ messages in thread
From: Yonggang Luo @ 2026-09-28  5:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Harsh Prateek Bora, Weiwei Li, Brian Cain,
	Daniel Henrique Barboza, Max Filippov, Chao Liu,
	Aleksandar Rikalo, Philippe Mathieu-Daude, Matthew Rosato,
	Ilya Leoshkevich, Alistair Francis, Stafford Horne, Chinmay Rath,
	Nicholas Piggin, Yoshinori Sato, Peter Maydell, Artyom Tarasenko,
	Laurent Vivier, Jiaxun Yang, Palmer Dabbelt, Edgar E. Iglesias,
	Aurelien Jarno, Philippe Mathieu-Daudé, Eric Farman,
	qemu-riscv, Richard Henderson, David Hildenbrand, Glenn Miles,
	Cornelia Huck, Mark Cave-Ayland, Song Gao, qemu-ppc, qemu-arm,
	Michael Rolnik, Pierrick Bouvier, Paolo Bonzini, qemu-s390x

Many TCG targets copy the same two-line raise: set cs->exception_index and call
cpu_loop_exit_restore. They also copy DEF_HELPER_2(raise_exception, ...).
helper_raise_exception is a global C symbol, so a unified binary cannot keep
that name on more than one target.

This series adds a shared C exit and two shared TCG helpers, then converts one
target per commit. Joiners call gen_helper_raise_excp or
gen_helper_raise_excp_restore and drop the copied DEF. Leftover TCG helpers that
still do extra work take an arch prefix. C wrappers keep the short name as
static inline where that is enough. The shared helpers only touch CPUState.
Translate may store arch state (error_code, PC) first. Guest trap numbers stay
below 0x10000. TCG loop codes such as EXCP_INTERRUPT start at 0x10000.

- Move helper_exit_atomic into cpu-exec-common.c with its DEF_HELPER, so the new
  helpers can sit beside it.
- Add cpu_loop_exit_excp next to cpu_loop_exit_restore. Set
  cpu->exception_index, then restore and exit the same way as
  cpu_loop_exit_restore.
- Add TCG raise_excp and raise_excp_restore next to cpu_loop_exit_excp.
  raise_excp exits with host_pc 0. raise_excp_restore exits with GETPC(). Each
  helper does one thing.
- Name RX and SH4 guest traps RX_EXCP_* and SH4_EXCP_* in their own commits,
  then convert the raises. Join privilege and illegal on RX through
  raise_excp_restore, and BRK and INT through raise_excp. Join illegal and
  FPU-disable on SH4. Keep SH4 sleep, trapa, and exclusive.
- Convert the remaining joiners one arch per commit: m68k, or1k, microblaze,
  sparc, loongarch, hppa, alpha, s390x, xtensa, avr, arm exception_internal,
  mips, and ppc. Store error_code or PC in translate where needed, then call the
  shared helper. loongarch and the mips 2-arg path use raise_excp_restore.
- Add gen_yield before the xtensa conversion. Fold gen_exception_nip into
  gen_exception_err_nip before the ppc conversion.
- Prefix leftover TCG helpers that still do extra work: riscv_raise_exception
  and hexagon_raise_exception. Tricore raise_exception_sync does not join.

v1: https://patchew.org/QEMU/20260918004225.827-1-luoyonggang@gmail.com/

Changes v1 -> v2:

- Move helper_exit_atomic into cpu-exec-common.c. Split the restore flag into
  raise_excp and raise_excp_restore, and define both there.
- Drop the helper-gen nested-extern change.
- Shorten the cpu_loop_exit_excp comment. Drop the generic EXCP_INTERRUPT note
  on the RX and SH4 trap enums, and put those enums in their own commits.
- Split xtensa gen_yield and the ppc gen_exception_nip fold out of the
  conversion commits.
- Omit the i386 conversion, the rx, mips, and hexagon helper_wait renames, and
  the arm raise_exception rename.

Yonggang Luo (24):
  accel/tcg: move helper_exit_atomic next to cpu_loop_exit_atomic
  accel/tcg: add cpu_loop_exit_excp
  accel/tcg: add raise_excp and raise_excp_restore helpers
  target/rx: name guest trap numbers RX_EXCP_*
  target/rx: convert raises to raise_excp
  target/sh4: name guest trap numbers SH4_EXCP_*
  target/sh4: convert raises to raise_excp
  target/m68k: convert raises to raise_excp
  target/or1k: convert exception to raise_excp
  target/microblaze: convert raise_exception to raise_excp
  target/sparc: convert raise_exception to raise_excp
  target/loongarch: convert raise_exception to raise_excp
  target/hexagon: convert raise_exception to hexagon_raise_exception
  target/hppa: convert excp to raise_excp
  target/alpha: convert excp to raise_excp
  target/s390x: convert exception to raise_excp
  target/xtensa: add gen_yield for EXCP_YIELD
  target/xtensa: convert exception to raise_excp
  target/avr: convert debug/break/sleep to raise_excp
  target/arm: convert exception_internal to raise_excp
  target/riscv: convert raise_exception to riscv_raise_exception
  target/mips: convert raise_exception to raise_excp
  target/ppc: fold gen_exception_nip into gen_exception_err_nip
  target/ppc: convert raise_exception to raise_excp

 MAINTAINERS                                   |  1 +
 accel/tcg/cpu-exec-common.c                   | 28 +++++++
 accel/tcg/cpu-exec-common.h                   |  4 +
 accel/tcg/tcg-runtime.c                       |  8 --
 accel/tcg/tcg-runtime.h                       |  2 -
 include/accel/tcg/cpu-loop.h                  | 12 +++
 include/exec/helper-gen-common.h              |  4 +
 include/exec/helper-proto-common.h            |  4 +
 target/alpha/helper.c                         | 11 ---
 target/alpha/helper.h                         |  1 -
 target/alpha/translate.c                      |  8 +-
 target/arm/tcg/helper-defs.h                  |  1 -
 target/arm/tcg/m_helper.c                     |  3 +-
 target/arm/tcg/op_helper.c                    | 33 ++------
 target/arm/tcg/translate.c                    |  2 +-
 target/avr/helper.c                           | 24 ------
 target/avr/helper.h                           |  3 -
 target/avr/translate.c                        |  4 +-
 target/hexagon/cpu.c                          | 13 +--
 target/hexagon/cpu.h                          |  2 +-
 target/hexagon/helper.h                       |  3 +-
 target/hexagon/internal.h                     |  5 --
 target/hexagon/macros.h                       |  2 +-
 target/hexagon/op_helper.c                    | 29 +++----
 target/hexagon/translate.c                    | 11 +--
 target/hppa/helper.h                          |  2 -
 target/hppa/op_helper.c                       | 15 +---
 target/hppa/sys_helper.c                      |  4 +-
 target/hppa/translate.c                       |  2 +-
 target/loongarch/tcg/helper.h                 |  2 -
 target/loongarch/tcg/op_helper.c              |  6 --
 target/loongarch/tcg/tcg_cpu.c                |  4 +-
 target/loongarch/tcg/translate.c              |  2 +-
 target/m68k/helper.c                          | 12 +--
 target/m68k/helper.h                          |  1 -
 target/m68k/op_helper.c                       | 19 -----
 target/m68k/translate.c                       |  2 +-
 target/microblaze/helper.c                    |  3 +-
 target/microblaze/helper.h                    |  2 -
 target/microblaze/op_helper.c                 | 22 +----
 target/microblaze/translate.c                 |  2 +-
 target/mips/helper.h                          |  4 -
 target/mips/tcg/exception.c                   | 20 +----
 target/mips/tcg/fpu_helper.c                  |  6 +-
 target/mips/tcg/translate.c                   |  9 +-
 target/or1k/exception.c                       | 31 -------
 target/or1k/exception.h                       |  7 +-
 target/or1k/exception_helper.c                | 13 +--
 target/or1k/helper.h                          |  1 -
 target/or1k/meson.build                       |  1 -
 target/or1k/translate.c                       |  2 +-
 target/ppc/cpu.h                              |  3 -
 target/ppc/helper.h                           |  2 -
 target/ppc/internal.h                         |  9 ++
 target/ppc/misc_helper.c                      |  1 +
 target/ppc/tcg-excp_helper.c                  | 21 -----
 target/ppc/timebase_helper.c                  |  1 +
 target/ppc/translate.c                        | 20 ++---
 target/riscv/helper.h                         |  2 +-
 target/riscv/tcg/insn_trans/trans_rvi.c.inc   |  6 +-
 .../tcg/insn_trans/trans_rvzicfiss.c.inc      |  3 +-
 target/riscv/tcg/op_helper.c                  |  5 +-
 target/riscv/tcg/translate.c                  | 10 ++-
 target/rx/cpu.h                               | 10 +++
 target/rx/helper.c                            | 16 ++--
 target/rx/helper.h                            |  5 --
 target/rx/op_helper.c                         | 44 +---------
 target/rx/translate.c                         | 13 ++-
 target/s390x/helper.h                         |  1 -
 target/s390x/tcg/mem_helper.c                 |  2 +-
 target/s390x/tcg/misc_helper.c                | 10 ---
 target/s390x/tcg/translate.c                  |  2 +-
 target/sh4/cpu.h                              | 21 +++++
 target/sh4/helper.c                           | 82 ++++++++++---------
 target/sh4/helper.h                           |  4 -
 target/sh4/op_helper.c                        | 43 ++--------
 target/sh4/translate.c                        | 12 ++-
 target/sparc/helper.c                         | 21 +----
 target/sparc/helper.h                         |  2 -
 target/sparc/translate.c                      |  6 +-
 target/xtensa/cpu.h                           |  1 +
 target/xtensa/exc_helper.c                    | 13 ++-
 target/xtensa/helper.h                        |  1 -
 target/xtensa/translate.c                     |  8 +-
 target/xtensa/win_helper.c                    | 12 +--
 85 files changed, 287 insertions(+), 537 deletions(-)
 create mode 100644 accel/tcg/cpu-exec-common.h
 delete mode 100644 target/or1k/exception.c

-- 
2.52.0.windows.1



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

end of thread, other threads:[~2026-09-30  7:54 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28  5:20 [PATCH v2 00/24] accel/tcg: share raise_excp across TCG targets Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 01/24] accel/tcg: move helper_exit_atomic next to cpu_loop_exit_atomic Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 02/24] accel/tcg: add cpu_loop_exit_excp Yonggang Luo
2026-09-29  5:23   ` Philippe Mathieu-Daudé
2026-09-29  5:27     ` Yonggang Luo
2026-09-30  7:53     ` Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 03/24] accel/tcg: add raise_excp and raise_excp_restore helpers Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 04/24] target/rx: name guest trap numbers RX_EXCP_* Yonggang Luo
2026-09-29  5:26   ` Philippe Mathieu-Daudé
2026-09-29  5:29     ` Yonggang Luo
2026-09-29  6:57       ` [PATCH 1/2] target/rx: Unify BRK and INT trap handling Philippe Mathieu-Daudé
2026-09-29  6:57         ` [PATCH 2/2] target/rx: Define exception vector constants Philippe Mathieu-Daudé
2026-09-28  5:20 ` [PATCH v2 05/24] target/rx: convert raises to raise_excp Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 06/24] target/sh4: name guest trap numbers SH4_EXCP_* Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 07/24] target/sh4: convert raises to raise_excp Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 08/24] target/m68k: " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 09/24] target/or1k: convert exception " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 10/24] target/microblaze: convert raise_exception " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 11/24] target/sparc: " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 12/24] target/loongarch: " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 13/24] target/hexagon: convert raise_exception to hexagon_raise_exception Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 14/24] target/hppa: convert excp to raise_excp Yonggang Luo
2026-09-29  5:21   ` Philippe Mathieu-Daudé
2026-09-28  5:20 ` [PATCH v2 15/24] target/alpha: " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 16/24] target/s390x: convert exception " Yonggang Luo
2026-09-28 17:42   ` Ilya Leoshkevich
2026-09-28  5:20 ` [PATCH v2 17/24] target/xtensa: add gen_yield for EXCP_YIELD Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 18/24] target/xtensa: convert exception to raise_excp Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 19/24] target/avr: convert debug/break/sleep " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 20/24] target/arm: convert exception_internal " Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 21/24] target/riscv: convert raise_exception to riscv_raise_exception Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 22/24] target/mips: convert raise_exception to raise_excp Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 23/24] target/ppc: fold gen_exception_nip into gen_exception_err_nip Yonggang Luo
2026-09-28  5:20 ` [PATCH v2 24/24] target/ppc: convert raise_exception to raise_excp Yonggang Luo

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.