Skip to contentSkip to conversation

Misc target/ patches for 2026-10-23

GIT PULL Philippe Mathieu-Daudé 2 participants 86 messages Oct 23 – Oct 24 RISC-V

lore
Share & tools
lore
#0 lore raw

The following changes since commit b6c4b7e86dec12d07f5cac65265b986d38ee9002:

Merge tag 'pbouvier/pr/tcg_tests-20261022' of https://gitlab.com/p-b-o/qemu into staging (2026-10-23 09:09:11 +0200)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/target-misc-20261023

for you to fetch changes up to a0deb11baf6e5818ccd641088d9465e0e0eac9b7:

MAINTAINERS: cover riscv GDB XML files (2026-10-23 17:52:30 +0200)

----------------------------------------------------------------
Misc target patches queue

- Make TCG halt-to-exec transition explicit and remove cpu_exec_halt()
- Various conversions to translate_for_debug()
- Add common CPUClass::exception_name() handler
- multi-target: prefix helpers with target prefix
- Remove target_long_bits() from GDB register reads
- MAINTAINERS updates
----------------------------------------------------------------

Marc-André Lureau (3):
MAINTAINERS: cover m68k GDB XML files
MAINTAINERS: cover x86 GDB XML files
MAINTAINERS: cover riscv GDB XML files

Matt Turner (2):
target/alpha: Record masked exceptions in FPCR for /S insns target/alpha: Determine tininess from the delivered result

Peter Maydell (10):
target/alpha: Convert to translate_for_debug target/avr: Convert to translate_for_debug target/or1k: Convert to translate_for_debug target/rx: Convert to translate_for_debug target/tricore: Convert to translate_for_debug target/hexagon: Convert to translate_for_debug target/hppa: Convert to translate_for_debug target/loongarch: Convert to translate_for_debug target/m68k: Convert to translate_for_debug target/mips: Convert to translate_for_debug

Philippe Mathieu-Daudé (50):
accel/tcg: Refactor poll-while-halted flow in cpu_exec() accel/tcg: Introduce poll_during_halt() and leaving_halt() target/arm: Split leaving-halt handling from arm_cpu_exec_halt() target/arm: Convert cpu_exec_halt() to leaving_halt() target/i386: Split APIC polling from x86_cpu_exec_halt() target/i386: Split leaving-halt handling from x86_cpu_exec_halt() target/i386: Use generic halt transition handlers accel/tcg: Remove the redundant cpu_exec_halt() hook target/sparc/gdbstub: Replace gdb_get_regl() by gdb_get_reg64() target/mips/gdbstub: Reduce to a single gdb_get_regl() call target/mips/gdbstub: Replace target_long_bits() by mips_env_is_64bit() target/ppc: Factor ppc_env_is_64bit() out target/ppc/gdbstub: Replace target_long_bits() by ppc_env_is_64bit() target/ppc/gdbstub: Replace gdb_get_regl() by ppc_env_is_64bit() target/riscv: Factor riscv_gdb_get_reg_mxl() out target/riscv: Replace gdb_get_regl() by riscv_gdb_get_reg_mxl() target/hexagon: Expand gdb_get_regl() -> gdb_get_reg32() again
gdbstub: Remove unused gdb_get_regl()
include: Remove TARGET_LONG_SIZE definition
qemu/osdep: Document ARRAY_SIZE() macro rejects pointers util/cutils: Add STR_ARRAY_ELEM_OR_NULL() for string table lookups
cpus: Add helper to log raised exceptions with '-d int'
cpus: Introduce CPUClass::exception_name() handler target/alpha: Register CPUClass::exception_name() handler target/alpha: Use a static table in alpha_exception_name() target/arm: Register CPUClass::exception_name() handler target/avr: Implement and register CPUClass::exception_name() target/hexagon: Register CPUClass::exception_name() handler target/hppa: Register CPUClass::exception_name() handler target/i386: Replace magic value by proper EXCP0E_PAGE definition target/i386: Implement and register CPUClass::exception_name() target/loongarch: Register CPUClass::exception_name() handler target/m68k: Register CPUClass::exception_name() handler target/m68k: Use a static table in m68k_exception_name() target/microblaze: Implement and register CPUClass::exception_name() target/mips: Remove EXCP_LAST, use ARRAY_SIZE(excp_names) target/mips: Register CPUClass::exception_name() handler target/or1k: Register CPUClass::exception_name() handler target/ppc: Name the EBB exceptions
target/ppc: Use a static table in powerpc_excp_name() target/ppc: Register CPUClass::exception_name() handler target/riscv: Register CPUClass::exception_name() handler target/rx: Unify BRK and INT trap handling
target/rx: Register CPUClass::exception_name() handler target/s390x: Implement and register CPUClass::exception_name() target/sh4: Register CPUClass::exception_name() handler target/sh4: Use a static table in sh4_exception_name() target/sparc: Remove always-defined DEBUG_PCALL target/sparc: Register CPUClass::exception_name() handler target/xtensa: Implement and register CPUClass::exception_name()

Pierrick Bouvier (16):
target/alpha: define and call helpers using HELPER macro target/arm: define and call helpers using HELPER macro target/avr: define and call helpers using HELPER macro target/hppa: define and call helpers using HELPER macro target/i386: define and call helpers using HELPER macro target/loongarch: define and call helpers using HELPER macro target/m68k: define and call helpers using HELPER macro target/microblaze: define and call helpers using HELPER macro target/mips: define and call helpers using HELPER macro target/or1k: define and call helpers using HELPER macro target/ppc: define and call helpers using HELPER macro target/riscv: define and call helpers using HELPER macro target/s390x: define and call helpers using HELPER macro target/sh4: define and call helpers using HELPER macro target/sparc: define and call helpers using HELPER macro target/tricore: define and call helpers using HELPER macro

Yonggang Luo (2):
target/rx: Define exception vector constants
target/sh4: Define exception vector constants

 MAINTAINERS                             |   4 +
 include/accel/tcg/cpu-ops.h             |  36 +-
 include/exec/target_long.h              |   8 +-
 include/gdbstub/helpers.h               |  18 -
 include/hw/core/cpu.h                   |   2 +
 include/qemu/cutils.h                   |  17 +
 include/qemu/osdep.h                    |   9 +
 include/user/tswap-target.h             |   2 +-
 target/alpha/cpu.h                      |   4 +-
 target/arm/cpu.h                        |   4 +-
 target/arm/internals.h                  |   3 -
 target/arm/tcg/vec_internal.h           |   5 +-
 target/avr/cpu.h                        |   5 +-
 target/hexagon/cpu_bits.h               |   2 +
 target/hppa/cpu.h                       |   5 +-
 target/i386/cpu.h                       |   2 +
 target/i386/ops_sse.h                   | 401 +++++++-------
 target/i386/tcg/helper-tcg.h            |   3 +-
 target/loongarch/cpu-mmu.h              |   3 +-
 target/loongarch/internals.h            |   3 +-
 target/m68k/cpu.h                       |   5 +-
 target/microblaze/cpu.h                 |   2 +
 target/mips/cpu.h                       |   4 +-
 target/mips/internal.h                  |   8 +-
 target/mips/tcg/tcg-internal.h          |   2 -
 target/or1k/cpu.h                       |   5 +-
 target/ppc/cpu.h                        |   2 +
 target/ppc/internal.h                   |  18 +-
 target/riscv/cpu.h                      |   1 +
 target/riscv/internals.h                |   5 -
 target/rx/cpu.h                         |  17 +-
 target/rx/helper.h                      |   3 +-
 target/s390x/cpu.h                      |   2 +
 target/s390x/s390x-internal.h           |   1 -
 target/sh4/cpu.h                        |  22 +
 target/sparc/cpu.h                      |   1 +
 target/tricore/cpu.h                    |   3 +-
 target/xtensa/cpu.h                     |   2 +
 accel/tcg/cpu-exec-common.c             |  36 ++
 accel/tcg/cpu-exec.c                    |  20 +-
 target/alpha/clk_helper.c               |   2 +-
 target/alpha/cpu.c                      |   4 +-
 target/alpha/fpu_helper.c               | 130 +++--
 target/alpha/helper.c                   |  78 ++-
 target/alpha/int_helper.c               |  38 +-
 target/alpha/sys_helper.c               |  12 +-
 target/alpha/vax_helper.c               |  42 +-
 target/arm/cpu.c                        |  21 +-
 target/arm/helper.c                     |  77 ++-
 target/arm/tcg/cpu-v7m.c                |   1 -
 target/arm/tcg/helper-a64.c             |   6 +-
 target/arm/tcg/mve_helper.c             |  28 +-
 target/arm/tcg/psci.c                   |   2 +-
 target/arm/tcg/sme_helper.c             |   4 +-
 target/arm/tcg/sve_helper.c             | 141 ++---
 target/arm/tcg/tlb_helper.c             |   2 +-
 target/arm/tcg/vec_helper.c             |  72 +--
 target/arm/tcg/vec_helper64.c           |  64 +--
 target/avr/cpu.c                        |  20 +-
 target/avr/helper.c                     |  23 +-
 target/hexagon/cpu.c                    |  51 +-
 target/hexagon/gdbstub.c                |   4 +-
 target/hexagon/hexswi.c                 |  30 +-
 target/hppa/cpu.c                       |  45 +-
 target/hppa/fpu_helper.c                |   2 +-
 target/hppa/int_helper.c                |  48 +-
 target/hppa/mem_helper.c                |  21 +-
 target/hppa/op_helper.c                 |   2 +-
 target/hppa/sys_helper.c                |   6 +-
 target/i386/cpu.c                       |  30 ++
 target/i386/tcg/bpt_helper.c            |   6 +-
 target/i386/tcg/cc_helper.c             |  14 +-
 target/i386/tcg/excp_helper.c           |  15 +-
 target/i386/tcg/fpu_helper.c            | 182 +++----
 target/i386/tcg/int_helper.c            |  34 +-
 target/i386/tcg/mem_helper.c            |   4 +-
 target/i386/tcg/misc_helper.c           |  16 +-
 target/i386/tcg/mpx_helper.c            |  12 +-
 target/i386/tcg/seg_helper.c            |  43 +-
 target/i386/tcg/system/bpt_helper.c     |   6 +-
 target/i386/tcg/system/misc_helper.c    |  32 +-
 target/i386/tcg/system/seg_helper.c     |  21 +-
 target/i386/tcg/system/smm_helper.c     |  12 +-
 target/i386/tcg/system/svm_helper.c     |  16 +-
 target/i386/tcg/tcg-cpu.c               |   3 +-
 target/i386/tcg/user/seg_helper.c       |   4 +-
 target/loongarch/cpu.c                  |  42 +-
 target/loongarch/cpu_helper.c           |  12 +-
 target/loongarch/tcg/csr_helper.c       |  22 +-
 target/loongarch/tcg/fpu_helper.c       | 126 ++---
 target/loongarch/tcg/iocsr_helper.c     |  16 +-
 target/loongarch/tcg/op_helper.c        |  18 +-
 target/loongarch/tcg/tcg_cpu.c          |  42 --
 target/loongarch/tcg/tlb_helper.c       |  26 +-
 target/loongarch/tcg/vec_helper.c       |   4 +-
 target/m68k/cpu.c                       |   4 +-
 target/m68k/helper.c                    |  16 +-
 target/m68k/op_helper.c                 | 161 +++---
 target/microblaze/cpu.c                 |  16 +-
 target/microblaze/op_helper.c           |  46 +-
 target/mips/cpu.c                       |   4 +-
 target/mips/gdbstub.c                   |  85 +--
 target/mips/system/physaddr.c           |  13 +-
 target/mips/tcg/dsp_helper.c            | 187 +++----
 target/mips/tcg/exception.c             |  18 +-
 target/mips/tcg/fpu_helper.c            | 291 +++++-----
 target/mips/tcg/ldst_helper.c           |  18 +-
 target/mips/tcg/lmmi_helper.c           |  98 ++--
 target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
 target/mips/tcg/octeon_crypto.c         | 100 ++--
 target/mips/tcg/op_helper.c             |  34 +-
 target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
 target/mips/tcg/system/lcsr_helper.c    |   8 +-
 target/mips/tcg/system/special_helper.c |  12 +-
 target/mips/tcg/system/tlb_helper.c     |  14 +-
 target/mips/tcg/vr54xx_helper.c         |  30 +-
 target/or1k/cpu.c                       |   4 +-
 target/or1k/exception.c                 |  22 +
 target/or1k/fpu_helper.c                |  16 +-
 target/or1k/interrupt.c                 |  19 +-
 target/or1k/mmu.c                       |  21 +-
 target/ppc/cpu_init.c                   |   4 +-
 target/ppc/dfp_helper.c                 |  52 +-
 target/ppc/excp_helper.c                | 140 ++---
 target/ppc/fpu_helper.c                 | 396 +++++++-------
 target/ppc/gdbstub.c                    |  38 +-
 target/ppc/int_helper.c                 | 292 +++++-----
 target/ppc/mem_helper.c                 |  28 +-
 target/ppc/misc_helper.c                |  56 +-
 target/ppc/mmu-hash64.c                 |  18 +-
 target/ppc/mmu_helper.c                 |  70 +--
 target/ppc/power8-pmu.c                 |  14 +-
 target/ppc/tcg-excp_helper.c            |  56 +-
 target/ppc/timebase_helper.c            |  54 +-
 target/riscv/cpu.c                      |  22 +-
 target/riscv/gdbstub.c                  |  35 +-
 target/riscv/tcg/debug.c                |   2 +-
 target/riscv/tcg/fpu_helper.c           | 196 +++----
 target/riscv/tcg/op_helper.c            |  76 +--
 target/riscv/tcg/tcg-cpu.c              |   1 -
 target/rx/cpu.c                         |   4 +-
 target/rx/helper.c                      |  72 ++-
 target/rx/op_helper.c                   |  17 +-
 target/rx/translate.c                   |  23 +-
 target/s390x/cpu-system.c               |   2 +-
 target/s390x/cpu.c                      |   2 +-
 target/s390x/interrupt.c                |  16 +
 target/s390x/tcg/excp_helper.c          |   6 +-
 target/s390x/tcg/mem_helper.c           |   2 +-
 target/s390x/tcg/misc_helper.c          |   3 +-
 target/sh4/cpu.c                        |   2 +-
 target/sh4/helper.c                     | 109 ++--
 target/sh4/op_helper.c                  |  92 ++--
 target/sparc/cpu.c                      |   2 +-
 target/sparc/fop_helper.c               | 106 ++--
 target/sparc/gdbstub.c                  |  13 +-
 target/sparc/helper.c                   |  22 +-
 target/sparc/int32_helper.c             |  22 +-
 target/sparc/int64_helper.c             |  48 +-
 target/sparc/ldst_helper.c              |  14 +-
 target/sparc/vis_helper.c               |  94 ++--
 target/sparc/win_helper.c               |  38 +-
 target/tricore/cpu.c                    |   3 +-
 target/tricore/fpu_helper.c             |  32 +-
 target/tricore/helper.c                 |  13 +-
 target/tricore/op_helper.c              | 220 ++++----
 target/xtensa/cpu.c                     |  25 +-
 target/xtensa/exc_helper.c              |   3 +-
 util/cutils.c                           |   6 +
 target/ppc/translate/vsx-impl.c.inc     |   2 +-
 170 files changed, 3773 insertions(+), 3422 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

[PULL 04/83] target/arm: Convert cpu_exec_halt() to leaving_halt()

arm_cpu_exec_halt() now merely checks cpu_has_work() and conditionally call arm_cpu_leaving_halt(), which is now the generic flow in cpu_has_work_after_processing_async_events().

Register the leaving_halt handler to use the generic target-agnostic flow and remove the arm_cpu_exec_halt() wrapper.

Message-ID: <[email protected]>

---
 target/arm/internals.h   |  3 ---
 target/arm/cpu.c         | 12 +-----------
 target/arm/tcg/cpu-v7m.c |  1 -
 3 files changed, 1 insertion(+), 15 deletions(-)
target/arm/internals.h +0 -3
index 06092d29b36..509ed236a1a 100644
@@ -431,9 +431,6 @@ void arm_restore_state_to_opc(CPUState *cs,
 #ifdef CONFIG_TCG
 TCGTBCPUState arm_get_tb_cpu_state(CPUState *cs);
 void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
-
-/* Our implementation of TCGCPUOps::cpu_exec_halt */
-bool arm_cpu_exec_halt(CPUState *cs);
 int arm_cpu_mmu_index(CPUState *cs, bool ifetch);
 #endif /* CONFIG_TCG */
 
target/arm/cpu.c +1 -11
index af0c64d196e..03a0ae02ebb 100644
@@ -883,16 +883,6 @@ static void arm_cpu_leaving_halt(CPUState *cs)
     /* clear the halt reason */
     qatomic_set(&cpu->env.halt_reason, NOT_HALTED);
 }
-
-bool arm_cpu_exec_halt(CPUState *cs)
-{
-    bool leave_halt = cpu_has_work(cs);
-
-    if (leave_halt) {
-        arm_cpu_leaving_halt(cs);
-    }
-    return leave_halt;
-}
 #endif
 
 /*
@@ -2627,7 +2617,7 @@ static const TCGCPUOps arm_tcg_ops = {
     .tlb_fill_align = arm_cpu_tlb_fill_align,
     .pointer_wrap = aprofile_pointer_wrap,
     .cpu_exec_interrupt = arm_cpu_exec_interrupt,
-    .cpu_exec_halt = arm_cpu_exec_halt,
+    .leaving_halt = arm_cpu_leaving_halt,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = arm_cpu_do_interrupt,
     .do_transaction_failed = arm_cpu_do_transaction_failed,
target/arm/tcg/cpu-v7m.c +0 -1
index 48b31d5eac8..1093c6cbf63 100644
@@ -302,7 +302,6 @@ static const TCGCPUOps arm_v7m_tcg_ops = {
     .tlb_fill_align = arm_cpu_tlb_fill_align,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt,
-    .cpu_exec_halt = arm_cpu_exec_halt,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = arm_v7m_cpu_do_interrupt,
     .do_transaction_failed = arm_cpu_do_transaction_failed,
Signature · 1 line
2.55.0
#2 lore raw

[PULL 03/83] target/arm: Split leaving-halt handling from arm_cpu_exec_halt()

In reply to Philippe Mathieu-Daudé

Move WFxT timer cleanup and halt-reason reset into arm_cpu_leaving_halt(). Keep arm_cpu_exec_halt() focused on deciding whether the CPU can leave the halted state.

Message-ID: <[email protected]>

---
 target/arm/cpu.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
target/arm/cpu.c +13 -7
index 73fdc6e460f..af0c64d196e 100644
@@ -872,18 +872,24 @@ static bool arm_cpu_internal_is_big_endian(CPUState *cs)
 }
 
 #ifdef CONFIG_TCG
+static void arm_cpu_leaving_halt(CPUState *cs)
+{
+    ARMCPU *cpu = ARM_CPU(cs);
+
+    /* We're about to come out of WFI/WFE: disable the WFxT timer */
+    if (cpu->wfxt_timer) {
+        timer_del(cpu->wfxt_timer);
+    }
+    /* clear the halt reason */
+    qatomic_set(&cpu->env.halt_reason, NOT_HALTED);
+}
+
 bool arm_cpu_exec_halt(CPUState *cs)
 {
     bool leave_halt = cpu_has_work(cs);
 
     if (leave_halt) {
-        /* We're about to come out of WFI/WFE: disable the WFxT timer */
-        ARMCPU *cpu = ARM_CPU(cs);
-        if (cpu->wfxt_timer) {
-            timer_del(cpu->wfxt_timer);
-        }
-        /* clear the halt reason */
-        qatomic_set(&cpu->env.halt_reason, NOT_HALTED);
+        arm_cpu_leaving_halt(cs);
     }
     return leave_halt;
 }
Signature · 1 line
2.55.0
#3 lore raw

[PULL 05/83] target/i386: Split APIC polling from x86_cpu_exec_halt()

In reply to Philippe Mathieu-Daudé

Move APIC polling into x86_cpu_poll_during_halt() while keeping the remaining halt handling in x86_cpu_exec_halt().

Message-ID: <[email protected]>

---
 target/i386/tcg/helper-tcg.h        |  1 +
 target/i386/tcg/system/seg_helper.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
target/i386/tcg/helper-tcg.h +1 -0
index f4b2ff740d5..58e8ca0bc1b 100644
@@ -37,6 +37,7 @@
  */
 void x86_cpu_do_interrupt(CPUState *cpu);
 #ifndef CONFIG_USER_ONLY
+void x86_cpu_poll_during_halt(CPUState *cpu);
 bool x86_cpu_exec_halt(CPUState *cpu);
 bool x86_need_replay_interrupt(int interrupt_request);
 bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req);
target/i386/tcg/system/seg_helper.c +9 -2
index 8c7856be81e..9ce608a0bb7 100644
@@ -128,10 +128,9 @@ void x86_cpu_do_interrupt(CPUState *cs)
     }
 }
 
-bool x86_cpu_exec_halt(CPUState *cpu)
+void x86_cpu_poll_during_halt(CPUState *cpu)
 {
     X86CPU *x86_cpu = X86_CPU(cpu);
-    CPUX86State *env = &x86_cpu->env;
 
     if (cpu_test_interrupt(cpu, CPU_INTERRUPT_POLL)) {
         bql_lock();
@@ -139,6 +138,14 @@ bool x86_cpu_exec_halt(CPUState *cpu)
         cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL);
         bql_unlock();
     }
+}
+
+bool x86_cpu_exec_halt(CPUState *cpu)
+{
+    X86CPU *x86_cpu = X86_CPU(cpu);
+    CPUX86State *env = &x86_cpu->env;
+
+    x86_cpu_poll_during_halt(cpu);
 
     if (!cpu_has_work(cpu)) {
         return false;
Signature · 1 line
2.55.0
#4 lore raw

[PULL 02/83] accel/tcg: Introduce poll_during_halt() and leaving_halt()

In reply to Philippe Mathieu-Daudé

Split target-specific halt handling into an optional poll_during_halt() callback before cpu_has_work() and a leaving_halt() callback after work is found.

Keep cpu_exec_halt() as a legacy alternative for targets that have not migrated. Require each target to provide either cpu_exec_halt() or leaving_halt(), but not both.

Message-ID: <[email protected]>

---
 include/accel/tcg/cpu-ops.h | 24 +++++++++++++++++++++++-
 accel/tcg/cpu-exec.c        | 21 +++++++++++++++++----
 2 files changed, 40 insertions(+), 5 deletions(-)
include/accel/tcg/cpu-ops.h +23 -1
index 3ff6e6810e0..1ee5d3d8bdb 100644
@@ -169,6 +169,27 @@ struct TCGCPUOps {
      */
     vaddr (*untagged_addr)(CPUState *cs, vaddr addr);
 #else
+    /**
+     * @poll_during_halt: Poll target-specific events while the CPU is halted.
+     * @cpu: vCPU context
+     *
+     * Called when the CPU is halted to handle target-specific asynchronous
+     * event processing before instruction execution begins.
+     * The caller does not hold the BQL.
+     */
+    void (*poll_during_halt)(CPUState *cpu);
+    /**
+     * @leaving_halt: Perform target-specific cleanup before resuming
+     *                execution.
+     * @cpu: vCPU context
+     *
+     * Called after a halted CPU has detected pending work and is about to
+     * resume execution from the halted state. This callback performs any
+     * necessary target-specific state transitions or synchronization before
+     * instruction execution resumes. The caller does not hold the BQL.
+     * Either this callback or @cpu_exec_halt must be provided (but not both).
+     */
+    void (*leaving_halt)(CPUState *cpu);
     /** @do_interrupt: Callback for interrupt handling.  */
     void (*do_interrupt)(CPUState *cpu);
     /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */
@@ -185,7 +206,8 @@ struct TCGCPUOps {
      * if it should remain in the halted state. (This should generally
      * be the same value that cpu_has_work() would return.)
      *
-     * This method must be provided. If the target does not need to
+     * Either @leaving_halt or this method must be provided, but not both.
+     * If the target does not need to
      * do anything special for halt, the same function used for its
      * SysemuCPUOps::has_work method can be used here, as they have the
      * same function signature.
accel/tcg/cpu-exec.c +17 -4
index 853c4b2f67a..122ad9e2e49 100644
@@ -48,6 +48,7 @@
 #include "internal-common.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "accel/tcg/iommu.h"
+#include "hw/core/sysemu-cpu-ops.h"
 #endif
 
 /* -icount align implementation. */
@@ -659,10 +660,22 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
 static bool cpu_poll_while_halted(CPUState *cpu)
 {
     const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
-    bool leave_halt = tcg_ops->cpu_exec_halt(cpu);
 
-    if (!leave_halt) {
-        return false;
+    if (tcg_ops->leaving_halt) {
+        assert(!tcg_ops->cpu_exec_halt);
+        if (tcg_ops->poll_during_halt) {
+            tcg_ops->poll_during_halt(cpu);
+        }
+        if (!cpu_has_work(cpu)) {
+            return false;
+        }
+        tcg_ops->leaving_halt(cpu);
+    } else {
+        assert(!tcg_ops->poll_during_halt);
+        assert(cpu->cc->sysemu_ops->has_work == tcg_ops->cpu_exec_halt);
+        if (!tcg_ops->cpu_exec_halt(cpu)) {
+            return false;
+        }
     }
 
     cpu->halted = 0; /* allow execution */
@@ -1061,7 +1074,7 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
         /* Check mandatory TCGCPUOps handlers */
         const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
 #ifndef CONFIG_USER_ONLY
-        assert(tcg_ops->cpu_exec_halt);
+        assert(tcg_ops->cpu_exec_halt || tcg_ops->leaving_halt);
         assert(tcg_ops->cpu_exec_interrupt);
         assert(tcg_ops->cpu_exec_reset);
         assert(tcg_ops->pointer_wrap);
Signature · 1 line
2.55.0
#5 lore raw

[PULL 07/83] target/i386: Use generic halt transition handlers

In reply to Philippe Mathieu-Daudé

Register x86_cpu_poll_during_halt() and x86_cpu_leaving_halt() with the generic TCG halt flow. Remove the target-specific x86_cpu_exec_halt() wrapper.

Message-ID: <[email protected]>

---
 target/i386/tcg/helper-tcg.h        |  1 -
 target/i386/tcg/system/seg_helper.c | 11 -----------
 target/i386/tcg/tcg-cpu.c           |  3 ++-
 3 files changed, 2 insertions(+), 13 deletions(-)
target/i386/tcg/helper-tcg.h +0 -1
index 96accb30a80..4d543556a9f 100644
@@ -38,7 +38,6 @@
 void x86_cpu_do_interrupt(CPUState *cpu);
 #ifndef CONFIG_USER_ONLY
 void x86_cpu_poll_during_halt(CPUState *cpu);
-bool x86_cpu_exec_halt(CPUState *cpu);
 void x86_cpu_leaving_halt(CPUState *cpu);
 bool x86_need_replay_interrupt(int interrupt_request);
 bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req);
target/i386/tcg/system/seg_helper.c +0 -11
index 566b3d4d80c..e24d01000ad 100644
@@ -157,17 +157,6 @@ void x86_cpu_leaving_halt(CPUState *cpu)
     }
 }
 
-bool x86_cpu_exec_halt(CPUState *cpu)
-{
-    if (!cpu_has_work(cpu)) {
-        return false;
-    }
-
-    x86_cpu_leaving_halt(cpu);
-
-    return true;
-}
-
 bool x86_need_replay_interrupt(int interrupt_request)
 {
     /*
target/i386/tcg/tcg-cpu.c +2 -1
index 9db9795a3b2..167ff7695ae 100644
@@ -182,7 +182,8 @@ const TCGCPUOps x86_tcg_ops = {
     .tlb_fill = x86_cpu_tlb_fill,
     .pointer_wrap = x86_pointer_wrap,
     .do_interrupt = x86_cpu_do_interrupt,
-    .cpu_exec_halt = x86_cpu_exec_halt,
+    .poll_during_halt = x86_cpu_poll_during_halt,
+    .leaving_halt = x86_cpu_leaving_halt,
     .cpu_exec_interrupt = x86_cpu_exec_interrupt,
     .cpu_exec_reset = x86_cpu_exec_reset,
     .do_unaligned_access = x86_cpu_do_unaligned_access,
Signature · 1 line
2.55.0
#6 lore raw

[PULL 08/83] accel/tcg: Remove the redundant cpu_exec_halt() hook

In reply to Philippe Mathieu-Daudé

All remaining users of cpu_exec_halt simply alias cpu_has_work(). Call cpu_has_work() directly from the generic halt flow and remove the redundant hook registrations and interface definition.

Make affected cpu_has_work() helpers private where possible.

Message-ID: <[email protected]>

---
 include/accel/tcg/cpu-ops.h    | 18 ------------------
 target/loongarch/internals.h   |  1 -
 target/riscv/internals.h       |  5 -----
 target/s390x/s390x-internal.h  |  1 -
 accel/tcg/cpu-exec.c           | 23 ++++++++---------------
 target/alpha/cpu.c             |  1 -
 target/avr/cpu.c               |  1 -
 target/hexagon/cpu.c           |  1 -
 target/hppa/cpu.c              |  1 -
 target/loongarch/cpu.c         |  2 +-
 target/loongarch/tcg/tcg_cpu.c |  1 -
 target/m68k/cpu.c              |  1 -
 target/microblaze/cpu.c        |  1 -
 target/mips/cpu.c              |  1 -
 target/or1k/cpu.c              |  1 -
 target/ppc/cpu_init.c          |  1 -
 target/riscv/cpu.c             |  2 +-
 target/riscv/tcg/tcg-cpu.c     |  1 -
 target/rx/cpu.c                |  1 -
 target/s390x/cpu-system.c      |  2 +-
 target/s390x/cpu.c             |  1 -
 target/sh4/cpu.c               |  1 -
 target/sparc/cpu.c             |  1 -
 target/tricore/cpu.c           |  1 -
 target/xtensa/cpu.c            |  1 -
 25 files changed, 11 insertions(+), 60 deletions(-)
include/accel/tcg/cpu-ops.h +0 -18
index 1ee5d3d8bdb..4195a29e1e4 100644
@@ -187,7 +187,6 @@ struct TCGCPUOps {
      * resume execution from the halted state. This callback performs any
      * necessary target-specific state transitions or synchronization before
      * instruction execution resumes. The caller does not hold the BQL.
-     * Either this callback or @cpu_exec_halt must be provided (but not both).
      */
     void (*leaving_halt)(CPUState *cpu);
     /** @do_interrupt: Callback for interrupt handling.  */
@@ -196,23 +195,6 @@ struct TCGCPUOps {
     bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);
     /** @cpu_exec_reset: Callback for reset in cpu_exec.  */
     void (*cpu_exec_reset)(CPUState *cpu);
-    /**
-     * @cpu_exec_halt: Callback for handling halt in cpu_exec.
-     *
-     * The target CPU should do any special processing here that it needs
-     * to do when the CPU is in the halted state.
-     *
-     * Return true to indicate that the CPU should now leave halt, false
-     * if it should remain in the halted state. (This should generally
-     * be the same value that cpu_has_work() would return.)
-     *
-     * Either @leaving_halt or this method must be provided, but not both.
-     * If the target does not need to
-     * do anything special for halt, the same function used for its
-     * SysemuCPUOps::has_work method can be used here, as they have the
-     * same function signature.
-     */
-    bool (*cpu_exec_halt)(CPUState *cpu);
     /**
      * @tlb_fill_align: Handle a softmmu tlb miss
      * @cpu: cpu context
target/loongarch/internals.h +0 -1
index 952c98f74ae..9d064d1948b 100644
@@ -38,7 +38,6 @@ void cpu_loongarch_timer_cb(void *opaque);
 uint64_t cpu_loongarch_get_timer_counter(CPUTimerState *timer);
 uint64_t cpu_loongarch_get_timer_ticks(CPUTimerState *timer);
 void cpu_loongarch_set_timer_config(CPUTimerState *timer, uint64_t value);
-bool loongarch_cpu_has_work(CPUState *cs);
 bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env);
 #endif /* !CONFIG_USER_ONLY */
 
target/riscv/internals.h +0 -5
index 9f1dec6748f..5466879a4aa 100644
@@ -201,11 +201,6 @@ static inline target_ulong get_xepc_mask(CPURISCVState *env)
     }
 }
 
-#ifndef CONFIG_USER_ONLY
-/* Our implementation of SysemuCPUOps::has_work */
-bool riscv_cpu_has_work(CPUState *cs);
-#endif
-
 extern const struct SemihostingCPUOps riscv_semihosting_ops;
 void riscv_get_dump_info(const CPUState *cs, ArchDumpInfo *info,
                          const GuestPhysBlockList *guest_phys_blocks);
target/s390x/s390x-internal.h +0 -1
index 9dd2243d486..1dfd4317d28 100644
@@ -248,7 +248,6 @@ bool s390_cpu_system_realize(DeviceState *dev, Error **errp);
 void s390_cpu_finalize(Object *obj);
 void s390_cpu_system_class_init(CPUClass *cc);
 void s390_cpu_machine_reset_cb(void *opaque);
-bool s390_cpu_has_work(CPUState *cs);
 
 void s390_get_dump_info(const CPUState *cs, ArchDumpInfo *info,
                         const GuestPhysBlockList *guest_phys_blocks);
accel/tcg/cpu-exec.c +8 -15
index 122ad9e2e49..9ead35418d3 100644
@@ -48,7 +48,6 @@
 #include "internal-common.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "accel/tcg/iommu.h"
-#include "hw/core/sysemu-cpu-ops.h"
 #endif
 
 /* -icount align implementation. */
@@ -661,21 +660,16 @@ static bool cpu_poll_while_halted(CPUState *cpu)
 {
     const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
 
+    if (tcg_ops->poll_during_halt) {
+        tcg_ops->poll_during_halt(cpu);
+    }
+
+    if (!cpu_has_work(cpu)) {
+        return false;
+    }
+
     if (tcg_ops->leaving_halt) {
-        assert(!tcg_ops->cpu_exec_halt);
-        if (tcg_ops->poll_during_halt) {
-            tcg_ops->poll_during_halt(cpu);
-        }
-        if (!cpu_has_work(cpu)) {
-            return false;
-        }
         tcg_ops->leaving_halt(cpu);
-    } else {
-        assert(!tcg_ops->poll_during_halt);
-        assert(cpu->cc->sysemu_ops->has_work == tcg_ops->cpu_exec_halt);
-        if (!tcg_ops->cpu_exec_halt(cpu)) {
-            return false;
-        }
     }
 
     cpu->halted = 0; /* allow execution */
@@ -1074,7 +1068,6 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
         /* Check mandatory TCGCPUOps handlers */
         const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
 #ifndef CONFIG_USER_ONLY
-        assert(tcg_ops->cpu_exec_halt || tcg_ops->leaving_halt);
         assert(tcg_ops->cpu_exec_interrupt);
         assert(tcg_ops->cpu_exec_reset);
         assert(tcg_ops->pointer_wrap);
target/alpha/cpu.c +0 -1
index 12e86021663..7d1d036e1d3 100644
@@ -265,7 +265,6 @@ static const TCGCPUOps alpha_tcg_ops = {
     .tlb_fill = alpha_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = alpha_cpu_exec_interrupt,
-    .cpu_exec_halt = alpha_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = alpha_cpu_do_interrupt,
     .do_transaction_failed = alpha_cpu_do_transaction_failed,
target/avr/cpu.c +0 -1
index f8409f32ab9..a01e6fa4751 100644
@@ -246,7 +246,6 @@ static const TCGCPUOps avr_tcg_ops = {
     .restore_state_to_opc = avr_restore_state_to_opc,
     .mmu_index = avr_cpu_mmu_index,
     .cpu_exec_interrupt = avr_cpu_exec_interrupt,
-    .cpu_exec_halt = avr_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .tlb_fill = avr_cpu_tlb_fill,
     .do_interrupt = avr_cpu_do_interrupt,
target/hexagon/cpu.c +0 -1
index f20d6de6f63..304031e97f0 100644
@@ -821,7 +821,6 @@ static const TCGCPUOps hexagon_tcg_ops = {
     .cpu_exec_reset = cpu_reset,
     .tlb_fill = hexagon_tlb_fill,
     .do_unaligned_access = hexagon_cpu_do_unaligned_access,
-    .cpu_exec_halt = hexagon_cpu_has_work,
     .do_interrupt = hexagon_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
 };
target/hppa/cpu.c +0 -1
index 07b49e51326..7b1309a7c38 100644
@@ -270,7 +270,6 @@ static const TCGCPUOps hppa_tcg_ops = {
     .tlb_fill_align = hppa_cpu_tlb_fill_align,
     .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = hppa_cpu_exec_interrupt,
-    .cpu_exec_halt = hppa_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = hppa_cpu_do_interrupt,
     .do_unaligned_access = hppa_cpu_do_unaligned_access,
target/loongarch/cpu.c +1 -1
index 5e182922b7d..a95fdfc2b62 100644
@@ -117,7 +117,7 @@ bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env)
 #endif
 
 #ifndef CONFIG_USER_ONLY
-bool loongarch_cpu_has_work(CPUState *cs)
+static bool loongarch_cpu_has_work(CPUState *cs)
 {
     bool has_work = false;
 
target/loongarch/tcg/tcg_cpu.c +0 -1
index 4b1d44a1644..7ea2a1eb933 100644
@@ -327,7 +327,6 @@ const TCGCPUOps loongarch_tcg_ops = {
     .tlb_fill = loongarch_cpu_tlb_fill,
     .pointer_wrap = loongarch_pointer_wrap,
     .cpu_exec_interrupt = loongarch_cpu_exec_interrupt,
-    .cpu_exec_halt = loongarch_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = loongarch_cpu_do_interrupt,
     .do_transaction_failed = loongarch_cpu_do_transaction_failed,
target/m68k/cpu.c +0 -1
index 9b52ad5fc23..c7771cbf643 100644
@@ -710,7 +710,6 @@ static const TCGCPUOps m68k_tcg_ops = {
     .tlb_fill = m68k_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = m68k_cpu_exec_interrupt,
-    .cpu_exec_halt = m68k_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = m68k_cpu_do_interrupt,
     .do_transaction_failed = m68k_cpu_transaction_failed,
target/microblaze/cpu.c +0 -1
index 389a5124b12..6013a8def8e 100644
@@ -448,7 +448,6 @@ static const TCGCPUOps mb_tcg_ops = {
     .tlb_fill = mb_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = mb_cpu_exec_interrupt,
-    .cpu_exec_halt = mb_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = mb_cpu_do_interrupt,
     .do_transaction_failed = mb_cpu_transaction_failed,
target/mips/cpu.c +0 -1
index 0fead20d651..c069aa1c0b7 100644
@@ -716,7 +716,6 @@ static const TCGCPUOps mips_tcg_ops = {
     .tlb_fill = mips_cpu_tlb_fill,
     .pointer_wrap = mips_pointer_wrap,
     .cpu_exec_interrupt = mips_cpu_exec_interrupt,
-    .cpu_exec_halt = mips_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = mips_cpu_do_interrupt,
     .do_transaction_failed = mips_cpu_do_transaction_failed,
target/or1k/cpu.c +0 -1
index 66c00c0930c..42d9351b6d7 100644
@@ -266,7 +266,6 @@ static const TCGCPUOps openrisc_tcg_ops = {
     .tlb_fill = openrisc_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = openrisc_cpu_exec_interrupt,
-    .cpu_exec_halt = openrisc_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = openrisc_cpu_do_interrupt,
 #endif /* !CONFIG_USER_ONLY */
target/ppc/cpu_init.c +0 -1
index 578dd9194eb..0431c0e0ae5 100644
@@ -7498,7 +7498,6 @@ static const TCGCPUOps ppc_tcg_ops = {
   .tlb_fill = ppc_cpu_tlb_fill,
   .pointer_wrap = ppc_pointer_wrap,
   .cpu_exec_interrupt = ppc_cpu_exec_interrupt,
-  .cpu_exec_halt = ppc_cpu_has_work,
   .cpu_exec_reset = cpu_reset,
   .do_interrupt = ppc_cpu_do_interrupt,
   .cpu_exec_enter = ppc_cpu_exec_enter,
target/riscv/cpu.c +1 -1
index b202a4eb6ea..f9946f54ced 100644
@@ -963,7 +963,7 @@ uint64_t riscv_cpu_get_mip(const CPURISCVState *env)
     return qatomic_read(&env->mip);
 }
 
-bool riscv_cpu_has_work(CPUState *cs)
+static bool riscv_cpu_has_work(CPUState *cs)
 {
     RISCVCPU *cpu = RISCV_CPU(cs);
     CPURISCVState *env = &cpu->env;
target/riscv/tcg/tcg-cpu.c +0 -1
index e07ca95e49b..80c04636175 100644
@@ -306,7 +306,6 @@ const TCGCPUOps riscv_tcg_ops = {
     .pointer_wrap = riscv_pointer_wrap,
     .cpu_exec_enter = riscv_cpu_exec_enter,
     .cpu_exec_interrupt = riscv_cpu_exec_interrupt,
-    .cpu_exec_halt = riscv_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = riscv_cpu_do_interrupt,
     .do_transaction_failed = riscv_cpu_do_transaction_failed,
target/rx/cpu.c +0 -1
index 9b8473d71cf..69946928995 100644
@@ -227,7 +227,6 @@ static const TCGCPUOps rx_tcg_ops = {
     .pointer_wrap = cpu_pointer_wrap_uint32,
 
     .cpu_exec_interrupt = rx_cpu_exec_interrupt,
-    .cpu_exec_halt = rx_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = rx_cpu_do_interrupt,
 };
target/s390x/cpu-system.c +1 -1
index 784bf4e90b9..715ff3ca945 100644
@@ -39,7 +39,7 @@
 #include "system/tcg.h"
 #include "hw/core/sysemu-cpu-ops.h"
 
-bool s390_cpu_has_work(CPUState *cs)
+static bool s390_cpu_has_work(CPUState *cs)
 {
     S390CPU *cpu = S390_CPU(cs);
 
target/s390x/cpu.c +0 -1
index 85afc5dec9a..e7f81fabff6 100644
@@ -384,7 +384,6 @@ static const TCGCPUOps s390_tcg_ops = {
     .tlb_fill = s390_cpu_tlb_fill,
     .pointer_wrap = s390_pointer_wrap,
     .cpu_exec_interrupt = s390_cpu_exec_interrupt,
-    .cpu_exec_halt = s390_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = s390_cpu_do_interrupt,
     .debug_excp_handler = s390x_cpu_debug_excp_handler,
target/sh4/cpu.c +0 -1
index 3bbdee301d5..55c73a1da35 100644
@@ -312,7 +312,6 @@ static const TCGCPUOps superh_tcg_ops = {
     .tlb_fill = superh_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_notreached,
     .cpu_exec_interrupt = superh_cpu_exec_interrupt,
-    .cpu_exec_halt = superh_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = superh_cpu_do_interrupt,
     .do_unaligned_access = superh_cpu_do_unaligned_access,
target/sparc/cpu.c +0 -1
index ae9bdca9df8..1529f9570da 100644
@@ -1074,7 +1074,6 @@ static const TCGCPUOps sparc_tcg_ops = {
     .tlb_fill = sparc_cpu_tlb_fill,
     .pointer_wrap = sparc_pointer_wrap,
     .cpu_exec_interrupt = sparc_cpu_exec_interrupt,
-    .cpu_exec_halt = sparc_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = sparc_cpu_do_interrupt,
     .do_transaction_failed = sparc_cpu_do_transaction_failed,
target/tricore/cpu.c +0 -1
index 84a05e3d363..82b56c3cd56 100644
@@ -223,7 +223,6 @@ static const TCGCPUOps tricore_tcg_ops = {
     .tlb_fill = tricore_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = tricore_cpu_exec_interrupt,
-    .cpu_exec_halt = tricore_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
 };
 
target/xtensa/cpu.c +0 -1
index 7c25b9ab707..99c8bd4b5fb 100644
@@ -325,7 +325,6 @@ static const TCGCPUOps xtensa_tcg_ops = {
     .tlb_fill = xtensa_cpu_tlb_fill,
     .pointer_wrap = cpu_pointer_wrap_uint32,
     .cpu_exec_interrupt = xtensa_cpu_exec_interrupt,
-    .cpu_exec_halt = xtensa_cpu_has_work,
     .cpu_exec_reset = cpu_reset,
     .do_interrupt = xtensa_cpu_do_interrupt,
     .do_transaction_failed = xtensa_cpu_do_transaction_failed,
Signature · 1 line
2.55.0
#7 lore raw

[PULL 06/83] target/i386: Split leaving-halt handling from x86_cpu_exec_halt()

In reply to Philippe Mathieu-Daudé

Move debug exception handling performed when leaving HLT into x86_cpu_leaving_halt(). Keep x86_cpu_exec_halt() responsible for checking whether the CPU can resume.

Document that #DB IRQ delivery through do_interrupt_all() runs in the vCPU thread and does not require BQL protection.

Message-ID: <[email protected]>

---
 target/i386/tcg/helper-tcg.h        |  1 +
 target/i386/tcg/system/seg_helper.c | 25 +++++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)
target/i386/tcg/helper-tcg.h +1 -0
index 58e8ca0bc1b..96accb30a80 100644
@@ -39,6 +39,7 @@ void x86_cpu_do_interrupt(CPUState *cpu);
 #ifndef CONFIG_USER_ONLY
 void x86_cpu_poll_during_halt(CPUState *cpu);
 bool x86_cpu_exec_halt(CPUState *cpu);
+void x86_cpu_leaving_halt(CPUState *cpu);
 bool x86_need_replay_interrupt(int interrupt_request);
 bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req);
 #endif
target/i386/tcg/system/seg_helper.c +17 -8
index 9ce608a0bb7..566b3d4d80c 100644
@@ -140,22 +140,31 @@ void x86_cpu_poll_during_halt(CPUState *cpu)
     }
 }
 
-bool x86_cpu_exec_halt(CPUState *cpu)
+void x86_cpu_leaving_halt(CPUState *cpu)
 {
     X86CPU *x86_cpu = X86_CPU(cpu);
-    CPUX86State *env = &x86_cpu->env;
-
-    x86_cpu_poll_during_halt(cpu);
-
-    if (!cpu_has_work(cpu)) {
-        return false;
-    }
+    CPUX86State *env = cpu_env(cpu);
 
     /* Complete HLT instruction.  */
     if (env->eflags & TF_MASK) {
         env->dr[6] |= DR6_BS;
+        /*
+         * do_interrupt_all() is the normal TCG exception-delivery path
+         * and runs in the same vCPU thread context, so #DB delivery does
+         * not require BQL protection here.
+         */
         do_interrupt_all(x86_cpu, EXCP01_DB, 0, 0, env->eip, 0);
     }
+}
+
+bool x86_cpu_exec_halt(CPUState *cpu)
+{
+    if (!cpu_has_work(cpu)) {
+        return false;
+    }
+
+    x86_cpu_leaving_halt(cpu);
+
     return true;
 }
 
Signature · 1 line
2.55.0
#8 lore raw

[PULL 11/83] target/mips/gdbstub: Replace target_long_bits() by mips_env_is_64bit()

In reply to Philippe Mathieu-Daudé

Add a mips_env_is_64bit() helper and inline gdb_get_regl() as mips_gdb_get_regl(), so that the GDB register size follows the emulated CPU model rather than the target build's TARGET_LONG_BITS.

Message-ID: <[email protected]>

---
 target/mips/internal.h |  5 +++++
 target/mips/gdbstub.c  | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
target/mips/internal.h +5 -0
index 7dba22300b1..0c9b1335ebb 100644
@@ -228,6 +228,11 @@ static inline void mips_env_set_pc(CPUMIPSState *env, target_ulong value)
     }
 }
 
+static inline bool mips_env_is_64bit(const CPUMIPSState *env)
+{
+    return env->cpu_model->insn_flags & CPU_MIPS64;
+}
+
 static inline bool mips_env_is_bigendian(CPUMIPSState *env)
 {
     return extract32(env->CP0_Config0, CP0C0_BE, 1);
target/mips/gdbstub.c +9 -2
index 7598aab6158..78d3e9a5b9b 100644
@@ -24,13 +24,20 @@
 #include "gdbstub/helpers.h"
 #include "fpu_helper.h"
 
+static int mips_gdb_get_regl(const CPUMIPSState *env,
+                             GByteArray *buf, uint64_t val)
+{
+    return mips_env_is_64bit(env) ? gdb_get_reg64(buf, val)
+                                  : gdb_get_reg32(buf, val);
+}
+
 int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 {
     CPUMIPSState *env = cpu_env(cs);
     uint64_t val;
 
     if (n < 32) {
-        return gdb_get_regl(mem_buf, env->active_tc.gpr[n]);
+        return mips_gdb_get_regl(env, mem_buf, env->active_tc.gpr[n]);
     }
     if (env->CP0_Config1 & (1 << CP0C1_FP) && n >= 38 && n < 72) {
         switch (n) {
@@ -83,7 +90,7 @@ int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
             break;
         }
     }
-    return gdb_get_regl(mem_buf, val);
+    return mips_gdb_get_regl(env, mem_buf, val);
 }
 
 int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
Signature · 1 line
2.55.0
#9 lore raw

[PULL 09/83] target/sparc/gdbstub: Replace gdb_get_regl() by gdb_get_reg64()

In reply to Philippe Mathieu-Daudé

The gdb_get_regl() calls in sparc_cp0_gdb_read_register() are guarded within:

  #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
  /* 32-bit */
  #else
  /* 64-bit */
  #endif

Since the #else branch is only compiled for 64-bit targets where gdb_get_regl() forwards to gdb_get_reg64(), we can call the latter directly, dropping the use of the deprecated helper. Assert the invariant at build time to be safe.

Message-ID: <[email protected]>

---
 target/sparc/gdbstub.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
target/sparc/gdbstub.c +7 -6
index 2874ce1b350..d3ccf533839 100644
@@ -106,22 +106,23 @@ static int sparc_cp0_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
         return gdb_get_rega(mem_buf, 0); /* csr */
     }
 #else
+    QEMU_BUILD_BUG_ON(TARGET_LONG_BITS != 64);
     switch (n) {
     case 0:
-        return gdb_get_regl(mem_buf, env->pc);
+        return gdb_get_reg64(mem_buf, env->pc);
     case 1:
-        return gdb_get_regl(mem_buf, env->npc);
+        return gdb_get_reg64(mem_buf, env->npc);
     case 2:
-        return gdb_get_regl(mem_buf, (cpu_get_ccr(env) << 32) |
+        return gdb_get_reg64(mem_buf, (cpu_get_ccr(env) << 32) |
                                      ((env->asi & 0xff) << 24) |
                                      ((env->pstate & 0xfff) << 8) |
                                      cpu_get_cwp64(env));
     case 3:
-        return gdb_get_regl(mem_buf, cpu_get_fsr(env));
+        return gdb_get_reg64(mem_buf, cpu_get_fsr(env));
     case 4:
-        return gdb_get_regl(mem_buf, env->fprs);
+        return gdb_get_reg64(mem_buf, env->fprs);
     case 5:
-        return gdb_get_regl(mem_buf, env->y);
+        return gdb_get_reg64(mem_buf, env->y);
     }
 #endif
     return 0;
Signature · 1 line
2.55.0
#10 lore raw

[PULL 01/83] accel/tcg: Refactor poll-while-halted flow in cpu_exec()

In reply to Philippe Mathieu-Daudé

Invert cpu_handle_halt()'s logic to read in cpu_exec() as "if halted, poll for async events and find work; if no work, return". Rename as cpu_poll_while_halted().

Message-ID: <[email protected]>

---
 accel/tcg/cpu-exec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
accel/tcg/cpu-exec.c +4 -4
index 5b4bca5084f..853c4b2f67a 100644
@@ -656,18 +656,18 @@ static inline void tb_add_jump(TranslationBlock *tb, int n,
 }
 
 #ifndef CONFIG_USER_ONLY
-static inline bool cpu_handle_halt(CPUState *cpu)
+static bool cpu_poll_while_halted(CPUState *cpu)
 {
     const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
     bool leave_halt = tcg_ops->cpu_exec_halt(cpu);
 
     if (!leave_halt) {
-        return true;
+        return false;
     }
 
     cpu->halted = 0; /* allow execution */
 
-    return false;
+    return true;
 }
 #endif /* !CONFIG_USER_ONLY */
 
@@ -1029,7 +1029,7 @@ int cpu_exec(CPUState *cpu)
 
 #ifndef CONFIG_USER_ONLY
     if (cpu->halted) {
-        if (cpu_handle_halt(cpu)) {
+        if (!cpu_poll_while_halted(cpu)) {
             return EXCP_HALTED;
         }
         assert(!cpu->halted);
Signature · 1 line
2.55.0
#11 lore raw

[PULL 10/83] target/mips/gdbstub: Reduce to a single gdb_get_regl() call

In reply to Philippe Mathieu-Daudé

Store the register value in a local @val in each switch case, then append it once at the end of mips_cpu_gdb_read_register().

No functional change.

Message-ID: <[email protected]>

---
 target/mips/gdbstub.c | 76 ++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 33 deletions(-)
target/mips/gdbstub.c +43 -33
index 8e0b08a096c..7598aab6158 100644
@@ -27,6 +27,7 @@
 int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 {
     CPUMIPSState *env = cpu_env(cs);
+    uint64_t val;
 
     if (n < 32) {
         return gdb_get_regl(mem_buf, env->active_tc.gpr[n]);
@@ -34,46 +35,55 @@ int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
     if (env->CP0_Config1 & (1 << CP0C1_FP) && n >= 38 && n < 72) {
         switch (n) {
         case 70:
-            return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr31);
+            val = (int32_t)env->active_fpu.fcr31;
+            break;
         case 71:
-            return gdb_get_regl(mem_buf, (int32_t)env->active_fpu.fcr0);
+            val = (int32_t)env->active_fpu.fcr0;
+            break;
         default:
             if (env->CP0_Status & (1 << CP0St_FR)) {
-                return gdb_get_regl(mem_buf,
-                    env->active_fpu.fpr[n - 38].d);
+                val = env->active_fpu.fpr[n - 38].d;
             } else {
-                return gdb_get_regl(mem_buf,
-                    env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX]);
+                val = env->active_fpu.fpr[n - 38].w[FP_ENDIAN_IDX];
             }
+            break;
+        }
+    } else {
+        switch (n) {
+        case 32:
+            val = (int32_t)env->CP0_Status;
+            break;
+        case 33:
+            val = env->active_tc.LO[0];
+            break;
+        case 34:
+            val = env->active_tc.HI[0];
+            break;
+        case 35:
+            val = env->CP0_BadVAddr;
+            break;
+        case 36:
+            val = (int32_t)env->CP0_Cause;
+            break;
+        case 37:
+            val = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16);
+            break;
+        case 72:
+            val = 0; /* fp */
+            break;
+        case 89:
+            val = (int32_t)env->CP0_PRid;
+            break;
+        default:
+            if (n > 89) {
+                return 0;
+            }
+            /* 16 embedded regs.  */
+            val = 0;
+            break;
         }
     }
-    switch (n) {
-    case 32:
-        return gdb_get_regl(mem_buf, (int32_t)env->CP0_Status);
-    case 33:
-        return gdb_get_regl(mem_buf, env->active_tc.LO[0]);
-    case 34:
-        return gdb_get_regl(mem_buf, env->active_tc.HI[0]);
-    case 35:
-        return gdb_get_regl(mem_buf, env->CP0_BadVAddr);
-    case 36:
-        return gdb_get_regl(mem_buf, (int32_t)env->CP0_Cause);
-    case 37:
-        return gdb_get_regl(mem_buf, env->active_tc.PC |
-                                     !!(env->hflags & MIPS_HFLAG_M16));
-    case 72:
-        return gdb_get_regl(mem_buf, 0); /* fp */
-    case 89:
-        return gdb_get_regl(mem_buf, (int32_t)env->CP0_PRid);
-    default:
-        if (n > 89) {
-            return 0;
-        }
-        /* 16 embedded regs.  */
-        return gdb_get_regl(mem_buf, 0);
-    }
-
-    return 0;
+    return gdb_get_regl(mem_buf, val);
 }
 
 int mips_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
Signature · 1 line
2.55.0
#12 lore raw

[PULL 13/83] target/ppc/gdbstub: Replace target_long_bits() by ppc_env_is_64bit()

In reply to Philippe Mathieu-Daudé

Add a gdb_get_reg_bits() helper deriving the register width from ppc_env_is_64bit(), and use it instead of target_long_bits() and TARGET_LONG_SIZE.

Message-ID: <[email protected]>

---
 target/ppc/gdbstub.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
target/ppc/gdbstub.c +12 -7
index 4d622c5cad5..ee02be63ce8 100644
@@ -23,12 +23,17 @@
 #include "gdbstub/helpers.h"
 #include "internal.h"
 
-static unsigned ppc_gdb_register_len(int n)
+static int gdb_get_reg_bits(const CPUPPCState *env)
+{
+    return ppc_env_is_64bit(env) ? 64 : 32;
+}
+
+static unsigned ppc_gdb_register_len(const CPUPPCState *env, int n)
 {
     switch (n) {
     case 0 ... 31:
         /* gprs */
-        return target_long_bits() / 8;
+        return gdb_get_reg_bits(env) / 8;
     case 66:
         /* cr */
     case 69:
@@ -42,7 +47,7 @@ static unsigned ppc_gdb_register_len(int n)
         /* lr */
     case 68:
         /* ctr */
-        return target_long_bits() / 8;
+        return gdb_get_reg_bits(env) / 8;
     default:
         return 0;
     }
@@ -85,7 +90,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
 {
     CPUPPCState *env = cpu_env(cs);
     uint8_t *mem_buf;
-    unsigned r = ppc_gdb_register_len(n);
+    unsigned r = ppc_gdb_register_len(env, n);
 
     if (!r) {
         return r;
@@ -127,7 +132,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
 int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUPPCState *env = cpu_env(cs);
-    unsigned r = ppc_gdb_register_len(n);
+    unsigned r = ppc_gdb_register_len(env, n);
 
     if (!r) {
         return r;
@@ -251,7 +256,7 @@ static int gdb_get_spr_reg(CPUState *cs, GByteArray *buf, int n)
         return 0;
     }
 
-    len = TARGET_LONG_SIZE;
+    len = gdb_get_reg_bits(env) / 8;
 
     /* Handle those SPRs that are not part of the env->spr[] array */
     target_ulong val;
@@ -294,7 +299,7 @@ static int gdb_set_spr_reg(CPUState *cs, uint8_t *mem_buf, int n)
         return 0;
     }
 
-    len = TARGET_LONG_SIZE;
+    len = gdb_get_reg_bits(env) / 8;
     ppc_maybe_bswap_register(env, mem_buf, len);
 
     /* Handle those SPRs that are not part of the env->spr[] array */
Signature · 1 line
2.55.0
#13 lore raw

[PULL 12/83] target/ppc: Factor ppc_env_is_64bit() out

In reply to Philippe Mathieu-Daudé

Replace the open-coded PPC_64B test in register_BookE206_sprs() by a ppc_env_is_64bit() helper for re-use in the next commit.

Message-ID: <[email protected]>

---
 target/ppc/internal.h | 11 +++++++++++
 target/ppc/cpu_init.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
target/ppc/internal.h +11 -0
index b3ed57eaf73..11fa4ee5417 100644
@@ -23,6 +23,17 @@
 #include "hw/core/registerfields.h"
 #include "exec/page-protection.h"
 
+/**
+ * ppc_env_is_64bit:
+ * @env: the cpu context
+ *
+ * Return whether the CPU is a 64-bit implementation.
+ */
+static inline bool ppc_env_is_64bit(const CPUPPCState *env)
+{
+    return env->insns_flags & PPC_64B;
+}
+
 static inline bool ppc_env_is_little_endian(const CPUPPCState *env)
 {
     return FIELD_EX64(env->msr, MSR, LE);
target/ppc/cpu_init.c +1 -1
index 0431c0e0ae5..89a8b14a393 100644
@@ -869,7 +869,7 @@ static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask,
             spr_register(env, mas_sprn[i], mas_names[i],
                          SPR_NOACCESS, SPR_NOACCESS,
                          &spr_read_generic,
-                         (i == 2 && (env->insns_flags & PPC_64B))
+                         (i == 2 && ppc_env_is_64bit(env))
                          ? &spr_write_generic : &spr_write_generic32,
                          0x00000000);
         }
Signature · 1 line
2.55.0
#14 lore raw

[PULL 15/83] target/riscv: Factor riscv_gdb_get_reg_mxl() out

In reply to Philippe Mathieu-Daudé

Move the MXL-based selection of the register width out of riscv_cpu_gdb_read_register() into a helper, so it can be reused by the following patch.

Message-ID: <[email protected]>

---
 target/riscv/gdbstub.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
target/riscv/gdbstub.c +18 -11
index 9abbf5bcdf0..b3c11db5397 100644
@@ -54,9 +54,25 @@ static uint64_t ldn(CPURISCVState *env, uint8_t *mem_buf, size_t regsz)
     return (mo_endian_env(env) == MO_LE ? ldn_le_p : ldn_be_p)(mem_buf, regsz);
 }
 
-int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
+static int riscv_gdb_get_reg_mxl(CPUState *cs,
+                                 GByteArray *buf, uint64_t val)
 {
     RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cs);
+
+    switch (mcc->def->misa_mxl_max) {
+    case MXL_RV32:
+        return gdb_get_reg32(buf, val);
+    case MXL_RV64:
+    case MXL_RV128:
+        return gdb_get_reg64(buf, val);
+    default:
+        g_assert_not_reached();
+    }
+    return 0;
+}
+
+int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
+{
     RISCVCPU *cpu = RISCV_CPU(cs);
     CPURISCVState *env = &cpu->env;
     uint64_t tmp;
@@ -69,16 +85,7 @@ int riscv_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
         return 0;
     }
 
-    switch (mcc->def->misa_mxl_max) {
-    case MXL_RV32:
-        return gdb_get_reg32(mem_buf, tmp);
-    case MXL_RV64:
-    case MXL_RV128:
-        return gdb_get_reg64(mem_buf, tmp);
-    default:
-        g_assert_not_reached();
-    }
-    return 0;
+    return riscv_gdb_get_reg_mxl(cs, mem_buf, tmp);
 }
 
 int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
Signature · 1 line
2.55.0
#15 lore raw

[PULL 14/83] target/ppc/gdbstub: Replace gdb_get_regl() by ppc_env_is_64bit()

In reply to Philippe Mathieu-Daudé

Inline the deprecated gdb_get_regl() as ppc_gdb_get_regl(), replacing the target_long_bits() check by a ppc_env_is_64bit() one.

Message-ID: <[email protected]>

---
 target/ppc/gdbstub.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
target/ppc/gdbstub.c +13 -6
index ee02be63ce8..0071c2b3bab 100644
@@ -53,6 +53,13 @@ static unsigned ppc_gdb_register_len(const CPUPPCState *env, int n)
     }
 }
 
+static inline int ppc_gdb_get_regl(const CPUPPCState *env,
+                                   GByteArray *buf, uint64_t val)
+{
+    return ppc_env_is_64bit(env) ? gdb_get_reg64(buf, val)
+                                 : gdb_get_reg32(buf, val);
+}
+
 /*
  * We need to present the registers to gdb in the "current" memory
  * ordering.  For user-only mode we get this for free;
@@ -98,14 +105,14 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
 
     if (n < 32) {
         /* gprs */
-        gdb_get_regl(buf, env->gpr[n]);
+        ppc_gdb_get_regl(env, buf, env->gpr[n]);
     } else {
         switch (n) {
         case 64:
-            gdb_get_regl(buf, env->nip);
+            ppc_gdb_get_regl(env, buf, env->nip);
             break;
         case 65:
-            gdb_get_regl(buf, env->msr);
+            ppc_gdb_get_regl(env, buf, env->msr);
             break;
         case 66:
             {
@@ -114,10 +121,10 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
                 break;
             }
         case 67:
-            gdb_get_regl(buf, env->lr);
+            ppc_gdb_get_regl(env, buf, env->lr);
             break;
         case 68:
-            gdb_get_regl(buf, env->ctr);
+            ppc_gdb_get_regl(env, buf, env->ctr);
             break;
         case 69:
             gdb_get_reg32(buf, cpu_read_xer(env));
@@ -281,7 +288,7 @@ static int gdb_get_spr_reg(CPUState *cs, GByteArray *buf, int n)
     default:
         val = env->spr[reg];
     }
-    gdb_get_regl(buf, val);
+    ppc_gdb_get_regl(env, buf, val);
 
     ppc_maybe_bswap_register(env, gdb_get_reg_ptr(buf, len), len);
     return len;
Signature · 1 line
2.55.0
#16 lore raw

[PULL 21/83] util/cutils: Add STR_ARRAY_ELEM_OR_NULL() for string table lookups

In reply to Philippe Mathieu-Daudé

Many functions map an enum or exception number to a name, either with a switch statement or by indexing a string table after an open-coded bounds check. Add STR_ARRAY_ELEM_OR_NULL(array, index), which returns array[index], or NULL when index is out of bounds, so such code can use a static table and a single call.

The array is passed as 'const char *const *', so only arrays of strings are accepted; hence the STR_ prefix rather than a generic name.

Misuse is caught at build time:
- pointer instead of array: "negative width in bit-field" error, plus -Wsizeof-pointer-div (GCC);
- array of non-strings (int[], char[][N], int *[]):
-Wincompatible-pointer-types;
- array of non-const 'char *': -Wincompatible-pointer-types (GCC), -Wincompatible-pointer-types-discards-qualifiers (clang);
- pointer as index: -Wint-conversion.

Message-ID: <[email protected]>

---
 include/qemu/cutils.h | 17 +++++++++++++++++
 include/qemu/osdep.h  |  3 +++
 util/cutils.c         |  6 ++++++
 3 files changed, 26 insertions(+)
include/qemu/cutils.h +17 -0
index d249f226766..ad4c778ea3a 100644
@@ -19,6 +19,23 @@ const char *si_prefix(unsigned int exp10);
  */
 const char *iec_binary_prefix(unsigned int exp2);
 
+const char *str_array_elem_or_null(const char *const *array,
+                                   size_t nelem, uint64_t index);
+
+/**
+ * STR_ARRAY_ELEM_OR_NULL() - Return a string array element, or NULL if
+ *                            out of bounds
+ * @array: array of strings to index
+ * @index: index of the element to return
+ *
+ * Return @array[@index] if @index is a valid index, otherwise return
+ * NULL. @index is converted to uint64_t, so negative values of signed
+ * types are out of bounds and also yield NULL. Useful to look up entries
+ * in enum-indexed string tables without a prior bounds check.
+ */
+#define STR_ARRAY_ELEM_OR_NULL(array, index) \
+    str_array_elem_or_null(array, ARRAY_SIZE(array), index)
+
 /**
  * pstrcpy:
  * @buf: buffer to copy string into
include/qemu/osdep.h +3 -0
index 5d5695ade28..50c7ce33b6a 100644
@@ -532,6 +532,9 @@ void QEMU_ERROR("code path is reachable")
  * ARRAY_SIZE() - Return the number of elements of an array
  * @x: the array
  *
+ * For bounds-checked lookups in arrays of strings, see
+ * STR_ARRAY_ELEM_OR_NULL() in "qemu/cutils.h".
+ *
  * Note: fails to build if @x is a pointer.
  */
 #ifndef ARRAY_SIZE
util/cutils.c +6 -0
index 91ddadfd15a..d8a04ead5a4 100644
@@ -954,6 +954,12 @@ const char *iec_binary_prefix(unsigned int exp2)
     return prefixes[exp2 / 10];
 }
 
+const char *str_array_elem_or_null(const char *const *array,
+                                   size_t nelem, uint64_t index)
+{
+    return index >= nelem ? NULL : array[index];
+}
+
 /*
  * Return human readable string for size @val.
  * @val can be anything that uint64_t allows (no more than "16 EiB").
Signature · 1 line
2.55.0
#17 lore raw

[PULL 22/83] cpus: Add helper to log raised exceptions with '-d int'

In reply to Philippe Mathieu-Daudé

Add log_raise_exception(), a common helper cpu_loop_*() can call to log a raised exception when '-d int' is used, and qemu_excp_name() to resolve QEMU-internal exceptions to names.

Use it in cpu_loop_exit_atomic() to log the EXCP_ATOMIC reason.

Message-ID: <[email protected]>

---
 accel/tcg/cpu-exec-common.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
accel/tcg/cpu-exec-common.c +30 -0
index 68077c8fd9d..bd2cb9d6311 100644
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "exec/log.h"
 #include "system/tcg.h"
 #include "qemu/plugin.h"
@@ -89,6 +90,34 @@ void tcg_update_all_cflags(void)
     }
 }
 
+#define EXCP_QEMU_INTERNAL 0x10000
+
+static const char *qemu_excp_name(int excp)
+{
+    static const char *excp_name[] = {
+        [EXCP_INTERRUPT - EXCP_QEMU_INTERNAL] = "async interruption",
+        [EXCP_HLT       - EXCP_QEMU_INTERNAL] = "hlt instruction",
+        [EXCP_DEBUG     - EXCP_QEMU_INTERNAL] = "debug",
+        [EXCP_HALTED    - EXCP_QEMU_INTERNAL] = "halted",
+        [EXCP_YIELD     - EXCP_QEMU_INTERNAL] = "yield",
+        [EXCP_ATOMIC    - EXCP_QEMU_INTERNAL] = "emulate atomic",
+    };
+    assert(excp >= EXCP_QEMU_INTERNAL);
+    excp -= EXCP_QEMU_INTERNAL;
+    return STR_ARRAY_ELEM_OR_NULL(excp_name, excp) ?: "unknown";
+}
+
+static void log_raise_exception(const CPUState *cpu, int excp)
+{
+    if (!qemu_loglevel_mask(CPU_LOG_INT)) {
+        return;
+    }
+    if (excp >= EXCP_QEMU_INTERNAL) {
+        qemu_log_mask(CPU_LOG_INT, "raise exception: 0x%x (internal: %s)\n",
+                                   excp, qemu_excp_name(excp));
+    }
+}
+
 /* exit the current TB, but without causing any exception to be raised */
 void cpu_loop_exit_noexc(CPUState *cpu)
 {
@@ -118,5 +147,6 @@ void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc)
     /* Prevent looping if already executing in a serial context. */
     g_assert(!cpu_in_serial_context(cpu));
     cpu->exception_index = EXCP_ATOMIC;
+    log_raise_exception(cpu, EXCP_ATOMIC);
     cpu_loop_exit_restore(cpu, pc);
 }
Signature · 1 line
2.55.0
#18 lore raw

[PULL 25/83] target/alpha: Use a static table in alpha_exception_name()

In reply to Philippe Mathieu-Daudé

Replace the switch statement with a static lookup table.

With '-d int', unlisted exception codes are now logged as "unknown" instead of "<unknown>".

Message-ID: <[email protected]>

---
 target/alpha/helper.c | 55 ++++++++++++-------------------------------
 1 file changed, 15 insertions(+), 40 deletions(-)
target/alpha/helper.c +15 -40
index cedb0006892..84997ef3a99 100644
@@ -19,6 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "exec/cputlb.h"
 #include "exec/page-protection.h"
@@ -37,47 +38,21 @@
 
 const char *alpha_exception_name(int excp)
 {
-    const char *name;
+    static const char * const excp_names[] = {
+        [EXCP_RESET]            = "reset",
+        [EXCP_MCHK]             = "mchk",
+        [EXCP_SMP_INTERRUPT]    = "smp_interrupt",
+        [EXCP_CLK_INTERRUPT]    = "clk_interrupt",
+        [EXCP_DEV_INTERRUPT]    = "dev_interrupt",
+        [EXCP_MMFAULT]          = "mmfault",
+        [EXCP_UNALIGN]          = "unalign",
+        [EXCP_OPCDEC]           = "opcdec",
+        [EXCP_ARITH]            = "arith",
+        [EXCP_FEN]              = "fen",
+        [EXCP_CALL_PAL]         = "call_pal",
+    };
 
-    switch (excp) {
-    case EXCP_RESET:
-        name = "reset";
-        break;
-    case EXCP_MCHK:
-        name = "mchk";
-        break;
-    case EXCP_SMP_INTERRUPT:
-        name = "smp_interrupt";
-        break;
-    case EXCP_CLK_INTERRUPT:
-        name = "clk_interrupt";
-        break;
-    case EXCP_DEV_INTERRUPT:
-        name = "dev_interrupt";
-        break;
-    case EXCP_MMFAULT:
-        name = "mmfault";
-        break;
-    case EXCP_UNALIGN:
-        name = "unalign";
-        break;
-    case EXCP_OPCDEC:
-        name = "opcdec";
-        break;
-    case EXCP_ARITH:
-        name = "arith";
-        break;
-    case EXCP_FEN:
-        name = "fen";
-        break;
-    case EXCP_CALL_PAL:
-        name = "call_pal";
-        break;
-    default:
-        name = "<unknown>";
-        break;
-    }
-    return name;
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
 }
 
 uint64_t cpu_alpha_load_fpcr(CPUAlphaState *env)
Signature · 1 line
2.55.0
#19 lore raw

[PULL 19/83] include: Remove TARGET_LONG_SIZE definition

In reply to Philippe Mathieu-Daudé

All the code base uses TARGET_LONG_BITS,
remove TARGET_LONG_SIZE as unnecessary.

Message-ID: <[email protected]>

---
 include/exec/target_long.h  | 8 +++-----
 include/user/tswap-target.h | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)
include/exec/target_long.h +3 -5
index 3cd8e26a23f..5d403c60402 100644
@@ -20,17 +20,15 @@
 #error TARGET_LONG_BITS not defined
 #endif
 
-#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8)
-
 /* target_ulong is the type of a virtual address */
-#if TARGET_LONG_SIZE == 4
+#if TARGET_LONG_BITS == 32
 typedef int32_t target_long;
 typedef uint32_t target_ulong;
 #define TARGET_FMT_lx "%08x"
 #define TARGET_FMT_ld "%d"
 #define TARGET_FMT_lu "%u"
 #define MO_TL MO_32
-#elif TARGET_LONG_SIZE == 8
+#elif TARGET_LONG_BITS == 64
 typedef int64_t target_long;
 typedef uint64_t target_ulong;
 #define TARGET_FMT_lx "%016" PRIx64
@@ -38,7 +36,7 @@ typedef uint64_t target_ulong;
 #define TARGET_FMT_lu "%" PRIu64
 #define MO_TL MO_64
 #else
-#error TARGET_LONG_SIZE undefined
+#error TARGET_LONG_BITS invalid
 #endif
 
 #endif /* _TARGET_LONG_H_ */
include/user/tswap-target.h +1 -1
index 4719330dbbc..1c66a5b9344 100644
@@ -11,7 +11,7 @@
 #include "exec/cpu-defs.h"
 #include "exec/tswap.h"
 
-#if TARGET_LONG_SIZE == 4
+#if TARGET_LONG_BITS == 32
 #define tswapl(s) tswap32(s)
 #define bswaptls(s) bswap32s(s)
 #else
Signature · 1 line
2.55.0
#20 lore raw

[PULL 18/83] gdbstub: Remove unused gdb_get_regl()

In reply to Philippe Mathieu-Daudé

All callers have been converted to target-specific helpers, so gdb_get_regl() is unused now. Drop it, together with the "cpu-param.h" include that only provided TARGET_LONG_BITS for it.

Message-ID: <[email protected]>

---
 include/gdbstub/helpers.h | 18 ------------------
 1 file changed, 18 deletions(-)
include/gdbstub/helpers.h +0 -18
index b2f41d6d280..9833725b611 100644
@@ -15,10 +15,6 @@
 #include "qemu/bswap.h"
 #include "qemu/target-info.h"
 
-#ifdef COMPILING_PER_TARGET
-#include "cpu-param.h"
-#endif
-
 /*
  * The GDB remote protocol transfers values in target byte order. As
  * the gdbstub may be batching up several register values we always
@@ -88,20 +84,6 @@ static inline int gdb_get_zeroes(GByteArray *array, size_t len)
     return len;
 }
 
-/**
- * gdb_get_regl: append @val in @buf using 32 or 64-bit, depending on target
- *
- * This function is legacy and deprecated, thus should not be used in new code.
- */
-static inline int gdb_get_regl(GByteArray *buf, uint64_t val)
-{
-    if (target_long_bits() == 64) {
-        return gdb_get_reg64(buf, val);
-    } else {
-        return gdb_get_reg32(buf, val);
-    }
-}
-
 /**
  * gdb_get_reg_ptr: get pointer to start of last element
  * @len: length of element
Signature · 1 line
2.55.0
#21 lore raw

[PULL 17/83] target/hexagon: Expand gdb_get_regl() -> gdb_get_reg32() again

In reply to Philippe Mathieu-Daudé

Commit 780fbbef2a2 ("target/hexagon: gdbstub - Add sys reg support") re-introduced calls to gdb_get_regl(). Since Hexagon target is only built as 32-bit, replace them again by gdb_get_reg32(), similarly to commit previous 7831e5f48d2 ("target/hexagon: Expand gdb_get_regl() -> gdb_get_reg32()").

Message-ID: <[email protected]>

---
 target/hexagon/gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/hexagon/gdbstub.c +2 -2
index ca6d4a98369..85d9845cc94 100644
@@ -96,12 +96,12 @@ int hexagon_sys_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
             val = cpu->globalregs ?
                 hexagon_globalreg_read(cpu->globalregs, n, env->threadId) : 0;
         }
-        return gdb_get_regl(mem_buf, val);
+        return gdb_get_reg32(mem_buf, val);
     }
     n -= NUM_SREGS;
 
     if (n < NUM_GREGS) {
-        return gdb_get_regl(mem_buf, hexagon_greg_read(env, n));
+        return gdb_get_reg32(mem_buf, hexagon_greg_read(env, n));
     }
     n -= NUM_GREGS;
 
Signature · 1 line
2.55.0
#22 lore raw

[PULL 20/83] qemu/osdep: Document ARRAY_SIZE() macro rejects pointers

In reply to Philippe Mathieu-Daudé

Since commit ed63ec0d22c ("ARRAY_SIZE: check that argument is an array"), passing a pointer to ARRAY_SIZE() is a build error. Document that.

Message-ID: <[email protected]>

---
 include/qemu/osdep.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/qemu/osdep.h +6 -0
index 1ec5b42230b..5d5695ade28 100644
@@ -528,6 +528,12 @@ void QEMU_ERROR("code path is reachable")
  */
 #define QEMU_IS_ARRAY(x) (!__builtin_types_compatible_p(typeof(x), \
                                                         typeof(&(x)[0])))
+/**
+ * ARRAY_SIZE() - Return the number of elements of an array
+ * @x: the array
+ *
+ * Note: fails to build if @x is a pointer.
+ */
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \
                        QEMU_BUILD_BUG_ON_ZERO(!QEMU_IS_ARRAY(x)))
Signature · 1 line
2.55.0
#23 lore raw

[PULL 27/83] target/avr: Implement and register CPUClass::exception_name()

In reply to Philippe Mathieu-Daudé

Implement avr_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve AVR exception codes to names.

Message-ID: <[email protected]>

---
 target/avr/cpu.h |  2 ++
 target/avr/cpu.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
target/avr/cpu.h +2 -0
index 1e4e839bd83..b1b5b637617 100644
@@ -44,6 +44,8 @@
 #define EXCP_RESET 1
 #define EXCP_INT(n) (EXCP_RESET + (n) + 1)
 
+const char *avr_exception_name(int excp);
+
 /* Number of CPU registers */
 #define NUMBER_OF_CPU_REGISTERS 32
 
target/avr/cpu.c +17 -0
index a01e6fa4751..244871e5e63 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "qemu/qemu-print.h"
 #include "exec/translation-block.h"
@@ -257,6 +258,21 @@ static const TCGCPUOps avr_tcg_ops = {
     .pointer_wrap = cpu_pointer_wrap_uint32,
 };
 
+const char *avr_exception_name(int excp)
+{
+    static const char * const excp_names[] = {
+        [EXCP_RESET]    = "RESET",
+        [EXCP_INT(0)]   = "INT#0",
+        [EXCP_INT(1)]   = "INT#1",
+        [EXCP_INT(2)]   = "INT#2",
+        [EXCP_INT(3)]   = "INT#3",
+        [EXCP_INT(4)]   = "INT#4",
+        [EXCP_INT(5)]   = "INT#5",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 static void avr_cpu_class_init(ObjectClass *oc, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
@@ -272,6 +288,7 @@ static void avr_cpu_class_init(ObjectClass *oc, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = avr_cpu_class_by_name;
+    cc->exception_name = avr_exception_name;
 
     cc->dump_state = avr_cpu_dump_state;
     cc->set_pc = avr_cpu_set_pc;
Signature · 1 line
2.55.0
#24 lore raw

[PULL 29/83] target/hppa: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor hppa_exception_name() out of hppa_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve HPPA exception codes to names.

With '-d int', hppa_cpu_do_interrupt() now logs "INT: cpu N excp I (NAME)", NAME being "unknown" for unlisted codes, instead of "INT: cpu N NAME" or "INT: cpu N unknown I".

Message-ID: <[email protected]>

---
 target/hppa/cpu.h        |  2 ++
 target/hppa/cpu.c        | 42 +++++++++++++++++++++++++++++++++++
 target/hppa/int_helper.c | 48 +++-------------------------------------
 3 files changed, 47 insertions(+), 45 deletions(-)
target/hppa/cpu.h +2 -0
index f453444d7f9..3914b3285c5 100644
@@ -98,6 +98,8 @@
 /* Emulated hardware TOC button */
 #define EXCP_TOC                 32 /* TOC = Transfer of control (NMI) */
 
+const char *hppa_exception_name(int excp);
+
 #define CPU_INTERRUPT_NMI       CPU_INTERRUPT_TGT_EXT_3         /* TOC */
 
 /* Taken from Linux kernel: arch/parisc/include/asm/psw.h */
target/hppa/cpu.c +42 -0

60 lines not on this page · raw message

target/hppa/int_helper.c +3 -45

56 lines not on this page · raw message

Signature · 1 line
2.55.0
#25 lore raw

[PULL 26/83] target/arm: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor arm_exception_name() out of arm_log_exception() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve ARM exception codes to names.

Message-ID: <[email protected]>

---
 target/arm/cpu.h    |  4 ++-
 target/arm/cpu.c    |  1 +
 target/arm/helper.c | 77 ++++++++++++++++++++++-----------------------
 3 files changed, 42 insertions(+), 40 deletions(-)
target/arm/cpu.h +3 -1
index a0355ba9e1a..add993ef101 100644
@@ -65,7 +65,9 @@
 #define EXCP_VINMI          27
 #define EXCP_VFNMI          28
 #define EXCP_MON_TRAP       29   /* AArch32 trap to Monitor mode */
-/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
+/* NB: add new EXCP_ defines to the array in arm_exception_name() too */
+
+const char *arm_exception_name(int excp);
 
 #define ARMV7M_EXCP_RESET   1
 #define ARMV7M_EXCP_NMI     2
target/arm/cpu.c +1 -0
index 03a0ae02ebb..510fc9eeb3b 100644
@@ -2645,6 +2645,7 @@ static void arm_cpu_class_init(ObjectClass *oc, const void *data)
                                        &acc->parent_phases);
 
     cc->class_by_name = arm_cpu_class_by_name;
+    cc->exception_name = arm_exception_name;
     cc->dump_state = arm_cpu_dump_state;
     cc->set_pc = arm_cpu_set_pc;
     cc->get_pc = arm_cpu_get_pc;
target/arm/helper.c +38 -39

96 lines not on this page · raw message

Signature · 1 line
2.55.0
#26 lore raw

[PULL 16/83] target/riscv: Replace gdb_get_regl() by riscv_gdb_get_reg_mxl()

In reply to Philippe Mathieu-Daudé

riscv_gdb_get_reg_mxl() picks the register width from the CPU's misa_mxl_max instead of target_long_bits(); use it in place of the deprecated gdb_get_regl().

Message-ID: <[email protected]>

---
 target/riscv/gdbstub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/riscv/gdbstub.c +3 -3
index b3c11db5397..50e834e367c 100644
@@ -183,7 +183,7 @@ static int riscv_gdb_get_csr(CPUState *cs, GByteArray *buf, int n)
 
         result = riscv_csrrw_debug(env, n, &val, 0, 0);
         if (result == RISCV_EXCP_NONE) {
-            return gdb_get_regl(buf, val);
+            return riscv_gdb_get_reg_mxl(cs, buf, val);
         }
     }
     return 0;
@@ -211,7 +211,7 @@ static int riscv_gdb_get_virtual(CPUState *cs, GByteArray *buf, int n)
 {
     if (n == 0) {
 #ifdef CONFIG_USER_ONLY
-        return gdb_get_regl(buf, 0);
+        return riscv_gdb_get_reg_mxl(cs, buf, 0);
 #else
         RISCVCPU *cpu = RISCV_CPU(cs);
         CPURISCVState *env = &cpu->env;
@@ -219,7 +219,7 @@ static int riscv_gdb_get_virtual(CPUState *cs, GByteArray *buf, int n)
         /* Per RiscV debug spec v1.0.0 rc4 */
         uint32_t vbit = (env->virt_enabled) ? BIT(2) : 0;
 
-        return gdb_get_regl(buf, env->priv | vbit);
+        return riscv_gdb_get_reg_mxl(cs, buf, env->priv | vbit);
 #endif
     }
     return 0;
Signature · 1 line
2.55.0
#27 lore raw

[PULL 23/83] cpus: Introduce CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Have targets register a helper to resolve their exceptions.

Message-ID: <[email protected]>

---
 include/hw/core/cpu.h       | 2 ++
 accel/tcg/cpu-exec-common.c | 6 ++++++
 2 files changed, 8 insertions(+)
include/hw/core/cpu.h +2 -0
index a3b4c6c08a7..5b7c330047d 100644
@@ -108,6 +108,7 @@ struct SemihostingCPUOps;
  * @list_cpus: list available CPU models and flags.
  * @parse_features: Callback to parse command line arguments.
  * @reset_dump_flags: #CPUDumpFlags to use for reset logging.
+ * @exception_name: Callback for getting architecture exception name.
  * @memory_rw_debug: Callback for GDB memory access.
  * @dump_state: Callback for dumping state.
  * @query_cpu_fast:
@@ -178,6 +179,7 @@ struct CPUClass {
     const char * (*gdb_arch_name)(CPUState *cpu);
     const char * (*gdb_get_core_xml_file)(CPUState *cpu);
 
+    const char *(*exception_name)(int exception);
     void (*disas_set_info)(const CPUState *cpu, disassemble_info *info);
 
     const char *deprecation_note;
accel/tcg/cpu-exec-common.c +6 -0
index bd2cb9d6311..4e5e69649aa 100644
@@ -115,6 +115,12 @@ static void log_raise_exception(const CPUState *cpu, int excp)
     if (excp >= EXCP_QEMU_INTERNAL) {
         qemu_log_mask(CPU_LOG_INT, "raise exception: 0x%x (internal: %s)\n",
                                    excp, qemu_excp_name(excp));
+    } else {
+        const CPUClass *cc = cpu->cc;
+        const char *name = cc->exception_name ? cc->exception_name(excp)
+                                              : "unknown";
+
+        qemu_log_mask(CPU_LOG_INT, "raise exception: %d (%s)\n", excp, name);
     }
 }
 
Signature · 1 line
2.55.0
#28 lore raw

[PULL 31/83] target/i386: Implement and register CPUClass::exception_name()

In reply to Philippe Mathieu-Daudé

Implement x86_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve X86 exception codes to names.

Use the new helper in check_exception() and do_interrupt_all().

With '-d int', both now print a name in parentheses after the vector number. do_interrupt_all() labels hardware interrupts "IRQ" and software INT n with n >= 0x20 "INT", instead of looking them up. check_exception() shows "none" when no exception is pending (old_exception == -1).

Message-ID: <[email protected]>

---
 target/i386/cpu.h             |  2 ++
 target/i386/cpu.c             | 30 ++++++++++++++++++++++++++++++
 target/i386/tcg/excp_helper.c |  7 +++++--
 target/i386/tcg/seg_helper.c  |  9 +++++++--
 4 files changed, 44 insertions(+), 4 deletions(-)
target/i386/cpu.h +2 -0
index e7a88074c07..3945e90371b 100644
@@ -1517,6 +1517,8 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);
 #define EXCP_SYSCALL    0x101 /* only for user emulation */
 #define EXCP_VSYSCALL   0x102 /* only for user emulation */
 
+const char *x86_exception_name(int excp);
+
 /* i386-specific interrupt pending bits.  */
 #define CPU_INTERRUPT_POLL      CPU_INTERRUPT_TGT_EXT_1
 #define CPU_INTERRUPT_SMI       CPU_INTERRUPT_TGT_EXT_2
target/i386/cpu.c +30 -0
index dd9cd7c5625..e65eca0459a 100644
@@ -9372,6 +9372,35 @@ static bool cpuid_has_xsave_feature(CPUX86State *env, const ExtSaveArea *esa)
     return false;
 }
 
+const char *x86_exception_name(int excp)
+{
+    static const char * const excp_names[] = {
+        [EXCP00_DIVZ]       = "DIV#0",
+        [EXCP01_DB]         = "DB",
+        [EXCP02_NMI]        = "NMI",
+        [EXCP03_INT3]       = "INT3",
+        [EXCP04_INTO]       = "INTO",
+        [EXCP05_BOUND]      = "BOUND",
+        [EXCP06_ILLOP]      = "ILLOP",
+        [EXCP07_PREX]       = "PREX",
+        [EXCP08_DBLE]       = "DBLE",
+        [EXCP09_XERR]       = "XERR",
+        [EXCP0A_TSS]        = "TSS",
+        [EXCP0B_NOSEG]      = "NOSEG",
+        [EXCP0C_STACK]      = "STACK",
+        [EXCP0D_GPF]        = "GPF",
+        [EXCP0E_PAGE]       = "PAGE",
+        [EXCP10_COPR]       = "COPR",
+        [EXCP11_ALGN]       = "ALGN",
+        [EXCP12_MCHK]       = "MCHK",
+        [EXCP_VMEXIT]       = "VMEXIT",
+        [EXCP_SYSCALL]      = "SYSCALL",
+        [EXCP_VSYSCALL]     = "VSYSCALL",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 static void x86_cpu_reset_hold(Object *obj, ResetType type)
 {
     CPUState *cs = CPU(obj);
@@ -10948,6 +10977,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, const void *data)
     cc->reset_dump_flags = CPU_DUMP_FPU | CPU_DUMP_CCOP;
 
     cc->class_by_name = x86_cpu_class_by_name;
+    cc->exception_name = x86_exception_name;
     cc->list_cpus = x86_cpu_list;
     cc->parse_features = x86_cpu_parse_featurestr;
     cc->dump_state = x86_cpu_dump_state;
target/i386/tcg/excp_helper.c +5 -2
index d6410d6fc11..f1b9b188ecd 100644
@@ -56,8 +56,11 @@ static int check_exception(CPUX86State *env, int intno, int *error_code,
     int second_contributory = intno == 0 ||
                                (intno >= 10 && intno <= 13);
 
-    qemu_log_mask(CPU_LOG_INT, "check_exception old: 0x%x new 0x%x\n",
-                env->old_exception, intno);
+    qemu_log_mask(CPU_LOG_INT, "check_exception old: 0x%x (%s) new 0x%x (%s)\n",
+                env->old_exception,
+                env->old_exception == -1 ? "none"
+                    : x86_exception_name(env->old_exception),
+                intno, x86_exception_name(intno));
 
 #if !defined(CONFIG_USER_ONLY)
     if (env->old_exception == EXCP08_DBLE) {
target/i386/tcg/seg_helper.c +7 -2
index c89d97e022b..d75ee54f9e8 100644
@@ -1207,10 +1207,15 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_int,
     if (qemu_loglevel_mask(CPU_LOG_INT)) {
         if ((env->cr[0] & CR0_PE_MASK)) {
             static int count;
+            const char *name = is_hw ? "IRQ"
+                             : is_int && intno >= 0x20 ? "INT"
+                             : x86_exception_name(intno);
 
-            qemu_log("%6d: v=%02x e=%04x i=%d cpl=%d IP=%04x:" TARGET_FMT_lx
+            qemu_log("%6d: v=%02x (%s) e=%04x i=%d"
+                     " cpl=%d IP=%04x:" TARGET_FMT_lx
                      " pc=" TARGET_FMT_lx " SP=%04x:" TARGET_FMT_lx,
-                     count, intno, error_code, is_int,
+                     count, intno, name,
+                     error_code, is_int,
                      env->hflags & HF_CPL_MASK,
                      env->segs[R_CS].selector, env->eip,
                      (int)env->segs[R_CS].base + env->eip,
Signature · 1 line
2.55.0
#29 lore raw

[PULL 30/83] target/i386: Replace magic value by proper EXCP0E_PAGE definition

In reply to Philippe Mathieu-Daudé

No functional change: EXCP0E_PAGE is the 0x0e page-fault vector.

Message-ID: <[email protected]>

---
 target/i386/tcg/seg_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/tcg/seg_helper.c +1 -1
index cad19f9ca6b..c89d97e022b 100644
@@ -1215,7 +1215,7 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_int,
                      env->segs[R_CS].selector, env->eip,
                      (int)env->segs[R_CS].base + env->eip,
                      env->segs[R_SS].selector, env->regs[R_ESP]);
-            if (intno == 0x0e) {
+            if (intno == EXCP0E_PAGE) {
                 qemu_log(" CR2=" TARGET_FMT_lx, env->cr[2]);
             } else {
                 qemu_log(" env->regs[R_EAX]=" TARGET_FMT_lx, env->regs[R_EAX]);
Signature · 1 line
2.55.0
#30 lore raw

[PULL 28/83] target/hexagon: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Expose the hexagon event_name[] array via a hexagon_event_name() helper and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve Hexagon exception codes to names. Make the table 'const char * const' while moving it.

With '-d int', hexagon_cpu_do_interrupt() used to index event_name[] directly. Codes without an entry (table holes, or values past its end) are now logged as "unknown", instead of passing NULL to "%s" or reading past the array.

Message-ID: <[email protected]>

---
 target/hexagon/cpu_bits.h |  2 ++
 target/hexagon/cpu.c      | 35 +++++++++++++++++++++++++++++++++++
 target/hexagon/hexswi.c   | 30 +-----------------------------
 3 files changed, 38 insertions(+), 29 deletions(-)
target/hexagon/cpu_bits.h +2 -0
index a8fba4aa188..7d1bdfcbc71 100644
@@ -61,6 +61,8 @@ enum hex_event {
     HEX_EVENT_INTF = 0x1f,
 };
 
+const char *hexagon_event_name(int event);
+
 enum hex_cause {
     HEX_CAUSE_NONE = -1,
     HEX_CAUSE_RESET = 0x000,
target/hexagon/cpu.c +35 -0
index 304031e97f0..8df63e43260 100644
@@ -18,6 +18,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qemu/qemu-print.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "internal.h"
 #include "exec/cputlb.h"
@@ -318,6 +319,39 @@ void hexagon_debug(CPUHexagonState *env)
     hexagon_dump(env, stdout, CPU_DUMP_FPU);
 }
 
+const char *hexagon_event_name(int event)
+{
+    static const char * const event_name[] = {
+        [HEX_EVENT_RESET] = "HEX_EVENT_RESET",
+        [HEX_EVENT_IMPRECISE] = "HEX_EVENT_IMPRECISE",
+        [HEX_EVENT_PRECISE] = "HEX_EVENT_PRECISE",
+        [HEX_EVENT_TLB_MISS_X] = "HEX_EVENT_TLB_MISS_X",
+        [HEX_EVENT_TLB_MISS_RW] = "HEX_EVENT_TLB_MISS_RW",
+        [HEX_EVENT_TRAP0] = "HEX_EVENT_TRAP0",
+        [HEX_EVENT_TRAP1] = "HEX_EVENT_TRAP1",
+        [HEX_EVENT_FPTRAP] = "HEX_EVENT_FPTRAP",
+        [HEX_EVENT_DEBUG] = "HEX_EVENT_DEBUG",
+        [HEX_EVENT_INT0] = "HEX_EVENT_INT0",
+        [HEX_EVENT_INT1] = "HEX_EVENT_INT1",
+        [HEX_EVENT_INT2] = "HEX_EVENT_INT2",
+        [HEX_EVENT_INT3] = "HEX_EVENT_INT3",
+        [HEX_EVENT_INT4] = "HEX_EVENT_INT4",
+        [HEX_EVENT_INT5] = "HEX_EVENT_INT5",
+        [HEX_EVENT_INT6] = "HEX_EVENT_INT6",
+        [HEX_EVENT_INT7] = "HEX_EVENT_INT7",
+        [HEX_EVENT_INT8] = "HEX_EVENT_INT8",
+        [HEX_EVENT_INT9] = "HEX_EVENT_INT9",
+        [HEX_EVENT_INTA] = "HEX_EVENT_INTA",
+        [HEX_EVENT_INTB] = "HEX_EVENT_INTB",
+        [HEX_EVENT_INTC] = "HEX_EVENT_INTC",
+        [HEX_EVENT_INTD] = "HEX_EVENT_INTD",
+        [HEX_EVENT_INTE] = "HEX_EVENT_INTE",
+        [HEX_EVENT_INTF] = "HEX_EVENT_INTF",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(event_name, event) ?: "unknown";
+}
+
 static void hexagon_cpu_set_pc(CPUState *cs, vaddr value)
 {
     cpu_env(cs)->gpr[HEX_REG_PC] = value;
@@ -840,6 +874,7 @@ static void hexagon_cpu_class_init(ObjectClass *c, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = hexagon_cpu_class_by_name;
+    cc->exception_name = hexagon_event_name;
     cc->dump_state = hexagon_dump_state;
     cc->set_pc = hexagon_cpu_set_pc;
     cc->get_pc = hexagon_cpu_get_pc;
target/hexagon/hexswi.c +1 -29
index e7362b56650..19439658392 100644
@@ -735,34 +735,6 @@ static void set_addresses(CPUHexagonState *env, uint32_t pc_offset,
     env->gpr[HEX_REG_PC] = evb | (exception_index << 2);
 }
 
-static const char *event_name[] = {
-    [HEX_EVENT_RESET] = "HEX_EVENT_RESET",
-    [HEX_EVENT_IMPRECISE] = "HEX_EVENT_IMPRECISE",
-    [HEX_EVENT_PRECISE] = "HEX_EVENT_PRECISE",
-    [HEX_EVENT_TLB_MISS_X] = "HEX_EVENT_TLB_MISS_X",
-    [HEX_EVENT_TLB_MISS_RW] = "HEX_EVENT_TLB_MISS_RW",
-    [HEX_EVENT_TRAP0] = "HEX_EVENT_TRAP0",
-    [HEX_EVENT_TRAP1] = "HEX_EVENT_TRAP1",
-    [HEX_EVENT_FPTRAP] = "HEX_EVENT_FPTRAP",
-    [HEX_EVENT_DEBUG] = "HEX_EVENT_DEBUG",
-    [HEX_EVENT_INT0] = "HEX_EVENT_INT0",
-    [HEX_EVENT_INT1] = "HEX_EVENT_INT1",
-    [HEX_EVENT_INT2] = "HEX_EVENT_INT2",
-    [HEX_EVENT_INT3] = "HEX_EVENT_INT3",
-    [HEX_EVENT_INT4] = "HEX_EVENT_INT4",
-    [HEX_EVENT_INT5] = "HEX_EVENT_INT5",
-    [HEX_EVENT_INT6] = "HEX_EVENT_INT6",
-    [HEX_EVENT_INT7] = "HEX_EVENT_INT7",
-    [HEX_EVENT_INT8] = "HEX_EVENT_INT8",
-    [HEX_EVENT_INT9] = "HEX_EVENT_INT9",
-    [HEX_EVENT_INTA] = "HEX_EVENT_INTA",
-    [HEX_EVENT_INTB] = "HEX_EVENT_INTB",
-    [HEX_EVENT_INTC] = "HEX_EVENT_INTC",
-    [HEX_EVENT_INTD] = "HEX_EVENT_INTD",
-    [HEX_EVENT_INTE] = "HEX_EVENT_INTE",
-    [HEX_EVENT_INTF] = "HEX_EVENT_INTF"
-};
-
 void hexagon_cpu_do_interrupt(CPUState *cs)
 
 {
@@ -775,7 +747,7 @@ void hexagon_cpu_do_interrupt(CPUState *cs)
     qemu_log_mask(CPU_LOG_INT,
                   "\t%s: event 0x%02x:%s, cause 0x%" PRIx32 "(%" PRIu32 ")\n",
                   __func__, (unsigned)cs->exception_index,
-                  event_name[cs->exception_index], env->cause_code,
+                  hexagon_event_name(cs->exception_index), env->cause_code,
                   env->cause_code);
 
     env->llsc_addr = ~0;
Signature · 1 line
2.55.0
#31 lore raw

[PULL 32/83] target/loongarch: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Move loongarch_exception_name() out of tcg_cpu.c and expose the prototype so non-TCG code path can access it. Register it as the CPUClass::exception_name() handler, so the common exception logging can resolve LoongArch exception codes to names.

With '-d int', unlisted codes are now logged as "unknown" instead of "Unknown".

Message-ID: <[email protected]>

---
 target/loongarch/internals.h   |  2 ++
 target/loongarch/cpu.c         | 38 +++++++++++++++++++++++++++++++
 target/loongarch/tcg/tcg_cpu.c | 41 ----------------------------------
 3 files changed, 40 insertions(+), 41 deletions(-)
target/loongarch/internals.h +2 -0
index 9d064d1948b..bc32bba7f75 100644
@@ -41,6 +41,8 @@ void cpu_loongarch_set_timer_config(CPUTimerState *timer, uint64_t value);
 bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env);
 #endif /* !CONFIG_USER_ONLY */
 
+const char *loongarch_exception_name(int exception);
+
 uint64_t read_fcc(CPULoongArchState *env);
 void write_fcc(CPULoongArchState *env, uint64_t val);
 
target/loongarch/cpu.c +38 -0
index a95fdfc2b62..9579f4db2a1 100644
@@ -835,6 +835,43 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags)
     }
 }
 
+static const struct {
+    int32_t exccode;
+    const char * const name;
+} excp_names[] = {
+    {EXCCODE_INT, "Interrupt"},
+    {EXCCODE_PIL, "Page invalid exception for load"},
+    {EXCCODE_PIS, "Page invalid exception for store"},
+    {EXCCODE_PIF, "Page invalid exception for fetch"},
+    {EXCCODE_PME, "Page modified exception"},
+    {EXCCODE_PNR, "Page Not Readable exception"},
+    {EXCCODE_PNX, "Page Not Executable exception"},
+    {EXCCODE_PPI, "Page Privilege error"},
+    {EXCCODE_ADEF, "Address error for instruction fetch"},
+    {EXCCODE_ADEM, "Address error for Memory access"},
+    {EXCCODE_SYS, "Syscall"},
+    {EXCCODE_BRK, "Break"},
+    {EXCCODE_INE, "Instruction Non-Existent"},
+    {EXCCODE_IPE, "Instruction privilege error"},
+    {EXCCODE_FPD, "Floating Point Disabled"},
+    {EXCCODE_FPE, "Floating Point Exception"},
+    {EXCCODE_DBP, "Debug breakpoint"},
+    {EXCCODE_BCE, "Bound Check Exception"},
+    {EXCCODE_SXD, "128 bit vector instructions Disable exception"},
+    {EXCCODE_ASXD, "256 bit vector instructions Disable exception"},
+    {EXCP_HLT, "EXCP_HLT"},
+};
+
+const char *loongarch_exception_name(int exception)
+{
+    for (size_t i = 0; i < ARRAY_SIZE(excp_names); i++) {
+        if (excp_names[i].exccode == exception) {
+            return excp_names[i].name;
+        }
+    }
+    return "unknown";
+}
+
 #ifndef CONFIG_USER_ONLY
 #include "hw/core/sysemu-cpu-ops.h"
 
@@ -877,6 +914,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, const void *data)
                                        &lacc->parent_phases);
 
     cc->class_by_name = loongarch_cpu_class_by_name;
+    cc->exception_name = loongarch_exception_name;
     cc->dump_state = loongarch_cpu_dump_state;
     cc->set_pc = loongarch_cpu_set_pc;
     cc->get_pc = loongarch_cpu_get_pc;
target/loongarch/tcg/tcg_cpu.c +0 -41

47 lines not on this page · raw message

Signature · 1 line
2.55.0
#32 lore raw

[PULL 33/83] target/m68k: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Expose m68k_exception_name() prototype and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve M68k exception codes to names.

Message-ID: <[email protected]>

---
 target/m68k/cpu.h       | 2 ++
 target/m68k/cpu.c       | 1 +
 target/m68k/op_helper.c | 8 ++++++--
 3 files changed, 9 insertions(+), 2 deletions(-)
target/m68k/cpu.h +2 -0
index 7cf3791108c..44b4afc41c6 100644
@@ -69,6 +69,8 @@
 #define EXCP_RTE            0x100
 #define EXCP_SEMIHOSTING    0x101
 
+const char *m68k_exception_name(int excp);
+
 #define M68K_DTTR0   0
 #define M68K_DTTR1   1
 #define M68K_ITTR0   2
target/m68k/cpu.c +1 -0
index c7771cbf643..01c6b6afb1f 100644
@@ -729,6 +729,7 @@ static void m68k_cpu_class_init(ObjectClass *c, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = m68k_cpu_class_by_name;
+    cc->exception_name = m68k_exception_name;
     cc->dump_state = m68k_cpu_dump_state;
     cc->set_pc = m68k_cpu_set_pc;
     cc->get_pc = m68k_cpu_get_pc;
target/m68k/op_helper.c +6 -2
index 38f7a689814..c600f83ddbf 100644
@@ -80,9 +80,11 @@ throwaway:
     cpu_m68k_set_sr(env, sr);
 }
 
-static const char *m68k_exception_name(int index)
+#endif /* !CONFIG_USER_ONLY */
+
+const char *m68k_exception_name(int excp)
 {
-    switch (index) {
+    switch (excp) {
     case EXCP_ACCESS:
         return "Access Fault";
     case EXCP_ADDRESS:
@@ -185,6 +187,8 @@ static const char *m68k_exception_name(int index)
     return "Unassigned";
 }
 
+#ifndef CONFIG_USER_ONLY
+
 static void do_plugin_vcpu_interrupt_cb(CPUState *cs, uint64_t from)
 {
     switch (cs->exception_index) {
Signature · 1 line
2.55.0
#33 lore raw

[PULL 24/83] target/alpha: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor alpha_exception_name() out of alpha_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve Alpha exception codes to names.

Message-ID: <[email protected]>

---
 target/alpha/cpu.h    |  1 +
 target/alpha/cpu.c    |  1 +
 target/alpha/helper.c | 82 ++++++++++++++++++++++++-------------------
 3 files changed, 48 insertions(+), 36 deletions(-)
target/alpha/cpu.h +1 -0
index 378bd96d941..8f780502476 100644
@@ -284,6 +284,7 @@ void alpha_cpu_do_interrupt(CPUState *cpu);
 bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
 hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
 #endif /* !CONFIG_USER_ONLY */
+const char *alpha_exception_name(int exception);
 void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/alpha/cpu.c +1 -0
index 7d1d036e1d3..6e514dcf4cd 100644
@@ -282,6 +282,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, const void *data)
                                     &acc->parent_realize);
 
     cc->class_by_name = alpha_cpu_class_by_name;
+    cc->exception_name = alpha_exception_name;
     cc->dump_state = alpha_cpu_dump_state;
     cc->set_pc = alpha_cpu_set_pc;
     cc->get_pc = alpha_cpu_get_pc;
target/alpha/helper.c +46 -36

95 lines not on this page · raw message

Signature · 1 line
2.55.0
#34 lore raw

[PULL 35/83] target/microblaze: Implement and register CPUClass::exception_name()

In reply to Philippe Mathieu-Daudé

Implement microblaze_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve MicroBlaze exception codes to names.

Message-ID: <[email protected]>

---
 target/microblaze/cpu.h |  2 ++
 target/microblaze/cpu.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
target/microblaze/cpu.h +2 -0
index b9602f72b94..fc2783693e3 100644
@@ -36,6 +36,8 @@ typedef struct CPUArchState CPUMBState;
 #define EXCP_HW_BREAK   4
 #define EXCP_HW_EXCP    5
 
+const char *microblaze_exception_name(int excp);
+
 /* MicroBlaze-specific interrupt pending bits.  */
 #define CPU_INTERRUPT_NMI       CPU_INTERRUPT_TGT_EXT_3
 
target/microblaze/cpu.c +15 -0
index 6013a8def8e..6d3f7cdae81 100644
@@ -23,6 +23,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "qemu/module.h"
@@ -79,6 +80,19 @@ static const struct {
 /* If no specific version gets selected, default to the following.  */
 #define DEFAULT_CPU_VERSION "10.0"
 
+const char *microblaze_exception_name(int excp)
+{
+    static const char * const excp_names[] = {
+        [EXCP_MMU]      = "mmu",
+        [EXCP_IRQ]      = "irq",
+        [EXCP_SYSCALL]  = "syscall",
+        [EXCP_HW_BREAK] = "hw break",
+        [EXCP_HW_EXCP]  = "hw excp",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 static void mb_cpu_set_pc(CPUState *cs, vaddr value)
 {
     MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
@@ -468,6 +482,7 @@ static void mb_cpu_class_init(ObjectClass *oc, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = mb_cpu_class_by_name;
+    cc->exception_name = microblaze_exception_name;
     cc->dump_state = mb_cpu_dump_state;
     cc->set_pc = mb_cpu_set_pc;
     cc->get_pc = mb_cpu_get_pc;
Signature · 1 line
2.55.0
#35 lore raw

[PULL 36/83] target/mips: Remove EXCP_LAST, use ARRAY_SIZE(excp_names)

In reply to Philippe Mathieu-Daudé

EXCP_LAST was only used to size excp_names[] and to bound-check mips_exception_name(). Let the table size itself from its initializers and check the index with ARRAY_SIZE(), so adding an exception no longer requires updating EXCP_LAST.

Message-ID: <[email protected]>

---
 target/mips/cpu.h           | 2 --
 target/mips/tcg/exception.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)
target/mips/cpu.h +0 -2
index 32549791a18..5d8b78a70b8 100644
@@ -1347,8 +1347,6 @@ enum {
     EXCP_TLBXI,
     EXCP_TLBRI,
     EXCP_SEMIHOST,
-
-    EXCP_LAST = EXCP_SEMIHOST,
 };
 
 /*
target/mips/tcg/exception.c +2 -2
index 630b8b809fa..2f02f9be877 100644
@@ -88,7 +88,7 @@ void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb)
     env->hflags |= tb->flags & MIPS_HFLAG_BMASK;
 }
 
-static const char * const excp_names[EXCP_LAST + 1] = {
+static const char * const excp_names[] = {
     [EXCP_RESET] = "reset",
     [EXCP_SRESET] = "soft reset",
     [EXCP_DSS] = "debug single step",
@@ -131,7 +131,7 @@ static const char * const excp_names[EXCP_LAST + 1] = {
 
 const char *mips_exception_name(int32_t exception)
 {
-    if (exception < 0 || exception > EXCP_LAST) {
+    if (exception < 0 || exception >= ARRAY_SIZE(excp_names)) {
         return "unknown";
     }
     return excp_names[exception];
Signature · 1 line
2.55.0
#36 lore raw

[PULL 37/83] target/mips: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Register mips_exception_name() as the CPUClass::exception_name() handler, so the common exception logging can resolve MIPS exception codes to names. Return "unknown" for missing array entries.

With '-d int', codes without an entry in excp_names[] are now logged as "unknown" instead of passing NULL to "%s".

Message-ID: <[email protected]>

---
 target/mips/cpu.h              | 2 ++
 target/mips/tcg/tcg-internal.h | 2 --
 target/mips/cpu.c              | 1 +
 target/mips/tcg/exception.c    | 8 +++-----
 4 files changed, 6 insertions(+), 7 deletions(-)
target/mips/cpu.h +2 -0
index 5d8b78a70b8..b080c5de4de 100644
@@ -1349,6 +1349,8 @@ enum {
     EXCP_SEMIHOST,
 };
 
+const char *mips_exception_name(int excp);
+
 /*
  * This is an internally generated WAKE request line.
  * It is driven by the CPU itself. Raised when the MT
target/mips/tcg/tcg-internal.h +0 -2
index 950e6afc3f2..9f230e757d6 100644
@@ -27,8 +27,6 @@ void mips_restore_state_to_opc(CPUState *cs,
                                const TranslationBlock *tb,
                                const uint64_t *data);
 
-const char *mips_exception_name(int32_t exception);
-
 G_NORETURN void do_raise_exception_err(CPUMIPSState *env, uint32_t exception,
                                        int error_code, uintptr_t pc);
 
target/mips/cpu.c +1 -0
index c069aa1c0b7..759a4e93a0a 100644
@@ -741,6 +741,7 @@ static void mips_cpu_class_init(ObjectClass *c, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = mips_cpu_class_by_name;
+    cc->exception_name = mips_exception_name;
     cc->dump_state = mips_cpu_dump_state;
     cc->set_pc = mips_cpu_set_pc;
     cc->get_pc = mips_cpu_get_pc;
target/mips/tcg/exception.c +3 -5
index 2f02f9be877..823866ee600 100644
@@ -20,6 +20,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "internal.h"
 #include "exec/helper-proto.h"
@@ -129,12 +130,9 @@ static const char * const excp_names[] = {
     [EXCP_SEMIHOST] = "Semihosting",
 };
 
-const char *mips_exception_name(int32_t exception)
+const char *mips_exception_name(int excp)
 {
-    if (exception < 0 || exception >= ARRAY_SIZE(excp_names)) {
-        return "unknown";
-    }
-    return excp_names[exception];
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
 }
 
 void do_raise_exception_err(CPUMIPSState *env, uint32_t exception,
Signature · 1 line
2.55.0
#37 lore raw

[PULL 34/83] target/m68k: Use a static table in m68k_exception_name()

In reply to Philippe Mathieu-Daudé

Replace the switch statement with a static lookup table.

Message-ID: <[email protected]>

---
 target/m68k/op_helper.c | 153 ++++++++++++++--------------------------
 1 file changed, 54 insertions(+), 99 deletions(-)
target/m68k/op_helper.c +54 -99
index c600f83ddbf..c9db8a1b39d 100644
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "exec/helper-proto.h"
 #include "accel/tcg/cpu-ldst.h"
@@ -84,107 +85,61 @@ throwaway:
 
 const char *m68k_exception_name(int excp)
 {
-    switch (excp) {
-    case EXCP_ACCESS:
-        return "Access Fault";
-    case EXCP_ADDRESS:
-        return "Address Error";
-    case EXCP_ILLEGAL:
-        return "Illegal Instruction";
-    case EXCP_DIV0:
-        return "Divide by Zero";
-    case EXCP_CHK:
-        return "CHK/CHK2";
-    case EXCP_TRAPCC:
-        return "FTRAPcc, TRAPcc, TRAPV";
-    case EXCP_PRIVILEGE:
-        return "Privilege Violation";
-    case EXCP_TRACE:
-        return "Trace";
-    case EXCP_LINEA:
-        return "A-Line";
-    case EXCP_LINEF:
-        return "F-Line";
-    case EXCP_DEBEGBP: /* 68020/030 only */
-        return "Copro Protocol Violation";
-    case EXCP_FORMAT:
-        return "Format Error";
-    case EXCP_UNINITIALIZED:
-        return "Uninitialized Interrupt";
-    case EXCP_SPURIOUS:
-        return "Spurious Interrupt";
-    case EXCP_INT_LEVEL_1:
-        return "Level 1 Interrupt";
-    case EXCP_INT_LEVEL_1 + 1:
-        return "Level 2 Interrupt";
-    case EXCP_INT_LEVEL_1 + 2:
-        return "Level 3 Interrupt";
-    case EXCP_INT_LEVEL_1 + 3:
-        return "Level 4 Interrupt";
-    case EXCP_INT_LEVEL_1 + 4:
-        return "Level 5 Interrupt";
-    case EXCP_INT_LEVEL_1 + 5:
-        return "Level 6 Interrupt";
-    case EXCP_INT_LEVEL_1 + 6:
-        return "Level 7 Interrupt";
-    case EXCP_TRAP0:
-        return "TRAP #0";
-    case EXCP_TRAP0 + 1:
-        return "TRAP #1";
-    case EXCP_TRAP0 + 2:
-        return "TRAP #2";
-    case EXCP_TRAP0 + 3:
-        return "TRAP #3";
-    case EXCP_TRAP0 + 4:
-        return "TRAP #4";
-    case EXCP_TRAP0 + 5:
-        return "TRAP #5";
-    case EXCP_TRAP0 + 6:
-        return "TRAP #6";
-    case EXCP_TRAP0 + 7:
-        return "TRAP #7";
-    case EXCP_TRAP0 + 8:
-        return "TRAP #8";
-    case EXCP_TRAP0 + 9:
-        return "TRAP #9";
-    case EXCP_TRAP0 + 10:
-        return "TRAP #10";
-    case EXCP_TRAP0 + 11:
-        return "TRAP #11";
-    case EXCP_TRAP0 + 12:
-        return "TRAP #12";
-    case EXCP_TRAP0 + 13:
-        return "TRAP #13";
-    case EXCP_TRAP0 + 14:
-        return "TRAP #14";
-    case EXCP_TRAP0 + 15:
-        return "TRAP #15";
-    case EXCP_FP_BSUN:
-        return "FP Branch/Set on unordered condition";
-    case EXCP_FP_INEX:
-        return "FP Inexact Result";
-    case EXCP_FP_DZ:
-        return "FP Divide by Zero";
-    case EXCP_FP_UNFL:
-        return "FP Underflow";
-    case EXCP_FP_OPERR:
-        return "FP Operand Error";
-    case EXCP_FP_OVFL:
-        return "FP Overflow";
-    case EXCP_FP_SNAN:
-        return "FP Signaling NAN";
-    case EXCP_FP_UNIMP:
-        return "FP Unimplemented Data Type";
-    case EXCP_MMU_CONF: /* 68030/68851 only */
-        return "MMU Configuration Error";
-    case EXCP_MMU_ILLEGAL: /* 68851 only */
-        return "MMU Illegal Operation";
-    case EXCP_MMU_ACCESS: /* 68851 only */
-        return "MMU Access Level Violation";
-    case 64 ... 255:
+    static const char * const excp_names[] = {
+        [EXCP_ACCESS]           = "Access Fault",
+        [EXCP_ADDRESS]          = "Address Error",
+        [EXCP_ILLEGAL]          = "Illegal Instruction",
+        [EXCP_DIV0]             = "Divide by Zero",
+        [EXCP_CHK]              = "CHK/CHK2",
+        [EXCP_TRAPCC]           = "FTRAPcc, TRAPcc, TRAPV",
+        [EXCP_PRIVILEGE]        = "Privilege Violation",
+        [EXCP_TRACE]            = "Trace",
+        [EXCP_LINEA]            = "A-Line",
+        [EXCP_LINEF]            = "F-Line",
+        [EXCP_DEBEGBP]          = "Copro Protocol Violation", /* 68020/030 only */
+        [EXCP_FORMAT]           = "Format Error",
+        [EXCP_UNINITIALIZED]    = "Uninitialized Interrupt",
+        [EXCP_SPURIOUS]         = "Spurious Interrupt",
+        [EXCP_INT_LEVEL_1]      = "Level 1 Interrupt",
+        [EXCP_INT_LEVEL_1 + 1]  = "Level 2 Interrupt",
+        [EXCP_INT_LEVEL_1 + 2]  = "Level 3 Interrupt",
+        [EXCP_INT_LEVEL_1 + 3]  = "Level 4 Interrupt",
+        [EXCP_INT_LEVEL_1 + 4]  = "Level 5 Interrupt",
+        [EXCP_INT_LEVEL_1 + 5]  = "Level 6 Interrupt",
+        [EXCP_INT_LEVEL_1 + 6]  = "Level 7 Interrupt",
+        [EXCP_TRAP0]            = "TRAP #0",
+        [EXCP_TRAP0 + 1]        = "TRAP #1",
+        [EXCP_TRAP0 + 2]        = "TRAP #2",
+        [EXCP_TRAP0 + 3]        = "TRAP #3",
+        [EXCP_TRAP0 + 4]        = "TRAP #4",
+        [EXCP_TRAP0 + 5]        = "TRAP #5",
+        [EXCP_TRAP0 + 6]        = "TRAP #6",
+        [EXCP_TRAP0 + 7]        = "TRAP #7",
+        [EXCP_TRAP0 + 8]        = "TRAP #8",
+        [EXCP_TRAP0 + 9]        = "TRAP #9",
+        [EXCP_TRAP0 + 10]       = "TRAP #10",
+        [EXCP_TRAP0 + 11]       = "TRAP #11",
+        [EXCP_TRAP0 + 12]       = "TRAP #12",
+        [EXCP_TRAP0 + 13]       = "TRAP #13",
+        [EXCP_TRAP0 + 14]       = "TRAP #14",
+        [EXCP_TRAP0 + 15]       = "TRAP #15",
+        [EXCP_FP_BSUN]          = "FP Branch/Set on unordered condition",
+        [EXCP_FP_INEX]          = "FP Inexact Result",
+        [EXCP_FP_DZ]            = "FP Divide by Zero",
+        [EXCP_FP_UNFL]          = "FP Underflow",
+        [EXCP_FP_OPERR]         = "FP Operand Error",
+        [EXCP_FP_OVFL]          = "FP Overflow",
+        [EXCP_FP_SNAN]          = "FP Signaling NAN",
+        [EXCP_FP_UNIMP]         = "FP Unimplemented Data Type",
+        [EXCP_MMU_CONF]         = "MMU Configuration Error", /* 68030/68851 only */
+        [EXCP_MMU_ILLEGAL]      = "MMU Illegal Operation", /* 68851 only */
+        [EXCP_MMU_ACCESS]       = "MMU Access Level Violation", /* 68851 only */
+    };
+
+    if (excp >= 64 && excp <= 255) {
         return "User Defined Vector";
     }
-    return "Unassigned";
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "Unassigned";
 }
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.55.0
#38 lore raw

[PULL 39/83] target/ppc: Name the EBB exceptions

In reply to Philippe Mathieu-Daudé

POWERPC_EXCP_PERFM_EBB and POWERPC_EXCP_EXTERNAL_EBB are raised on POWER8+. With '-d int', powerpc_excp() logs them through powerpc_excp_name(), which has no entry for them and reaches g_assert_not_reached(), aborting QEMU. Add their names.

Fixes cb76bbc43fda ("target/ppc: add PPC_INTERRUPT_EBB and EBB exceptions")

Message-ID: <[email protected]>

---
 target/ppc/excp_helper.c | 2 ++
 1 file changed, 2 insertions(+)
target/ppc/excp_helper.c +2 -0
index 6d05b865058..895127fb2e6 100644
@@ -100,6 +100,8 @@ static const char *powerpc_excp_name(int excp)
     case POWERPC_EXCP_SDOOR_HV: return "SDOOR_HV";
     case POWERPC_EXCP_HVIRT:    return "HVIRT";
     case POWERPC_EXCP_SYSCALL_VECTORED: return "SYSCALL_VECTORED";
+    case POWERPC_EXCP_PERFM_EBB: return "PERFM_EBB";
+    case POWERPC_EXCP_EXTERNAL_EBB: return "EXTERNAL_EBB";
     default:
         g_assert_not_reached();
     }
Signature · 1 line
2.55.0
#39 lore raw

[PULL 38/83] target/or1k: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor openrisc_excp_name() out of openrisc_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve OpenRISC exception codes to names.

Message-ID: <[email protected]>

---
 target/or1k/cpu.h       |  2 ++
 target/or1k/cpu.c       |  1 +
 target/or1k/exception.c | 22 ++++++++++++++++++++++
 target/or1k/interrupt.c | 19 +------------------
 4 files changed, 26 insertions(+), 18 deletions(-)
target/or1k/cpu.h +2 -0
index fc4387ce7ae..96ed1779fae 100644
@@ -155,6 +155,8 @@ enum {
     EXCP_NR,
 };
 
+const char *openrisc_excp_name(int excp);
+
 /* Supervisor register */
 enum {
     SR_SM = (1 << 0),
target/or1k/cpu.c +1 -0
index 42d9351b6d7..5aba8a42a95 100644
@@ -284,6 +284,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, const void *data)
                                        &occ->parent_phases);
 
     cc->class_by_name = openrisc_cpu_class_by_name;
+    cc->exception_name = openrisc_excp_name;
     cc->dump_state = openrisc_cpu_dump_state;
     cc->set_pc = openrisc_cpu_set_pc;
     cc->get_pc = openrisc_cpu_get_pc;
target/or1k/exception.c +22 -0
index 785181ef2ed..55c539a86db 100644
@@ -18,10 +18,32 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "accel/tcg/cpu-loop.h"
 #include "cpu.h"
 #include "exception.h"
 
+const char *openrisc_excp_name(int excp)
+{
+    static const char * const excp_name[EXCP_NR] = {
+        [EXCP_RESET]    = "RESET",
+        [EXCP_BUSERR]   = "BUSERR (bus error)",
+        [EXCP_DPF]      = "DFP (data protection fault)",
+        [EXCP_IPF]      = "IPF (code protection fault)",
+        [EXCP_TICK]     = "TICK (timer interrupt)",
+        [EXCP_ALIGN]    = "ALIGN",
+        [EXCP_ILLEGAL]  = "ILLEGAL",
+        [EXCP_INT]      = "INT (device interrupt)",
+        [EXCP_DTLBMISS] = "DTLBMISS (data tlb miss)",
+        [EXCP_ITLBMISS] = "ITLBMISS (code tlb miss)",
+        [EXCP_RANGE]    = "RANGE",
+        [EXCP_SYSCALL]  = "SYSCALL",
+        [EXCP_FPE]      = "FPE",
+        [EXCP_TRAP]     = "TRAP",
+    };
+    return STR_ARRAY_ELEM_OR_NULL(excp_name, excp) ?: "unknown";
+}
+
 G_NORETURN void or1k_raise_exception(OpenRISCCPU *cpu, uint32_t excp)
 {
     CPUState *cs = CPU(cpu);
target/or1k/interrupt.c +1 -18
index 6e89157639a..399c98e3881 100644
@@ -66,26 +66,9 @@ void openrisc_cpu_do_interrupt(CPUState *cs)
     }
 
     if (exception > 0 && exception < EXCP_NR) {
-        static const char * const int_name[EXCP_NR] = {
-            [EXCP_RESET]    = "RESET",
-            [EXCP_BUSERR]   = "BUSERR (bus error)",
-            [EXCP_DPF]      = "DFP (data protection fault)",
-            [EXCP_IPF]      = "IPF (code protection fault)",
-            [EXCP_TICK]     = "TICK (timer interrupt)",
-            [EXCP_ALIGN]    = "ALIGN",
-            [EXCP_ILLEGAL]  = "ILLEGAL",
-            [EXCP_INT]      = "INT (device interrupt)",
-            [EXCP_DTLBMISS] = "DTLBMISS (data tlb miss)",
-            [EXCP_ITLBMISS] = "ITLBMISS (code tlb miss)",
-            [EXCP_RANGE]    = "RANGE",
-            [EXCP_SYSCALL]  = "SYSCALL",
-            [EXCP_FPE]      = "FPE",
-            [EXCP_TRAP]     = "TRAP",
-        };
-
         qemu_log_mask(CPU_LOG_INT, "CPU: %d INT: %s\n",
                       cs->cpu_index,
-                      int_name[exception]);
+                      openrisc_excp_name(exception));
 
         hwaddr vect_pc = exception << 8;
         if (env->cpucfgr & CPUCFGR_EVBARP) {
Signature · 1 line
2.55.0
#40 lore raw

[PULL 43/83] target/rx: Unify BRK and INT trap handling

In reply to Philippe Mathieu-Daudé

BRK is equivalent to INT #0, so route both instructions through the same trap helper.

Message-ID: <[email protected]>

---
 target/rx/helper.h    |  3 +--
 target/rx/op_helper.c |  7 +------
 target/rx/translate.c | 21 ++++++++++-----------
 3 files changed, 12 insertions(+), 19 deletions(-)
target/rx/helper.h +1 -2
index b1ef843be1e..13f019ff81a 100644
@@ -2,8 +2,7 @@ DEF_HELPER_1(raise_illegal_instruction, noreturn, env)
 DEF_HELPER_1(raise_access_fault, noreturn, env)
 DEF_HELPER_1(raise_privilege_violation, noreturn, env)
 DEF_HELPER_1(wait, noreturn, env)
-DEF_HELPER_2(rxint, noreturn, env, i32)
-DEF_HELPER_1(rxbrk, noreturn, env)
+DEF_HELPER_2(trap, noreturn, env, i32)
 DEF_HELPER_3(rx_fadd, f32, env, f32, f32)
 DEF_HELPER_3(rx_fsub, f32, env, f32, f32)
 DEF_HELPER_3(rx_fmul, f32, env, f32, f32)
target/rx/op_helper.c +1 -6
index 5a7a87943fe..fb1fa4ffa69 100644
@@ -455,12 +455,7 @@ G_NORETURN void helper_wait(CPURXState *env)
     raise_exception(env, EXCP_HLT, 0);
 }
 
-G_NORETURN void helper_rxint(CPURXState *env, uint32_t vec)
+G_NORETURN void helper_trap(CPURXState *env, uint32_t vec)
 {
     raise_exception(env, 0x100 + vec, 0);
 }
-
-G_NORETURN void helper_rxbrk(CPURXState *env)
-{
-    raise_exception(env, 0x100, 0);
-}
target/rx/translate.c +10 -11
index bd445bc0634..0672c5c5653 100644
@@ -2170,26 +2170,25 @@ static bool trans_RTE(DisasContext *ctx, arg_RTE *a)
     return true;
 }
 
+static bool do_trap(DisasContext *ctx, uint8_t vec)
+{
+    tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next);
+    gen_helper_trap(tcg_env, tcg_constant_i32(vec));
+    ctx->base.is_jmp = DISAS_NORETURN;
+    return true;
+}
+
 /* brk */
 static bool trans_BRK(DisasContext *ctx, arg_BRK *a)
 {
-    tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next);
-    gen_helper_rxbrk(tcg_env);
-    ctx->base.is_jmp = DISAS_NORETURN;
-    return true;
+    return do_trap(ctx, 0);
 }
 
 /* int #imm */
 static bool trans_INT(DisasContext *ctx, arg_INT *a)
 {
-    TCGv_i32 vec;
-
     tcg_debug_assert(a->imm < 0x100);
-    vec = tcg_constant_i32(a->imm);
-    tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next);
-    gen_helper_rxint(tcg_env, vec);
-    ctx->base.is_jmp = DISAS_NORETURN;
-    return true;
+    return do_trap(ctx, a->imm);
 }
 
 /* wait */
Signature · 1 line
2.55.0
#41 lore raw

[PULL 41/83] target/ppc: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Expose powerpc_excp_name() prototype and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve PPC exception codes to names.

Message-ID: <[email protected]>

---
 target/ppc/cpu.h         | 2 ++
 target/ppc/cpu_init.c    | 1 +
 target/ppc/excp_helper.c | 5 +++--
 3 files changed, 6 insertions(+), 2 deletions(-)
target/ppc/cpu.h +2 -0
index fbffc9b3005..0f44096bad7 100644
@@ -153,6 +153,8 @@ enum {
     POWERPC_EXCP_SYSCALL_USER = 0x203, /* System call in user mode only      */
 };
 
+const char *powerpc_excp_name(int excp);
+
 /* Exceptions error codes                                                    */
 enum {
     /* Exception subtypes for POWERPC_EXCP_ALIGN                             */
target/ppc/cpu_init.c +1 -0
index 89a8b14a393..7f3036d903e 100644
@@ -7530,6 +7530,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, const void *data)
                                        &pcc->parent_phases);
 
     cc->class_by_name = ppc_cpu_class_by_name;
+    cc->exception_name = powerpc_excp_name;
     cc->list_cpus = ppc_cpu_list;
     cc->dump_state = ppc_cpu_dump_state;
     cc->set_pc = ppc_cpu_set_pc;
target/ppc/excp_helper.c +3 -2
index 4892cbaeb07..76ac41e964d 100644
@@ -34,9 +34,8 @@
 
 /*****************************************************************************/
 /* Exception processing */
-#ifndef CONFIG_USER_ONLY
 
-static const char *powerpc_excp_name(int excp)
+const char *powerpc_excp_name(int excp)
 {
     static const char * const excp_names[POWERPC_EXCP_NB] = {
         [POWERPC_EXCP_CRITICAL] = "CRITICAL",
@@ -108,6 +107,8 @@ static const char *powerpc_excp_name(int excp)
     return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
 }
 
+#ifndef CONFIG_USER_ONLY
+
 static void dump_syscall(CPUPPCState *env)
 {
     qemu_log_mask(CPU_LOG_INT, "syscall r0=%016" PRIx64
Signature · 1 line
2.55.0
#42 lore raw

[PULL 45/83] target/rx: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor rx_exception_name() out of rx_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve RX exception codes to names.

With '-d int', unlisted codes are now logged as "unknown" instead of "unknown exception".

Message-ID: <[email protected]>

---
 target/rx/cpu.h    |  1 +
 target/rx/cpu.c    |  1 +
 target/rx/helper.c | 53 ++++++++++++++++++++++++++++------------------
 3 files changed, 34 insertions(+), 21 deletions(-)
target/rx/cpu.h +1 -0
index 0d9f4898a26..06208380621 100644
@@ -147,6 +147,7 @@ struct RXCPUClass {
 #define CPU_RESOLVING_TYPE TYPE_RX_CPU
 
 const char *rx_crname(uint8_t cr);
+const char *rx_exception_name(int excp);
 void rx_cpu_do_interrupt(CPUState *cpu);
 bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);
 hwaddr rx_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
target/rx/cpu.c +1 -0
index 69946928995..44ec3c3d62f 100644
@@ -244,6 +244,7 @@ static void rx_cpu_class_init(ObjectClass *klass, const void *data)
                                        &rcc->parent_phases);
 
     cc->class_by_name = rx_cpu_class_by_name;
+    cc->exception_name = rx_exception_name;
     cc->dump_state = rx_cpu_dump_state;
     cc->set_pc = rx_cpu_set_pc;
     cc->get_pc = rx_cpu_get_pc;
target/rx/helper.c +32 -21

72 lines not on this page · raw message

Signature · 1 line
2.55.0
#43 lore raw

[PULL 42/83] target/riscv: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor riscv_excp_name() and riscv_intr_name() out of riscv_cpu_get_trap_name(). Register riscv_excp_name() as the CPUClass::exception_name() handler, so the common exception logging can resolve RISCV exception codes to names.

Message-ID: <[email protected]>

---
 target/riscv/cpu.h           |  1 +
 target/riscv/cpu.c           | 20 ++++++++++----------
 target/riscv/tcg/op_helper.c |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)
target/riscv/cpu.h +1 -0
index b65d6319940..49a1186bdbb 100644
@@ -672,6 +672,7 @@ G_NORETURN void  riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                         MMUAccessType access_type, int mmu_idx,
                         bool probe, uintptr_t retaddr);
+const char *riscv_excp_name(int excp);
 char *riscv_isa_string(RISCVCPU *cpu);
 int riscv_cpu_max_xlen(RISCVCPUClass *mcc);
 bool riscv_cpu_option_set(RISCVCPU *cpu, const char *optname);
target/riscv/cpu.c +10 -10
index f9946f54ced..ae750f85c6c 100644
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qemu/qemu-print.h"
 #include "qemu/ctype.h"
 #include "qemu/log.h"
@@ -398,6 +399,11 @@ static const char * const riscv_excp_names[] = {
     [RISCV_EXCP_SEMIHOST] = "semihost",
 };
 
+const char *riscv_excp_name(int excp)
+{
+    return STR_ARRAY_ELEM_OR_NULL(riscv_excp_names, excp) ?: "unknown";
+}
+
 static const char * const riscv_intr_names[] = {
     [IRQ_U_SOFT] = "u_software",
     [IRQ_S_SOFT] = "s_software",
@@ -417,17 +423,10 @@ static const char * const riscv_intr_names[] = {
 
 const char *riscv_cpu_get_trap_name(uint64_t cause, bool async)
 {
-    if (async) {
-        if ((cause < ARRAY_SIZE(riscv_intr_names)) && riscv_intr_names[cause]) {
-            return riscv_intr_names[cause];
-        }
-    } else {
-        if ((cause < ARRAY_SIZE(riscv_excp_names)) && riscv_excp_names[cause]) {
-            return riscv_excp_names[cause];
-        }
-    }
+    const char *name = async ? STR_ARRAY_ELEM_OR_NULL(riscv_intr_names, cause)
+                             : STR_ARRAY_ELEM_OR_NULL(riscv_excp_names, cause);
 
-    return "(unknown)";
+    return name ?: "unknown";
 }
 
 void riscv_cpu_set_misa_ext(CPURISCVState *env, uint32_t ext)
@@ -3130,6 +3129,7 @@ static void riscv_cpu_common_class_init(ObjectClass *c, const void *data)
                                        &mcc->parent_phases);
 
     cc->class_by_name = riscv_cpu_class_by_name;
+    cc->exception_name = riscv_excp_name;
     cc->dump_state = riscv_cpu_dump_state;
     cc->set_pc = riscv_cpu_set_pc;
     cc->get_pc = riscv_cpu_get_pc;
target/riscv/tcg/op_helper.c +1 -1
index b8b3e43ccd5..f85f5cd83c9 100644
@@ -41,7 +41,7 @@ G_NORETURN void riscv_raise_exception(CPURISCVState *env,
     CPUState *cs = env_cpu(env);
 
     trace_riscv_exception(exception,
-                          riscv_cpu_get_trap_name(exception, false),
+                          riscv_excp_name(exception),
                           env->pc);
 
     cs->exception_index = exception;
Signature · 1 line
2.55.0
#44 lore raw

[PULL 46/83] target/s390x: Implement and register CPUClass::exception_name()

In reply to Philippe Mathieu-Daudé

Implement s390x_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve s390x exception codes to names.

Use the new helper in s390_cpu_do_interrupt() and helper_exception().

With '-d int', s390_cpu_do_interrupt() now logs the exception name in parentheses after its number.

Message-ID: <[email protected]>

---
 target/s390x/cpu.h             |  2 ++
 target/s390x/cpu.c             |  1 +
 target/s390x/interrupt.c       | 16 ++++++++++++++++
 target/s390x/tcg/excp_helper.c |  6 ++++--
 target/s390x/tcg/misc_helper.c |  3 ++-
 5 files changed, 25 insertions(+), 3 deletions(-)
target/s390x/cpu.h +2 -0
index ef73b15218e..37b6e541312 100644
@@ -437,6 +437,8 @@ QEMU_BUILD_BUG_ON(FLAG_MASK_PER_IFETCH_NULLIFY !=
 #define EXCP_IO  7 /* I/O interrupt */
 #define EXCP_MCHK 8 /* machine check */
 
+const char *s390x_exception_name(int excp);
+
 #define INTERRUPT_EXT_CPU_TIMER          (1 << 3)
 #define INTERRUPT_EXT_CLOCK_COMPARATOR   (1 << 4)
 #define INTERRUPT_EXTERNAL_CALL          (1 << 5)
target/s390x/cpu.c +1 -0
index e7f81fabff6..d1250945d48 100644
@@ -407,6 +407,7 @@ static void s390_cpu_class_init(ObjectClass *oc, const void *data)
                                        &scc->parent_phases);
 
     cc->class_by_name = s390_cpu_class_by_name;
+    cc->exception_name = s390x_exception_name;
     cc->list_cpus = s390_cpu_list;
     cc->dump_state = s390_cpu_dump_state;
     cc->query_cpu_fast = s390_query_cpu_fast;
target/s390x/interrupt.c +16 -0
index d7e3fd45e4b..28174522944 100644
@@ -8,6 +8,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "kvm/kvm_s390x.h"
 #include "s390x-internal.h"
@@ -19,6 +20,21 @@
 #include "hw/s390x/s390_flic.h"
 #endif
 
+const char *s390x_exception_name(int excp)
+{
+    static const char * const excp_names[] = {
+        [EXCP_EXT]      = "external interrupt",
+        [EXCP_SVC]      = "supervisor call",
+        [EXCP_PGM]      = "program interruption",
+        [EXCP_RESTART]  = "restart interrupt",
+        [EXCP_STOP]     = "stop interrupt",
+        [EXCP_IO]       = "I/O interrupt",
+        [EXCP_MCHK]     = "machine check",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 /* Ensure to exit the TB after this call! */
 void trigger_pgm_exception(CPUS390XState *env, uint32_t code)
 {
target/s390x/tcg/excp_helper.c +4 -2
index d952bb20cf1..83fe65e1f8c 100644
@@ -508,8 +508,10 @@ void s390_cpu_do_interrupt(CPUState *cs)
     bool stopped = false;
     uint64_t last_pc = cpu->env.psw.addr;
 
-    qemu_log_mask(CPU_LOG_INT, "%s: %d at psw=%" PRIx64 ":%" PRIx64 "\n",
-                  __func__, cs->exception_index, env->psw.mask, env->psw.addr);
+    qemu_log_mask(CPU_LOG_INT, "%s: %d (%s) at psw=%" PRIx64 ":%" PRIx64 "\n",
+                  __func__, cs->exception_index,
+                  s390x_exception_name(cs->exception_index),
+                  env->psw.mask, env->psw.addr);
 
 try_deliver:
     /* handle machine checks */
target/s390x/tcg/misc_helper.c +2 -1
index f1c8563af00..a01c5d894e7 100644
@@ -61,7 +61,8 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp)
 {
     CPUState *cs = env_cpu(env);
 
-    HELPER_LOG("%s: exception %d\n", __func__, excp);
+    HELPER_LOG("%s: exception %d (%s)\n", __func__, excp,
+               s390x_exception_name(excp));
     cs->exception_index = excp;
     cpu_loop_exit(cs);
 }
Signature · 1 line
2.55.0
#45 lore raw

[PULL 47/83] target/sh4: Define exception vector constants

In reply to Philippe Mathieu-Daudé

From: Yonggang Luo <[email protected]>

Name SH4 exception vectors and use the definitions throughout exception handling and exception raising.

Message-ID: <[email protected]>

---
 target/sh4/cpu.h       | 21 +++++++++++++++
 target/sh4/helper.c    | 60 +++++++++++++++++++++---------------------
 target/sh4/op_helper.c | 16 +++++------
 3 files changed, 59 insertions(+), 38 deletions(-)
target/sh4/cpu.h +21 -0
index 6984bb462fb..a1e9049b7be 100644
@@ -135,6 +135,27 @@ typedef struct memory_content {
     struct memory_content *next;
 } memory_content;
 
+/* Guest trap numbers. */
+enum {
+    SH4_EXCP_RESET = 0x000,
+    SH4_EXCP_MANUAL_RESET = 0x020,
+    SH4_EXCP_TLB_MISS = 0x040,
+    SH4_EXCP_DTLB_MISS_WRITE = 0x060,
+    SH4_EXCP_INITIAL_PAGE_WRITE = 0x080,
+    SH4_EXCP_TLB_VIOLATION = 0x0a0,
+    SH4_EXCP_DTLB_VIOLATION_WRITE = 0x0c0,
+    SH4_EXCP_ADDR_ERROR = 0x0e0,
+    SH4_EXCP_DATA_WRITE = 0x100,
+    SH4_EXCP_FPU = 0x120,
+    SH4_EXCP_TLB_MULTIPLE = 0x140,
+    SH4_EXCP_TRAPA = 0x160,
+    SH4_EXCP_ILLEGAL_INSTRUCTION = 0x180,
+    SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION = 0x1a0,
+    SH4_EXCP_USER_BREAK = 0x1e0,
+    SH4_EXCP_FPU_DISABLE = 0x800,
+    SH4_EXCP_SLOT_FPU_DISABLE = 0x820,
+};
+
 typedef struct CPUArchState {
     uint32_t flags;             /* general execution flags */
     uint32_t gregs[24];         /* general registers */
target/sh4/helper.c +30 -30

138 lines not on this page · raw message

target/sh4/op_helper.c +8 -8
index 777380f8e40..8beac9ca034 100644
@@ -33,10 +33,10 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
     switch (access_type) {
     case MMU_INST_FETCH:
     case MMU_DATA_LOAD:
-        cs->exception_index = 0x0e0;
+        cs->exception_index = SH4_EXCP_ADDR_ERROR;
         break;
     case MMU_DATA_STORE:
-        cs->exception_index = 0x100;
+        cs->exception_index = SH4_EXCP_DATA_WRITE;
         break;
     default:
         g_assert_not_reached();
@@ -67,22 +67,22 @@ void raise_exception(CPUSH4State *env, int index,
 
 void helper_raise_illegal_instruction(CPUSH4State *env)
 {
-    raise_exception(env, 0x180, 0);
+    raise_exception(env, SH4_EXCP_ILLEGAL_INSTRUCTION, 0);
 }
 
 void helper_raise_slot_illegal_instruction(CPUSH4State *env)
 {
-    raise_exception(env, 0x1a0, 0);
+    raise_exception(env, SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION, 0);
 }
 
 void helper_raise_fpu_disable(CPUSH4State *env)
 {
-    raise_exception(env, 0x800, 0);
+    raise_exception(env, SH4_EXCP_FPU_DISABLE, 0);
 }
 
 void helper_raise_slot_fpu_disable(CPUSH4State *env)
 {
-    raise_exception(env, 0x820, 0);
+    raise_exception(env, SH4_EXCP_SLOT_FPU_DISABLE, 0);
 }
 
 void helper_sleep(CPUSH4State *env)
@@ -97,7 +97,7 @@ void helper_sleep(CPUSH4State *env)
 void helper_trapa(CPUSH4State *env, uint32_t tra)
 {
     env->tra = tra << 2;
-    raise_exception(env, 0x160, 0);
+    raise_exception(env, SH4_EXCP_TRAPA, 0);
 }
 
 void helper_exclusive(CPUSH4State *env)
@@ -255,7 +255,7 @@ static void update_fpscr(CPUSH4State *env, uintptr_t retaddr)
         cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT;
         enable = (env->fpscr & FPSCR_ENABLE_MASK) >> FPSCR_ENABLE_SHIFT;
         if (cause & enable) {
-            raise_exception(env, 0x120, retaddr);
+            raise_exception(env, SH4_EXCP_FPU, retaddr);
         }
     }
 }
Signature · 1 line
2.55.0
#46 lore raw

[PULL 48/83] target/sh4: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

Factor sh4_exception_name() out of superh_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve SH-4 exception codes to names.

Message-ID: <[email protected]>

---
 target/sh4/cpu.h    |   1 +
 target/sh4/cpu.c    |   1 +
 target/sh4/helper.c | 101 +++++++++++++++++++++++---------------------
 3 files changed, 56 insertions(+), 47 deletions(-)
target/sh4/cpu.h +1 -0
index a1e9049b7be..94f2f1278b9 100644
@@ -258,6 +258,7 @@ struct SuperHCPUClass {
     uint32_t cvr;
 };
 
+const char *sh4_exception_name(int excp);
 void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/sh4/cpu.c +1 -0
index 55c73a1da35..17731935779 100644
@@ -333,6 +333,7 @@ static void superh_cpu_class_init(ObjectClass *oc, const void *data)
                                        &scc->parent_phases);
 
     cc->class_by_name = superh_cpu_class_by_name;
+    cc->exception_name = sh4_exception_name;
     cc->dump_state = superh_cpu_dump_state;
     cc->set_pc = superh_cpu_set_pc;
     cc->get_pc = superh_cpu_get_pc;
target/sh4/helper.c +54 -47

113 lines not on this page · raw message

Signature · 1 line
2.55.0
#47 lore raw

[PULL 49/83] target/sh4: Use a static table in sh4_exception_name()

In reply to Philippe Mathieu-Daudé

Replace the switch statement with a static lookup table.

With '-d int', unlisted exception codes are now logged as "unknown" instead of "???".

Message-ID: <[email protected]>

---
 target/sh4/helper.c | 66 ++++++++++++++-------------------------------
 1 file changed, 20 insertions(+), 46 deletions(-)
target/sh4/helper.c +20 -46
index 5856bab6983..96465dd94fb 100644
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 
 #include "cpu.h"
 #include "exec/cputlb.h"
@@ -49,54 +50,27 @@
 
 const char *sh4_exception_name(int excp)
 {
-    const char *name;
+    /* Exception codes (EXPEVT) are multiples of 0x20 */
+    static const char * const excp_names[] = {
+        [SH4_EXCP_ADDR_ERROR >> 5]               = "addr_error",
+        [SH4_EXCP_TLB_MISS >> 5]                 = "tlb_miss",
+        [SH4_EXCP_TLB_VIOLATION >> 5]            = "tlb_violation",
+        [SH4_EXCP_ILLEGAL_INSTRUCTION >> 5]      = "illegal_instruction",
+        [SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION >> 5] = "slot_illegal_instruction",
+        [SH4_EXCP_FPU_DISABLE >> 5]              = "fpu_disable",
+        [SH4_EXCP_SLOT_FPU_DISABLE >> 5]         = "slot_fpu",
+        [SH4_EXCP_DATA_WRITE >> 5]               = "data_write",
+        [SH4_EXCP_DTLB_MISS_WRITE >> 5]          = "dtlb_miss_write",
+        [SH4_EXCP_DTLB_VIOLATION_WRITE >> 5]     = "dtlb_violation_write",
+        [SH4_EXCP_FPU >> 5]                      = "fpu_exception",
+        [SH4_EXCP_INITIAL_PAGE_WRITE >> 5]       = "initial_page_write",
+        [SH4_EXCP_TRAPA >> 5]                    = "trapa",
+    };
 
-    switch (excp) {
-    case SH4_EXCP_ADDR_ERROR:
-        name = "addr_error";
-        break;
-    case SH4_EXCP_TLB_MISS:
-        name = "tlb_miss";
-        break;
-    case SH4_EXCP_TLB_VIOLATION:
-        name = "tlb_violation";
-        break;
-    case SH4_EXCP_ILLEGAL_INSTRUCTION:
-        name = "illegal_instruction";
-        break;
-    case SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION:
-        name = "slot_illegal_instruction";
-        break;
-    case SH4_EXCP_FPU_DISABLE:
-        name = "fpu_disable";
-        break;
-    case SH4_EXCP_SLOT_FPU_DISABLE:
-        name = "slot_fpu";
-        break;
-    case SH4_EXCP_DATA_WRITE:
-        name = "data_write";
-        break;
-    case SH4_EXCP_DTLB_MISS_WRITE:
-        name = "dtlb_miss_write";
-        break;
-    case SH4_EXCP_DTLB_VIOLATION_WRITE:
-        name = "dtlb_violation_write";
-        break;
-    case SH4_EXCP_FPU:
-        name = "fpu_exception";
-        break;
-    case SH4_EXCP_INITIAL_PAGE_WRITE:
-        name = "initial_page_write";
-        break;
-    case SH4_EXCP_TRAPA:
-        name = "trapa";
-        break;
-    default:
-        name = "???";
-        break;
+    if (excp & 0x1f) {
+        return "unknown";
     }
-
-    return name;
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp >> 5) ?: "unknown";
 }
 
 #if defined(CONFIG_USER_ONLY)
Signature · 1 line
2.55.0
#48 lore raw

[PULL 50/83] target/sparc: Remove always-defined DEBUG_PCALL

In reply to Philippe Mathieu-Daudé

DEBUG_PCALL has been unconditionally defined for 14 years now (see commit b884fc5ecaa "target-sparc: Make CPU_LOG_INT useful by default"), so the #ifdef guards around the exception name table and the CPU_LOG_INT block are always taken. Remove the define and the now-redundant guards.

Message-ID: <[email protected]>

---
 target/sparc/int64_helper.c | 6 ------
 1 file changed, 6 deletions(-)
target/sparc/int64_helper.c +0 -6
index 60ab0478fc6..10341e0c282 100644
@@ -26,9 +26,6 @@
 #include "trace.h"
 #include "qemu/plugin.h"
 
-#define DEBUG_PCALL
-
-#ifdef DEBUG_PCALL
 static const char * const excp_names[0x80] = {
     [TT_TFAULT] = "Instruction Access Fault",
     [TT_TMISS] = "Instruction Access MMU Miss",
@@ -62,7 +59,6 @@ static const char * const excp_names[0x80] = {
     [TT_EXTINT | 0xe] = "External Interrupt 14",
     [TT_EXTINT | 0xf] = "External Interrupt 15",
 };
-#endif
 
 #if !defined(CONFIG_USER_ONLY)
 void cpu_check_irqs(CPUSPARCState *env)
@@ -138,7 +134,6 @@ void sparc_cpu_do_interrupt(CPUState *cs)
     int intno = cs->exception_index;
     trap_state *tsptr;
 
-#ifdef DEBUG_PCALL
     if (qemu_loglevel_mask(CPU_LOG_INT)) {
         static int count;
         const char *name;
@@ -177,7 +172,6 @@ void sparc_cpu_do_interrupt(CPUState *cs)
 #endif
         count++;
     }
-#endif
 #if !defined(CONFIG_USER_ONLY)
     if (env->tl >= env->maxtl) {
         cpu_abort(cs, "Trap 0x%04x while trap level (%d) >= MAXTL (%d),"
Signature · 1 line
2.55.0
#49 lore raw

[PULL 53/83] target/alpha: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert alpha to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/alpha/cpu.h    |  3 ++-
 target/alpha/cpu.c    |  2 +-
 target/alpha/helper.c | 15 +++++++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)
target/alpha/cpu.h +2 -1
index 8f780502476..5b2280c6095 100644
@@ -282,7 +282,8 @@ extern const VMStateDescription vmstate_alpha_cpu;
 
 void alpha_cpu_do_interrupt(CPUState *cpu);
 bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool alpha_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                   TranslateForDebugResult *result);
 #endif /* !CONFIG_USER_ONLY */
 const char *alpha_exception_name(int exception);
 void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
target/alpha/cpu.c +1 -1
index 6e514dcf4cd..fd099c8e70f 100644
@@ -242,7 +242,7 @@ static void alpha_cpu_initfn(Object *obj)
 
 static const struct SysemuCPUOps alpha_sysemu_ops = {
     .has_work = alpha_cpu_has_work,
-    .get_phys_addr_debug = alpha_cpu_get_phys_addr_debug,
+    .translate_for_debug = alpha_cpu_translate_for_debug,
 };
 #endif
 
target/alpha/helper.c +13 -2
index 84997ef3a99..d59ecc0d4a9 100644
@@ -317,14 +317,25 @@ static int get_physical_address(CPUAlphaState *env, vaddr addr,
     return ret;
 }
 
-hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool alpha_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                   TranslateForDebugResult *result)
 {
     hwaddr phys;
     int prot, fail;
 
     fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot);
+    if (fail >= 0) {
+        return false;
+    }
+
     phys |= addr & ~TARGET_PAGE_MASK;
-    return (fail >= 0 ? -1 : phys);
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
Signature · 1 line
2.55.0
#50 lore raw

[PULL 51/83] target/sparc: Register CPUClass::exception_name() handler

In reply to Philippe Mathieu-Daudé

For each SPARC / SPARC64 target:
factor sparc_exception_name() out of sparc_cpu_do_interrupt() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve SPARC exception codes to names.

With '-d int', unlisted codes are now logged as "unknown" instead of "Unknown". On SPARC, the "Error state" abort message now names trap instructions (0x80-0xff) instead of calling them "Unknown". On SPARC64, trap 0x1ff is now named "Hyperprivileged Trap Instruction"; it was "Unknown" because of an off-by-one in the former range check.

Message-ID: <[email protected]>

---
 target/sparc/cpu.h          |  1 +
 target/sparc/cpu.c          |  1 +
 target/sparc/int32_helper.c | 22 ++++++++--------------
 target/sparc/int64_helper.c | 36 ++++++++++++++++++------------------
 4 files changed, 28 insertions(+), 32 deletions(-)
target/sparc/cpu.h +1 -0
index 31a16c2af03..3c1ba223eb2 100644
@@ -583,6 +583,7 @@ extern const VMStateDescription vmstate_sparc_cpu;
 hwaddr sparc_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
 #endif
 
+const char *sparc_exception_name(int excp);
 void sparc_cpu_do_interrupt(CPUState *cpu);
 int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/sparc/cpu.c +1 -0
index 1529f9570da..3c71f60bb4f 100644
@@ -1097,6 +1097,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
                                        &scc->parent_phases);
 
     cc->class_by_name = sparc_cpu_class_by_name;
+    cc->exception_name = sparc_exception_name;
     cc->list_cpus = sparc_cpu_list,
     cc->parse_features = sparc_cpu_parse_features;
     cc->dump_state = sparc_cpu_dump_state;
target/sparc/int32_helper.c +8 -14
index d6bb3fa1e54..03ed5dffc9d 100644
@@ -19,6 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/main-loop.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "trace.h"
 #include "accel/tcg/cpu-ldst.h"
@@ -58,12 +59,12 @@ static const char * const excp_names[0x80] = {
     [TT_NCP_INSN] = "Coprocessor Disabled",
 };
 
-static const char *excp_name_str(int32_t exception_index)
+const char *sparc_exception_name(int excp)
 {
-    if (exception_index < 0 || exception_index >= ARRAY_SIZE(excp_names)) {
-        return "Unknown";
+    if (excp >= 0x80 && excp < 0x100) {
+        return "Trap Instruction";
     }
-    return excp_names[exception_index];
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
 }
 
 #if !defined(CONFIG_USER_ONLY)
@@ -107,15 +108,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
 
     if (qemu_loglevel_mask(CPU_LOG_INT)) {
         static int count;
-        const char *name;
-
-        if (intno < 0 || intno >= 0x100) {
-            name = "Unknown";
-        } else if (intno >= 0x80) {
-            name = "Trap Instruction";
-        } else {
-            name = excp_name_str(intno);
-        }
+        const char *name = sparc_exception_name(intno);
 
         qemu_log("%6d: %s (v=%02x)\n", count, name, intno);
         log_cpu_state(cs, 0);
@@ -129,7 +122,8 @@ void sparc_cpu_do_interrupt(CPUState *cs)
         } else {
             cpu_abort(cs, "Trap 0x%02x (%s) while interrupts disabled, "
                           "Error state",
-                      cs->exception_index, excp_name_str(cs->exception_index));
+                      cs->exception_index,
+                      sparc_exception_name(cs->exception_index));
         }
         return;
     }
target/sparc/int64_helper.c +18 -18
index 10341e0c282..849b1a436b2 100644
@@ -18,6 +18,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qemu/main-loop.h"
 #include "cpu.h"
 #include "exec/cpu-common.h"
@@ -60,6 +61,22 @@ static const char * const excp_names[0x80] = {
     [TT_EXTINT | 0xf] = "External Interrupt 15",
 };
 
+const char *sparc_exception_name(int excp)
+{
+    if (excp < 0 || excp >= 0x200) {
+        return "unknown";
+    } else if (excp >= 0x180) {
+        return "Hyperprivileged Trap Instruction";
+    } else if (excp >= 0x100) {
+        return "Trap Instruction";
+    } else if (excp >= 0xc0) {
+        return "Window Fill";
+    } else if (excp >= 0x80) {
+        return "Window Spill";
+    }
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 #if !defined(CONFIG_USER_ONLY)
 void cpu_check_irqs(CPUSPARCState *env)
 {
@@ -136,24 +153,7 @@ void sparc_cpu_do_interrupt(CPUState *cs)
 
     if (qemu_loglevel_mask(CPU_LOG_INT)) {
         static int count;
-        const char *name;
-
-        if (intno < 0 || intno >= 0x1ff) {
-            name = "Unknown";
-        } else if (intno >= 0x180) {
-            name = "Hyperprivileged Trap Instruction";
-        } else if (intno >= 0x100) {
-            name = "Trap Instruction";
-        } else if (intno >= 0xc0) {
-            name = "Window Fill";
-        } else if (intno >= 0x80) {
-            name = "Window Spill";
-        } else {
-            name = excp_names[intno];
-            if (!name) {
-                name = "Unknown";
-            }
-        }
+        const char *name = sparc_exception_name(intno);
 
         qemu_log("%6d: %s (v=%04x)\n", count, name, intno);
         log_cpu_state(cs, 0);
Signature · 1 line
2.55.0
#51 lore raw

[PULL 40/83] target/ppc: Use a static table in powerpc_excp_name()

In reply to Philippe Mathieu-Daudé

Replace the switch statement with a static lookup table.

Unlisted exception codes now return "unknown" instead of reaching g_assert_not_reached(), so with '-d int' they are logged instead of aborting QEMU. Do this before registering the function as the CPUClass::exception_name() handler, which must accept any code.

Message-ID: <[email protected]>

---
 target/ppc/excp_helper.c | 137 ++++++++++++++++++++-------------------
 1 file changed, 69 insertions(+), 68 deletions(-)
target/ppc/excp_helper.c +69 -68
index 895127fb2e6..4892cbaeb07 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 #include "qemu/main-loop.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 #include "system/memory.h"
 #include "system/tcg.h"
 #include "system/system.h"
@@ -37,74 +38,74 @@
 
 static const char *powerpc_excp_name(int excp)
 {
-    switch (excp) {
-    case POWERPC_EXCP_CRITICAL: return "CRITICAL";
-    case POWERPC_EXCP_MCHECK:   return "MCHECK";
-    case POWERPC_EXCP_DSI:      return "DSI";
-    case POWERPC_EXCP_ISI:      return "ISI";
-    case POWERPC_EXCP_EXTERNAL: return "EXTERNAL";
-    case POWERPC_EXCP_ALIGN:    return "ALIGN";
-    case POWERPC_EXCP_PROGRAM:  return "PROGRAM";
-    case POWERPC_EXCP_FPU:      return "FPU";
-    case POWERPC_EXCP_SYSCALL:  return "SYSCALL";
-    case POWERPC_EXCP_APU:      return "APU";
-    case POWERPC_EXCP_DECR:     return "DECR";
-    case POWERPC_EXCP_FIT:      return "FIT";
-    case POWERPC_EXCP_WDT:      return "WDT";
-    case POWERPC_EXCP_DTLB:     return "DTLB";
-    case POWERPC_EXCP_ITLB:     return "ITLB";
-    case POWERPC_EXCP_DEBUG:    return "DEBUG";
-    case POWERPC_EXCP_SPEU:     return "SPEU";
-    case POWERPC_EXCP_EFPDI:    return "EFPDI";
-    case POWERPC_EXCP_EFPRI:    return "EFPRI";
-    case POWERPC_EXCP_EPERFM:   return "EPERFM";
-    case POWERPC_EXCP_DOORI:    return "DOORI";
-    case POWERPC_EXCP_DOORCI:   return "DOORCI";
-    case POWERPC_EXCP_GDOORI:   return "GDOORI";
-    case POWERPC_EXCP_GDOORCI:  return "GDOORCI";
-    case POWERPC_EXCP_HYPPRIV:  return "HYPPRIV";
-    case POWERPC_EXCP_RESET:    return "RESET";
-    case POWERPC_EXCP_DSEG:     return "DSEG";
-    case POWERPC_EXCP_ISEG:     return "ISEG";
-    case POWERPC_EXCP_HDECR:    return "HDECR";
-    case POWERPC_EXCP_TRACE:    return "TRACE";
-    case POWERPC_EXCP_HDSI:     return "HDSI";
-    case POWERPC_EXCP_HISI:     return "HISI";
-    case POWERPC_EXCP_HDSEG:    return "HDSEG";
-    case POWERPC_EXCP_HISEG:    return "HISEG";
-    case POWERPC_EXCP_VPU:      return "VPU";
-    case POWERPC_EXCP_PIT:      return "PIT";
-    case POWERPC_EXCP_EMUL:     return "EMUL";
-    case POWERPC_EXCP_IFTLB:    return "IFTLB";
-    case POWERPC_EXCP_DLTLB:    return "DLTLB";
-    case POWERPC_EXCP_DSTLB:    return "DSTLB";
-    case POWERPC_EXCP_FPA:      return "FPA";
-    case POWERPC_EXCP_DABR:     return "DABR";
-    case POWERPC_EXCP_IABR:     return "IABR";
-    case POWERPC_EXCP_SMI:      return "SMI";
-    case POWERPC_EXCP_PERFM:    return "PERFM";
-    case POWERPC_EXCP_THERM:    return "THERM";
-    case POWERPC_EXCP_VPUA:     return "VPUA";
-    case POWERPC_EXCP_SOFTP:    return "SOFTP";
-    case POWERPC_EXCP_MAINT:    return "MAINT";
-    case POWERPC_EXCP_MEXTBR:   return "MEXTBR";
-    case POWERPC_EXCP_NMEXTBR:  return "NMEXTBR";
-    case POWERPC_EXCP_ITLBE:    return "ITLBE";
-    case POWERPC_EXCP_DTLBE:    return "DTLBE";
-    case POWERPC_EXCP_VSXU:     return "VSXU";
-    case POWERPC_EXCP_FU:       return "FU";
-    case POWERPC_EXCP_HV_EMU:   return "HV_EMU";
-    case POWERPC_EXCP_HV_MAINT: return "HV_MAINT";
-    case POWERPC_EXCP_HV_FU:    return "HV_FU";
-    case POWERPC_EXCP_SDOOR:    return "SDOOR";
-    case POWERPC_EXCP_SDOOR_HV: return "SDOOR_HV";
-    case POWERPC_EXCP_HVIRT:    return "HVIRT";
-    case POWERPC_EXCP_SYSCALL_VECTORED: return "SYSCALL_VECTORED";
-    case POWERPC_EXCP_PERFM_EBB: return "PERFM_EBB";
-    case POWERPC_EXCP_EXTERNAL_EBB: return "EXTERNAL_EBB";
-    default:
-        g_assert_not_reached();
-    }
+    static const char * const excp_names[POWERPC_EXCP_NB] = {
+        [POWERPC_EXCP_CRITICAL] = "CRITICAL",
+        [POWERPC_EXCP_MCHECK]   = "MCHECK",
+        [POWERPC_EXCP_DSI]      = "DSI",
+        [POWERPC_EXCP_ISI]      = "ISI",
+        [POWERPC_EXCP_EXTERNAL] = "EXTERNAL",
+        [POWERPC_EXCP_ALIGN]    = "ALIGN",
+        [POWERPC_EXCP_PROGRAM]  = "PROGRAM",
+        [POWERPC_EXCP_FPU]      = "FPU",
+        [POWERPC_EXCP_SYSCALL]  = "SYSCALL",
+        [POWERPC_EXCP_APU]      = "APU",
+        [POWERPC_EXCP_DECR]     = "DECR",
+        [POWERPC_EXCP_FIT]      = "FIT",
+        [POWERPC_EXCP_WDT]      = "WDT",
+        [POWERPC_EXCP_DTLB]     = "DTLB",
+        [POWERPC_EXCP_ITLB]     = "ITLB",
+        [POWERPC_EXCP_DEBUG]    = "DEBUG",
+        [POWERPC_EXCP_SPEU]     = "SPEU",
+        [POWERPC_EXCP_EFPDI]    = "EFPDI",
+        [POWERPC_EXCP_EFPRI]    = "EFPRI",
+        [POWERPC_EXCP_EPERFM]   = "EPERFM",
+        [POWERPC_EXCP_DOORI]    = "DOORI",
+        [POWERPC_EXCP_DOORCI]   = "DOORCI",
+        [POWERPC_EXCP_GDOORI]   = "GDOORI",
+        [POWERPC_EXCP_GDOORCI]  = "GDOORCI",
+        [POWERPC_EXCP_HYPPRIV]  = "HYPPRIV",
+        [POWERPC_EXCP_RESET]    = "RESET",
+        [POWERPC_EXCP_DSEG]     = "DSEG",
+        [POWERPC_EXCP_ISEG]     = "ISEG",
+        [POWERPC_EXCP_HDECR]    = "HDECR",
+        [POWERPC_EXCP_TRACE]    = "TRACE",
+        [POWERPC_EXCP_HDSI]     = "HDSI",
+        [POWERPC_EXCP_HISI]     = "HISI",
+        [POWERPC_EXCP_HDSEG]    = "HDSEG",
+        [POWERPC_EXCP_HISEG]    = "HISEG",
+        [POWERPC_EXCP_VPU]      = "VPU",
+        [POWERPC_EXCP_PIT]      = "PIT",
+        [POWERPC_EXCP_EMUL]     = "EMUL",
+        [POWERPC_EXCP_IFTLB]    = "IFTLB",
+        [POWERPC_EXCP_DLTLB]    = "DLTLB",
+        [POWERPC_EXCP_DSTLB]    = "DSTLB",
+        [POWERPC_EXCP_FPA]      = "FPA",
+        [POWERPC_EXCP_DABR]     = "DABR",
+        [POWERPC_EXCP_IABR]     = "IABR",
+        [POWERPC_EXCP_SMI]      = "SMI",
+        [POWERPC_EXCP_PERFM]    = "PERFM",
+        [POWERPC_EXCP_THERM]    = "THERM",
+        [POWERPC_EXCP_VPUA]     = "VPUA",
+        [POWERPC_EXCP_SOFTP]    = "SOFTP",
+        [POWERPC_EXCP_MAINT]    = "MAINT",
+        [POWERPC_EXCP_MEXTBR]   = "MEXTBR",
+        [POWERPC_EXCP_NMEXTBR]  = "NMEXTBR",
+        [POWERPC_EXCP_ITLBE]    = "ITLBE",
+        [POWERPC_EXCP_DTLBE]    = "DTLBE",
+        [POWERPC_EXCP_VSXU]     = "VSXU",
+        [POWERPC_EXCP_FU]       = "FU",
+        [POWERPC_EXCP_HV_EMU]   = "HV_EMU",
+        [POWERPC_EXCP_HV_MAINT] = "HV_MAINT",
+        [POWERPC_EXCP_HV_FU]    = "HV_FU",
+        [POWERPC_EXCP_SDOOR]    = "SDOOR",
+        [POWERPC_EXCP_SDOOR_HV] = "SDOOR_HV",
+        [POWERPC_EXCP_HVIRT]    = "HVIRT",
+        [POWERPC_EXCP_SYSCALL_VECTORED] = "SYSCALL_VECTORED",
+        [POWERPC_EXCP_PERFM_EBB]        = "PERFM_EBB",
+        [POWERPC_EXCP_EXTERNAL_EBB]     = "EXTERNAL_EBB",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
 }
 
 static void dump_syscall(CPUPPCState *env)
Signature · 1 line
2.55.0
#52 lore raw

[PULL 58/83] target/alpha: Record masked exceptions in FPCR for /S insns

In reply to Philippe Mathieu-Daudé

From: Matt Turner <[email protected]>

The trap qualifiers (/U, /V, /I) control whether an exception traps, but EV6 still records every exception in the FPCR status bits. Commit 471d493047 ("target-alpha: Set fpcr_exc_status even for disabled exceptions") made helper_fp_exc_raise follow this, but in helper_fp_exc_raise_s it only added a second "exc &= ~ignore" and left the mask in the initializer, so for insns with software completion the masked exceptions still never reached env->fpcr.

The most visible effect is on inexact: the IEEE-mode code generated by gcc -mieee (e.g. ADDT/SU, DIVT/SUD) has no /I qualifier, so FE_INEXACT was never set. Many of glibc's math tests fail because of that, and the narrowing functions such as f32addf64 return results 1ulp off because their round-to-odd step depends on inexact.

Record all exceptions first and only then apply the ignore mask, as helper_fp_exc_raise does. Which exceptions trap is unchanged.

Fixes 471d493047 ("target-alpha: Set fpcr_exc_status even for disabled exceptions")

Message-ID: <[email protected]>

---
 target/alpha/fpu_helper.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
target/alpha/fpu_helper.c +9 -1
index 529eadca9f2..643ce641e83 100644
@@ -86,9 +86,17 @@ void helper_fp_exc_raise(CPUAlphaState *env, uint32_t ignore, uint32_t regno)
 /* Raise exceptions for ieee fp insns with software completion.  */
 void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)
 {
-    uint32_t exc = env->error_code & ~ignore;
+    uint32_t exc = env->error_code;
     if (exc) {
+        /*
+         * The qualifiers can suppress the raising of exceptions,
+         * but real hardware still records that they occurred.
+         */
         env->fpcr |= exc;
+        exc &= ~ignore;
+        if (!exc) {
+            return;
+        }
         exc &= env->fpcr_exc_enable;
         /*
          * In system mode, the software handler gets invoked
Signature · 1 line
2.55.0
#53 lore raw

[PULL 52/83] target/xtensa: Implement and register CPUClass::exception_name()

In reply to Philippe Mathieu-Daudé

Implement xtensa_exception_name() and register it as the CPUClass::exception_name() handler, so the common exception logging can resolve Xtensa exception codes to names.

Use the new helper in xtensa_cpu_do_interrupt().

With '-d int', xtensa_cpu_do_interrupt() now logs the exception name after its number.

Message-ID: <[email protected]>

---
 target/xtensa/cpu.h        |  2 ++
 target/xtensa/cpu.c        | 24 ++++++++++++++++++++++++
 target/xtensa/exc_helper.c |  3 ++-
 3 files changed, 28 insertions(+), 1 deletion(-)
target/xtensa/cpu.h +2 -0
index 49d6ad9083d..3440c27862b 100644
@@ -262,6 +262,8 @@ enum {
     EXC_MAX
 };
 
+const char *xtensa_exception_name(int excp);
+
 enum {
     ILLEGAL_INSTRUCTION_CAUSE = 0,
     SYSCALL_CAUSE,
target/xtensa/cpu.c +24 -0
index 99c8bd4b5fb..c193396928f 100644
@@ -29,6 +29,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "exec/cpu-defs.h"
 #include "cpu.h"
@@ -239,6 +240,28 @@ static void xtensa_cpu_disas_set_info(const CPUState *cs,
                                      : BFD_ENDIAN_LITTLE;
 }
 
+const char *xtensa_exception_name(int excp)
+{
+    static const char * const excp_names[] = {
+        [EXC_RESET0]                = "reset",
+        [EXC_RESET1]                = "reset",
+        [EXC_MEMORY_ERROR]          = "memory error",
+        [EXC_WINDOW_OVERFLOW4]      = "window overflow",
+        [EXC_WINDOW_UNDERFLOW4]     = "window underflow",
+        [EXC_WINDOW_OVERFLOW8]      = "window overflow",
+        [EXC_WINDOW_UNDERFLOW8]     = "window underflow",
+        [EXC_WINDOW_OVERFLOW12]     = "window overflow",
+        [EXC_WINDOW_UNDERFLOW12]    = "window underflow",
+        [EXC_IRQ]                   = "interrupt",
+        [EXC_KERNEL]                = "kernel",
+        [EXC_USER]                  = "user",
+        [EXC_DOUBLE]                = "double",
+        [EXC_DEBUG]                 = "debug",
+    };
+
+    return STR_ARRAY_ELEM_OR_NULL(excp_names, excp) ?: "unknown";
+}
+
 static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
 {
     CPUState *cs = CPU(dev);
@@ -347,6 +370,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, const void *data)
                                        &xcc->parent_phases);
 
     cc->class_by_name = xtensa_cpu_class_by_name;
+    cc->exception_name = xtensa_exception_name;
     cc->dump_state = xtensa_cpu_dump_state;
     cc->set_pc = xtensa_cpu_set_pc;
     cc->get_pc = xtensa_cpu_get_pc;
target/xtensa/exc_helper.c +2 -1
index 7cb67d179a8..ff71e5d6462 100644
@@ -236,9 +236,10 @@ void xtensa_cpu_do_interrupt(CPUState *cs)
     case EXC_USER:
     case EXC_DOUBLE:
     case EXC_DEBUG:
-        qemu_log_mask(CPU_LOG_INT, "%s(%d) "
+        qemu_log_mask(CPU_LOG_INT, "%s(%d:%s) "
                       "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
                       __func__, cs->exception_index,
+                      xtensa_exception_name(cs->exception_index),
                       env->pc, env->regs[0], env->sregs[PS],
                       env->sregs[CCOUNT]);
         if (env->config->exception_vector[cs->exception_index]) {
Signature · 1 line
2.55.0
#54 lore raw

[PULL 59/83] target/alpha: Determine tininess from the delivered result

In reply to Philippe Mathieu-Daudé

From: Matt Turner <[email protected]>

Alpha raises underflow only if the result it delivers is tiny. softfloat implements IEEE 754 tininess after rounding, which rounds as if the exponent range were unbounded. The two disagree about a result that rounds up to the smallest normal:

0x4p-1024 / 0x1.0000000000001p+0 in FE_UPWARD = 0x4p-1024

The binade below DBL_MIN has a finer spacing than the denormals, so with an unbounded exponent the quotient rounds to a value below DBL_MIN and softfloat raises underflow. Alpha does not. glibc marks math/test-float32x-float64-div as XFAIL on Alpha because of this (glibc commit a32db99a38), and under qemu that test unexpectedly passes.

Every result that is tiny by Alpha's rule is also tiny by the IEEE one, so there is no need for another tininess mode in softfloat. Pass soft_to_fpcr_exc whether the delivered result is normal, and drop underflow when it is. Only the S and T format add, sub, mul, div and cvtts helpers can underflow; the rest pass false.

An insn with a denormal operand is different. Unless DNZ is set it traps for software completion and the kernel computes the result, and the kernel's emulation raises underflow in the same situation:

0x3.ffffffffffffcp-1024 / 0x1.fffffffffffffp-1 in FE_UPWARD

    = 0x4p-1024, FPCR_UNF set

That result is tiny whether tininess is detected before rounding, as math-emu does, or after rounding, as softfloat does. linux-user computes these results in the helper instead of trapping, so keep softfloat's underflow when float_flag_input_denormal_used is set. That check is for CONFIG_USER_ONLY only: in system mode gen_ieee_input raises the trap before the helper runs, and with DNZ set the operand is flushed rather than used.

Message-ID: <[email protected]>

---
 target/alpha/fpu_helper.c | 60 ++++++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 20 deletions(-)
target/alpha/fpu_helper.c +40 -20
index 643ce641e83..e91e907c215 100644
@@ -38,7 +38,11 @@ void helper_setflushzero(CPUAlphaState *env, uint32_t val)
 #define CONVERT_BIT(X, SRC, DST) \
     (SRC > DST ? (X) / (SRC / DST) & (DST) : ((X) & SRC) * (DST / SRC))
 
-static uint32_t soft_to_fpcr_exc(CPUAlphaState *env)
+/*
+ * NORMAL is whether the delivered result is normal.  Operations that
+ * cannot underflow pass false.
+ */
+static uint32_t soft_to_fpcr_exc(CPUAlphaState *env, bool normal)
 {
     FloatExceptionFlags exc = get_float_exception_flags(&FP_STATUS);
     uint32_t ret = 0;
@@ -48,8 +52,24 @@ static uint32_t soft_to_fpcr_exc(CPUAlphaState *env)
         ret |= CONVERT_BIT(exc, float_flag_invalid, FPCR_INV);
         ret |= CONVERT_BIT(exc, float_flag_divbyzero, FPCR_DZE);
         ret |= CONVERT_BIT(exc, float_flag_overflow, FPCR_OVF);
-        ret |= CONVERT_BIT(exc, float_flag_underflow, FPCR_UNF);
         ret |= CONVERT_BIT(exc, float_flag_inexact, FPCR_INE);
+
+        /*
+         * Alpha raises no underflow when the delivered result is normal.
+         * softfloat does when that result was rounded up to the smallest
+         * normal, so drop it.  In user mode, a denormal operand means the
+         * result is the one the kernel's software completion would compute,
+         * and that does raise underflow.
+         */
+        if (exc & float_flag_underflow) {
+            bool tiny = !normal;
+#ifdef CONFIG_USER_ONLY
+            tiny |= exc & float_flag_input_denormal_used;
+#endif
+            if (tiny) {
+                ret |= FPCR_UNF;
+            }
+        }
     }
 
     return ret;
@@ -227,7 +247,7 @@ uint64_t helper_adds(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = s_to_float32(a);
     fb = s_to_float32(b);
     fr = float32_add(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float32_is_normal(fr));
 
     return float32_to_s(fr);
 }
@@ -239,7 +259,7 @@ uint64_t helper_subs(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = s_to_float32(a);
     fb = s_to_float32(b);
     fr = float32_sub(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float32_is_normal(fr));
 
     return float32_to_s(fr);
 }
@@ -251,7 +271,7 @@ uint64_t helper_muls(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = s_to_float32(a);
     fb = s_to_float32(b);
     fr = float32_mul(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float32_is_normal(fr));
 
     return float32_to_s(fr);
 }
@@ -263,7 +283,7 @@ uint64_t helper_alpha_divs(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = s_to_float32(a);
     fb = s_to_float32(b);
     fr = float32_div(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float32_is_normal(fr));
 
     return float32_to_s(fr);
 }
@@ -274,7 +294,7 @@ uint64_t helper_sqrts(CPUAlphaState *env, uint64_t a)
 
     fa = s_to_float32(a);
     fr = float32_sqrt(fa, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return float32_to_s(fr);
 }
@@ -304,7 +324,7 @@ uint64_t helper_addt(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = t_to_float64(a);
     fb = t_to_float64(b);
     fr = float64_add(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float64_is_normal(fr));
 
     return float64_to_t(fr);
 }
@@ -316,7 +336,7 @@ uint64_t helper_subt(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = t_to_float64(a);
     fb = t_to_float64(b);
     fr = float64_sub(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float64_is_normal(fr));
 
     return float64_to_t(fr);
 }
@@ -328,7 +348,7 @@ uint64_t helper_mult(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = t_to_float64(a);
     fb = t_to_float64(b);
     fr = float64_mul(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float64_is_normal(fr));
 
     return float64_to_t(fr);
 }
@@ -340,7 +360,7 @@ uint64_t helper_divt(CPUAlphaState *env, uint64_t a, uint64_t b)
     fa = t_to_float64(a);
     fb = t_to_float64(b);
     fr = float64_div(fa, fb, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float64_is_normal(fr));
 
     return float64_to_t(fr);
 }
@@ -351,7 +371,7 @@ uint64_t helper_sqrtt(CPUAlphaState *env, uint64_t a)
 
     fa = t_to_float64(a);
     fr = float64_sqrt(fa, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return float64_to_t(fr);
 }
@@ -368,7 +388,7 @@ uint64_t helper_cmptun(CPUAlphaState *env, uint64_t a, uint64_t b)
     if (float64_unordered_quiet(fa, fb, &FP_STATUS)) {
         ret = 0x4000000000000000ULL;
     }
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return ret;
 }
@@ -384,7 +404,7 @@ uint64_t helper_cmpteq(CPUAlphaState *env, uint64_t a, uint64_t b)
     if (float64_eq_quiet(fa, fb, &FP_STATUS)) {
         ret = 0x4000000000000000ULL;
     }
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return ret;
 }
@@ -400,7 +420,7 @@ uint64_t helper_cmptle(CPUAlphaState *env, uint64_t a, uint64_t b)
     if (float64_le(fa, fb, &FP_STATUS)) {
         ret = 0x4000000000000000ULL;
     }
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return ret;
 }
@@ -416,7 +436,7 @@ uint64_t helper_cmptlt(CPUAlphaState *env, uint64_t a, uint64_t b)
     if (float64_lt(fa, fb, &FP_STATUS)) {
         ret = 0x4000000000000000ULL;
     }
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return ret;
 }
@@ -429,7 +449,7 @@ uint64_t helper_cvtts(CPUAlphaState *env, uint64_t a)
 
     fa = t_to_float64(a);
     fr = float64_to_float32(fa, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, float32_is_normal(fr));
 
     return float32_to_s(fr);
 }
@@ -441,7 +461,7 @@ uint64_t helper_cvtst(CPUAlphaState *env, uint64_t a)
 
     fa = s_to_float32(a);
     fr = float32_to_float64(fa, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return float64_to_t(fr);
 }
@@ -449,7 +469,7 @@ uint64_t helper_cvtst(CPUAlphaState *env, uint64_t a)
 uint64_t helper_cvtqs(CPUAlphaState *env, uint64_t a)
 {
     float32 fr = int64_to_float32(a, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
 
     return float32_to_s(fr);
 }
@@ -504,7 +524,7 @@ uint64_t helper_cvttq_c(CPUAlphaState *env, uint64_t a)
 uint64_t helper_cvtqt(CPUAlphaState *env, uint64_t a)
 {
     float64 fr = int64_to_float64(a, &FP_STATUS);
-    env->error_code = soft_to_fpcr_exc(env);
+    env->error_code = soft_to_fpcr_exc(env, false);
     return float64_to_t(fr);
 }
 
Signature · 1 line
2.55.0
#55 lore raw

[PULL 61/83] target/arm: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/arm/tcg/vec_internal.h |   5 +-
 target/arm/tcg/helper-a64.c   |   6 +-
 target/arm/tcg/mve_helper.c   |  28 +++----
 target/arm/tcg/psci.c         |   2 +-
 target/arm/tcg/sme_helper.c   |   4 +-
 target/arm/tcg/sve_helper.c   | 141 +++++++++++++++++-----------------
 target/arm/tcg/tlb_helper.c   |   2 +-
 target/arm/tcg/vec_helper.c   |  72 ++++++++---------
 target/arm/tcg/vec_helper64.c |  64 +++++++--------
 9 files changed, 163 insertions(+), 161 deletions(-)
target/arm/tcg/vec_internal.h +3 -2
index 8f6d8a984b3..6d9d7c35efa 100644
@@ -22,6 +22,7 @@
 
 #include "fpu/softfloat.h"
 #include "vector-type.h"
+#include "exec/helper-head.h.inc"
 
 typedef struct CPUArchState CPUARMState;
 
@@ -364,8 +365,8 @@ static inline float64 float64_maybe_ah_chs(float64 a, bool fpcr_ah)
 }
 
 /* Not actually called directly as a helper, but uses similar machinery. */
-bfloat16 helper_sme2_ah_fmax_b16(bfloat16 a, bfloat16 b, float_status *fpst);
-bfloat16 helper_sme2_ah_fmin_b16(bfloat16 a, bfloat16 b, float_status *fpst);
+bfloat16 HELPER(sme2_ah_fmax_b16)(bfloat16 a, bfloat16 b, float_status *fpst);
+bfloat16 HELPER(sme2_ah_fmin_b16)(bfloat16 a, bfloat16 b, float_status *fpst);
 
 float32 sve_f16_to_f32(float16 f, float_status *fpst);
 float16 sve_f32_to_f16(float32 f, float_status *fpst);
target/arm/tcg/helper-a64.c +3 -3
index f76d89990c3..fdfa220574f 100644
@@ -707,7 +707,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
         } else {
             env->regs[15] = new_pc & ~0x3;
         }
-        helper_rebuild_hflags_a32(env, new_el);
+        HELPER(rebuild_hflags_a32)(env, new_el);
         qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to "
                       "AArch32 EL%d PC 0x%" PRIx32 "\n",
                       cur_el, new_el, env->regs[15]);
@@ -721,7 +721,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
             env->pstate &= ~PSTATE_SS;
         }
         aarch64_restore_sp(env, new_el);
-        helper_rebuild_hflags_a64(env, new_el);
+        HELPER(rebuild_hflags_a64)(env, new_el);
 
         /*
          * Apply TBI to the exception return address.  We had to delay this
@@ -777,7 +777,7 @@ illegal_return:
     if (!arm_singlestep_active(env)) {
         env->pstate &= ~PSTATE_SS;
     }
-    helper_rebuild_hflags_a64(env, cur_el);
+    HELPER(rebuild_hflags_a64)(env, cur_el);
     qemu_log_mask(LOG_GUEST_ERROR, "Illegal exception return at EL%d: "
                   "resuming execution at 0x%" PRIx64 "\n", cur_el, env->pc);
 }
target/arm/tcg/mve_helper.c +14 -14
index 09ae2334167..4a8e0b210e6 100644
@@ -3310,14 +3310,14 @@ DO_VCMP_FP_BOTH(vfcmples, vfcmple_scalars, 4, float32, !DO_GT32)
         mve_advance_vpt(env);                                           \
     }
 
-DO_VCVT_FIXED(vcvt_sh, 2, int16_t, helper_vfp_shtoh)
-DO_VCVT_FIXED(vcvt_uh, 2, uint16_t, helper_vfp_uhtoh)
-DO_VCVT_FIXED(vcvt_hs, 2, int16_t, helper_vfp_toshh_round_to_zero)
-DO_VCVT_FIXED(vcvt_hu, 2, uint16_t, helper_vfp_touhh_round_to_zero)
-DO_VCVT_FIXED(vcvt_sf, 4, int32_t, helper_vfp_sltos)
-DO_VCVT_FIXED(vcvt_uf, 4, uint32_t, helper_vfp_ultos)
-DO_VCVT_FIXED(vcvt_fs, 4, int32_t, helper_vfp_tosls_round_to_zero)
-DO_VCVT_FIXED(vcvt_fu, 4, uint32_t, helper_vfp_touls_round_to_zero)
+DO_VCVT_FIXED(vcvt_sh, 2, int16_t, HELPER(vfp_shtoh))
+DO_VCVT_FIXED(vcvt_uh, 2, uint16_t, HELPER(vfp_uhtoh))
+DO_VCVT_FIXED(vcvt_hs, 2, int16_t, HELPER(vfp_toshh_round_to_zero))
+DO_VCVT_FIXED(vcvt_hu, 2, uint16_t, HELPER(vfp_touhh_round_to_zero))
+DO_VCVT_FIXED(vcvt_sf, 4, int32_t, HELPER(vfp_sltos))
+DO_VCVT_FIXED(vcvt_uf, 4, uint32_t, HELPER(vfp_ultos))
+DO_VCVT_FIXED(vcvt_fs, 4, int32_t, HELPER(vfp_tosls_round_to_zero))
+DO_VCVT_FIXED(vcvt_fu, 4, uint32_t, HELPER(vfp_touls_round_to_zero))
 
 /* VCVT with specified rmode */
 #define DO_VCVT_RMODE(OP, ESIZE, TYPE, FN)                              \
@@ -3351,13 +3351,13 @@ DO_VCVT_FIXED(vcvt_fu, 4, uint32_t, helper_vfp_touls_round_to_zero)
         mve_advance_vpt(env);                                           \
     }
 
-DO_VCVT_RMODE(vcvt_rm_sh, 2, uint16_t, helper_vfp_toshh)
-DO_VCVT_RMODE(vcvt_rm_uh, 2, uint16_t, helper_vfp_touhh)
-DO_VCVT_RMODE(vcvt_rm_ss, 4, uint32_t, helper_vfp_tosls)
-DO_VCVT_RMODE(vcvt_rm_us, 4, uint32_t, helper_vfp_touls)
+DO_VCVT_RMODE(vcvt_rm_sh, 2, uint16_t, HELPER(vfp_toshh))
+DO_VCVT_RMODE(vcvt_rm_uh, 2, uint16_t, HELPER(vfp_touhh))
+DO_VCVT_RMODE(vcvt_rm_ss, 4, uint32_t, HELPER(vfp_tosls))
+DO_VCVT_RMODE(vcvt_rm_us, 4, uint32_t, HELPER(vfp_touls))
 
-#define DO_VRINT_RM_H(M, F, S) helper_rinth(M, S)
-#define DO_VRINT_RM_S(M, F, S) helper_rints(M, S)
+#define DO_VRINT_RM_H(M, F, S) HELPER(rinth)(M, S)
+#define DO_VRINT_RM_S(M, F, S) HELPER(rints)(M, S)
 
 DO_VCVT_RMODE(vrint_rm_h, 2, uint16_t, DO_VRINT_RM_H)
 DO_VCVT_RMODE(vrint_rm_s, 4, uint32_t, DO_VRINT_RM_S)
target/arm/tcg/psci.c +1 -1
index 56754bde951..d8e01df7623 100644
@@ -172,7 +172,7 @@ void arm_handle_psci_call(ARMCPU *cpu)
         } else {
             env->regs[0] = 0;
         }
-        helper_wfi(env, 4);
+        HELPER(wfi)(env, 4);
         break;
     case QEMU_PSCI_1_0_FN_PSCI_FEATURES:
         switch (param[1]) {
target/arm/tcg/sme_helper.c +2 -2
index 9de95428d2a..5fb629362b9 100644
@@ -34,12 +34,12 @@
 #define HELPER_H "tcg/helper-sme-defs.h"
 #include "exec/helper-info.c.inc"
 
-void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask)
+void HELPER(set_svcr)(CPUARMState *env, uint32_t val, uint32_t mask)
 {
     aarch64_set_svcr(env, val, mask);
 }
 
-void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
+void HELPER(sme_zero)(CPUARMState *env, uint32_t imm, uint32_t svl)
 {
     uint32_t i;
 
target/arm/tcg/sve_helper.c +71 -70

240 lines not on this page · raw message

target/arm/tcg/tlb_helper.c +1 -1
index 4c3f16dc2aa..4a1611f23f5 100644
@@ -289,7 +289,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
     arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi);
 }
 
-void helper_exception_pc_alignment(CPUARMState *env, vaddr pc)
+void HELPER(exception_pc_alignment)(CPUARMState *env, vaddr pc)
 {
     ARMMMUFaultInfo fi = { .type = ARMFault_Alignment };
     int target_el = exception_target_el(env);
target/arm/tcg/vec_helper.c +36 -36

126 lines not on this page · raw message

target/arm/tcg/vec_helper64.c +32 -32

91 lines not on this page · raw message

Signature · 1 line
2.55.0
#56 lore raw

[PULL 65/83] target/loongarch: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/loongarch/tcg/csr_helper.c   |  22 ++---
 target/loongarch/tcg/fpu_helper.c   | 126 ++++++++++++++--------------
 target/loongarch/tcg/iocsr_helper.c |  16 ++--
 target/loongarch/tcg/op_helper.c    |  18 ++--
 target/loongarch/tcg/tlb_helper.c   |  26 +++---
 target/loongarch/tcg/vec_helper.c   |   4 +-
 6 files changed, 106 insertions(+), 106 deletions(-)
target/loongarch/tcg/csr_helper.c +11 -11
index 1a6919417fc..7cba8035df4 100644
@@ -18,7 +18,7 @@
 #include "cpu-csr.h"
 #include "cpu-mmu.h"
 
-target_ulong helper_csrwr_stlbps(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_stlbps)(CPULoongArchState *env, target_ulong val)
 {
     CPUSysState *sys = env_sys(env);
     int64_t old_v = sys->CSR_STLBPS;
@@ -40,7 +40,7 @@ target_ulong helper_csrwr_stlbps(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrrd_pgd(CPULoongArchState *env)
+target_ulong HELPER(csrrd_pgd)(CPULoongArchState *env)
 {
     int64_t v;
     CPUSysState *sys = env_sys(env);
@@ -60,7 +60,7 @@ target_ulong helper_csrrd_pgd(CPULoongArchState *env)
     return v;
 }
 
-target_ulong helper_csrrd_cpuid(CPULoongArchState *env)
+target_ulong HELPER(csrrd_cpuid)(CPULoongArchState *env)
 {
     LoongArchCPU *lac = env_archcpu(env);
     CPUSysState *sys = env_sys(env);
@@ -70,12 +70,12 @@ target_ulong helper_csrrd_cpuid(CPULoongArchState *env)
     return sys->CSR_CPUID;
 }
 
-target_ulong helper_csrrd_tval(CPULoongArchState *env)
+target_ulong HELPER(csrrd_tval)(CPULoongArchState *env)
 {
     return cpu_loongarch_get_timer_ticks(env_timer(env));
 }
 
-target_ulong helper_csrrd_msgir(CPULoongArchState *env)
+target_ulong HELPER(csrrd_msgir)(CPULoongArchState *env)
 {
     int irq, new;
     CPUSysState *sys = env_sys(env);
@@ -97,7 +97,7 @@ target_ulong helper_csrrd_msgir(CPULoongArchState *env)
     return irq;
 }
 
-target_ulong helper_csrwr_estat(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_estat)(CPULoongArchState *env, target_ulong val)
 {
     CPUSysState *sys = env_sys(env);
     int64_t old_v = sys->CSR_ESTAT;
@@ -118,7 +118,7 @@ target_ulong helper_csrwr_estat(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrwr_asid(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_asid)(CPULoongArchState *env, target_ulong val)
 {
     CPUSysState *sys = env_sys(env);
     int64_t old_v = sys->CSR_ASID;
@@ -131,7 +131,7 @@ target_ulong helper_csrwr_asid(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrwr_tcfg(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_tcfg)(CPULoongArchState *env, target_ulong val)
 {
     CPUTimerState *timer = env_timer(env);
     CPUSysState *sys = container_of(timer, CPUSysState, timer_state);
@@ -142,7 +142,7 @@ target_ulong helper_csrwr_tcfg(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrwr_ticlr(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_ticlr)(CPULoongArchState *env, target_ulong val)
 {
     CPUTimerState *timer = env_timer(env);
     int64_t old_v = 0;
@@ -155,7 +155,7 @@ target_ulong helper_csrwr_ticlr(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrwr_pwcl(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_pwcl)(CPULoongArchState *env, target_ulong val)
 {
     uint8_t shift, ptbase;
     CPUSysState *sys = env_sys(env);
@@ -180,7 +180,7 @@ target_ulong helper_csrwr_pwcl(CPULoongArchState *env, target_ulong val)
     return old_v;
 }
 
-target_ulong helper_csrwr_pwch(CPULoongArchState *env, target_ulong val)
+target_ulong HELPER(csrwr_pwch)(CPULoongArchState *env, target_ulong val)
 {
     uint8_t has_ptw;
     CPUSysState *sys = env_sys(env);
target/loongarch/tcg/fpu_helper.c +63 -63

504 lines not on this page · raw message

target/loongarch/tcg/iocsr_helper.c +8 -8
index b0f171608bc..be705cebbb1 100644
@@ -14,52 +14,52 @@
 #define GET_MEMTXATTRS(cas) \
         ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index})
 
-uint64_t helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr)
+uint64_t HELPER(iocsrrd_b)(CPULoongArchState *env, target_ulong r_addr)
 {
     return address_space_ldub(env->address_space_iocsr, r_addr,
                               GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr)
+uint64_t HELPER(iocsrrd_h)(CPULoongArchState *env, target_ulong r_addr)
 {
     return address_space_lduw_le(env->address_space_iocsr, r_addr,
                                  GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr)
+uint64_t HELPER(iocsrrd_w)(CPULoongArchState *env, target_ulong r_addr)
 {
     return address_space_ldl_le(env->address_space_iocsr, r_addr,
                                 GET_MEMTXATTRS(env), NULL);
 }
 
-uint64_t helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr)
+uint64_t HELPER(iocsrrd_d)(CPULoongArchState *env, target_ulong r_addr)
 {
     return address_space_ldq_le(env->address_space_iocsr, r_addr,
                                 GET_MEMTXATTRS(env), NULL);
 }
 
-void helper_iocsrwr_b(CPULoongArchState *env, target_ulong w_addr,
+void HELPER(iocsrwr_b)(CPULoongArchState *env, target_ulong w_addr,
                       target_ulong val)
 {
     address_space_stb(env->address_space_iocsr, w_addr,
                       val, GET_MEMTXATTRS(env), NULL);
 }
 
-void helper_iocsrwr_h(CPULoongArchState *env, target_ulong w_addr,
+void HELPER(iocsrwr_h)(CPULoongArchState *env, target_ulong w_addr,
                       target_ulong val)
 {
     address_space_stw_le(env->address_space_iocsr, w_addr,
                          val, GET_MEMTXATTRS(env), NULL);
 }
 
-void helper_iocsrwr_w(CPULoongArchState *env, target_ulong w_addr,
+void HELPER(iocsrwr_w)(CPULoongArchState *env, target_ulong w_addr,
                       target_ulong val)
 {
     address_space_stl_le(env->address_space_iocsr, w_addr,
                          val, GET_MEMTXATTRS(env), NULL);
 }
 
-void helper_iocsrwr_d(CPULoongArchState *env, target_ulong w_addr,
+void HELPER(iocsrwr_d)(CPULoongArchState *env, target_ulong w_addr,
                       target_ulong val)
 {
     address_space_stq_le(env->address_space_iocsr, w_addr,
target/loongarch/tcg/op_helper.c +9 -9
index f98fe4d4a16..44772d03a4b 100644
@@ -17,13 +17,13 @@
 #include "cpu-csr.h"
 
 /* Exceptions helpers */
-void helper_raise_exception(CPULoongArchState *env, uint32_t exception)
+void HELPER(raise_exception)(CPULoongArchState *env, uint32_t exception)
 {
     do_raise_exception(env, exception, GETPC());
 }
 
 /* loongarch assert op */
-void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk)
+void HELPER(asrtle_d)(CPULoongArchState *env, target_ulong rj, target_ulong rk)
 {
     CPUSysState *sys = env_sys(env);
 
@@ -33,7 +33,7 @@ void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk)
     }
 }
 
-void helper_asrtgt_d(CPULoongArchState *env, target_ulong rj, target_ulong rk)
+void HELPER(asrtgt_d)(CPULoongArchState *env, target_ulong rj, target_ulong rk)
 {
     CPUSysState *sys = env_sys(env);
 
@@ -43,7 +43,7 @@ void helper_asrtgt_d(CPULoongArchState *env, target_ulong rj, target_ulong rk)
     }
 }
 
-target_ulong helper_crc32(target_ulong val, target_ulong m, uint64_t sz)
+target_ulong HELPER(crc32)(target_ulong val, target_ulong m, uint64_t sz)
 {
     uint8_t buf[8];
     target_ulong mask = ((sz * 8) == 64) ? -1ULL : ((1ULL << (sz * 8)) - 1);
@@ -53,7 +53,7 @@ target_ulong helper_crc32(target_ulong val, target_ulong m, uint64_t sz)
     return (int32_t) (crc32(val ^ 0xffffffff, buf, sz) ^ 0xffffffff);
 }
 
-target_ulong helper_crc32c(target_ulong val, target_ulong m, uint64_t sz)
+target_ulong HELPER(crc32c)(target_ulong val, target_ulong m, uint64_t sz)
 {
     uint8_t buf[8];
     target_ulong mask = ((sz * 8) == 64) ? -1ULL : ((1ULL << (sz * 8)) - 1);
@@ -62,12 +62,12 @@ target_ulong helper_crc32c(target_ulong val, target_ulong m, uint64_t sz)
     return (int32_t) (crc32c(val, buf, sz) ^ 0xffffffff);
 }
 
-target_ulong helper_cpucfg(CPULoongArchState *env, target_ulong rj)
+target_ulong HELPER(cpucfg)(CPULoongArchState *env, target_ulong rj)
 {
     return rj >= ARRAY_SIZE(env->cpucfg) ? 0 : env->cpucfg[rj];
 }
 
-uint64_t helper_rdtime_d(CPULoongArchState *env)
+uint64_t HELPER(rdtime_d)(CPULoongArchState *env)
 {
 #ifdef CONFIG_USER_ONLY
     return cpu_get_host_ticks();
@@ -86,7 +86,7 @@ uint64_t helper_rdtime_d(CPULoongArchState *env)
 }
 
 #ifndef CONFIG_USER_ONLY
-void helper_ertn(CPULoongArchState *env)
+void HELPER(ertn)(CPULoongArchState *env)
 {
     uint64_t csr_pplv, csr_pie;
     CPUSysState *sys = env_sys(env);
@@ -115,7 +115,7 @@ void helper_ertn(CPULoongArchState *env)
     env->lladdr = 1;
 }
 
-void helper_idle(CPULoongArchState *env)
+void HELPER(idle)(CPULoongArchState *env)
 {
     CPUState *cs = env_cpu(env);
 
target/loongarch/tcg/tlb_helper.c +13 -13
index 40cc0764248..479c0b208d6 100644
@@ -310,7 +310,7 @@ static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr,
     return false;
 }
 
-void helper_tlbsrch(CPULoongArchState *env)
+void HELPER(tlbsrch)(CPULoongArchState *env)
 {
     int index, match;
     CPUSysState *sys = env_sys(env);
@@ -330,7 +330,7 @@ void helper_tlbsrch(CPULoongArchState *env)
     sys->CSR_TLBIDX = FIELD_DP64(sys->CSR_TLBIDX, CSR_TLBIDX, NE, 1);
 }
 
-void helper_tlbrd(CPULoongArchState *env)
+void HELPER(tlbrd)(CPULoongArchState *env)
 {
     LoongArchTLB *tlb;
     int index;
@@ -389,7 +389,7 @@ static void update_tlb_index(CPULoongArchState *env, MMUContext *context,
     *old = new;
 }
 
-void helper_tlbwr(CPULoongArchState *env)
+void HELPER(tlbwr)(CPULoongArchState *env)
 {
     CPUSysState *sys = env_sys(env);
     int index = FIELD_EX64(sys->CSR_TLBIDX, CSR_TLBIDX, INDEX);
@@ -469,7 +469,7 @@ static int get_tlb_random_index(CPULoongArchState *env, vaddr addr,
     return index;
 }
 
-void helper_tlbfill(CPULoongArchState *env)
+void HELPER(tlbfill)(CPULoongArchState *env)
 {
     vaddr entryhi;
     int index, pagesize;
@@ -492,7 +492,7 @@ void helper_tlbfill(CPULoongArchState *env)
     fill_tlb_entry(env, env->tlb + index, &context);
 }
 
-void helper_tlbclr(CPULoongArchState *env)
+void HELPER(tlbclr)(CPULoongArchState *env)
 {
     LoongArchTLB *tlb;
     int i, index;
@@ -527,7 +527,7 @@ void helper_tlbclr(CPULoongArchState *env)
     tlb_flush(env_cpu(env));
 }
 
-void helper_tlbflush(CPULoongArchState *env)
+void HELPER(tlbflush)(CPULoongArchState *env)
 {
     int i, index;
     CPUSysState *sys = env_sys(env);
@@ -552,7 +552,7 @@ void helper_tlbflush(CPULoongArchState *env)
     tlb_flush(env_cpu(env));
 }
 
-void helper_invtlb_all(CPULoongArchState *env)
+void HELPER(invtlb_all)(CPULoongArchState *env)
 {
     for (int i = 0; i < LOONGARCH_TLB_MAX; i++) {
         env->tlb[i].tlb_misc = FIELD_DP64(env->tlb[i].tlb_misc,
@@ -561,7 +561,7 @@ void helper_invtlb_all(CPULoongArchState *env)
     tlb_flush(env_cpu(env));
 }
 
-void helper_invtlb_all_g(CPULoongArchState *env, uint32_t g)
+void HELPER(invtlb_all_g)(CPULoongArchState *env, uint32_t g)
 {
     for (int i = 0; i < LOONGARCH_TLB_MAX; i++) {
         LoongArchTLB *tlb = &env->tlb[i];
@@ -574,7 +574,7 @@ void helper_invtlb_all_g(CPULoongArchState *env, uint32_t g)
     tlb_flush(env_cpu(env));
 }
 
-void helper_invtlb_all_asid(CPULoongArchState *env, target_ulong info)
+void HELPER(invtlb_all_asid)(CPULoongArchState *env, target_ulong info)
 {
     uint16_t asid = info & R_CSR_ASID_ASID_MASK;
 
@@ -590,7 +590,7 @@ void helper_invtlb_all_asid(CPULoongArchState *env, target_ulong info)
     tlb_flush(env_cpu(env));
 }
 
-void helper_invtlb_page_asid(CPULoongArchState *env, target_ulong info,
+void HELPER(invtlb_page_asid)(CPULoongArchState *env, target_ulong info,
                              target_ulong addr)
 {
     int asid = info & 0x3ff;
@@ -604,7 +604,7 @@ void helper_invtlb_page_asid(CPULoongArchState *env, target_ulong info,
     }
 }
 
-void helper_invtlb_page_asid_or_g(CPULoongArchState *env,
+void HELPER(invtlb_page_asid_or_g)(CPULoongArchState *env,
                                   target_ulong info, target_ulong addr)
 {
     int asid = info & 0x3ff;
@@ -718,7 +718,7 @@ static inline uint64_t loongarch_sanitize_hw_pte(CPULoongArchState *env,
     return (pte & ~ppn_mask) | ((pte & ppn_mask) & palen_mask);
 }
 
-target_ulong helper_lddir(CPULoongArchState *env, target_ulong base,
+target_ulong HELPER(lddir)(CPULoongArchState *env, target_ulong base,
                           uint32_t level, uint32_t mem_idx)
 {
     CPUState *cs = env_cpu(env);
@@ -759,7 +759,7 @@ target_ulong helper_lddir(CPULoongArchState *env, target_ulong base,
     return val & palen_mask;
 }
 
-void helper_ldpte(CPULoongArchState *env, target_ulong base, target_ulong odd,
+void HELPER(ldpte)(CPULoongArchState *env, target_ulong base, target_ulong odd,
                   uint32_t mem_idx)
 {
     CPUState *cs = env_cpu(env);
target/loongarch/tcg/vec_helper.c +2 -2
index a270998e638..3ada636cd9f 100644
@@ -2511,8 +2511,8 @@ void HELPER(NAME)(void *vd, void *vj,                    \
     }                                                    \
 }
 
-FCLASS(vfclass_s, 32, UW, helper_fclass_s)
-FCLASS(vfclass_d, 64, UD, helper_fclass_d)
+FCLASS(vfclass_s, 32, UW, HELPER(fclass_s))
+FCLASS(vfclass_d, 64, UD, HELPER(fclass_d))
 
 #define FSQRT(BIT, T)                                  \
 static T do_fsqrt_## BIT(CPULoongArchState *env, T fj) \
Signature · 1 line
2.55.0
#57 lore raw

[PULL 56/83] target/rx: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert rx to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/rx/cpu.h    |  3 ++-
 target/rx/cpu.c    |  2 +-
 target/rx/helper.c | 10 ++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)
target/rx/cpu.h +2 -1
index 06208380621..0c749fc58d4 100644
@@ -150,7 +150,8 @@ const char *rx_crname(uint8_t cr);
 const char *rx_exception_name(int excp);
 void rx_cpu_do_interrupt(CPUState *cpu);
 bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool rx_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                TranslateForDebugResult *result);
 void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/rx/cpu.c +1 -1
index 44ec3c3d62f..c35a98f7cef 100644
@@ -209,7 +209,7 @@ static void rx_cpu_init(Object *obj)
 
 static const struct SysemuCPUOps rx_sysemu_ops = {
     .has_work = rx_cpu_has_work,
-    .get_phys_addr_debug = rx_cpu_get_phys_addr_debug,
+    .translate_for_debug = rx_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps rx_tcg_ops = {
target/rx/helper.c +8 -2
index ed9cadc0bd4..f170a14721e 100644
@@ -159,7 +159,13 @@ bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     return false;
 }
 
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool rx_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                TranslateForDebugResult *result)
 {
-    return addr;
+    *result = (TranslateForDebugResult) {
+        .physaddr = addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.55.0
#58 lore raw

[PULL 63/83] target/hppa: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/hppa/fpu_helper.c | 2 +-
 target/hppa/op_helper.c  | 2 +-
 target/hppa/sys_helper.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
target/hppa/fpu_helper.c +1 -1
index cdbebcfeb3a..a0c8c91ee54 100644
@@ -82,7 +82,7 @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
 
 void cpu_hppa_loaded_fr0(CPUHPPAState *env)
 {
-    helper_loaded_fr0(env);
+    HELPER(loaded_fr0)(env);
 }
 
 #define CONVERT_BIT(X, SRC, DST)        \
target/hppa/op_helper.c +1 -1
index 3542c275663..ea0680aa9eb 100644
@@ -341,7 +341,7 @@ target_ulong HELPER(probe)(CPUHPPAState *env, target_ulong addr,
         if (excp == EXCP_DTLB_MISS) {
             excp = EXCP_NA_DTLB_MISS;
         }
-        helper_hppa_excp(env, excp);
+        HELPER(hppa_excp)(env, excp);
     }
     return (want & prot) != 0;
 #endif
target/hppa/sys_helper.c +3 -3
index f7fd80b5830..ccfc2b48816 100644
@@ -51,13 +51,13 @@ void HELPER(write_interval_timer)(CPUHPPAState *env, target_ulong val)
 void HELPER(hppa_halt)(CPUHPPAState *env)
 {
     qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
-    helper_hppa_excp(env, EXCP_HLT);
+    HELPER(hppa_excp)(env, EXCP_HLT);
 }
 
 void HELPER(hppa_reset)(CPUHPPAState *env)
 {
     qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
-    helper_hppa_excp(env, EXCP_HLT);
+    HELPER(hppa_excp)(env, EXCP_HLT);
 }
 
 target_ulong HELPER(swap_system_mask)(CPUHPPAState *env, target_ulong nsm)
@@ -120,7 +120,7 @@ static void getshadowregs(CPUHPPAState *env)
 void HELPER(rfi_r)(CPUHPPAState *env)
 {
     getshadowregs(env);
-    helper_rfi(env);
+    HELPER(rfi)(env);
 }
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.55.0
#59 lore raw

[PULL 62/83] target/avr: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/avr/helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
target/avr/helper.c +6 -6
index 8f90b8d9a45..49bd2f57c9f 100644
@@ -159,7 +159,7 @@ bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
  *  helpers
  */
 
-void helper_sleep(CPUAVRState *env)
+void HELPER(sleep)(CPUAVRState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -167,7 +167,7 @@ void helper_sleep(CPUAVRState *env)
     cpu_loop_exit(cs);
 }
 
-void helper_unsupported(CPUAVRState *env)
+void HELPER(unsupported)(CPUAVRState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -183,7 +183,7 @@ void helper_unsupported(CPUAVRState *env)
     cpu_loop_exit(cs);
 }
 
-void helper_debug(CPUAVRState *env)
+void HELPER(debug)(CPUAVRState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -191,7 +191,7 @@ void helper_debug(CPUAVRState *env)
     cpu_loop_exit(cs);
 }
 
-void helper_break(CPUAVRState *env)
+void HELPER(break)(CPUAVRState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -199,7 +199,7 @@ void helper_break(CPUAVRState *env)
     cpu_loop_exit(cs);
 }
 
-void helper_wdr(CPUAVRState *env)
+void HELPER(wdr)(CPUAVRState *env)
 {
     qemu_log_mask(LOG_UNIMP, "WDG reset (not implemented)\n");
 }
@@ -281,7 +281,7 @@ const MemoryRegionOps avr_cpu_reg2 = {
  *  this function implements ST instruction when there is a possibility to write
  *  into a CPU register
  */
-void helper_fullwr(CPUAVRState *env, uint32_t data, uint32_t addr)
+void HELPER(fullwr)(CPUAVRState *env, uint32_t data, uint32_t addr)
 {
     env->fullacc = false;
 
Signature · 1 line
2.55.0
#60 lore raw

[PULL 70/83] target/ppc: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/ppc/internal.h               |   7 +-
 target/ppc/dfp_helper.c             |  52 ++--
 target/ppc/fpu_helper.c             | 396 ++++++++++++++--------------
 target/ppc/int_helper.c             | 292 ++++++++++----------
 target/ppc/mem_helper.c             |  28 +-
 target/ppc/misc_helper.c            |  56 ++--
 target/ppc/mmu-hash64.c             |  18 +-
 target/ppc/mmu_helper.c             |  70 ++---
 target/ppc/power8-pmu.c             |  14 +-
 target/ppc/tcg-excp_helper.c        |  56 ++--
 target/ppc/timebase_helper.c        |  54 ++--
 target/ppc/translate/vsx-impl.c.inc |   2 +-
 12 files changed, 526 insertions(+), 519 deletions(-)
target/ppc/internal.h +4 -3
index 11fa4ee5417..8ba12eb63db 100644
@@ -22,6 +22,7 @@
 #include "exec/memop.h"
 #include "hw/core/registerfields.h"
 #include "exec/page-protection.h"
+#include "exec/helper-head.h.inc"
 
 /**
  * ppc_env_is_64bit:
@@ -241,9 +242,9 @@ EXTRACT_HELPER(IMM8, 11, 8);
 EXTRACT_HELPER(DCMX, 16, 7);
 EXTRACT_HELPER_SPLIT_3(DCMX_XV, 5, 16, 0, 1, 2, 5, 1, 6, 6);
 
-void helper_compute_fprf_float16(CPUPPCState *env, float16 arg);
-void helper_compute_fprf_float32(CPUPPCState *env, float32 arg);
-void helper_compute_fprf_float128(CPUPPCState *env, float128 arg);
+void HELPER(compute_fprf_float16)(CPUPPCState *env, float16 arg);
+void HELPER(compute_fprf_float32)(CPUPPCState *env, float32 arg);
+void HELPER(compute_fprf_float128)(CPUPPCState *env, float128 arg);
 
 /* translate.c */
 
target/ppc/dfp_helper.c +26 -26

208 lines not on this page · raw message

target/ppc/fpu_helper.c +198 -198

1,469 lines not on this page · raw message

target/ppc/int_helper.c +149 -143

1,129 lines not on this page · raw message

target/ppc/mem_helper.c +14 -14
index dc5eab8c76c..1f0613479d5 100644
@@ -73,7 +73,7 @@ static void *probe_contiguous(CPUPPCState *env, target_ulong addr, uint32_t nb,
     return NULL;
 }
 
-void helper_LMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
+void HELPER(LMW)(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     uintptr_t raddr = GETPC();
     int mmu_idx = ppc_env_mmu_index(env, false);
@@ -98,7 +98,7 @@ void helper_LMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
     }
 }
 
-void helper_STMW(CPUPPCState *env, target_ulong addr, uint32_t reg)
+void HELPER(STMW)(CPUPPCState *env, target_ulong addr, uint32_t reg)
 {
     uintptr_t raddr = GETPC();
     int mmu_idx = ppc_env_mmu_index(env, false);
@@ -190,7 +190,7 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb,
     env->gpr[reg] = val;
 }
 
-void helper_LSW(CPUPPCState *env, target_ulong addr,
+void HELPER(LSW)(CPUPPCState *env, target_ulong addr,
                 uint32_t nb, uint32_t reg)
 {
     do_lsw(env, addr, nb, reg, GETPC());
@@ -202,7 +202,7 @@ void helper_LSW(CPUPPCState *env, target_ulong addr,
  * this is valid, but rA won't be loaded.  For now, I'll follow the
  * spec...
  */
-void helper_LSWX(CPUPPCState *env, target_ulong addr, uint32_t reg,
+void HELPER(LSWX)(CPUPPCState *env, target_ulong addr, uint32_t reg,
                  uint32_t ra, uint32_t rb)
 {
     if (likely(xer_bc != 0)) {
@@ -218,7 +218,7 @@ void helper_LSWX(CPUPPCState *env, target_ulong addr, uint32_t reg,
     }
 }
 
-void helper_STSW(CPUPPCState *env, target_ulong addr, uint32_t nb,
+void HELPER(STSW)(CPUPPCState *env, target_ulong addr, uint32_t nb,
                  uint32_t reg)
 {
     uintptr_t raddr = GETPC();
@@ -319,13 +319,13 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr,
     clear_helper_retaddr();
 }
 
-void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx)
+void HELPER(dcbz)(CPUPPCState *env, target_ulong addr, int mmu_idx)
 {
     dcbz_common(env, addr, mmu_idx, env->dcache_line_size, GETPC());
 }
 
 #ifdef TARGET_PPC64
-void helper_dcbzl(CPUPPCState *env, target_ulong addr)
+void HELPER(dcbzl)(CPUPPCState *env, target_ulong addr)
 {
     int dcbz_size = env->dcache_line_size;
 
@@ -341,7 +341,7 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr)
 }
 #endif
 
-void helper_ICBI(CPUPPCState *env, target_ulong addr)
+void HELPER(ICBI)(CPUPPCState *env, target_ulong addr)
 {
     unsigned mmu_idx = cpu_mmu_index(env_cpu(env), false);
     MemOpIdx oi = make_memop_idx(MO_UL | MO_UNALN, mmu_idx);
@@ -357,7 +357,7 @@ void helper_ICBI(CPUPPCState *env, target_ulong addr)
     cpu_ldl_mmu(env, addr, oi, GETPC());
 }
 
-void helper_ICBIEP(CPUPPCState *env, target_ulong addr)
+void HELPER(ICBIEP)(CPUPPCState *env, target_ulong addr)
 {
 #if !defined(CONFIG_USER_ONLY)
     MemOpIdx oi = make_memop_idx(MO_UL | MO_UNALN, PPC_TLB_EPID_LOAD);
@@ -385,7 +385,7 @@ void helper_ICBIEP(CPUPPCState *env, target_ulong addr)
  */
 
 #define LVE(name, access, swap, element)                        \
-    void helper_##name(CPUPPCState *env, ppc_avr_t *r,          \
+    void HELPER(name)(CPUPPCState *env, ppc_avr_t *r,           \
                        target_ulong addr)                       \
     {                                                           \
         size_t n_elems = ARRAY_SIZE(r->element);                \
@@ -411,7 +411,7 @@ LVE(LVEWX, cpu_ldl_be_data_ra, bswap32, u32)
 #undef LVE
 
 #define STVE(name, access, swap, element)                               \
-    void helper_##name(CPUPPCState *env, ppc_avr_t *r,                  \
+    void HELPER(name)(CPUPPCState *env, ppc_avr_t *r,                   \
                        target_ulong addr)                               \
     {                                                                   \
         size_t n_elems = ARRAY_SIZE(r->element);                        \
@@ -441,7 +441,7 @@ STVE(STVEWX, cpu_stl_be_data_ra, bswap32, u32)
 #define GET_NB(rb) ((rb >> 56) & 0xFF)
 
 #define VSX_LXVL(name, lj)                                              \
-void helper_##name(CPUPPCState *env, target_ulong addr,                 \
+void HELPER(name)(CPUPPCState *env, target_ulong addr,                  \
                    ppc_vsr_t *xt, target_ulong rb)                      \
 {                                                                       \
     ppc_vsr_t t;                                                        \
@@ -471,7 +471,7 @@ VSX_LXVL(LXVLL, 1)
 #undef VSX_LXVL
 
 #define VSX_STXVL(name, lj)                                       \
-void helper_##name(CPUPPCState *env, target_ulong addr,           \
+void HELPER(name)(CPUPPCState *env, target_ulong addr,            \
                    ppc_vsr_t *xt, target_ulong rb)                \
 {                                                                 \
     target_ulong nb = GET_NB(rb);                                 \
@@ -504,7 +504,7 @@ VSX_STXVL(STXVLL, 1)
 #undef HI_IDX
 #undef LO_IDX
 
-void helper_tbegin(CPUPPCState *env)
+void HELPER(tbegin)(CPUPPCState *env)
 {
     /*
      * As a degenerate implementation, always fail tbegin.  The reason
target/ppc/misc_helper.c +28 -28

64 lines not on this page · raw message

target/ppc/mmu-hash64.c +9 -9
index 2c33d98001d..e5238f0c245 100644

Lines of this file are not shown. View the raw message.

target/ppc/mmu_helper.c +35 -35

70 lines not on this page · raw message

target/ppc/power8-pmu.c +7 -7
index 2a7a5b493af..772e257e87a 100644

Lines of this file are not shown. View the raw message.

target/ppc/tcg-excp_helper.c +28 -28

56 lines not on this page · raw message

target/ppc/timebase_helper.c +27 -27

54 lines not on this page · raw message

target/ppc/translate/vsx-impl.c.inc +1 -1
index 78311dcba9d..95003be99b2 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.55.0

Part of the diff is not shown here. View the raw message.

#61 lore raw

[PULL 60/83] target/alpha: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/alpha/clk_helper.c |  2 +-
 target/alpha/fpu_helper.c | 60 +++++++++++++++++++--------------------
 target/alpha/helper.c     |  6 ++--
 target/alpha/int_helper.c | 38 ++++++++++++-------------
 target/alpha/sys_helper.c | 12 ++++----
 target/alpha/vax_helper.c | 42 +++++++++++++--------------
 6 files changed, 80 insertions(+), 80 deletions(-)
target/alpha/clk_helper.c +1 -1
index 26ffc231cda..36674221a66 100644
@@ -11,7 +11,7 @@
 #include "exec/helper-proto.h"
 #include "cpu.h"
 
-uint64_t helper_load_pcc(CPUAlphaState *env)
+uint64_t HELPER(load_pcc)(CPUAlphaState *env)
 {
 #ifndef CONFIG_USER_ONLY
     /*
target/alpha/fpu_helper.c +30 -30

230 lines not on this page · raw message

target/alpha/helper.c +3 -3
index d59ecc0d4a9..55c7782b4d2 100644
@@ -111,12 +111,12 @@ void cpu_alpha_store_fpcr(CPUAlphaState *env, uint64_t val)
     env->fpcr_flush_to_zero = t;
 }
 
-uint64_t helper_load_fpcr(CPUAlphaState *env)
+uint64_t HELPER(load_fpcr)(CPUAlphaState *env)
 {
     return cpu_alpha_load_fpcr(env);
 }
 
-void helper_store_fpcr(CPUAlphaState *env, uint64_t val)
+void HELPER(store_fpcr)(CPUAlphaState *env, uint64_t val)
 {
     cpu_alpha_store_fpcr(env, val);
 }
@@ -531,7 +531,7 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags)
 
 /* This should only be called from translate, via gen_excp.
    We expect that ENV->PC has already been updated.  */
-G_NORETURN void helper_excp(CPUAlphaState *env, int excp, int error)
+G_NORETURN void HELPER(excp)(CPUAlphaState *env, int excp, int error)
 {
     CPUState *cs = env_cpu(env);
 
target/alpha/int_helper.c +19 -19
index 6bfe63500e0..11b0af82bc1 100644
@@ -23,7 +23,7 @@
 #include "qemu/host-utils.h"
 
 
-uint64_t helper_zapnot(uint64_t val, uint64_t mskb)
+uint64_t HELPER(zapnot)(uint64_t val, uint64_t mskb)
 {
     uint64_t mask;
 
@@ -39,12 +39,12 @@ uint64_t helper_zapnot(uint64_t val, uint64_t mskb)
     return val & mask;
 }
 
-uint64_t helper_zap(uint64_t val, uint64_t mask)
+uint64_t HELPER(zap)(uint64_t val, uint64_t mask)
 {
-    return helper_zapnot(val, ~mask);
+    return HELPER(zapnot)(val, ~mask);
 }
 
-uint64_t helper_cmpbe0(uint64_t a)
+uint64_t HELPER(cmpbe0)(uint64_t a)
 {
     uint64_t m = 0x7f7f7f7f7f7f7f7fULL;
     uint64_t c = ~(((a & m) + m) | a | m);
@@ -58,7 +58,7 @@ uint64_t helper_cmpbe0(uint64_t a)
     return c >> 56;
 }
 
-uint64_t helper_cmpbge(uint64_t a, uint64_t b)
+uint64_t HELPER(cmpbge)(uint64_t a, uint64_t b)
 {
     uint64_t mask = 0x00ff00ff00ff00ffULL;
     uint64_t test = 0x0100010001000100ULL;
@@ -87,7 +87,7 @@ uint64_t helper_cmpbge(uint64_t a, uint64_t b)
     return cl >> 50;
 }
 
-uint64_t helper_minub8(uint64_t op1, uint64_t op2)
+uint64_t HELPER(minub8)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     uint8_t opa, opb, opr;
@@ -102,7 +102,7 @@ uint64_t helper_minub8(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_minsb8(uint64_t op1, uint64_t op2)
+uint64_t HELPER(minsb8)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     int8_t opa, opb;
@@ -118,7 +118,7 @@ uint64_t helper_minsb8(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_minuw4(uint64_t op1, uint64_t op2)
+uint64_t HELPER(minuw4)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     uint16_t opa, opb, opr;
@@ -133,7 +133,7 @@ uint64_t helper_minuw4(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_minsw4(uint64_t op1, uint64_t op2)
+uint64_t HELPER(minsw4)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     int16_t opa, opb;
@@ -149,7 +149,7 @@ uint64_t helper_minsw4(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_maxub8(uint64_t op1, uint64_t op2)
+uint64_t HELPER(maxub8)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     uint8_t opa, opb, opr;
@@ -164,7 +164,7 @@ uint64_t helper_maxub8(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_maxsb8(uint64_t op1, uint64_t op2)
+uint64_t HELPER(maxsb8)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     int8_t opa, opb;
@@ -180,7 +180,7 @@ uint64_t helper_maxsb8(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_maxuw4(uint64_t op1, uint64_t op2)
+uint64_t HELPER(maxuw4)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     uint16_t opa, opb, opr;
@@ -195,7 +195,7 @@ uint64_t helper_maxuw4(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_maxsw4(uint64_t op1, uint64_t op2)
+uint64_t HELPER(maxsw4)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     int16_t opa, opb;
@@ -211,7 +211,7 @@ uint64_t helper_maxsw4(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_perr(uint64_t op1, uint64_t op2)
+uint64_t HELPER(perr)(uint64_t op1, uint64_t op2)
 {
     uint64_t res = 0;
     uint8_t opa, opb, opr;
@@ -230,12 +230,12 @@ uint64_t helper_perr(uint64_t op1, uint64_t op2)
     return res;
 }
 
-uint64_t helper_pklb(uint64_t op1)
+uint64_t HELPER(pklb)(uint64_t op1)
 {
     return (op1 & 0xff) | ((op1 >> 24) & 0xff00);
 }
 
-uint64_t helper_pkwb(uint64_t op1)
+uint64_t HELPER(pkwb)(uint64_t op1)
 {
     return ((op1 & 0xff)
             | ((op1 >> 8) & 0xff00)
@@ -243,12 +243,12 @@ uint64_t helper_pkwb(uint64_t op1)
             | ((op1 >> 24) & 0xff000000));
 }
 
-uint64_t helper_unpkbl(uint64_t op1)
+uint64_t HELPER(unpkbl)(uint64_t op1)
 {
     return (op1 & 0xff) | ((op1 & 0xff00) << 24);
 }
 
-uint64_t helper_unpkbw(uint64_t op1)
+uint64_t HELPER(unpkbw)(uint64_t op1)
 {
     return ((op1 & 0xff)
             | ((op1 & 0xff00) << 8)
@@ -256,7 +256,7 @@ uint64_t helper_unpkbw(uint64_t op1)
             | ((op1 & 0xff000000) << 24));
 }
 
-void helper_check_overflow(CPUAlphaState *env, uint64_t op1, uint64_t op2)
+void HELPER(check_overflow)(CPUAlphaState *env, uint64_t op1, uint64_t op2)
 {
     if (unlikely(op1 != op2)) {
         arith_excp(env, GETPC(), EXC_M_IOV, 0);
target/alpha/sys_helper.c +6 -6
index 0e0a619975b..95613e97f2b 100644
@@ -27,17 +27,17 @@
 
 
 /* PALcode support special instructions */
-void helper_tbia(CPUAlphaState *env)
+void HELPER(tbia)(CPUAlphaState *env)
 {
     tlb_flush(env_cpu(env));
 }
 
-void helper_tbis(CPUAlphaState *env, uint64_t p)
+void HELPER(tbis)(CPUAlphaState *env, uint64_t p)
 {
     tlb_flush_page(env_cpu(env), p);
 }
 
-void helper_halt(uint64_t restart)
+void HELPER(halt)(uint64_t restart)
 {
     if (restart) {
         qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
@@ -46,17 +46,17 @@ void helper_halt(uint64_t restart)
     }
 }
 
-uint64_t helper_get_vmtime(void)
+uint64_t HELPER(get_vmtime)(void)
 {
     return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 }
 
-uint64_t helper_get_walltime(void)
+uint64_t HELPER(get_walltime)(void)
 {
     return qemu_clock_get_ns(rtc_clock);
 }
 
-void helper_set_alarm(CPUAlphaState *env, uint64_t expire)
+void HELPER(set_alarm)(CPUAlphaState *env, uint64_t expire)
 {
     AlphaCPU *cpu = env_archcpu(env);
 
target/alpha/vax_helper.c +21 -21

166 lines not on this page · raw message

Signature · 1 line
2.55.0
#62 lore raw

[PULL 44/83] target/rx: Define exception vector constants

In reply to Philippe Mathieu-Daudé

From: Yonggang Luo <[email protected]>

Name RX exception vectors and trap ranges, and use the definitions throughout exception handling and exception raising.

Assert that exception indexes remain within the defined range before accessing their vector tables.

Message-ID: <[email protected]>

---
 target/rx/cpu.h       | 13 +++++++++++++
 target/rx/helper.c    | 21 +++++++++++----------
 target/rx/op_helper.c | 10 +++++-----
 target/rx/translate.c |  2 +-
 4 files changed, 30 insertions(+), 16 deletions(-)
target/rx/cpu.h +13 -0
index 64ba48a7329..0d9f4898a26 100644
@@ -71,6 +71,19 @@ enum {
     NUM_REGS = 16,
 };
 
+#define RX_EXCP_TRAP_COUNT          0x100
+
+enum {
+    RX_EXCP_PRIVILEGE_VIOLATION     = 20,
+    RX_EXCP_ACCESS                  = 21,
+    RX_EXCP_ILLEGAL_INSTRUCTION     = 23,
+    RX_EXCP_FPU                     = 25,
+    RX_EXCP_NMI                     = 30,
+    RX_EXCP_TRAP_BASE               = 0x100, /* Up to RX_EXCP_TRAP_COUNT */
+};
+
+#define RX_EXCP_COUNT   (RX_EXCP_TRAP_BASE + RX_EXCP_TRAP_COUNT)
+
 typedef struct CPUArchState {
     /* CPU registers */
     uint32_t regs[NUM_REGS];    /* general registers */
target/rx/helper.c +11 -10
index 0f99279bbaa..bc76dd28ab3 100644
@@ -86,13 +86,14 @@ void rx_cpu_do_interrupt(CPUState *cs)
         env->isp -= 4;
         cpu_stl_le_data(env, env->isp, env->pc);
 
-        if (vec < 0x100) {
-            env->pc = cpu_ldl_le_data(env, 0xffffff80 + vec * 4);
-        } else {
+        assert(vec < RX_EXCP_COUNT);
+        if (vec >= RX_EXCP_TRAP_BASE) {
             env->pc = cpu_ldl_le_data(env, env->intb + (vec & 0xff) * 4);
+        } else {
+            env->pc = cpu_ldl_le_data(env, 0xffffff80 + vec * 4);
         }
 
-        if (vec == 30) {
+        if (vec == RX_EXCP_NMI) {
             /* Non-maskable interrupt */
             qemu_plugin_vcpu_interrupt_cb(cs, last_pc);
         } else {
@@ -100,22 +101,22 @@ void rx_cpu_do_interrupt(CPUState *cs)
         }
 
         switch (vec) {
-        case 20:
+        case RX_EXCP_PRIVILEGE_VIOLATION:
             expname = "privilege violation";
             break;
-        case 21:
+        case RX_EXCP_ACCESS:
             expname = "access exception";
             break;
-        case 23:
+        case RX_EXCP_ILLEGAL_INSTRUCTION:
             expname = "illegal instruction";
             break;
-        case 25:
+        case RX_EXCP_FPU:
             expname = "fpu exception";
             break;
-        case 30:
+        case RX_EXCP_NMI:
             expname = "non-maskable interrupt";
             break;
-        case 0x100 ... 0x1ff:
+        case RX_EXCP_TRAP_BASE ... RX_EXCP_TRAP_BASE + RX_EXCP_TRAP_COUNT - 1:
             expname = "unconditional trap";
         }
         qemu_log_mask(CPU_LOG_INT, "exception 0x%02x [%s] raised\n",
target/rx/op_helper.c +5 -5
index fb1fa4ffa69..06841088ac0 100644
@@ -115,7 +115,7 @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr)
         enable = FIELD_EX32(env->fpsw, FPSW, ENABLE);
         enable |= 1 << 5; /* CE always enabled */
         if (cause & enable) {
-            raise_exception(env, 21, retaddr);
+            raise_exception(env, RX_EXCP_ACCESS, retaddr);
         }
     }
 }
@@ -432,17 +432,17 @@ void raise_exception(CPURXState *env, int index,
 
 G_NORETURN void helper_raise_privilege_violation(CPURXState *env)
 {
-    raise_exception(env, 20, GETPC());
+    raise_exception(env, RX_EXCP_PRIVILEGE_VIOLATION, GETPC());
 }
 
 G_NORETURN void helper_raise_access_fault(CPURXState *env)
 {
-    raise_exception(env, 21, GETPC());
+    raise_exception(env, RX_EXCP_ACCESS, GETPC());
 }
 
 G_NORETURN void helper_raise_illegal_instruction(CPURXState *env)
 {
-    raise_exception(env, 23, GETPC());
+    raise_exception(env, RX_EXCP_ILLEGAL_INSTRUCTION, GETPC());
 }
 
 G_NORETURN void helper_wait(CPURXState *env)
@@ -457,5 +457,5 @@ G_NORETURN void helper_wait(CPURXState *env)
 
 G_NORETURN void helper_trap(CPURXState *env, uint32_t vec)
 {
-    raise_exception(env, 0x100 + vec, 0);
+    raise_exception(env, RX_EXCP_TRAP_BASE + vec, 0);
 }
target/rx/translate.c +1 -1
index 0672c5c5653..a350f6b4d26 100644
@@ -2187,7 +2187,7 @@ static bool trans_BRK(DisasContext *ctx, arg_BRK *a)
 /* int #imm */
 static bool trans_INT(DisasContext *ctx, arg_INT *a)
 {
-    tcg_debug_assert(a->imm < 0x100);
+    tcg_debug_assert(a->imm < RX_EXCP_TRAP_COUNT);
     return do_trap(ctx, a->imm);
 }
 
Signature · 1 line
2.55.0
#63 lore raw

[PULL 54/83] target/avr: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert avr to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/avr/cpu.h    |  3 ++-
 target/avr/cpu.c    |  2 +-
 target/avr/helper.c | 11 +++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)
target/avr/cpu.h +2 -1
index b1b5b637617..a98fa6ceadc 100644
@@ -179,7 +179,8 @@ extern const struct VMStateDescription vms_avr_cpu;
 
 void avr_cpu_do_interrupt(CPUState *cpu);
 bool avr_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr avr_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool avr_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                 TranslateForDebugResult *result);
 int avr_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int avr_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 int avr_print_insn(bfd_vma addr, disassemble_info *info);
target/avr/cpu.c +1 -1
index 244871e5e63..83710f56518 100644
@@ -234,7 +234,7 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags)
 
 static const struct SysemuCPUOps avr_sysemu_ops = {
     .has_work = avr_cpu_has_work,
-    .get_phys_addr_debug = avr_cpu_get_phys_addr_debug,
+    .translate_for_debug = avr_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps avr_tcg_ops = {
target/avr/helper.c +9 -2
index f452c9d9040..8f90b8d9a45 100644
@@ -108,9 +108,16 @@ void avr_cpu_do_interrupt(CPUState *cs)
     qemu_plugin_vcpu_interrupt_cb(cs, ret);
 }
 
-hwaddr avr_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool avr_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                 TranslateForDebugResult *result)
 {
-    return addr; /* I assume 1:1 address correspondence */
+    /* I assume 1:1 address correspondence */
+    *result = (TranslateForDebugResult) {
+        .physaddr = addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
Signature · 1 line
2.55.0
#64 lore raw

[PULL 67/83] target/microblaze: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/microblaze/op_helper.c | 46 +++++++++++++++++------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
target/microblaze/op_helper.c +23 -23
index c169312e954..c53103ecd79 100644
@@ -27,7 +27,7 @@
 #include "accel/tcg/cpu-loop.h"
 #include "fpu/softfloat.h"
 
-void helper_put(uint32_t id, uint32_t ctrl, uint32_t data)
+void HELPER(put)(uint32_t id, uint32_t ctrl, uint32_t data)
 {
     int test = ctrl & STREAM_TEST;
     int atomic = ctrl & STREAM_ATOMIC;
@@ -44,7 +44,7 @@ void helper_put(uint32_t id, uint32_t ctrl, uint32_t data)
              atomic ? "a" : "");
 }
 
-uint32_t helper_get(uint32_t id, uint32_t ctrl)
+uint32_t HELPER(get)(uint32_t id, uint32_t ctrl)
 {
     int test = ctrl & STREAM_TEST;
     int atomic = ctrl & STREAM_ATOMIC;
@@ -62,7 +62,7 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)
     return 0xdead0000 | id;
 }
 
-void helper_microblaze_raise_exception(CPUMBState *env, uint32_t index)
+void HELPER(microblaze_raise_exception)(CPUMBState *env, uint32_t index)
 {
     CPUState *cs = env_cpu(env);
 
@@ -84,7 +84,7 @@ static void raise_divzero(CPUMBState *env, uint32_t esr, uintptr_t unwind_pc)
     }
 }
 
-uint32_t helper_divs(CPUMBState *env, uint32_t ra, uint32_t rb)
+uint32_t HELPER(divs)(CPUMBState *env, uint32_t ra, uint32_t rb)
 {
     if (!ra) {
         raise_divzero(env, ESR_EC_DIVZERO, GETPC());
@@ -108,7 +108,7 @@ uint32_t helper_divs(CPUMBState *env, uint32_t ra, uint32_t rb)
     return (int32_t)rb / (int32_t)ra;
 }
 
-uint32_t helper_divu(CPUMBState *env, uint32_t ra, uint32_t rb)
+uint32_t HELPER(divu)(CPUMBState *env, uint32_t ra, uint32_t rb)
 {
     if (!ra) {
         raise_divzero(env, ESR_EC_DIVZERO, GETPC());
@@ -154,7 +154,7 @@ static void update_fpu_flags(CPUMBState *env, int flags, uintptr_t ra)
     }
 }
 
-uint32_t helper_microblaze_fadd(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(microblaze_fadd)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fd, fa, fb;
     int flags;
@@ -169,7 +169,7 @@ uint32_t helper_microblaze_fadd(CPUMBState *env, uint32_t a, uint32_t b)
     return fd.l;
 }
 
-uint32_t helper_frsub(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(frsub)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fd, fa, fb;
     int flags;
@@ -183,7 +183,7 @@ uint32_t helper_frsub(CPUMBState *env, uint32_t a, uint32_t b)
     return fd.l;
 }
 
-uint32_t helper_microblaze_fmul(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(microblaze_fmul)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fd, fa, fb;
     int flags;
@@ -198,7 +198,7 @@ uint32_t helper_microblaze_fmul(CPUMBState *env, uint32_t a, uint32_t b)
     return fd.l;
 }
 
-uint32_t helper_microblaze_fdiv(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(microblaze_fdiv)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fd, fa, fb;
     int flags;
@@ -213,7 +213,7 @@ uint32_t helper_microblaze_fdiv(CPUMBState *env, uint32_t a, uint32_t b)
     return fd.l;
 }
 
-uint32_t helper_fcmp_un(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_un)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     uint32_t r = 0;
@@ -235,7 +235,7 @@ uint32_t helper_fcmp_un(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_lt(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_lt)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int r;
@@ -251,7 +251,7 @@ uint32_t helper_fcmp_lt(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_eq(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_eq)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int flags;
@@ -267,7 +267,7 @@ uint32_t helper_fcmp_eq(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_le(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_le)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int flags;
@@ -284,7 +284,7 @@ uint32_t helper_fcmp_le(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_gt(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_gt)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int flags, r;
@@ -298,7 +298,7 @@ uint32_t helper_fcmp_gt(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_ne(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_ne)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int flags, r;
@@ -313,7 +313,7 @@ uint32_t helper_fcmp_ne(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_fcmp_ge(CPUMBState *env, uint32_t a, uint32_t b)
+uint32_t HELPER(fcmp_ge)(CPUMBState *env, uint32_t a, uint32_t b)
 {
     CPU_FloatU fa, fb;
     int flags, r;
@@ -328,7 +328,7 @@ uint32_t helper_fcmp_ge(CPUMBState *env, uint32_t a, uint32_t b)
     return r;
 }
 
-uint32_t helper_flt(CPUMBState *env, uint32_t a)
+uint32_t HELPER(flt)(CPUMBState *env, uint32_t a)
 {
     CPU_FloatU fd, fa;
 
@@ -337,7 +337,7 @@ uint32_t helper_flt(CPUMBState *env, uint32_t a)
     return fd.l;
 }
 
-uint32_t helper_fint(CPUMBState *env, uint32_t a)
+uint32_t HELPER(fint)(CPUMBState *env, uint32_t a)
 {
     CPU_FloatU fa;
     uint32_t r;
@@ -352,7 +352,7 @@ uint32_t helper_fint(CPUMBState *env, uint32_t a)
     return r;
 }
 
-uint32_t helper_microblaze_fsqrt(CPUMBState *env, uint32_t a)
+uint32_t HELPER(microblaze_fsqrt)(CPUMBState *env, uint32_t a)
 {
     CPU_FloatU fd, fa;
     int flags;
@@ -366,7 +366,7 @@ uint32_t helper_microblaze_fsqrt(CPUMBState *env, uint32_t a)
     return fd.l;
 }
 
-uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
+uint32_t HELPER(pcmpbf)(uint32_t a, uint32_t b)
 {
     unsigned int i;
     uint32_t mask = 0xff000000;
@@ -379,7 +379,7 @@ uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
     return 0;
 }
 
-void helper_stackprot(CPUMBState *env, uint32_t addr)
+void HELPER(stackprot)(CPUMBState *env, uint32_t addr)
 {
     if (addr < env->slr || addr > env->shr) {
         CPUState *cs = env_cpu(env);
@@ -399,12 +399,12 @@ void helper_stackprot(CPUMBState *env, uint32_t addr)
 #include "system/memory.h"
 
 /* Writes/reads to the MMU's special regs end up here.  */
-uint32_t helper_mmu_read(CPUMBState *env, uint32_t ext, uint32_t rn)
+uint32_t HELPER(mmu_read)(CPUMBState *env, uint32_t ext, uint32_t rn)
 {
     return mmu_read(env, ext, rn);
 }
 
-void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)
+void HELPER(mmu_write)(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)
 {
     mmu_write(env, ext, rn, v);
 }
Signature · 1 line
2.55.0
#65 lore raw

[PULL 57/83] target/tricore: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert tricore to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/tricore/cpu.h    |  3 ++-
 target/tricore/cpu.c    |  2 +-
 target/tricore/helper.c | 13 ++++++++++---
 3 files changed, 13 insertions(+), 5 deletions(-)
target/tricore/cpu.h +2 -1
index 12e497d2a7a..17e3d1fe804 100644
@@ -79,7 +79,8 @@ struct TriCoreCPUClass {
     ResettablePhases parent_phases;
 };
 
-hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool tricore_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                     TranslateForDebugResult *result);
 void tricore_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 
 FIELD(PCXI, PCPN_13, 24, 8)
target/tricore/cpu.c +1 -1
index 82b56c3cd56..fa782f82f00 100644
@@ -207,7 +207,7 @@ static bool tricore_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 
 static const struct SysemuCPUOps tricore_sysemu_ops = {
     .has_work = tricore_cpu_has_work,
-    .get_phys_addr_debug = tricore_cpu_get_phys_addr_debug,
+    .translate_for_debug = tricore_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps tricore_tcg_ops = {
target/tricore/helper.c +10 -3
index 273713a1473..9cc80b14c8c 100644
@@ -47,7 +47,8 @@ static int get_physical_address(CPUTriCoreState *env, hwaddr *physical,
     return ret;
 }
 
-hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool tricore_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                     TranslateForDebugResult *result)
 {
     TriCoreCPU *cpu = TRICORE_CPU(cs);
     hwaddr phys_addr;
@@ -56,9 +57,15 @@ hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
     if (get_physical_address(&cpu->env, &phys_addr, &prot, addr,
                              MMU_DATA_LOAD, mmu_idx)) {
-        return -1;
+        return false;
     }
-    return phys_addr;
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 /* TODO: Add exception support */
Signature · 1 line
2.55.0
#66 lore raw

[PULL 79/83] target/m68k: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert m68k to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/m68k/cpu.h    |  3 ++-
 target/m68k/cpu.c    |  2 +-
 target/m68k/helper.c | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 6 deletions(-)
target/m68k/cpu.h +2 -1
index 44b4afc41c6..781c98f7840 100644
@@ -187,7 +187,8 @@ struct M68kCPUClass {
 #ifndef CONFIG_USER_ONLY
 void m68k_cpu_do_interrupt(CPUState *cpu);
 bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr m68k_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool m68k_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                  TranslateForDebugResult *result);
 #endif /* !CONFIG_USER_ONLY */
 void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
target/m68k/cpu.c +1 -1
index 01c6b6afb1f..f7d289e591a 100644
@@ -688,7 +688,7 @@ static const MonitorDef m68k_monitor_defs[] = {
 
 static const struct SysemuCPUOps m68k_sysemu_ops = {
     .has_work = m68k_cpu_has_work,
-    .get_phys_addr_debug = m68k_cpu_get_phys_addr_debug,
+    .translate_for_debug = m68k_cpu_translate_for_debug,
 #ifdef CONFIG_HMP
     .monitor_defs = m68k_monitor_defs,
 #endif
target/m68k/helper.c +12 -4
index 5f91d206f59..c30854a6746 100644
@@ -908,7 +908,8 @@ txfail:
     return -1;
 }
 
-hwaddr m68k_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool m68k_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                  TranslateForDebugResult *result)
 {
     CPUM68KState *env = cpu_env(cs);
     hwaddr phys_addr;
@@ -918,7 +919,8 @@ hwaddr m68k_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
     if ((env->mmu.tcr & M68K_TCR_ENABLED) == 0) {
         /* MMU disabled */
-        return addr;
+        phys_addr = addr;
+        goto success;
     }
 
     access_type = ACCESS_DATA | ACCESS_DEBUG;
@@ -928,10 +930,16 @@ hwaddr m68k_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
     if (get_physical_address(env, &phys_addr, &prot,
                              addr, access_type, &page_size) != 0) {
-        return -1;
+        return false;
     }
 
-    return phys_addr;
+success:
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 /*
Signature · 1 line
2.55.0
#67 lore raw

[PULL 68/83] target/mips: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/mips/tcg/dsp_helper.c            | 187 +++----
 target/mips/tcg/exception.c             |   8 +-
 target/mips/tcg/fpu_helper.c            | 291 +++++-----
 target/mips/tcg/ldst_helper.c           |  18 +-
 target/mips/tcg/lmmi_helper.c           |  98 ++--
 target/mips/tcg/msa_helper.c            | 690 ++++++++++++------------
 target/mips/tcg/octeon_crypto.c         | 100 ++--
 target/mips/tcg/op_helper.c             |  34 +-
 target/mips/tcg/system/cp0_helper.c     | 276 +++++-----
 target/mips/tcg/system/lcsr_helper.c    |   8 +-
 target/mips/tcg/system/special_helper.c |  12 +-
 target/mips/tcg/system/tlb_helper.c     |  14 +-
 target/mips/tcg/vr54xx_helper.c         |  30 +-
 13 files changed, 892 insertions(+), 874 deletions(-)
target/mips/tcg/dsp_helper.c +94 -93
index 7a4362c8ef4..26fcfd5fb35 100644
@@ -1094,7 +1094,7 @@ static inline int32_t mipsdsp_cmpu_lt(uint32_t a, uint32_t b)
 
 /** DSP Arithmetic Sub-class insns **/
 #define MIPSDSP32_UNOP_ENV(name, func, element)                            \
-target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
+target_ulong HELPER(name)(target_ulong rt, CPUMIPSState *env)              \
 {                                                                          \
     DSP32Value dt;                                                         \
     unsigned int i;                                                     \
@@ -1114,7 +1114,7 @@ MIPSDSP32_UNOP_ENV(absq_s_w, sat_abs32, sw)
 
 #if defined(TARGET_MIPS64)
 #define MIPSDSP64_UNOP_ENV(name, func, element)                            \
-target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
+target_ulong HELPER(name)(target_ulong rt, CPUMIPSState *env)              \
 {                                                                          \
     DSP64Value dt;                                                         \
     unsigned int i;                                                        \
@@ -1134,7 +1134,7 @@ MIPSDSP64_UNOP_ENV(absq_s_pw, sat_abs32, sw)
 #endif
 
 #define MIPSDSP32_BINOP(name, func, element)                               \
-target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt)                \
 {                                                                          \
     DSP32Value ds, dt;                                                     \
     unsigned int i;                                                        \
@@ -1161,7 +1161,7 @@ MIPSDSP32_BINOP(subqh_w, rshift1_sub_q32, sw);
 #undef MIPSDSP32_BINOP
 
 #define MIPSDSP32_BINOP_ENV(name, func, element)                           \
-target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,                \
                            CPUMIPSState *env)                              \
 {                                                                          \
     DSP32Value ds, dt;                                                     \
@@ -1194,7 +1194,7 @@ MIPSDSP32_BINOP_ENV(subu_s_qb, satu8_sub, ub);
 
 #ifdef TARGET_MIPS64
 #define MIPSDSP64_BINOP(name, func, element)                               \
-target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt)                \
 {                                                                          \
     DSP64Value ds, dt;                                                     \
     unsigned int i;                                                        \
@@ -1215,7 +1215,7 @@ MIPSDSP64_BINOP(subuh_r_ob, rrshift1_sub_u8, ub);
 #undef MIPSDSP64_BINOP
 
 #define MIPSDSP64_BINOP_ENV(name, func, element)                           \
-target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,                \
                            CPUMIPSState *env)                              \
 {                                                                          \
     DSP64Value ds, dt;                                                     \
@@ -1251,7 +1251,7 @@ MIPSDSP64_BINOP_ENV(subu_s_qh, satu16_sub_u16_u16, uh);
 #endif
 
 #define SUBUH_QB(name, var) \
-target_ulong helper_##name##_qb(target_ulong rs, target_ulong rt) \
+target_ulong HELPER(name##_qb)(target_ulong rs, target_ulong rt)  \
 {                                                                 \
     uint8_t rs3, rs2, rs1, rs0;                                   \
     uint8_t rt3, rt2, rt1, rt0;                                   \
@@ -1274,7 +1274,7 @@ SUBUH_QB(subuh_r, 1);
 
 #undef SUBUH_QB
 
-target_ulong helper_addsc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
+target_ulong HELPER(addsc)(target_ulong rs, target_ulong rt, CPUMIPSState *env)
 {
     uint64_t temp, tempRs, tempRt;
     bool flag;
@@ -1289,7 +1289,7 @@ target_ulong helper_addsc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
     return (target_long)(int32_t)(temp & MIPSDSP_LLO);
 }
 
-target_ulong helper_addwc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
+target_ulong HELPER(addwc)(target_ulong rs, target_ulong rt, CPUMIPSState *env)
 {
     uint32_t rd;
     int32_t temp32, temp31;
@@ -1309,7 +1309,7 @@ target_ulong helper_addwc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
     return (target_long)(int32_t)rd;
 }
 
-target_ulong helper_modsub(target_ulong rs, target_ulong rt)
+target_ulong HELPER(modsub)(target_ulong rs, target_ulong rt)
 {
     int32_t decr;
     uint16_t lastindex;
@@ -1327,7 +1327,7 @@ target_ulong helper_modsub(target_ulong rs, target_ulong rt)
     return rd;
 }
 
-target_ulong helper_raddu_w_qb(target_ulong rs)
+target_ulong HELPER(raddu_w_qb)(target_ulong rs)
 {
     target_ulong ret = 0;
     DSP32Value ds;
@@ -1341,7 +1341,7 @@ target_ulong helper_raddu_w_qb(target_ulong rs)
 }
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_raddu_l_ob(target_ulong rs)
+target_ulong HELPER(raddu_l_ob)(target_ulong rs)
 {
     target_ulong ret = 0;
     DSP64Value ds;
@@ -1356,7 +1356,7 @@ target_ulong helper_raddu_l_ob(target_ulong rs)
 #endif
 
 #define PRECR_QB_PH(name, a, b)\
-target_ulong helper_##name##_qb_ph(target_ulong rs, target_ulong rt) \
+target_ulong HELPER(name##_qb_ph)(target_ulong rs, target_ulong rt)  \
 {                                                                    \
     uint8_t tempD, tempC, tempB, tempA;                              \
                                                                      \
@@ -1373,7 +1373,7 @@ PRECR_QB_PH(precrq, 24, 8);
 
 #undef PRECR_QB_OH
 
-target_ulong helper_precr_sra_ph_w(uint32_t sa, target_ulong rs,
+target_ulong HELPER(precr_sra_ph_w)(uint32_t sa, target_ulong rs,
                                    target_ulong rt)
 {
     uint16_t tempB, tempA;
@@ -1384,7 +1384,7 @@ target_ulong helper_precr_sra_ph_w(uint32_t sa, target_ulong rs,
     return MIPSDSP_RETURN32_16(tempB, tempA);
 }
 
-target_ulong helper_precr_sra_r_ph_w(uint32_t sa,
+target_ulong HELPER(precr_sra_r_ph_w)(uint32_t sa,
                                      target_ulong rs, target_ulong rt)
 {
     uint64_t tempB, tempA;
@@ -1402,7 +1402,7 @@ target_ulong helper_precr_sra_r_ph_w(uint32_t sa,
     return (target_long)(int32_t)rt;
 }
 
-target_ulong helper_precrq_ph_w(target_ulong rs, target_ulong rt)
+target_ulong HELPER(precrq_ph_w)(target_ulong rs, target_ulong rt)
 {
     uint16_t tempB, tempA;
 
@@ -1412,7 +1412,7 @@ target_ulong helper_precrq_ph_w(target_ulong rs, target_ulong rt)
     return MIPSDSP_RETURN32_16(tempB, tempA);
 }
 
-target_ulong helper_precrq_rs_ph_w(target_ulong rs, target_ulong rt,
+target_ulong HELPER(precrq_rs_ph_w)(target_ulong rs, target_ulong rt,
                                    CPUMIPSState *env)
 {
     uint16_t tempB, tempA;
@@ -1424,7 +1424,7 @@ target_ulong helper_precrq_rs_ph_w(target_ulong rs, target_ulong rt,
 }
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_precr_ob_qh(target_ulong rs, target_ulong rt)
+target_ulong HELPER(precr_ob_qh)(target_ulong rs, target_ulong rt)
 {
     uint8_t rs6, rs4, rs2, rs0;
     uint8_t rt6, rt4, rt2, rt0;
@@ -1453,7 +1453,7 @@ target_ulong helper_precr_ob_qh(target_ulong rs, target_ulong rt)
  * In case sa != 0, use rt3, rt1, rs3, rs1.
  */
 #define PRECR_QH_PW(name, var)                                        \
-target_ulong helper_precr_##name##_qh_pw(target_ulong rs,             \
+target_ulong HELPER(precr_##name##_qh_pw)(target_ulong rs,            \
                                          target_ulong rt,             \
                                          uint32_t sa)                 \
 {                                                                     \
@@ -1484,7 +1484,7 @@ PRECR_QH_PW(sra_r, 1);
 
 #undef PRECR_QH_PW
 
-target_ulong helper_precrq_ob_qh(target_ulong rs, target_ulong rt)
+target_ulong HELPER(precrq_ob_qh)(target_ulong rs, target_ulong rt)
 {
     uint8_t rs6, rs4, rs2, rs0;
     uint8_t rt6, rt4, rt2, rt0;
@@ -1507,7 +1507,7 @@ target_ulong helper_precrq_ob_qh(target_ulong rs, target_ulong rt)
     return temp;
 }
 
-target_ulong helper_precrq_qh_pw(target_ulong rs, target_ulong rt)
+target_ulong HELPER(precrq_qh_pw)(target_ulong rs, target_ulong rt)
 {
     uint16_t tempD, tempC, tempB, tempA;
 
@@ -1519,7 +1519,7 @@ target_ulong helper_precrq_qh_pw(target_ulong rs, target_ulong rt)
     return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA);
 }
 
-target_ulong helper_precrq_rs_qh_pw(target_ulong rs, target_ulong rt,
+target_ulong HELPER(precrq_rs_qh_pw)(target_ulong rs, target_ulong rt,
                                     CPUMIPSState *env)
 {
     uint32_t rs2, rs0;
@@ -1539,7 +1539,7 @@ target_ulong helper_precrq_rs_qh_pw(target_ulong rs, target_ulong rt,
     return MIPSDSP_RETURN64_16(tempD, tempC, tempB, tempA);
 }
 
-target_ulong helper_precrq_pw_l(target_ulong rs, target_ulong rt)
+target_ulong HELPER(precrq_pw_l)(target_ulong rs, target_ulong rt)
 {
     uint32_t tempB, tempA;
 
@@ -1550,7 +1550,7 @@ target_ulong helper_precrq_pw_l(target_ulong rs, target_ulong rt)
 }
 #endif
 
-target_ulong helper_precrqu_s_qb_ph(target_ulong rs, target_ulong rt,
+target_ulong HELPER(precrqu_s_qb_ph)(target_ulong rs, target_ulong rt,
                                     CPUMIPSState *env)
 {
     uint8_t  tempD, tempC, tempB, tempA;
@@ -1570,7 +1570,7 @@ target_ulong helper_precrqu_s_qb_ph(target_ulong rs, target_ulong rt,
 }
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_precrqu_s_ob_qh(target_ulong rs, target_ulong rt,
+target_ulong HELPER(precrqu_s_ob_qh)(target_ulong rs, target_ulong rt,
                                     CPUMIPSState *env)
 {
     int i;
@@ -1601,7 +1601,7 @@ target_ulong helper_precrqu_s_ob_qh(target_ulong rs, target_ulong rt,
 }
 
 #define PRECEQ_PW(name, a, b) \
-target_ulong helper_preceq_pw_##name(target_ulong rt) \
+target_ulong HELPER(preceq_pw_##name)(target_ulong rt) \
 {                                                       \
     uint16_t tempB, tempA;                              \
     uint32_t tempBI, tempAI;                            \
@@ -1625,7 +1625,7 @@ PRECEQ_PW(qhra, 32, 0);
 #endif
 
 #define PRECEQU_PH(name, a, b) \
-target_ulong helper_precequ_ph_##name(target_ulong rt) \
+target_ulong HELPER(precequ_ph_##name)(target_ulong rt) \
 {                                                        \
     uint16_t tempB, tempA;                               \
                                                          \
@@ -1647,7 +1647,7 @@ PRECEQU_PH(qbra, 16, 0);
 
 #if defined(TARGET_MIPS64)
 #define PRECEQU_QH(name, a, b, c, d) \
-target_ulong helper_precequ_qh_##name(target_ulong rt)       \
+target_ulong HELPER(precequ_qh_##name)(target_ulong rt)      \
 {                                                            \
     uint16_t tempD, tempC, tempB, tempA;                     \
                                                              \
@@ -1674,7 +1674,7 @@ PRECEQU_QH(obra, 48, 32, 16, 0);
 #endif
 
 #define PRECEU_PH(name, a, b) \
-target_ulong helper_preceu_ph_##name(target_ulong rt) \
+target_ulong HELPER(preceu_ph_##name)(target_ulong rt) \
 {                                                     \
     uint16_t tempB, tempA;                            \
                                                       \
@@ -1693,7 +1693,7 @@ PRECEU_PH(qbra, 16, 0);
 
 #if defined(TARGET_MIPS64)
 #define PRECEU_QH(name, a, b, c, d) \
-target_ulong helper_preceu_qh_##name(target_ulong rt)        \
+target_ulong HELPER(preceu_qh_##name)(target_ulong rt)       \
 {                                                            \
     uint16_t tempD, tempC, tempB, tempA;                     \
                                                              \
@@ -1716,7 +1716,7 @@ PRECEU_QH(obra, 48, 32, 16, 0);
 
 /** DSP GPR-Based Shift Sub-class insns **/
 #define SHIFT_QB(name, func) \
-target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt) \
+target_ulong HELPER(name##_qb)(target_ulong sa, target_ulong rt)  \
 {                                                                    \
     uint8_t rt3, rt2, rt1, rt0;                                      \
                                                                      \
@@ -1733,7 +1733,7 @@ target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt) \
 }
 
 #define SHIFT_QB_ENV(name, func) \
-target_ulong helper_##name##_qb(target_ulong sa, target_ulong rt,\
+target_ulong HELPER(name##_qb)(target_ulong sa, target_ulong rt, \
                                 CPUMIPSState *env) \
 {                                                                    \
     uint8_t rt3, rt2, rt1, rt0;                                      \
@@ -1761,7 +1761,7 @@ SHIFT_QB(shra_r, rnd8_rashift);
 
 #if defined(TARGET_MIPS64)
 #define SHIFT_OB(name, func) \
-target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa) \
+target_ulong HELPER(name##_ob)(target_ulong rt, target_ulong sa)  \
 {                                                                        \
     int i;                                                               \
     uint8_t rt_t[8];                                                     \
@@ -1780,7 +1780,7 @@ target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa) \
 }
 
 #define SHIFT_OB_ENV(name, func) \
-target_ulong helper_##name##_ob(target_ulong rt, target_ulong sa, \
+target_ulong HELPER(name##_ob)(target_ulong rt, target_ulong sa,  \
                                 CPUMIPSState *env)                       \
 {                                                                        \
     int i;                                                               \
@@ -1811,7 +1811,7 @@ SHIFT_OB(shra_r, rnd8_rashift);
 #endif
 
 #define SHIFT_PH(name, func) \
-target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt, \
+target_ulong HELPER(name##_ph)(target_ulong sa, target_ulong rt,  \
                                 CPUMIPSState *env)                \
 {                                                                 \
     uint16_t rth, rtl;                                            \
@@ -1833,7 +1833,7 @@ SHIFT_PH(shll_s, sat16_lshift);
 
 #if defined(TARGET_MIPS64)
 #define SHIFT_QH(name, func) \
-target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa) \
+target_ulong HELPER(name##_qh)(target_ulong rt, target_ulong sa)  \
 {                                                                 \
     uint16_t rt3, rt2, rt1, rt0;                                  \
                                                                   \
@@ -1850,7 +1850,7 @@ target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa) \
 }
 
 #define SHIFT_QH_ENV(name, func) \
-target_ulong helper_##name##_qh(target_ulong rt, target_ulong sa, \
+target_ulong HELPER(name##_qh)(target_ulong rt, target_ulong sa,  \
                                 CPUMIPSState *env)                \
 {                                                                 \
     uint16_t rt3, rt2, rt1, rt0;                                  \
@@ -1880,7 +1880,7 @@ SHIFT_QH(shra_r, rnd16_rashift);
 #endif
 
 #define SHIFT_W(name, func) \
-target_ulong helper_##name##_w(target_ulong sa, target_ulong rt) \
+target_ulong HELPER(name##_w)(target_ulong sa, target_ulong rt)  \
 {                                                                       \
     uint32_t temp;                                                      \
                                                                         \
@@ -1891,7 +1891,7 @@ target_ulong helper_##name##_w(target_ulong sa, target_ulong rt) \
 }
 
 #define SHIFT_W_ENV(name, func) \
-target_ulong helper_##name##_w(target_ulong sa, target_ulong rt, \
+target_ulong HELPER(name##_w)(target_ulong sa, target_ulong rt,  \
                                CPUMIPSState *env) \
 {                                                                       \
     uint32_t temp;                                                      \
@@ -1910,7 +1910,7 @@ SHIFT_W(shra_r, rnd32_rashift);
 
 #if defined(TARGET_MIPS64)
 #define SHIFT_PW(name, func) \
-target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa) \
+target_ulong HELPER(name##_pw)(target_ulong rt, target_ulong sa)  \
 {                                                                 \
     uint32_t rt1, rt0;                                            \
                                                                   \
@@ -1924,7 +1924,7 @@ target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa) \
 }
 
 #define SHIFT_PW_ENV(name, func) \
-target_ulong helper_##name##_pw(target_ulong rt, target_ulong sa, \
+target_ulong HELPER(name##_pw)(target_ulong rt, target_ulong sa,  \
                                 CPUMIPSState *env)                \
 {                                                                 \
     uint32_t rt1, rt0;                                            \
@@ -1950,7 +1950,7 @@ SHIFT_PW(shra_r, rnd32_rashift);
 #endif
 
 #define SHIFT_PH(name, func) \
-target_ulong helper_##name##_ph(target_ulong sa, target_ulong rt) \
+target_ulong HELPER(name##_ph)(target_ulong sa, target_ulong rt)  \
 {                                                                    \
     uint16_t rth, rtl;                                               \
                                                                      \
@@ -1978,7 +1978,7 @@ SHIFT_PH(shra_r, rnd16_rashift);
 #define MUL_RETURN32_16_PH(name, func, \
                            rsmov1, rsmov2, rsfilter, \
                            rtmov1, rtmov2, rtfilter) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt, \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,  \
                            CPUMIPSState *env)                \
 {                                                            \
     uint16_t rsB, rsA, rtB, rtA;                             \
@@ -2016,7 +2016,7 @@ MUL_RETURN32_16_PH(mulq_s_ph, sat16_mul_q15_q15, \
 #undef MUL_RETURN32_16_PH
 
 #define MUL_RETURN32_32_ph(name, func, movbits) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt, \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,  \
                                   CPUMIPSState *env)         \
 {                                                            \
     int16_t rsh, rth;                                        \
@@ -2035,7 +2035,7 @@ MUL_RETURN32_32_ph(muleq_s_w_phr, mul_q15_q15_overflowflag21, 0);
 #undef MUL_RETURN32_32_ph
 
 #define MUL_VOID_PH(name, use_ac_env) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,        \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,         \
                           CPUMIPSState *env)                             \
 {                                                                        \
     int16_t rsh, rsl, rth, rtl;                                          \
@@ -2071,7 +2071,7 @@ MUL_VOID_PH(mulsa_w_ph, 0);
 #define MUL_RETURN64_16_QH(name, func, \
                            rsmov1, rsmov2, rsmov3, rsmov4, rsfilter, \
                            rtmov1, rtmov2, rtmov3, rtmov4, rtfilter) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt,         \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,          \
                            CPUMIPSState *env)                        \
 {                                                                    \
     uint16_t rs3, rs2, rs1, rs0;                                     \
@@ -2110,7 +2110,7 @@ MUL_RETURN64_16_QH(mulq_rs_qh, rndq15_mul_q15_q15, \
 #define MUL_RETURN64_32_QH(name, \
                            rsmov1, rsmov2, \
                            rtmov1, rtmov2) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt, \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,  \
                            CPUMIPSState *env)                \
 {                                                            \
     uint16_t rsB, rsA;                                       \
@@ -2133,7 +2133,7 @@ MUL_RETURN64_32_QH(muleq_s_pw_qhr, 16, 0, 16, 0);
 
 #undef MUL_RETURN64_32_QH
 
-void helper_mulsaq_s_w_qh(target_ulong rs, target_ulong rt, uint32_t ac,
+void HELPER(mulsaq_s_w_qh)(target_ulong rs, target_ulong rt, uint32_t ac,
                           CPUMIPSState *env)
 {
     int16_t rs3, rs2, rs1, rs0;
@@ -2177,7 +2177,7 @@ void helper_mulsaq_s_w_qh(target_ulong rs, target_ulong rt, uint32_t ac,
 #endif
 
 #define DP_QB(name, func, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,        \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,         \
                    CPUMIPSState *env)                                    \
 {                                                                        \
     uint8_t rs3, rs2;                                                    \
@@ -2218,7 +2218,7 @@ DP_QB(dpsu_h_qbr, mul_u8_u8, 0, 8, 0, 8, 0);
 #define DP_OB(name, add_sub, \
               rsmov1, rsmov2, rsmov3, rsmov4, \
               rtmov1, rtmov2, rtmov3, rtmov4) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac,       \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,        \
                        CPUMIPSState *env)                               \
 {                                                                       \
     uint8_t rsD, rsC, rsB, rsA;                                         \
@@ -2281,7 +2281,7 @@ DP_OB(dpsu_h_obr, 0, 24, 16, 8, 0, 24, 16, 8, 0);
 #endif
 
 #define DP_NOFUNC_PH(name, is_add, rsmov1, rsmov2, rtmov1, rtmov2)             \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,              \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,               \
                    CPUMIPSState *env)                                          \
 {                                                                              \
     int16_t rsB, rsA, rtB, rtA;                                                \
@@ -2316,7 +2316,7 @@ DP_NOFUNC_PH(dpsx_w_ph, 0, 16, 0, 0, 16);
 #undef DP_NOFUNC_PH
 
 #define DP_HASFUNC_PH(name, is_add, rsmov1, rsmov2, rtmov1, rtmov2) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,   \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,    \
                    CPUMIPSState *env)                      \
 {                                                          \
     int16_t rsB, rsA, rtB, rtA;                            \
@@ -2355,7 +2355,7 @@ DP_HASFUNC_PH(dpsqx_s_w_ph, 0, 16, 0, 0, 16);
 #undef DP_HASFUNC_PH
 
 #define DP_128OPERATION_PH(name, is_add) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,  \
                           CPUMIPSState *env)                             \
 {                                                                        \
     int16_t rsh, rsl, rth, rtl;                                          \
@@ -2402,7 +2402,7 @@ DP_128OPERATION_PH(dpsqx_sa_w_ph, 0);
 
 #if defined(TARGET_MIPS64)
 #define DP_QH(name, is_add, use_ac_env) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac,    \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,     \
                    CPUMIPSState *env)                                \
 {                                                                    \
     int32_t rs3, rs2, rs1, rs0;                                      \
@@ -2470,7 +2470,7 @@ DP_QH(dpsq_s_w_qh, 0, 1);
 #endif
 
 #define DP_L_W(name, is_add) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,      \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,       \
                    CPUMIPSState *env)                                  \
 {                                                                      \
     int32_t temp63;                                                    \
@@ -2515,7 +2515,7 @@ DP_L_W(dpsq_sa_l_w, 0);
 
 #if defined(TARGET_MIPS64)
 #define DP_L_PW(name, func) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,  \
                    CPUMIPSState *env)                             \
 {                                                                 \
     int32_t rs1, rs0;                                             \
@@ -2565,7 +2565,7 @@ DP_L_PW(dpsq_sa_l_pw, sat64_acc_sub_q63);
 
 #undef DP_L_PW
 
-void helper_mulsaq_s_l_pw(target_ulong rs, target_ulong rt, uint32_t ac,
+void HELPER(mulsaq_s_l_pw)(target_ulong rs, target_ulong rt, uint32_t ac,
                           CPUMIPSState *env)
 {
     int32_t rs1, rs0;
@@ -2625,7 +2625,7 @@ void helper_mulsaq_s_l_pw(target_ulong rs, target_ulong rt, uint32_t ac,
 #endif
 
 #define MAQ_S_W(name, mov) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt, \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,  \
                    CPUMIPSState *env)                             \
 {                                                                 \
     int16_t rsh, rth;                                             \
@@ -2650,7 +2650,7 @@ MAQ_S_W(maq_s_w_phr, 0);
 #undef MAQ_S_W
 
 #define MAQ_SA_W(name, mov) \
-void helper_##name(uint32_t ac, target_ulong rs, target_ulong rt,        \
+void HELPER(name)(uint32_t ac, target_ulong rs, target_ulong rt,         \
                    CPUMIPSState *env)                                    \
 {                                                                        \
     int16_t rsh, rth;                                                    \
@@ -2673,7 +2673,7 @@ MAQ_SA_W(maq_sa_w_phr, 0);
 #undef MAQ_SA_W
 
 #define MULQ_W(name, addvar) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt,   \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,    \
                            CPUMIPSState *env)                  \
 {                                                              \
     int32_t rs_t, rt_t;                                        \
@@ -2703,7 +2703,7 @@ MULQ_W(mulq_rs_w, 0x80000000ull);
 #if defined(TARGET_MIPS64)
 
 #define MAQ_S_W_QH(name, mov) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,  \
                    CPUMIPSState *env)                             \
 {                                                                 \
     int16_t rs_t, rt_t;                                           \
@@ -2749,7 +2749,7 @@ MAQ_S_W_QH(maq_s_w_qhrr, 0);
 #undef MAQ_S_W_QH
 
 #define MAQ_SA_W(name, mov) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,  \
                    CPUMIPSState *env)                             \
 {                                                                 \
     int16_t rs_t, rt_t;                                           \
@@ -2780,7 +2780,7 @@ MAQ_SA_W(maq_sa_w_qhrr, 0);
 #undef MAQ_SA_W
 
 #define MAQ_S_L_PW(name, mov) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac, \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,  \
                    CPUMIPSState *env)                             \
 {                                                                 \
     int32_t rs_t, rt_t;                                           \
@@ -2822,7 +2822,7 @@ MAQ_S_L_PW(maq_s_l_pwr, 0);
 #undef MAQ_S_L_PW
 
 #define DM_OPERATE(name, func, is_add, sigext) \
-void helper_##name(target_ulong rs, target_ulong rt, uint32_t ac,    \
+void HELPER(name)(target_ulong rs, target_ulong rt, uint32_t ac,     \
                   CPUMIPSState *env)                                 \
 {                                                                    \
     int32_t rs1, rs0;                                                \
@@ -2900,7 +2900,7 @@ DM_OPERATE(dmsubu, mul_u32_u32, 0, 0);
 #endif
 
 /** DSP Bit/Manipulation Sub-class insns **/
-target_ulong helper_bitrev(target_ulong rt)
+target_ulong HELPER(bitrev)(target_ulong rt)
 {
     int32_t temp;
     uint32_t rd;
@@ -2917,7 +2917,7 @@ target_ulong helper_bitrev(target_ulong rt)
 }
 
 #define BIT_INSV(name, posfilter, ret_type)                     \
-target_ulong helper_##name(CPUMIPSState *env, target_ulong rs,  \
+target_ulong HELPER(name)(CPUMIPSState *env, target_ulong rs,   \
                            target_ulong rt)                     \
 {                                                               \
     uint32_t pos, size, msb, lsb;                               \
@@ -2952,7 +2952,7 @@ BIT_INSV(dinsv, 0x7F, target_long);
 
 /** DSP Compare-Pick Sub-class insns **/
 #define CMP_HAS_RET(name, func, split_num, filter, bit_size) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt) \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt)  \
 {                                                       \
     uint32_t rs_t, rt_t;                                \
     uint8_t cc;                                         \
@@ -2983,7 +2983,7 @@ CMP_HAS_RET(cmpgu_le_ob, cmpu_le, 8, MIPSDSP_Q0, 8);
 
 
 #define CMP_NO_RET(name, func, split_num, filter, bit_size) \
-void helper_##name(target_ulong rs, target_ulong rt,        \
+void HELPER(name)(target_ulong rs, target_ulong rt,         \
                             CPUMIPSState *env)              \
 {                                                           \
     int##bit_size##_t rs_t, rt_t;                           \
@@ -3028,7 +3028,7 @@ CMP_NO_RET(cmp_le_pw, cmp_le, 2, MIPSDSP_LLO, 32);
 #if defined(TARGET_MIPS64)
 
 #define CMPGDU_OB(name) \
-target_ulong helper_cmpgdu_##name##_ob(target_ulong rs, target_ulong rt, \
+target_ulong HELPER(cmpgdu_##name##_ob)(target_ulong rs, target_ulong rt, \
                                        CPUMIPSState *env)  \
 {                                                     \
     int i;                                            \
@@ -3058,7 +3058,7 @@ CMPGDU_OB(le)
 #endif
 
 #define PICK_INSN(name, split_num, filter, bit_size, ret32bit) \
-target_ulong helper_##name(target_ulong rs, target_ulong rt,   \
+target_ulong HELPER(name)(target_ulong rs, target_ulong rt,    \
                             CPUMIPSState *env)                 \
 {                                                              \
     uint32_t rs_t, rt_t;                                       \
@@ -3094,7 +3094,7 @@ PICK_INSN(pick_pw, 2, MIPSDSP_LLO, 32, 0);
 #endif
 #undef PICK_INSN
 
-target_ulong helper_packrl_ph(target_ulong rs, target_ulong rt)
+target_ulong HELPER(packrl_ph)(target_ulong rs, target_ulong rt)
 {
     uint32_t rsl, rth;
 
@@ -3105,7 +3105,7 @@ target_ulong helper_packrl_ph(target_ulong rs, target_ulong rt)
 }
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_packrl_pw(target_ulong rs, target_ulong rt)
+target_ulong HELPER(packrl_pw)(target_ulong rs, target_ulong rt)
 {
     uint32_t rs0, rt1;
 
@@ -3117,7 +3117,7 @@ target_ulong helper_packrl_pw(target_ulong rs, target_ulong rt)
 #endif
 
 /** DSP Accumulator and DSPControl Access Sub-class insns **/
-target_ulong helper_extr_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(extr_w)(target_ulong ac, target_ulong shift,
                            CPUMIPSState *env)
 {
     int32_t tempI;
@@ -3146,7 +3146,7 @@ target_ulong helper_extr_w(target_ulong ac, target_ulong shift,
     return (target_long)tempI;
 }
 
-target_ulong helper_extr_r_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(extr_r_w)(target_ulong ac, target_ulong shift,
                              CPUMIPSState *env)
 {
     int64_t tempDL[2];
@@ -3172,7 +3172,7 @@ target_ulong helper_extr_r_w(target_ulong ac, target_ulong shift,
     return (target_long)(int32_t)(tempDL[0] >> 1);
 }
 
-target_ulong helper_extr_rs_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(extr_rs_w)(target_ulong ac, target_ulong shift,
                               CPUMIPSState *env)
 {
     int32_t tempI, temp64;
@@ -3206,7 +3206,7 @@ target_ulong helper_extr_rs_w(target_ulong ac, target_ulong shift,
 }
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_dextr_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_w)(target_ulong ac, target_ulong shift,
                             CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3218,7 +3218,7 @@ target_ulong helper_dextr_w(target_ulong ac, target_ulong shift,
     return (int64_t)(int32_t)(temp[0] >> 1);
 }
 
-target_ulong helper_dextr_r_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_r_w)(target_ulong ac, target_ulong shift,
                               CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3245,7 +3245,7 @@ target_ulong helper_dextr_r_w(target_ulong ac, target_ulong shift,
     return (int64_t)(int32_t)(temp[0] >> 1);
 }
 
-target_ulong helper_dextr_rs_w(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_rs_w)(target_ulong ac, target_ulong shift,
                                CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3277,7 +3277,7 @@ target_ulong helper_dextr_rs_w(target_ulong ac, target_ulong shift,
     return (int64_t)(int32_t)(temp[0] >> 1);
 }
 
-target_ulong helper_dextr_l(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_l)(target_ulong ac, target_ulong shift,
                             CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3289,7 +3289,7 @@ target_ulong helper_dextr_l(target_ulong ac, target_ulong shift,
     return (temp[1] << 63) | (temp[0] >> 1);
 }
 
-target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_r_l)(target_ulong ac, target_ulong shift,
                               CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3316,7 +3316,7 @@ target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,
     return (temp[1] << 63) | (temp[0] >> 1);
 }
 
-target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_rs_l)(target_ulong ac, target_ulong shift,
                                CPUMIPSState *env)
 {
     uint64_t temp[3];
@@ -3351,7 +3351,7 @@ target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,
 }
 #endif
 
-target_ulong helper_extr_s_h(target_ulong ac, target_ulong shift,
+target_ulong HELPER(extr_s_h)(target_ulong ac, target_ulong shift,
                              CPUMIPSState *env)
 {
     int64_t temp, acc;
@@ -3376,7 +3376,7 @@ target_ulong helper_extr_s_h(target_ulong ac, target_ulong shift,
 
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_dextr_s_h(target_ulong ac, target_ulong shift,
+target_ulong HELPER(dextr_s_h)(target_ulong ac, target_ulong shift,
                               CPUMIPSState *env)
 {
     int64_t temp[2];
@@ -3405,7 +3405,7 @@ target_ulong helper_dextr_s_h(target_ulong ac, target_ulong shift,
 
 #endif
 
-target_ulong helper_extp(target_ulong ac, target_ulong size, CPUMIPSState *env)
+target_ulong HELPER(extp)(target_ulong ac, target_ulong size, CPUMIPSState *env)
 {
     int32_t start_pos;
     int sub;
@@ -3429,7 +3429,7 @@ target_ulong helper_extp(target_ulong ac, target_ulong size, CPUMIPSState *env)
     return (target_ulong)temp;
 }
 
-target_ulong helper_extpdp(target_ulong ac, target_ulong size,
+target_ulong HELPER(extpdp)(target_ulong ac, target_ulong size,
                            CPUMIPSState *env)
 {
     int32_t start_pos;
@@ -3457,7 +3457,8 @@ target_ulong helper_extpdp(target_ulong ac, target_ulong size,
 
 
 #if defined(TARGET_MIPS64)
-target_ulong helper_dextp(target_ulong ac, target_ulong size, CPUMIPSState *env)
+target_ulong HELPER(dextp)(target_ulong ac, target_ulong size,
+                           CPUMIPSState *env)
 {
     int start_pos;
     int len;
@@ -3486,7 +3487,7 @@ target_ulong helper_dextp(target_ulong ac, target_ulong size, CPUMIPSState *env)
     return temp;
 }
 
-target_ulong helper_dextpdp(target_ulong ac, target_ulong size,
+target_ulong HELPER(dextpdp)(target_ulong ac, target_ulong size,
                             CPUMIPSState *env)
 {
     int start_pos;
@@ -3518,7 +3519,7 @@ target_ulong helper_dextpdp(target_ulong ac, target_ulong size,
 
 #endif
 
-void helper_shilo(target_ulong ac, target_ulong rs, CPUMIPSState *env)
+void HELPER(shilo)(target_ulong ac, target_ulong rs, CPUMIPSState *env)
 {
     int8_t  rs5_0;
     uint64_t temp, acc;
@@ -3544,7 +3545,7 @@ void helper_shilo(target_ulong ac, target_ulong rs, CPUMIPSState *env)
 }
 
 #if defined(TARGET_MIPS64)
-void helper_dshilo(target_ulong shift, target_ulong ac, CPUMIPSState *env)
+void HELPER(dshilo)(target_ulong shift, target_ulong ac, CPUMIPSState *env)
 {
     int8_t shift_t;
     uint64_t tempB, tempA;
@@ -3570,7 +3571,7 @@ void helper_dshilo(target_ulong shift, target_ulong ac, CPUMIPSState *env)
 }
 
 #endif
-void helper_mthlip(target_ulong ac, target_ulong rs, CPUMIPSState *env)
+void HELPER(mthlip)(target_ulong ac, target_ulong rs, CPUMIPSState *env)
 {
     int32_t tempA, tempB, pos;
 
@@ -3588,7 +3589,7 @@ void helper_mthlip(target_ulong ac, target_ulong rs, CPUMIPSState *env)
 }
 
 #if defined(TARGET_MIPS64)
-void helper_dmthlip(target_ulong rs, target_ulong ac, CPUMIPSState *env)
+void HELPER(dmthlip)(target_ulong rs, target_ulong ac, CPUMIPSState *env)
 {
     uint8_t ac_t;
     uint8_t pos;
@@ -3677,7 +3678,7 @@ void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env)
     env->active_tc.DSPControl = dsp;
 }
 
-void helper_wrdsp(target_ulong rs, target_ulong mask_num, CPUMIPSState *env)
+void HELPER(wrdsp)(target_ulong rs, target_ulong mask_num, CPUMIPSState *env)
 {
     cpu_wrdsp(rs, mask_num, env);
 }
@@ -3733,7 +3734,7 @@ uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env)
     return temp;
 }
 
-target_ulong helper_rddsp(target_ulong mask_num, CPUMIPSState *env)
+target_ulong HELPER(rddsp)(target_ulong mask_num, CPUMIPSState *env)
 {
     return cpu_rddsp(mask_num, env);
 }
target/mips/tcg/exception.c +4 -4
index 823866ee600..626fb00bc40 100644
@@ -45,18 +45,18 @@ target_ulong exception_resume_pc(CPUMIPSState *env)
     return bad_pc;
 }
 
-void helper_raise_exception_err(CPUMIPSState *env, uint32_t exception,
+void HELPER(raise_exception_err)(CPUMIPSState *env, uint32_t exception,
                                 int error_code)
 {
     do_raise_exception_err(env, exception, error_code, 0);
 }
 
-void helper_raise_exception(CPUMIPSState *env, uint32_t exception)
+void HELPER(raise_exception)(CPUMIPSState *env, uint32_t exception)
 {
     do_raise_exception(env, exception, GETPC());
 }
 
-void helper_raise_exception_debug(CPUMIPSState *env)
+void HELPER(raise_exception_debug)(CPUMIPSState *env)
 {
     do_raise_exception(env, EXCP_DEBUG, 0);
 }
@@ -66,7 +66,7 @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
     do_raise_exception(env, exception, 0);
 }
 
-void helper_wait(CPUMIPSState *env)
+void HELPER(wait)(CPUMIPSState *env)
 {
     CPUState *cs = env_cpu(env);
 
target/mips/tcg/fpu_helper.c +147 -144

1,057 lines not on this page · raw message

target/mips/tcg/ldst_helper.c +9 -9
index 1b25466b496..13bf71ca228 100644
@@ -32,7 +32,7 @@
 #include "exec/tlb-flags.h"
 
 #define HELPER_LD_ATOMIC(name, insn, almask, do_cast)                         \
-target_ulong helper_##name(CPUMIPSState *env, target_ulong arg,               \
+target_ulong HELPER(name)(CPUMIPSState *env, target_ulong arg,                \
                            uint32_t memop_idx)                                \
 {                                                                             \
     MemOpIdx oi = memop_idx;                                                  \
@@ -73,7 +73,7 @@ static inline target_ulong get_lmask(CPUMIPSState *env,
     return value;
 }
 
-void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
+void HELPER(swl)(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
     target_ulong lmask = get_lmask(env, arg2, 32);
@@ -97,7 +97,7 @@ void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
     }
 }
 
-void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
+void HELPER(swr)(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
     target_ulong lmask = get_lmask(env, arg2, 32);
@@ -127,7 +127,7 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
  * or fault handling won't work.
  */
 
-void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
+void HELPER(sdl)(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
     target_ulong lmask = get_lmask(env, arg2, 64);
@@ -171,7 +171,7 @@ void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
     }
 }
 
-void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
+void HELPER(sdr)(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
                 int mem_idx)
 {
     target_ulong lmask = get_lmask(env, arg2, 64);
@@ -218,7 +218,7 @@ void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
 
 static const int multiple_regs[] = { 16, 17, 18, 19, 20, 21, 22, 23, 30 };
 
-void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
+void HELPER(lwm)(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
                 uint32_t memop_idx)
 {
     MemOpIdx oi = memop_idx;
@@ -239,7 +239,7 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
     }
 }
 
-void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
+void HELPER(swm)(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
                 uint32_t memop_idx)
 {
     MemOpIdx oi = memop_idx;
@@ -261,7 +261,7 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
 }
 
 #if defined(TARGET_MIPS64)
-void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
+void HELPER(ldm)(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
                 uint32_t memop_idx)
 {
     MemOpIdx oi = memop_idx;
@@ -282,7 +282,7 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
     }
 }
 
-void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
+void HELPER(sdm)(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
                 uint32_t memop_idx)
 {
     MemOpIdx oi = memop_idx;
target/mips/tcg/lmmi_helper.c +49 -49

388 lines not on this page · raw message

target/mips/tcg/msa_helper.c +352 -338

709 lines not on this page · raw message

target/mips/tcg/octeon_crypto.c +50 -50

100 lines not on this page · raw message

target/mips/tcg/op_helper.c +17 -17
index df1b5c37347..c3f0c05bc31 100644

Lines of this file are not shown. View the raw message.

target/mips/tcg/system/cp0_helper.c +138 -138

276 lines not on this page · raw message

target/mips/tcg/system/lcsr_helper.c +4 -4
index 25e03572fe9..5d7e5cb5422 100644

Lines of this file are not shown. View the raw message.

target/mips/tcg/system/special_helper.c +6 -6
index b54cbe88a38..cc46542806e 100644

Lines of this file are not shown. View the raw message.

target/mips/tcg/system/tlb_helper.c +7 -7
index 4398c6f80b4..0ff0c9c8717 100644

Lines of this file are not shown. View the raw message.

target/mips/tcg/vr54xx_helper.c +15 -15
index 2255bd11163..6c47fa7edb4 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.55.0

Part of the diff is not shown here. View the raw message.

#68 lore raw

[PULL 73/83] target/sh4: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/sh4/op_helper.c | 76 +++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 38 deletions(-)
target/sh4/op_helper.c +38 -38
index 8beac9ca034..6dbdf59385c 100644
@@ -46,7 +46,7 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
 
 #endif
 
-void helper_ldtlb(CPUSH4State *env)
+void HELPER(ldtlb)(CPUSH4State *env)
 {
 #ifdef CONFIG_USER_ONLY
     cpu_abort(env_cpu(env), "Unhandled ldtlb");
@@ -65,27 +65,27 @@ void raise_exception(CPUSH4State *env, int index,
     cpu_loop_exit_restore(cs, retaddr);
 }
 
-void helper_raise_illegal_instruction(CPUSH4State *env)
+void HELPER(raise_illegal_instruction)(CPUSH4State *env)
 {
     raise_exception(env, SH4_EXCP_ILLEGAL_INSTRUCTION, 0);
 }
 
-void helper_raise_slot_illegal_instruction(CPUSH4State *env)
+void HELPER(raise_slot_illegal_instruction)(CPUSH4State *env)
 {
     raise_exception(env, SH4_EXCP_SLOT_ILLEGAL_INSTRUCTION, 0);
 }
 
-void helper_raise_fpu_disable(CPUSH4State *env)
+void HELPER(raise_fpu_disable)(CPUSH4State *env)
 {
     raise_exception(env, SH4_EXCP_FPU_DISABLE, 0);
 }
 
-void helper_raise_slot_fpu_disable(CPUSH4State *env)
+void HELPER(raise_slot_fpu_disable)(CPUSH4State *env)
 {
     raise_exception(env, SH4_EXCP_SLOT_FPU_DISABLE, 0);
 }
 
-void helper_sleep(CPUSH4State *env)
+void HELPER(sleep)(CPUSH4State *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -94,19 +94,19 @@ void helper_sleep(CPUSH4State *env)
     raise_exception(env, EXCP_HLT, 0);
 }
 
-void helper_trapa(CPUSH4State *env, uint32_t tra)
+void HELPER(trapa)(CPUSH4State *env, uint32_t tra)
 {
     env->tra = tra << 2;
     raise_exception(env, SH4_EXCP_TRAPA, 0);
 }
 
-void helper_exclusive(CPUSH4State *env)
+void HELPER(exclusive)(CPUSH4State *env)
 {
     /* We do not want cpu_restore_state to run.  */
     cpu_loop_exit_atomic(env_cpu(env), 0);
 }
 
-void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
+void HELPER(movcal)(CPUSH4State *env, uint32_t address, uint32_t value)
 {
     if (cpu_sh4_is_cached (env, address))
     {
@@ -121,7 +121,7 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
     }
 }
 
-void helper_discard_movcal_backup(CPUSH4State *env)
+void HELPER(discard_movcal_backup)(CPUSH4State *env)
 {
     memory_content *current = env->movcal_backup;
 
@@ -135,7 +135,7 @@ void helper_discard_movcal_backup(CPUSH4State *env)
     }
 }
 
-void helper_ocbi(CPUSH4State *env, uint32_t address)
+void HELPER(ocbi)(CPUSH4State *env, uint32_t address)
 {
     unsigned mmu_idx = cpu_mmu_index(env_cpu(env), false);
     MemOpIdx oi = make_memop_idx(MO_TE | MO_UL | MO_UNALN, mmu_idx);
@@ -161,7 +161,7 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)
     }
 }
 
-void helper_macl(CPUSH4State *env, int32_t arg0, int32_t arg1)
+void HELPER(macl)(CPUSH4State *env, int32_t arg0, int32_t arg1)
 {
     const int64_t min = -(1ll << 47);
     const int64_t max = (1ll << 47) - 1;
@@ -180,7 +180,7 @@ void helper_macl(CPUSH4State *env, int32_t arg0, int32_t arg1)
     env->mac = res;
 }
 
-void helper_macw(CPUSH4State *env, int32_t arg0, int32_t arg1)
+void HELPER(macw)(CPUSH4State *env, int32_t arg0, int32_t arg1)
 {
     /* Inputs are already sign-extended from 16 bits. */
     int32_t mul = arg0 * arg1;
@@ -216,7 +216,7 @@ void cpu_load_fpscr(CPUSH4State *env, uint32_t val)
     set_flush_to_zero((val & FPSCR_DN) != 0, &env->fp_status);
 }
 
-void helper_ld_fpscr(CPUSH4State *env, uint32_t val)
+void HELPER(ld_fpscr)(CPUSH4State *env, uint32_t val)
 {
     cpu_load_fpscr(env, val);
 }
@@ -260,7 +260,7 @@ static void update_fpscr(CPUSH4State *env, uintptr_t retaddr)
     }
 }
 
-float32 helper_fadd_FT(CPUSH4State *env, float32 t0, float32 t1)
+float32 HELPER(fadd_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_add(t0, t1, &env->fp_status);
@@ -268,7 +268,7 @@ float32 helper_fadd_FT(CPUSH4State *env, float32 t0, float32 t1)
     return t0;
 }
 
-float64 helper_fadd_DT(CPUSH4State *env, float64 t0, float64 t1)
+float64 HELPER(fadd_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float64_add(t0, t1, &env->fp_status);
@@ -276,7 +276,7 @@ float64 helper_fadd_DT(CPUSH4State *env, float64 t0, float64 t1)
     return t0;
 }
 
-uint32_t helper_fcmp_eq_FT(CPUSH4State *env, float32 t0, float32 t1)
+uint32_t HELPER(fcmp_eq_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     int relation;
 
@@ -286,7 +286,7 @@ uint32_t helper_fcmp_eq_FT(CPUSH4State *env, float32 t0, float32 t1)
     return relation == float_relation_equal;
 }
 
-uint32_t helper_fcmp_eq_DT(CPUSH4State *env, float64 t0, float64 t1)
+uint32_t HELPER(fcmp_eq_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     int relation;
 
@@ -296,7 +296,7 @@ uint32_t helper_fcmp_eq_DT(CPUSH4State *env, float64 t0, float64 t1)
     return relation == float_relation_equal;
 }
 
-uint32_t helper_fcmp_gt_FT(CPUSH4State *env, float32 t0, float32 t1)
+uint32_t HELPER(fcmp_gt_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     int relation;
 
@@ -306,7 +306,7 @@ uint32_t helper_fcmp_gt_FT(CPUSH4State *env, float32 t0, float32 t1)
     return relation == float_relation_greater;
 }
 
-uint32_t helper_fcmp_gt_DT(CPUSH4State *env, float64 t0, float64 t1)
+uint32_t HELPER(fcmp_gt_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     int relation;
 
@@ -316,7 +316,7 @@ uint32_t helper_fcmp_gt_DT(CPUSH4State *env, float64 t0, float64 t1)
     return relation == float_relation_greater;
 }
 
-float64 helper_fcnvsd_FT_DT(CPUSH4State *env, float32 t0)
+float64 HELPER(fcnvsd_FT_DT)(CPUSH4State *env, float32 t0)
 {
     float64 ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -325,7 +325,7 @@ float64 helper_fcnvsd_FT_DT(CPUSH4State *env, float32 t0)
     return ret;
 }
 
-float32 helper_fcnvds_DT_FT(CPUSH4State *env, float64 t0)
+float32 HELPER(fcnvds_DT_FT)(CPUSH4State *env, float64 t0)
 {
     float32 ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -334,7 +334,7 @@ float32 helper_fcnvds_DT_FT(CPUSH4State *env, float64 t0)
     return ret;
 }
 
-float32 helper_fdiv_FT(CPUSH4State *env, float32 t0, float32 t1)
+float32 HELPER(fdiv_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_div(t0, t1, &env->fp_status);
@@ -342,7 +342,7 @@ float32 helper_fdiv_FT(CPUSH4State *env, float32 t0, float32 t1)
     return t0;
 }
 
-float64 helper_fdiv_DT(CPUSH4State *env, float64 t0, float64 t1)
+float64 HELPER(fdiv_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float64_div(t0, t1, &env->fp_status);
@@ -350,7 +350,7 @@ float64 helper_fdiv_DT(CPUSH4State *env, float64 t0, float64 t1)
     return t0;
 }
 
-float32 helper_float_FT(CPUSH4State *env, uint32_t t0)
+float32 HELPER(float_FT)(CPUSH4State *env, uint32_t t0)
 {
     float32 ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -359,7 +359,7 @@ float32 helper_float_FT(CPUSH4State *env, uint32_t t0)
     return ret;
 }
 
-float64 helper_float_DT(CPUSH4State *env, uint32_t t0)
+float64 HELPER(float_DT)(CPUSH4State *env, uint32_t t0)
 {
     float64 ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -368,7 +368,7 @@ float64 helper_float_DT(CPUSH4State *env, uint32_t t0)
     return ret;
 }
 
-float32 helper_fmac_FT(CPUSH4State *env, float32 t0, float32 t1, float32 t2)
+float32 HELPER(fmac_FT)(CPUSH4State *env, float32 t0, float32 t1, float32 t2)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_muladd(t0, t1, t2, 0, &env->fp_status);
@@ -376,7 +376,7 @@ float32 helper_fmac_FT(CPUSH4State *env, float32 t0, float32 t1, float32 t2)
     return t0;
 }
 
-float32 helper_fmul_FT(CPUSH4State *env, float32 t0, float32 t1)
+float32 HELPER(fmul_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_mul(t0, t1, &env->fp_status);
@@ -384,7 +384,7 @@ float32 helper_fmul_FT(CPUSH4State *env, float32 t0, float32 t1)
     return t0;
 }
 
-float64 helper_fmul_DT(CPUSH4State *env, float64 t0, float64 t1)
+float64 HELPER(fmul_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float64_mul(t0, t1, &env->fp_status);
@@ -392,7 +392,7 @@ float64 helper_fmul_DT(CPUSH4State *env, float64 t0, float64 t1)
     return t0;
 }
 
-float32 helper_fsqrt_FT(CPUSH4State *env, float32 t0)
+float32 HELPER(fsqrt_FT)(CPUSH4State *env, float32 t0)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_sqrt(t0, &env->fp_status);
@@ -400,7 +400,7 @@ float32 helper_fsqrt_FT(CPUSH4State *env, float32 t0)
     return t0;
 }
 
-float64 helper_fsqrt_DT(CPUSH4State *env, float64 t0)
+float64 HELPER(fsqrt_DT)(CPUSH4State *env, float64 t0)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float64_sqrt(t0, &env->fp_status);
@@ -408,7 +408,7 @@ float64 helper_fsqrt_DT(CPUSH4State *env, float64 t0)
     return t0;
 }
 
-float32 helper_fsrra_FT(CPUSH4State *env, float32 t0)
+float32 HELPER(fsrra_FT)(CPUSH4State *env, float32 t0)
 {
     set_float_exception_flags(0, &env->fp_status);
     /* "Approximate" 1/sqrt(x) via actual computation.  */
@@ -426,7 +426,7 @@ float32 helper_fsrra_FT(CPUSH4State *env, float32 t0)
     return t0;
 }
 
-float32 helper_fsub_FT(CPUSH4State *env, float32 t0, float32 t1)
+float32 HELPER(fsub_FT)(CPUSH4State *env, float32 t0, float32 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float32_sub(t0, t1, &env->fp_status);
@@ -434,7 +434,7 @@ float32 helper_fsub_FT(CPUSH4State *env, float32 t0, float32 t1)
     return t0;
 }
 
-float64 helper_fsub_DT(CPUSH4State *env, float64 t0, float64 t1)
+float64 HELPER(fsub_DT)(CPUSH4State *env, float64 t0, float64 t1)
 {
     set_float_exception_flags(0, &env->fp_status);
     t0 = float64_sub(t0, t1, &env->fp_status);
@@ -442,7 +442,7 @@ float64 helper_fsub_DT(CPUSH4State *env, float64 t0, float64 t1)
     return t0;
 }
 
-uint32_t helper_ftrc_FT(CPUSH4State *env, float32 t0)
+uint32_t HELPER(ftrc_FT)(CPUSH4State *env, float32 t0)
 {
     uint32_t ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -451,7 +451,7 @@ uint32_t helper_ftrc_FT(CPUSH4State *env, float32 t0)
     return ret;
 }
 
-uint32_t helper_ftrc_DT(CPUSH4State *env, float64 t0)
+uint32_t HELPER(ftrc_DT)(CPUSH4State *env, float64 t0)
 {
     uint32_t ret;
     set_float_exception_flags(0, &env->fp_status);
@@ -460,7 +460,7 @@ uint32_t helper_ftrc_DT(CPUSH4State *env, float64 t0)
     return ret;
 }
 
-void helper_fipr(CPUSH4State *env, uint32_t m, uint32_t n)
+void HELPER(fipr)(CPUSH4State *env, uint32_t m, uint32_t n)
 {
     int bank, i;
     float32 r, p;
@@ -480,7 +480,7 @@ void helper_fipr(CPUSH4State *env, uint32_t m, uint32_t n)
     env->fregs[bank + n + 3] = r;
 }
 
-void helper_ftrv(CPUSH4State *env, uint32_t n)
+void HELPER(ftrv)(CPUSH4State *env, uint32_t n)
 {
     int bank_matrix, bank_vector;
     int i, j;
Signature · 1 line
2.55.0
#69 lore raw

[PULL 75/83] target/tricore: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/tricore/fpu_helper.c |  32 +++---
 target/tricore/op_helper.c  | 220 ++++++++++++++++++------------------
 2 files changed, 126 insertions(+), 126 deletions(-)
target/tricore/fpu_helper.c +16 -16
index fa268a8a6bc..9d323a9b664 100644
@@ -118,7 +118,7 @@ static void f_update_psw_flags(CPUTriCoreState *env, uint8_t flags)
 }
 
 #define FADD_SUB(op)                                                           \
-uint32_t helper_tricore_f##op(CPUTriCoreState *env, uint32_t r1, uint32_t r2)  \
+uint32_t HELPER(tricore_f##op)(CPUTriCoreState *env, uint32_t r1, uint32_t r2) \
 {                                                                              \
     float32 arg1 = make_float32(r1);                                           \
     float32 arg2 = make_float32(r2);                                           \
@@ -144,7 +144,7 @@ uint32_t helper_tricore_f##op(CPUTriCoreState *env, uint32_t r1, uint32_t r2)  \
 FADD_SUB(add)
 FADD_SUB(sub)
 
-uint32_t helper_tricore_fmul(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
+uint32_t HELPER(tricore_fmul)(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
 {
     uint32_t flags;
     float32 arg1 = make_float32(r1);
@@ -203,7 +203,7 @@ static const uint8_t target_qseed_significand_table[128] = {
     14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
 };
 
-uint32_t helper_qseed(CPUTriCoreState *env, uint32_t r1)
+uint32_t HELPER(qseed)(CPUTriCoreState *env, uint32_t r1)
 {
     uint32_t arg1, S, E, M, E_minus_one, m_idx;
     uint32_t new_E, new_M, new_S, result;
@@ -251,7 +251,7 @@ uint32_t helper_qseed(CPUTriCoreState *env, uint32_t r1)
     return (uint32_t) result;
 }
 
-uint32_t helper_tricore_fdiv(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
+uint32_t HELPER(tricore_fdiv)(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
 {
     uint32_t flags;
     float32 arg1 = make_float32(r1);
@@ -277,7 +277,7 @@ uint32_t helper_tricore_fdiv(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
     return (uint32_t)f_result;
 }
 
-uint32_t helper_fmadd(CPUTriCoreState *env, uint32_t r1,
+uint32_t HELPER(fmadd)(CPUTriCoreState *env, uint32_t r1,
                       uint32_t r2, uint32_t r3)
 {
     uint32_t flags;
@@ -303,7 +303,7 @@ uint32_t helper_fmadd(CPUTriCoreState *env, uint32_t r1,
     return (uint32_t)f_result;
 }
 
-uint32_t helper_fmsub(CPUTriCoreState *env, uint32_t r1,
+uint32_t HELPER(fmsub)(CPUTriCoreState *env, uint32_t r1,
                       uint32_t r2, uint32_t r3)
 {
     uint32_t flags;
@@ -331,7 +331,7 @@ uint32_t helper_fmsub(CPUTriCoreState *env, uint32_t r1,
     return (uint32_t)f_result;
 }
 
-uint32_t helper_tricore_fcmp(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
+uint32_t HELPER(tricore_fcmp)(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
 {
     uint32_t result, flags;
     float32 arg1 = make_float32(r1);
@@ -354,7 +354,7 @@ uint32_t helper_tricore_fcmp(CPUTriCoreState *env, uint32_t r1, uint32_t r2)
     return result;
 }
 
-uint32_t helper_tricore_ftoi(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(tricore_ftoi)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_arg = make_float32(arg);
     int32_t result, flags;
@@ -373,7 +373,7 @@ uint32_t helper_tricore_ftoi(CPUTriCoreState *env, uint32_t arg)
     return (uint32_t)result;
 }
 
-uint32_t helper_hptof(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(hptof)(CPUTriCoreState *env, uint32_t arg)
 {
     float16 f_arg = make_float16(arg);
     uint32_t result = 0;
@@ -409,7 +409,7 @@ uint32_t helper_hptof(CPUTriCoreState *env, uint32_t arg)
     return result;
 }
 
-uint32_t helper_ftohp(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(ftohp)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_arg = make_float32(arg);
     uint32_t result = 0;
@@ -447,7 +447,7 @@ uint32_t helper_ftohp(CPUTriCoreState *env, uint32_t arg)
     return result;
 }
 
-uint32_t helper_tricore_itof(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(tricore_itof)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_result;
     uint32_t flags;
@@ -462,7 +462,7 @@ uint32_t helper_tricore_itof(CPUTriCoreState *env, uint32_t arg)
     return (uint32_t)f_result;
 }
 
-uint32_t helper_utof(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(utof)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_result;
     uint32_t flags;
@@ -478,7 +478,7 @@ uint32_t helper_utof(CPUTriCoreState *env, uint32_t arg)
     return (uint32_t)f_result;
 }
 
-uint32_t helper_ftoiz(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(ftoiz)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_arg = make_float32(arg);
     uint32_t result;
@@ -503,7 +503,7 @@ uint32_t helper_ftoiz(CPUTriCoreState *env, uint32_t arg)
     return result;
 }
 
-uint32_t helper_ftou(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(ftou)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_arg = make_float32(arg);
     uint32_t result;
@@ -535,7 +535,7 @@ uint32_t helper_ftou(CPUTriCoreState *env, uint32_t arg)
     return result;
 }
 
-uint32_t helper_ftouz(CPUTriCoreState *env, uint32_t arg)
+uint32_t HELPER(ftouz)(CPUTriCoreState *env, uint32_t arg)
 {
     float32 f_arg = make_float32(arg);
     uint32_t result;
@@ -567,7 +567,7 @@ uint32_t helper_ftouz(CPUTriCoreState *env, uint32_t arg)
     return result;
 }
 
-void helper_updfl(CPUTriCoreState *env, uint32_t arg)
+void HELPER(updfl)(CPUTriCoreState *env, uint32_t arg)
 {
     env->FPU_FS =  extract32(arg, 7, 1) & extract32(arg, 15, 1);
     env->FPU_FI = (extract32(arg, 6, 1) & extract32(arg, 14, 1)) << 31;
target/tricore/op_helper.c +110 -110

874 lines not on this page · raw message

Signature · 1 line
2.55.0
#70 lore raw

[PULL 55/83] target/or1k: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert or1k to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/or1k/cpu.h |  3 ++-
 target/or1k/cpu.c |  2 +-
 target/or1k/mmu.c | 21 ++++++++++++++++-----
 3 files changed, 19 insertions(+), 7 deletions(-)
target/or1k/cpu.h +2 -1
index 96ed1779fae..50a665eec01 100644
@@ -298,7 +298,8 @@ void openrisc_translate_code(CPUState *cs, TranslationBlock *tb,
 int print_insn_or1k(bfd_vma addr, disassemble_info *info);
 
 #ifndef CONFIG_USER_ONLY
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool openrisc_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                      TranslateForDebugResult *result);
 
 bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                            MMUAccessType access_type, int mmu_idx,
target/or1k/cpu.c +1 -1
index 5aba8a42a95..8537d1a0326 100644
@@ -247,7 +247,7 @@ static void openrisc_any_initfn(Object *obj)
 
 static const struct SysemuCPUOps openrisc_sysemu_ops = {
     .has_work = openrisc_cpu_has_work,
-    .get_phys_addr_debug = openrisc_cpu_get_phys_addr_debug,
+    .translate_for_debug = openrisc_cpu_translate_for_debug,
 };
 #endif
 
target/or1k/mmu.c +16 -5
index 3fc56e1b771..a78e8c8ca2e 100644
@@ -139,7 +139,8 @@ bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
     cpu_loop_exit_restore(cs, retaddr);
 }
 
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool openrisc_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                      TranslateForDebugResult *result)
 {
     OpenRISCCPU *cpu = OPENRISC_CPU(cs);
     int prot, excp, sr = cpu->env.sr;
@@ -152,12 +153,15 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                             PAGE_READ,
                             (sr & SR_SM) != 0);
         if (!excp) {
-            return phys_addr;
+            break;
         }
         excp = get_phys_mmu(cpu, &phys_addr, &prot, addr,
                             PAGE_EXEC,
                             (sr & SR_SM) != 0);
-        return excp ? -1 : phys_addr;
+        if (excp) {
+            return false;
+        }
+        break;
 
     default:
         /* The mmu is partially enabled, and we don't really have
@@ -167,13 +171,20 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                             PAGE_EXEC | PAGE_READ | PAGE_WRITE,
                             (sr & SR_SM) != 0);
         if (!excp) {
-            return phys_addr;
+            break;
         }
         /* fallthru */
 
     case 0:
         /* The mmu is definitely disabled; lookups never fail.  */
         get_phys_nommu(&phys_addr, &prot, addr);
-        return phys_addr;
+        break;
     }
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.55.0
#71 lore raw

[PULL 77/83] target/hppa: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert hppa to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/hppa/cpu.h        |  3 ++-
 target/hppa/cpu.c        |  2 +-
 target/hppa/mem_helper.c | 21 ++++++++++++++++-----
 3 files changed, 19 insertions(+), 7 deletions(-)
target/hppa/cpu.h +2 -1
index 3914b3285c5..8818d47dcd4 100644
@@ -391,7 +391,8 @@ int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 void hppa_cpu_dump_state(CPUState *cs, FILE *f, int);
 #ifndef CONFIG_USER_ONLY
 void hppa_ptlbe(CPUHPPAState *env);
-hwaddr hppa_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr);
+bool hppa_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                  TranslateForDebugResult *result);
 void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled);
 bool hppa_cpu_tlb_fill_align(CPUState *cs, CPUTLBEntryFull *out, vaddr addr,
                              MMUAccessType access_type, int mmu_idx,
target/hppa/cpu.c +1 -1
index dbf86941cf0..9d643223980 100644
@@ -246,7 +246,7 @@ static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model)
 
 static const struct SysemuCPUOps hppa_sysemu_ops = {
     .has_work = hppa_cpu_has_work,
-    .get_phys_addr_debug = hppa_cpu_get_phys_addr_debug,
+    .translate_for_debug = hppa_cpu_translate_for_debug,
 };
 #endif
 
target/hppa/mem_helper.c +16 -5
index 01e6149c811..2393a155076 100644
@@ -346,7 +346,8 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
     return ret;
 }
 
-hwaddr hppa_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool hppa_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                  TranslateForDebugResult *result)
 {
     HPPACPU *cpu = HPPA_CPU(cs);
     hwaddr phys;
@@ -361,10 +362,20 @@ hwaddr hppa_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
     excp = hppa_get_physical_address(&cpu->env, addr, mmu_idx, 0, 0,
                                      &phys, &prot);
 
-    /* Since we're translating for debugging, the only error that is a
-       hard error is no translation at all.  Otherwise, while a real cpu
-       access might not have permission, the debugger does.  */
-    return excp == EXCP_DTLB_MISS ? -1 : phys;
+    /*
+     * Since we're translating for debugging, the only error that is a
+     * hard error is no translation at all.  Otherwise, while a real cpu
+     * access might not have permission, the debugger does.
+     */
+    if (excp == EXCP_DTLB_MISS) {
+        return false;
+    }
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 void hppa_set_ior_and_isr(CPUHPPAState *env, vaddr addr, bool mmu_disabled)
Signature · 1 line
2.55.0
#72 lore raw

[PULL 74/83] target/sparc: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/sparc/fop_helper.c   | 106 ++++++++++++++++++------------------
 target/sparc/helper.c       |  22 ++++----
 target/sparc/int64_helper.c |   6 +-
 target/sparc/ldst_helper.c  |  14 ++---
 target/sparc/vis_helper.c   |  94 ++++++++++++++++----------------
 target/sparc/win_helper.c   |  38 ++++++-------
 6 files changed, 140 insertions(+), 140 deletions(-)
target/sparc/fop_helper.c +53 -53
index 29fd1664384..90aa93f24dc 100644
@@ -84,91 +84,91 @@ static void check_ieee_exceptions(CPUSPARCState *env, uintptr_t ra)
     env->fsr_cexc_ftt = cexc;
 }
 
-float32 helper_fadds(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fadds)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_add(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float32 helper_fsubs(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fsubs)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_sub(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float32 helper_fmuls(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fmuls)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_mul(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float32 helper_fdivs(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fdivs)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_div(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_faddd(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(faddd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_add(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fsubd(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(fsubd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_sub(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fmuld(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(fmuld)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_mul(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fdivd(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(fdivd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_div(src1, src2, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_faddq(CPUSPARCState *env, Int128 src1, Int128 src2)
+Int128 HELPER(faddq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     float128 ret = float128_add(f128_in(src1), f128_in(src2), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-Int128 helper_fsubq(CPUSPARCState *env, Int128 src1, Int128 src2)
+Int128 HELPER(fsubq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     float128 ret = float128_sub(f128_in(src1), f128_in(src2), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-Int128 helper_fmulq(CPUSPARCState *env, Int128 src1, Int128 src2)
+Int128 HELPER(fmulq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     float128 ret = float128_mul(f128_in(src1), f128_in(src2), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-Int128 helper_fdivq(CPUSPARCState *env, Int128 src1, Int128 src2)
+Int128 HELPER(fdivq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     float128 ret = float128_div(f128_in(src1), f128_in(src2), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-float64 helper_fsmuld(CPUSPARCState *env, float32 src1, float32 src2)
+float64 HELPER(fsmuld)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float64 ret = float64_mul(float32_to_float64(src1, &env->fp_status),
                               float32_to_float64(src2, &env->fp_status),
@@ -177,7 +177,7 @@ float64 helper_fsmuld(CPUSPARCState *env, float32 src1, float32 src2)
     return ret;
 }
 
-Int128 helper_fdmulq(CPUSPARCState *env, float64 src1, float64 src2)
+Int128 HELPER(fdmulq)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float128 ret = float128_mul(float64_to_float128(src1, &env->fp_status),
                                 float64_to_float128(src2, &env->fp_status),
@@ -187,21 +187,21 @@ Int128 helper_fdmulq(CPUSPARCState *env, float64 src1, float64 src2)
 }
 
 /* Integer to float conversion.  */
-float32 helper_fitos(CPUSPARCState *env, int32_t src)
+float32 HELPER(fitos)(CPUSPARCState *env, int32_t src)
 {
     float32 ret = int32_to_float32(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fitod(CPUSPARCState *env, int32_t src)
+float64 HELPER(fitod)(CPUSPARCState *env, int32_t src)
 {
     float64 ret = int32_to_float64(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_fitoq(CPUSPARCState *env, int32_t src)
+Int128 HELPER(fitoq)(CPUSPARCState *env, int32_t src)
 {
     float128 ret = int32_to_float128(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
@@ -209,21 +209,21 @@ Int128 helper_fitoq(CPUSPARCState *env, int32_t src)
 }
 
 #ifdef TARGET_SPARC64
-float32 helper_fxtos(CPUSPARCState *env, int64_t src)
+float32 HELPER(fxtos)(CPUSPARCState *env, int64_t src)
 {
     float32 ret = int64_to_float32(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fxtod(CPUSPARCState *env, int64_t src)
+float64 HELPER(fxtod)(CPUSPARCState *env, int64_t src)
 {
     float64 ret = int64_to_float64(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_fxtoq(CPUSPARCState *env, int64_t src)
+Int128 HELPER(fxtoq)(CPUSPARCState *env, int64_t src)
 {
     float128 ret = int64_to_float128(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
@@ -232,42 +232,42 @@ Int128 helper_fxtoq(CPUSPARCState *env, int64_t src)
 #endif
 
 /* floating point conversion */
-float32 helper_fdtos(CPUSPARCState *env, float64 src)
+float32 HELPER(fdtos)(CPUSPARCState *env, float64 src)
 {
     float32 ret = float64_to_float32(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fstod(CPUSPARCState *env, float32 src)
+float64 HELPER(fstod)(CPUSPARCState *env, float32 src)
 {
     float64 ret = float32_to_float64(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float32 helper_fqtos(CPUSPARCState *env, Int128 src)
+float32 HELPER(fqtos)(CPUSPARCState *env, Int128 src)
 {
     float32 ret = float128_to_float32(f128_in(src), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_fstoq(CPUSPARCState *env, float32 src)
+Int128 HELPER(fstoq)(CPUSPARCState *env, float32 src)
 {
     float128 ret = float32_to_float128(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-float64 helper_fqtod(CPUSPARCState *env, Int128 src)
+float64 HELPER(fqtod)(CPUSPARCState *env, Int128 src)
 {
     float64 ret = float128_to_float64(f128_in(src), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_fdtoq(CPUSPARCState *env, float64 src)
+Int128 HELPER(fdtoq)(CPUSPARCState *env, float64 src)
 {
     float128 ret = float64_to_float128(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
@@ -275,21 +275,21 @@ Int128 helper_fdtoq(CPUSPARCState *env, float64 src)
 }
 
 /* Float to integer conversion.  */
-int32_t helper_fstoi(CPUSPARCState *env, float32 src)
+int32_t HELPER(fstoi)(CPUSPARCState *env, float32 src)
 {
     int32_t ret = float32_to_int32_round_to_zero(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-int32_t helper_fdtoi(CPUSPARCState *env, float64 src)
+int32_t HELPER(fdtoi)(CPUSPARCState *env, float64 src)
 {
     int32_t ret = float64_to_int32_round_to_zero(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-int32_t helper_fqtoi(CPUSPARCState *env, Int128 src)
+int32_t HELPER(fqtoi)(CPUSPARCState *env, Int128 src)
 {
     int32_t ret = float128_to_int32_round_to_zero(f128_in(src),
                                                   &env->fp_status);
@@ -298,21 +298,21 @@ int32_t helper_fqtoi(CPUSPARCState *env, Int128 src)
 }
 
 #ifdef TARGET_SPARC64
-int64_t helper_fstox(CPUSPARCState *env, float32 src)
+int64_t HELPER(fstox)(CPUSPARCState *env, float32 src)
 {
     int64_t ret = float32_to_int64_round_to_zero(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-int64_t helper_fdtox(CPUSPARCState *env, float64 src)
+int64_t HELPER(fdtox)(CPUSPARCState *env, float64 src)
 {
     int64_t ret = float64_to_int64_round_to_zero(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-int64_t helper_fqtox(CPUSPARCState *env, Int128 src)
+int64_t HELPER(fqtox)(CPUSPARCState *env, Int128 src)
 {
     int64_t ret = float128_to_int64_round_to_zero(f128_in(src),
                                                   &env->fp_status);
@@ -321,28 +321,28 @@ int64_t helper_fqtox(CPUSPARCState *env, Int128 src)
 }
 #endif
 
-float32 helper_fsqrts(CPUSPARCState *env, float32 src)
+float32 HELPER(fsqrts)(CPUSPARCState *env, float32 src)
 {
     float32 ret = float32_sqrt(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-float64 helper_fsqrtd(CPUSPARCState *env, float64 src)
+float64 HELPER(fsqrtd)(CPUSPARCState *env, float64 src)
 {
     float64 ret = float64_sqrt(src, &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return ret;
 }
 
-Int128 helper_fsqrtq(CPUSPARCState *env, Int128 src)
+Int128 HELPER(fsqrtq)(CPUSPARCState *env, Int128 src)
 {
     float128 ret = float128_sqrt(f128_in(src), &env->fp_status);
     check_ieee_exceptions(env, GETPC());
     return f128_ret(ret);
 }
 
-float32 helper_fmadds(CPUSPARCState *env, float32 s1,
+float32 HELPER(fmadds)(CPUSPARCState *env, float32 s1,
                       float32 s2, float32 s3, int32_t sc, uint32_t op)
 {
     float32 ret = float32_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status);
@@ -350,7 +350,7 @@ float32 helper_fmadds(CPUSPARCState *env, float32 s1,
     return ret;
 }
 
-float64 helper_fmaddd(CPUSPARCState *env, float64 s1,
+float64 HELPER(fmaddd)(CPUSPARCState *env, float64 s1,
                       float64 s2, float64 s3, int32_t sc, uint32_t op)
 {
     float64 ret = float64_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status);
@@ -358,7 +358,7 @@ float64 helper_fmaddd(CPUSPARCState *env, float64 s1,
     return ret;
 }
 
-float32 helper_fnadds(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fnadds)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_add(src1, src2, &env->fp_status);
 
@@ -373,7 +373,7 @@ float32 helper_fnadds(CPUSPARCState *env, float32 src1, float32 src2)
     return ret;
 }
 
-float32 helper_fnmuls(CPUSPARCState *env, float32 src1, float32 src2)
+float32 HELPER(fnmuls)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float32 ret = float32_mul(src1, src2, &env->fp_status);
 
@@ -385,7 +385,7 @@ float32 helper_fnmuls(CPUSPARCState *env, float32 src1, float32 src2)
     return ret;
 }
 
-float64 helper_fnaddd(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(fnaddd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_add(src1, src2, &env->fp_status);
 
@@ -400,7 +400,7 @@ float64 helper_fnaddd(CPUSPARCState *env, float64 src1, float64 src2)
     return ret;
 }
 
-float64 helper_fnmuld(CPUSPARCState *env, float64 src1, float64 src2)
+float64 HELPER(fnmuld)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float64 ret = float64_mul(src1, src2, &env->fp_status);
 
@@ -412,7 +412,7 @@ float64 helper_fnmuld(CPUSPARCState *env, float64 src1, float64 src2)
     return ret;
 }
 
-float64 helper_fnsmuld(CPUSPARCState *env, float32 src1, float32 src2)
+float64 HELPER(fnsmuld)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     float64 ret = float64_mul(float32_to_float64(src1, &env->fp_status),
                               float32_to_float64(src2, &env->fp_status),
@@ -450,45 +450,45 @@ static uint32_t finish_fcmp(CPUSPARCState *env, FloatRelation r, uintptr_t ra)
     g_assert_not_reached();
 }
 
-uint32_t helper_fcmps(CPUSPARCState *env, float32 src1, float32 src2)
+uint32_t HELPER(fcmps)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     FloatRelation r = float32_compare_quiet(src1, src2, &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_fcmpes(CPUSPARCState *env, float32 src1, float32 src2)
+uint32_t HELPER(fcmpes)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     FloatRelation r = float32_compare(src1, src2, &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_fcmpd(CPUSPARCState *env, float64 src1, float64 src2)
+uint32_t HELPER(fcmpd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     FloatRelation r = float64_compare_quiet(src1, src2, &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_fcmped(CPUSPARCState *env, float64 src1, float64 src2)
+uint32_t HELPER(fcmped)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     FloatRelation r = float64_compare(src1, src2, &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_fcmpq(CPUSPARCState *env, Int128 src1, Int128 src2)
+uint32_t HELPER(fcmpq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     FloatRelation r = float128_compare_quiet(f128_in(src1), f128_in(src2),
                                              &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2)
+uint32_t HELPER(fcmpeq)(CPUSPARCState *env, Int128 src1, Int128 src2)
 {
     FloatRelation r = float128_compare(f128_in(src1), f128_in(src2),
                                        &env->fp_status);
     return finish_fcmp(env, r, GETPC());
 }
 
-uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2)
+uint32_t HELPER(flcmps)(CPUSPARCState *env, float32 src1, float32 src2)
 {
     /*
      * FLCMP never raises an exception nor modifies any FSR fields.
@@ -516,7 +516,7 @@ uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2)
     g_assert_not_reached();
 }
 
-uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2)
+uint32_t HELPER(flcmpd)(CPUSPARCState *env, float64 src1, float64 src2)
 {
     float_status discard = env->fp_status;
     FloatRelation r;
@@ -559,7 +559,7 @@ target_ulong cpu_get_fsr(CPUSPARCState *env)
     return fsr;
 }
 
-target_ulong helper_get_fsr(CPUSPARCState *env)
+target_ulong HELPER(get_fsr)(CPUSPARCState *env)
 {
     return cpu_get_fsr(env);
 }
@@ -604,14 +604,14 @@ void cpu_put_fsr(CPUSPARCState *env, target_ulong fsr)
     set_fsr_nonsplit(env, fsr);
 }
 
-void helper_set_fsr_nofcc_noftt(CPUSPARCState *env, uint32_t fsr)
+void HELPER(set_fsr_nofcc_noftt)(CPUSPARCState *env, uint32_t fsr)
 {
     env->fsr_cexc_ftt &= FSR_FTT_MASK;
     env->fsr_cexc_ftt |= fsr & FSR_CEXC_MASK;
     set_fsr_nonsplit(env, fsr);
 }
 
-void helper_set_fsr_nofcc(CPUSPARCState *env, uint32_t fsr)
+void HELPER(set_fsr_nofcc)(CPUSPARCState *env, uint32_t fsr)
 {
     env->fsr_cexc_ftt = fsr & (FSR_CEXC_MASK | FSR_FTT_MASK);
     set_fsr_nonsplit(env, fsr);
target/sparc/helper.c +11 -11
index 8de261b0e30..f4eb78c4487 100644
@@ -33,7 +33,7 @@ void cpu_raise_exception_ra(CPUSPARCState *env, int tt, uintptr_t ra)
     cpu_loop_exit_restore(cs, ra);
 }
 
-void helper_raise_exception(CPUSPARCState *env, int tt)
+void HELPER(raise_exception)(CPUSPARCState *env, int tt)
 {
     CPUState *cs = env_cpu(env);
 
@@ -41,7 +41,7 @@ void helper_raise_exception(CPUSPARCState *env, int tt)
     cpu_loop_exit(cs);
 }
 
-void helper_debug(CPUSPARCState *env)
+void HELPER(debug)(CPUSPARCState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -50,14 +50,14 @@ void helper_debug(CPUSPARCState *env)
 }
 
 #ifdef TARGET_SPARC64
-void helper_tick_set_count(void *opaque, uint64_t count)
+void HELPER(tick_set_count)(void *opaque, uint64_t count)
 {
 #if !defined(CONFIG_USER_ONLY)
     cpu_tick_set_count(opaque, count);
 #endif
 }
 
-uint64_t helper_tick_get_count(CPUSPARCState *env, void *opaque, int mem_idx)
+uint64_t HELPER(tick_get_count)(CPUSPARCState *env, void *opaque, int mem_idx)
 {
 #if !defined(CONFIG_USER_ONLY)
     CPUTimer *timer = opaque;
@@ -74,7 +74,7 @@ uint64_t helper_tick_get_count(CPUSPARCState *env, void *opaque, int mem_idx)
 #endif
 }
 
-void helper_tick_set_limit(void *opaque, uint64_t limit)
+void HELPER(tick_set_limit)(void *opaque, uint64_t limit)
 {
 #if !defined(CONFIG_USER_ONLY)
     cpu_tick_set_limit(opaque, limit);
@@ -82,7 +82,7 @@ void helper_tick_set_limit(void *opaque, uint64_t limit)
 }
 #endif
 
-uint64_t helper_udiv(CPUSPARCState *env, target_ulong a, target_ulong b)
+uint64_t HELPER(udiv)(CPUSPARCState *env, target_ulong a, target_ulong b)
 {
     uint64_t a64 = (uint32_t)a | ((uint64_t)env->y << 32);
     uint32_t b32 = b;
@@ -100,7 +100,7 @@ uint64_t helper_udiv(CPUSPARCState *env, target_ulong a, target_ulong b)
     return r;
 }
 
-uint64_t helper_sdiv(CPUSPARCState *env, target_ulong a, target_ulong b)
+uint64_t HELPER(sdiv)(CPUSPARCState *env, target_ulong a, target_ulong b)
 {
     int64_t a64 = (uint32_t)a | ((uint64_t)env->y << 32);
     int32_t b32 = b;
@@ -130,7 +130,7 @@ uint64_t helper_sdiv(CPUSPARCState *env, target_ulong a, target_ulong b)
     return (uint32_t)r;
 }
 
-target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1,
+target_ulong HELPER(taddcctv)(CPUSPARCState *env, target_ulong src1,
                              target_ulong src2)
 {
     target_ulong dst, v;
@@ -166,7 +166,7 @@ target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1,
     cpu_raise_exception_ra(env, TT_TOVF, GETPC());
 }
 
-target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
+target_ulong HELPER(tsubcctv)(CPUSPARCState *env, target_ulong src1,
                              target_ulong src2)
 {
     target_ulong dst, v;
@@ -203,7 +203,7 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
 }
 
 #ifndef TARGET_SPARC64
-void helper_power_down(CPUSPARCState *env)
+void HELPER(power_down)(CPUSPARCState *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -214,7 +214,7 @@ void helper_power_down(CPUSPARCState *env)
     cpu_loop_exit(cs);
 }
 
-target_ulong helper_rdasr17(CPUSPARCState *env)
+target_ulong HELPER(rdasr17)(CPUSPARCState *env)
 {
     CPUState *cs = env_cpu(env);
     target_ulong val;
target/sparc/int64_helper.c +3 -3
index 849b1a436b2..dc2395c270e 100644
@@ -283,21 +283,21 @@ static bool do_modify_softint(CPUSPARCState *env, uint32_t value)
     return false;
 }
 
-void helper_set_softint(CPUSPARCState *env, uint64_t value)
+void HELPER(set_softint)(CPUSPARCState *env, uint64_t value)
 {
     if (do_modify_softint(env, env->softint | (uint32_t)value)) {
         trace_int_helper_set_softint(env->softint);
     }
 }
 
-void helper_clear_softint(CPUSPARCState *env, uint64_t value)
+void HELPER(clear_softint)(CPUSPARCState *env, uint64_t value)
 {
     if (do_modify_softint(env, env->softint & (uint32_t)~value)) {
         trace_int_helper_clear_softint(env->softint);
     }
 }
 
-void helper_write_softint(CPUSPARCState *env, uint64_t value)
+void HELPER(write_softint)(CPUSPARCState *env, uint64_t value)
 {
     if (do_modify_softint(env, (uint32_t)value)) {
         trace_int_helper_write_softint(env->softint);
target/sparc/ldst_helper.c +7 -7
index 4ec8799d1f7..74d9cc1c966 100644
@@ -580,7 +580,7 @@ static uint64_t leon3_cache_control_ld(CPUSPARCState *env, target_ulong addr,
     return ret;
 }
 
-uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
+uint64_t HELPER(ld_asi)(CPUSPARCState *env, target_ulong addr,
                        int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
@@ -804,7 +804,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
     return ret;
 }
 
-void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
+void HELPER(st_asi)(CPUSPARCState *env, target_ulong addr, uint64_t val,
                    int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
@@ -1154,7 +1154,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
 #endif
 }
 
-uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)
+uint64_t HELPER(ld_code)(CPUSPARCState *env, target_ulong addr, uint32_t oi)
 {
     MemOp mop = get_memop(oi);
     uintptr_t ra = GETPC();
@@ -1192,7 +1192,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)
 #else /* TARGET_SPARC64 */
 
 #ifdef CONFIG_USER_ONLY
-uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
+uint64_t HELPER(ld_asi)(CPUSPARCState *env, target_ulong addr,
                        int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
@@ -1281,7 +1281,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
     return ret;
 }
 
-void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
+void HELPER(st_asi)(CPUSPARCState *env, target_ulong addr, target_ulong val,
                    int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
@@ -1312,7 +1312,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
 
 #else /* CONFIG_USER_ONLY */
 
-uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
+uint64_t HELPER(ld_asi)(CPUSPARCState *env, target_ulong addr,
                        int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
@@ -1611,7 +1611,7 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
     return ret;
 }
 
-void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
+void HELPER(st_asi)(CPUSPARCState *env, target_ulong addr, target_ulong val,
                    int asi, uint32_t memop)
 {
     int size = 1 << (memop & MO_SIZE);
target/sparc/vis_helper.c +47 -47

300 lines not on this page · raw message

target/sparc/win_helper.c +19 -19
index 9ad9d01e8b9..872bd35652f 100644
@@ -121,7 +121,7 @@ int cpu_cwp_dec(CPUSPARCState *env, int cwp)
 }
 
 #ifndef TARGET_SPARC64
-void helper_rett(CPUSPARCState *env)
+void HELPER(rett)(CPUSPARCState *env)
 {
     unsigned int cwp;
 
@@ -140,7 +140,7 @@ void helper_rett(CPUSPARCState *env)
 
 /* XXX: use another pointer for %iN registers to avoid slow wrapping
    handling ? */
-void helper_save(CPUSPARCState *env)
+void HELPER(save)(CPUSPARCState *env)
 {
     uint32_t cwp;
 
@@ -151,7 +151,7 @@ void helper_save(CPUSPARCState *env)
     cpu_set_cwp(env, cwp);
 }
 
-void helper_restore(CPUSPARCState *env)
+void HELPER(restore)(CPUSPARCState *env)
 {
     uint32_t cwp;
 
@@ -162,7 +162,7 @@ void helper_restore(CPUSPARCState *env)
     cpu_set_cwp(env, cwp);
 }
 
-void helper_wrpsr(CPUSPARCState *env, target_ulong new_psr)
+void HELPER(wrpsr)(CPUSPARCState *env, target_ulong new_psr)
 {
     if ((new_psr & PSR_CWP) >= env->nwindows) {
         cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC());
@@ -174,7 +174,7 @@ void helper_wrpsr(CPUSPARCState *env, target_ulong new_psr)
     }
 }
 
-target_ulong helper_rdpsr(CPUSPARCState *env)
+target_ulong HELPER(rdpsr)(CPUSPARCState *env)
 {
     return cpu_get_psr(env);
 }
@@ -182,7 +182,7 @@ target_ulong helper_rdpsr(CPUSPARCState *env)
 #else
 /* XXX: use another pointer for %iN registers to avoid slow wrapping
    handling ? */
-void helper_save(CPUSPARCState *env)
+void HELPER(save)(CPUSPARCState *env)
 {
     uint32_t cwp;
 
@@ -204,7 +204,7 @@ void helper_save(CPUSPARCState *env)
     }
 }
 
-void helper_restore(CPUSPARCState *env)
+void HELPER(restore)(CPUSPARCState *env)
 {
     uint32_t cwp;
 
@@ -221,7 +221,7 @@ void helper_restore(CPUSPARCState *env)
     }
 }
 
-void helper_flushw(CPUSPARCState *env)
+void HELPER(flushw)(CPUSPARCState *env)
 {
     if (env->cansave != env->nwindows - 2) {
         int tt = TT_SPILL | (env->otherwin != 0
@@ -231,7 +231,7 @@ void helper_flushw(CPUSPARCState *env)
     }
 }
 
-void helper_saved(CPUSPARCState *env)
+void HELPER(saved)(CPUSPARCState *env)
 {
     env->cansave++;
     if (env->otherwin == 0) {
@@ -241,7 +241,7 @@ void helper_saved(CPUSPARCState *env)
     }
 }
 
-void helper_restored(CPUSPARCState *env)
+void HELPER(restored)(CPUSPARCState *env)
 {
     env->canrestore++;
     if (env->cleanwin < env->nwindows - 1) {
@@ -294,24 +294,24 @@ void cpu_put_cwp64(CPUSPARCState *env, int cwp)
     cpu_set_cwp(env, env->nwindows - 1 - cwp);
 }
 
-target_ulong helper_rdccr(CPUSPARCState *env)
+target_ulong HELPER(rdccr)(CPUSPARCState *env)
 {
     return cpu_get_ccr(env);
 }
 
-void helper_wrccr(CPUSPARCState *env, target_ulong new_ccr)
+void HELPER(wrccr)(CPUSPARCState *env, target_ulong new_ccr)
 {
     cpu_put_ccr(env, new_ccr);
 }
 
 /* CWP handling is reversed in V9, but we still use the V8 register
    order. */
-target_ulong helper_rdcwp(CPUSPARCState *env)
+target_ulong HELPER(rdcwp)(CPUSPARCState *env)
 {
     return cpu_get_cwp64(env);
 }
 
-void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp)
+void HELPER(wrcwp)(CPUSPARCState *env, target_ulong new_cwp)
 {
     cpu_put_cwp64(env, new_cwp);
 }
@@ -355,7 +355,7 @@ void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl)
     }
 }
 
-void helper_wrgl(CPUSPARCState *env, target_ulong new_gl)
+void HELPER(wrgl)(CPUSPARCState *env, target_ulong new_gl)
 {
     cpu_gl_switch_gregs(env, new_gl & 7);
     env->gl = new_gl & 7;
@@ -390,7 +390,7 @@ void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
     env->pstate = new_pstate;
 }
 
-void helper_wrpstate(CPUSPARCState *env, target_ulong new_state)
+void HELPER(wrpstate)(CPUSPARCState *env, target_ulong new_state)
 {
     cpu_change_pstate(env, new_state & 0xf3f);
 
@@ -403,7 +403,7 @@ void helper_wrpstate(CPUSPARCState *env, target_ulong new_state)
 #endif
 }
 
-void helper_wrpil(CPUSPARCState *env, target_ulong new_pil)
+void HELPER(wrpil)(CPUSPARCState *env, target_ulong new_pil)
 {
 #if !defined(CONFIG_USER_ONLY)
     trace_win_helper_wrpil(env->psrpil, (uint32_t)new_pil);
@@ -418,7 +418,7 @@ void helper_wrpil(CPUSPARCState *env, target_ulong new_pil)
 #endif
 }
 
-void helper_done(CPUSPARCState *env)
+void HELPER(done)(CPUSPARCState *env)
 {
     trap_state *tsptr = cpu_tsptr(env);
 
@@ -447,7 +447,7 @@ void helper_done(CPUSPARCState *env)
 #endif
 }
 
-void helper_retry(CPUSPARCState *env)
+void HELPER(retry)(CPUSPARCState *env)
 {
     trap_state *tsptr = cpu_tsptr(env);
 
Signature · 1 line
2.55.0
#73 lore raw

[PULL 66/83] target/m68k: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/m68k/op_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/m68k/op_helper.c +1 -1
index c9db8a1b39d..3ab64b9f760 100644
@@ -1036,7 +1036,7 @@ uint64_t HELPER(bfffo_mem)(CPUM68KState *env, uint32_t addr,
     uint64_t data = bf_load(env, d.addr, d.blen, ra);
     uint64_t mask = -1ull << (64 - d.len) >> d.bofs;
     uint64_t n = (data & mask) << d.bofs;
-    uint32_t ffo = helper_bfffo_reg(n >> 32, ofs, d.len);
+    uint32_t ffo = HELPER(bfffo_reg)(n >> 32, ofs, d.len);
 
     /*
      * Return FFO in the low word and N in the high word.
Signature · 1 line
2.55.0
#74 lore raw

[PULL 64/83] target/i386: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/i386/ops_sse.h                | 401 ++++++++++++++-------------
 target/i386/tcg/bpt_helper.c         |   6 +-
 target/i386/tcg/cc_helper.c          |  14 +-
 target/i386/tcg/excp_helper.c        |   8 +-
 target/i386/tcg/fpu_helper.c         | 182 ++++++------
 target/i386/tcg/int_helper.c         |  34 +--
 target/i386/tcg/mem_helper.c         |   4 +-
 target/i386/tcg/misc_helper.c        |  16 +-
 target/i386/tcg/mpx_helper.c         |  12 +-
 target/i386/tcg/seg_helper.c         |  32 +--
 target/i386/tcg/system/bpt_helper.c  |   6 +-
 target/i386/tcg/system/misc_helper.c |  32 +--
 target/i386/tcg/system/seg_helper.c  |   4 +-
 target/i386/tcg/system/smm_helper.c  |  12 +-
 target/i386/tcg/system/svm_helper.c  |  16 +-
 target/i386/tcg/user/seg_helper.c    |   4 +-
 16 files changed, 392 insertions(+), 391 deletions(-)
target/i386/ops_sse.h +201 -200
index 5176a9f9e35..b39fcde3539 100644
@@ -54,7 +54,7 @@
 #define FPSLL(x, c) ((x) << shift)
 #endif
 
-void glue(helper_psrlw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psrlw), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 15) {
@@ -69,7 +69,7 @@ void glue(helper_psrlw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psllw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psllw), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 15) {
@@ -84,7 +84,7 @@ void glue(helper_psllw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psraw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psraw), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 15) {
@@ -97,7 +97,7 @@ void glue(helper_psraw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psrld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psrld), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 31) {
@@ -112,7 +112,7 @@ void glue(helper_psrld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_pslld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(pslld), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 31) {
@@ -127,7 +127,7 @@ void glue(helper_pslld, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psrad, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psrad), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 31) {
@@ -140,7 +140,7 @@ void glue(helper_psrad, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psrlq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psrlq), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 63) {
@@ -155,7 +155,7 @@ void glue(helper_psrlq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_psllq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psllq), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift;
     if (c->Q(0) > 63) {
@@ -171,7 +171,7 @@ void glue(helper_psllq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 }
 
 #if SHIFT >= 1
-void glue(helper_psrldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(psrldq), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift, i, j;
 
@@ -189,7 +189,7 @@ void glue(helper_psrldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
     }
 }
 
-void glue(helper_pslldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
+void glue(HELPER(pslldq), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, Reg *c)
 {
     int shift, i, j;
 
@@ -306,11 +306,11 @@ static inline int satsw(int x)
 #define FAVG(a, b) (((a) + (b) + 1) >> 1)
 #endif
 
-SSE_HELPER_W(helper_pmulhuw, FMULHUW)
-SSE_HELPER_W(helper_pmulhw, FMULHW)
+SSE_HELPER_W(HELPER(pmulhuw), FMULHUW)
+SSE_HELPER_W(HELPER(pmulhw), FMULHW)
 
 #if SHIFT == 0
-void glue(helper_pmulhrw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(pmulhrw), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     d->W(0) = FMULHRW(d->W(0), s->W(0));
     d->W(1) = FMULHRW(d->W(1), s->W(1));
@@ -319,10 +319,10 @@ void glue(helper_pmulhrw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 }
 #endif
 
-SSE_HELPER_B(helper_pavgb, FAVG)
-SSE_HELPER_W(helper_pavgw, FAVG)
+SSE_HELPER_B(HELPER(pavgb), FAVG)
+SSE_HELPER_W(HELPER(pavgw), FAVG)
 
-void glue(helper_pmuludq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(pmuludq), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -331,7 +331,7 @@ void glue(helper_pmuludq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_pmaddwd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(pmaddwd), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -351,7 +351,7 @@ static inline int abs1(int a)
     }
 }
 #endif
-void glue(helper_psadbw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(psadbw), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -370,7 +370,7 @@ void glue(helper_psadbw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #if SHIFT < 2
-void glue(helper_maskmov, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(maskmov), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                   target_ulong a0)
 {
     int i;
@@ -395,14 +395,14 @@ void glue(helper_maskmov, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
     } while (0)
 
 #if SHIFT == 0
-void glue(helper_pshufw, SUFFIX)(Reg *d, Reg *s, int order)
+void glue(HELPER(pshufw), SUFFIX)(Reg *d, Reg *s, int order)
 {
     uint16_t r0, r1, r2, r3;
 
     SHUFFLE4(W, s, s, 0);
 }
 #else
-void glue(helper_shufps, SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
+void glue(HELPER(shufps), SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
 {
     uint32_t r0, r1, r2, r3;
     int i;
@@ -412,7 +412,7 @@ void glue(helper_shufps, SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
     }
 }
 
-void glue(helper_shufpd, SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
+void glue(HELPER(shufpd), SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
 {
     uint64_t r0, r1;
     int i;
@@ -426,7 +426,7 @@ void glue(helper_shufpd, SUFFIX)(Reg *d, Reg *v, Reg *s, int order)
     }
 }
 
-void glue(helper_pshufd, SUFFIX)(Reg *d, Reg *s, int order)
+void glue(HELPER(pshufd), SUFFIX)(Reg *d, Reg *s, int order)
 {
     uint32_t r0, r1, r2, r3;
     int i;
@@ -436,7 +436,7 @@ void glue(helper_pshufd, SUFFIX)(Reg *d, Reg *s, int order)
     }
 }
 
-void glue(helper_pshuflw, SUFFIX)(Reg *d, Reg *s, int order)
+void glue(HELPER(pshuflw), SUFFIX)(Reg *d, Reg *s, int order)
 {
     uint16_t r0, r1, r2, r3;
     int i, j;
@@ -447,7 +447,7 @@ void glue(helper_pshuflw, SUFFIX)(Reg *d, Reg *s, int order)
     }
 }
 
-void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order)
+void glue(HELPER(pshufhw), SUFFIX)(Reg *d, Reg *s, int order)
 {
     uint16_t r0, r1, r2, r3;
     int i, j;
@@ -464,7 +464,7 @@ void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order)
 /* XXX: not accurate */
 
 #define SSE_HELPER_P(name, F)                                           \
-    void glue(helper_ ## name ## ps, SUFFIX)(CPUX86State *env,          \
+    void HELPER(glue(name ## ps, SUFFIX))(CPUX86State *env,             \
             Reg *d, Reg *v, Reg *s)                                     \
     {                                                                   \
         int i;                                                          \
@@ -473,7 +473,7 @@ void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order)
         }                                                               \
     }                                                                   \
                                                                         \
-    void glue(helper_ ## name ## pd, SUFFIX)(CPUX86State *env,          \
+    void HELPER(glue(name ## pd, SUFFIX))(CPUX86State *env,             \
             Reg *d, Reg *v, Reg *s)                                     \
     {                                                                   \
         int i;                                                          \
@@ -487,7 +487,7 @@ void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order)
 #define SSE_HELPER_S(name, F)                                           \
     SSE_HELPER_P(name, F)                                               \
                                                                         \
-    void helper_ ## name ## ss(CPUX86State *env, Reg *d, Reg *v, Reg *s)\
+    void HELPER(name ## ss)(CPUX86State *env, Reg *d, Reg *v, Reg *s)   \
     {                                                                   \
         int i;                                                          \
         d->ZMM_S(0) = F(32, v->ZMM_S(0), s->ZMM_S(0));                  \
@@ -496,7 +496,7 @@ void glue(helper_pshufhw, SUFFIX)(Reg *d, Reg *s, int order)
         }                                                               \
     }                                                                   \
                                                                         \
-    void helper_ ## name ## sd(CPUX86State *env, Reg *d, Reg *v, Reg *s)\
+    void HELPER(name ## sd)(CPUX86State *env, Reg *d, Reg *v, Reg *s)   \
     {                                                                   \
         int i;                                                          \
         d->ZMM_D(0) = F(64, v->ZMM_D(0), s->ZMM_D(0));                  \
@@ -532,7 +532,7 @@ SSE_HELPER_S(div, FPU_DIV)
 SSE_HELPER_S(min, FPU_MIN)
 SSE_HELPER_S(max, FPU_MAX)
 
-void glue(helper_sqrtps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(sqrtps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 0; i < 2 << SHIFT; i++) {
@@ -540,7 +540,7 @@ void glue(helper_sqrtps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     }
 }
 
-void glue(helper_sqrtpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(sqrtpd), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 0; i < 1 << SHIFT; i++) {
@@ -549,7 +549,7 @@ void glue(helper_sqrtpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 }
 
 #if SHIFT == 1
-void helper_sqrtss(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void HELPER(sqrtss)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     d->ZMM_S(0) = float32_sqrt(s->ZMM_S(0), &env->sse_status);
@@ -558,7 +558,7 @@ void helper_sqrtss(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void helper_sqrtsd(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void HELPER(sqrtsd)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     d->ZMM_D(0) = float64_sqrt(s->ZMM_D(0), &env->sse_status);
@@ -569,7 +569,7 @@ void helper_sqrtsd(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 #endif
 
 /* float to float conversions */
-void glue(helper_cvtps2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(cvtps2pd), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 1 << SHIFT; --i >= 0; ) {
@@ -577,7 +577,7 @@ void glue(helper_cvtps2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     }
 }
 
-void glue(helper_cvtpd2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(cvtpd2ps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 0; i < 1 << SHIFT; i++) {
@@ -589,7 +589,7 @@ void glue(helper_cvtpd2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 }
 
 #if SHIFT >= 1
-void glue(helper_cvtph2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(cvtph2ps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
 
@@ -598,7 +598,7 @@ void glue(helper_cvtph2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     }
 }
 
-void glue(helper_cvtps2ph, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, int mode)
+void glue(HELPER(cvtps2ph), SUFFIX)(CPUX86State *env, Reg *d, Reg *s, int mode)
 {
     int i;
     FloatRoundMode prev_rounding_mode = get_float_rounding_mode(&env->sse_status);
@@ -618,7 +618,7 @@ void glue(helper_cvtps2ph, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, int mode)
 #endif
 
 #if SHIFT == 1
-void helper_cvtss2sd(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void HELPER(cvtss2sd)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     d->ZMM_D(0) = float32_to_float64(s->ZMM_S(0), &env->sse_status);
@@ -627,7 +627,7 @@ void helper_cvtss2sd(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void helper_cvtsd2ss(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void HELPER(cvtsd2ss)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     d->ZMM_S(0) = float64_to_float32(s->ZMM_D(0), &env->sse_status);
@@ -638,7 +638,7 @@ void helper_cvtsd2ss(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 #endif
 
 /* integer to float */
-void glue(helper_cvtdq2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(cvtdq2ps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 0; i < 2 << SHIFT; i++) {
@@ -646,7 +646,7 @@ void glue(helper_cvtdq2ps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     }
 }
 
-void glue(helper_cvtdq2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(cvtdq2pd), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int i;
     for (i = 1 << SHIFT; --i >= 0; ) {
@@ -656,35 +656,35 @@ void glue(helper_cvtdq2pd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 }
 
 #if SHIFT == 1
-void helper_cvtpi2ps(CPUX86State *env, ZMMReg *d, MMXReg *s)
+void HELPER(cvtpi2ps)(CPUX86State *env, ZMMReg *d, MMXReg *s)
 {
     d->ZMM_S(0) = int32_to_float32(s->MMX_L(0), &env->sse_status);
     d->ZMM_S(1) = int32_to_float32(s->MMX_L(1), &env->sse_status);
 }
 
-void helper_cvtpi2pd(CPUX86State *env, ZMMReg *d, MMXReg *s)
+void HELPER(cvtpi2pd)(CPUX86State *env, ZMMReg *d, MMXReg *s)
 {
     d->ZMM_D(0) = int32_to_float64(s->MMX_L(0), &env->sse_status);
     d->ZMM_D(1) = int32_to_float64(s->MMX_L(1), &env->sse_status);
 }
 
-void helper_cvtsi2ss(CPUX86State *env, ZMMReg *d, uint32_t val)
+void HELPER(cvtsi2ss)(CPUX86State *env, ZMMReg *d, uint32_t val)
 {
     d->ZMM_S(0) = int32_to_float32(val, &env->sse_status);
 }
 
-void helper_cvtsi2sd(CPUX86State *env, ZMMReg *d, uint32_t val)
+void HELPER(cvtsi2sd)(CPUX86State *env, ZMMReg *d, uint32_t val)
 {
     d->ZMM_D(0) = int32_to_float64(val, &env->sse_status);
 }
 
 #ifdef TARGET_X86_64
-void helper_cvtsq2ss(CPUX86State *env, ZMMReg *d, uint64_t val)
+void HELPER(cvtsq2ss)(CPUX86State *env, ZMMReg *d, uint64_t val)
 {
     d->ZMM_S(0) = int64_to_float32(val, &env->sse_status);
 }
 
-void helper_cvtsq2sd(CPUX86State *env, ZMMReg *d, uint64_t val)
+void HELPER(cvtsq2sd)(CPUX86State *env, ZMMReg *d, uint64_t val)
 {
     d->ZMM_D(0) = int64_to_float64(val, &env->sse_status);
 }
@@ -727,7 +727,7 @@ WRAP_FLOATCONV(int64_t, float64_to_int64, float64, INT64_MIN)
 WRAP_FLOATCONV(int64_t, float64_to_int64_round_to_zero, float64, INT64_MIN)
 #endif
 
-void glue(helper_cvtps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(cvtps2dq), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int i;
     for (i = 0; i < 2 << SHIFT; i++) {
@@ -735,7 +735,7 @@ void glue(helper_cvtps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
     }
 }
 
-void glue(helper_cvtpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(cvtpd2dq), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int i;
     for (i = 0; i < 1 << SHIFT; i++) {
@@ -747,35 +747,35 @@ void glue(helper_cvtpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 }
 
 #if SHIFT == 1
-void helper_cvtps2pi(CPUX86State *env, MMXReg *d, ZMMReg *s)
+void HELPER(cvtps2pi)(CPUX86State *env, MMXReg *d, ZMMReg *s)
 {
     d->MMX_L(0) = x86_float32_to_int32(s->ZMM_S(0), &env->sse_status);
     d->MMX_L(1) = x86_float32_to_int32(s->ZMM_S(1), &env->sse_status);
 }
 
-void helper_cvtpd2pi(CPUX86State *env, MMXReg *d, ZMMReg *s)
+void HELPER(cvtpd2pi)(CPUX86State *env, MMXReg *d, ZMMReg *s)
 {
     d->MMX_L(0) = x86_float64_to_int32(s->ZMM_D(0), &env->sse_status);
     d->MMX_L(1) = x86_float64_to_int32(s->ZMM_D(1), &env->sse_status);
 }
 
-int32_t helper_cvtss2si(CPUX86State *env, ZMMReg *s)
+int32_t HELPER(cvtss2si)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float32_to_int32(s->ZMM_S(0), &env->sse_status);
 }
 
-int32_t helper_cvtsd2si(CPUX86State *env, ZMMReg *s)
+int32_t HELPER(cvtsd2si)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float64_to_int32(s->ZMM_D(0), &env->sse_status);
 }
 
 #ifdef TARGET_X86_64
-int64_t helper_cvtss2sq(CPUX86State *env, ZMMReg *s)
+int64_t HELPER(cvtss2sq)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float32_to_int64(s->ZMM_S(0), &env->sse_status);
 }
 
-int64_t helper_cvtsd2sq(CPUX86State *env, ZMMReg *s)
+int64_t HELPER(cvtsd2sq)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float64_to_int64(s->ZMM_D(0), &env->sse_status);
 }
@@ -783,7 +783,7 @@ int64_t helper_cvtsd2sq(CPUX86State *env, ZMMReg *s)
 #endif
 
 /* float to integer truncated */
-void glue(helper_cvttps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(cvttps2dq), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int i;
     for (i = 0; i < 2 << SHIFT; i++) {
@@ -792,7 +792,7 @@ void glue(helper_cvttps2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
     }
 }
 
-void glue(helper_cvttpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(cvttpd2dq), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int i;
     for (i = 0; i < 1 << SHIFT; i++) {
@@ -805,42 +805,42 @@ void glue(helper_cvttpd2dq, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 }
 
 #if SHIFT == 1
-void helper_cvttps2pi(CPUX86State *env, MMXReg *d, ZMMReg *s)
+void HELPER(cvttps2pi)(CPUX86State *env, MMXReg *d, ZMMReg *s)
 {
     d->MMX_L(0) = x86_float32_to_int32_round_to_zero(s->ZMM_S(0), &env->sse_status);
     d->MMX_L(1) = x86_float32_to_int32_round_to_zero(s->ZMM_S(1), &env->sse_status);
 }
 
-void helper_cvttpd2pi(CPUX86State *env, MMXReg *d, ZMMReg *s)
+void HELPER(cvttpd2pi)(CPUX86State *env, MMXReg *d, ZMMReg *s)
 {
     d->MMX_L(0) = x86_float64_to_int32_round_to_zero(s->ZMM_D(0), &env->sse_status);
     d->MMX_L(1) = x86_float64_to_int32_round_to_zero(s->ZMM_D(1), &env->sse_status);
 }
 
-int32_t helper_cvttss2si(CPUX86State *env, ZMMReg *s)
+int32_t HELPER(cvttss2si)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float32_to_int32_round_to_zero(s->ZMM_S(0), &env->sse_status);
 }
 
-int32_t helper_cvttsd2si(CPUX86State *env, ZMMReg *s)
+int32_t HELPER(cvttsd2si)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float64_to_int32_round_to_zero(s->ZMM_D(0), &env->sse_status);
 }
 
 #ifdef TARGET_X86_64
-int64_t helper_cvttss2sq(CPUX86State *env, ZMMReg *s)
+int64_t HELPER(cvttss2sq)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float32_to_int64_round_to_zero(s->ZMM_S(0), &env->sse_status);
 }
 
-int64_t helper_cvttsd2sq(CPUX86State *env, ZMMReg *s)
+int64_t HELPER(cvttsd2sq)(CPUX86State *env, ZMMReg *s)
 {
     return x86_float64_to_int64_round_to_zero(s->ZMM_D(0), &env->sse_status);
 }
 #endif
 #endif
 
-void glue(helper_rsqrtps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(rsqrtps), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
     int i;
@@ -853,7 +853,7 @@ void glue(helper_rsqrtps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 }
 
 #if SHIFT == 1
-void helper_rsqrtss(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s)
+void HELPER(rsqrtss)(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
     int i;
@@ -867,7 +867,7 @@ void helper_rsqrtss(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s)
 }
 #endif
 
-void glue(helper_rcpps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void glue(HELPER(rcpps), SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
     int i;
@@ -878,7 +878,7 @@ void glue(helper_rcpps, SUFFIX)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 }
 
 #if SHIFT == 1
-void helper_rcpss(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s)
+void HELPER(rcpss)(CPUX86State *env, ZMMReg *d, ZMMReg *v, ZMMReg *s)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
     int i;
@@ -903,12 +903,12 @@ static inline uint64_t helper_extrq(uint64_t src, int shift, int len)
     return (src >> shift) & mask;
 }
 
-void helper_extrq_r(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void HELPER(extrq_r)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     d->ZMM_Q(0) = helper_extrq(d->ZMM_Q(0), s->ZMM_B(1) & 63, s->ZMM_B(0) & 63);
 }
 
-void helper_extrq_i(CPUX86State *env, ZMMReg *d, int index, int length)
+void HELPER(extrq_i)(CPUX86State *env, ZMMReg *d, int index, int length)
 {
     d->ZMM_Q(0) = helper_extrq(d->ZMM_Q(0), index, length);
 }
@@ -925,19 +925,20 @@ static inline uint64_t helper_insertq(uint64_t dest, uint64_t src, int shift, in
     return (dest & ~(mask << shift)) | ((src & mask) << shift);
 }
 
-void helper_insertq_r(CPUX86State *env, ZMMReg *d, ZMMReg *s)
+void HELPER(insertq_r)(CPUX86State *env, ZMMReg *d, ZMMReg *s)
 {
     d->ZMM_Q(0) = helper_insertq(d->ZMM_Q(0), s->ZMM_Q(0), s->ZMM_B(9) & 63, s->ZMM_B(8) & 63);
 }
 
-void helper_insertq_i(CPUX86State *env, ZMMReg *d, ZMMReg *s, int index, int length)
+void HELPER(insertq_i)(CPUX86State *env, ZMMReg *d, ZMMReg *s, int index,
+                       int length)
 {
     d->ZMM_Q(0) = helper_insertq(d->ZMM_Q(0), s->ZMM_Q(0), index, length);
 }
 #endif
 
 #define SSE_HELPER_HPS(name, F)  \
-void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
+void HELPER(glue(name, SUFFIX))(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
 {                                                                 \
     float32 r[2 << SHIFT];                                        \
     int i, j, k;                                                  \
@@ -958,7 +959,7 @@ SSE_HELPER_HPS(haddps, float32_add)
 SSE_HELPER_HPS(hsubps, float32_sub)
 
 #define SSE_HELPER_HPD(name, F)  \
-void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
+void HELPER(glue(name, SUFFIX))(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
 {                                                                 \
     float64 r[1 << SHIFT];                                        \
     int i, j, k;                                                  \
@@ -978,7 +979,7 @@ void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
 SSE_HELPER_HPD(haddpd, float64_add)
 SSE_HELPER_HPD(hsubpd, float64_sub)
 
-void glue(helper_addsubps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(addsubps), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     for (i = 0; i < 2 << SHIFT; i += 2) {
@@ -987,7 +988,7 @@ void glue(helper_addsubps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(addsubpd), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     for (i = 0; i < 1 << SHIFT; i += 2) {
@@ -997,7 +998,7 @@ void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #define SSE_HELPER_CMP_P(name, F, C)                                    \
-    void glue(helper_ ## name ## ps, SUFFIX)(CPUX86State *env,          \
+    void HELPER(glue(name ## ps, SUFFIX))(CPUX86State *env,             \
                                              Reg *d, Reg *v, Reg *s)    \
     {                                                                   \
         int i;                                                          \
@@ -1006,7 +1007,7 @@ void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
         }                                                               \
     }                                                                   \
                                                                         \
-    void glue(helper_ ## name ## pd, SUFFIX)(CPUX86State *env,          \
+    void HELPER(glue(name ## pd, SUFFIX))(CPUX86State *env,             \
                                              Reg *d, Reg *v, Reg *s)    \
     {                                                                   \
         int i;                                                          \
@@ -1018,7 +1019,7 @@ void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 #if SHIFT == 1
 #define SSE_HELPER_CMP(name, F, C)                                          \
     SSE_HELPER_CMP_P(name, F, C)                                            \
-    void helper_ ## name ## ss(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
+    void HELPER(name ## ss)(CPUX86State *env, Reg *d, Reg *v, Reg *s)       \
     {                                                                       \
         int i;                                                              \
         d->ZMM_L(0) = C(F(32, v->ZMM_S(0), s->ZMM_S(0))) ? -1 : 0;          \
@@ -1027,7 +1028,7 @@ void glue(helper_addsubpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
         }                                                                   \
     }                                                                       \
                                                                             \
-    void helper_ ## name ## sd(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
+    void HELPER(name ## sd)(CPUX86State *env, Reg *d, Reg *v, Reg *s)       \
     {                                                                       \
         int i;                                                              \
         d->ZMM_Q(0) = C(F(64, v->ZMM_D(0), s->ZMM_D(0))) ? -1 : 0;          \
@@ -1102,7 +1103,7 @@ SSE_HELPER_CMP(cmptrues, FPU_CMPS,  !FPU_FALSE)
 #if SHIFT == 1
 static const int comis_eflags[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C};
 
-void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s)
+void HELPER(ucomiss)(CPUX86State *env, Reg *d, Reg *s)
 {
     FloatRelation ret;
     float32 s0, s1;
@@ -1114,7 +1115,7 @@ void helper_ucomiss(CPUX86State *env, Reg *d, Reg *s)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_comiss(CPUX86State *env, Reg *d, Reg *s)
+void HELPER(comiss)(CPUX86State *env, Reg *d, Reg *s)
 {
     FloatRelation ret;
     float32 s0, s1;
@@ -1126,7 +1127,7 @@ void helper_comiss(CPUX86State *env, Reg *d, Reg *s)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s)
+void HELPER(ucomisd)(CPUX86State *env, Reg *d, Reg *s)
 {
     FloatRelation ret;
     float64 d0, d1;
@@ -1138,7 +1139,7 @@ void helper_ucomisd(CPUX86State *env, Reg *d, Reg *s)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_comisd(CPUX86State *env, Reg *d, Reg *s)
+void HELPER(comisd)(CPUX86State *env, Reg *d, Reg *s)
 {
     FloatRelation ret;
     float64 d0, d1;
@@ -1151,7 +1152,7 @@ void helper_comisd(CPUX86State *env, Reg *d, Reg *s)
 }
 #endif
 
-uint32_t glue(helper_movmskps, SUFFIX)(CPUX86State *env, Reg *s)
+uint32_t glue(HELPER(movmskps), SUFFIX)(CPUX86State *env, Reg *s)
 {
     uint32_t mask;
     int i;
@@ -1163,7 +1164,7 @@ uint32_t glue(helper_movmskps, SUFFIX)(CPUX86State *env, Reg *s)
     return mask;
 }
 
-uint32_t glue(helper_movmskpd, SUFFIX)(CPUX86State *env, Reg *s)
+uint32_t glue(HELPER(movmskpd), SUFFIX)(CPUX86State *env, Reg *s)
 {
     uint32_t mask;
     int i;
@@ -1178,7 +1179,7 @@ uint32_t glue(helper_movmskpd, SUFFIX)(CPUX86State *env, Reg *s)
 #endif
 
 #define PACK_HELPER_B(name, F) \
-void glue(helper_pack ## name, SUFFIX)(CPUX86State *env,      \
+void HELPER(glue(pack ## name, SUFFIX))(CPUX86State *env,     \
         Reg *d, Reg *v, Reg *s)                               \
 {                                                             \
     uint8_t r[PACK_WIDTH * 2];                                \
@@ -1199,7 +1200,7 @@ void glue(helper_pack ## name, SUFFIX)(CPUX86State *env,      \
 PACK_HELPER_B(sswb, satsb)
 PACK_HELPER_B(uswb, satub)
 
-void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(packssdw), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     uint16_t r[PACK_WIDTH];
     int j, k;
@@ -1219,7 +1220,7 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 
 #define UNPCK_OP(base_name, base)                                       \
                                                                         \
-    void glue(helper_punpck ## base_name ## bw, SUFFIX)(CPUX86State *env,\
+    void HELPER(glue(punpck ## base_name ## bw, SUFFIX))(CPUX86State *env, \
                                                 Reg *d, Reg *v, Reg *s) \
     {                                                                   \
         uint8_t r[PACK_WIDTH * 2];                                      \
@@ -1237,7 +1238,7 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
         }                                                               \
     }                                                                   \
                                                                         \
-    void glue(helper_punpck ## base_name ## wd, SUFFIX)(CPUX86State *env,\
+    void HELPER(glue(punpck ## base_name ## wd, SUFFIX))(CPUX86State *env, \
                                                 Reg *d, Reg *v, Reg *s) \
     {                                                                   \
         uint16_t r[PACK_WIDTH];                                         \
@@ -1255,7 +1256,7 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
         }                                                               \
     }                                                                   \
                                                                         \
-    void glue(helper_punpck ## base_name ## dq, SUFFIX)(CPUX86State *env,\
+    void HELPER(glue(punpck ## base_name ## dq, SUFFIX))(CPUX86State *env, \
                                                 Reg *d, Reg *v, Reg *s) \
     {                                                                   \
         uint32_t r[PACK_WIDTH / 2];                                     \
@@ -1274,7 +1275,7 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }                                                                   \
                                                                         \
     XMM_ONLY(                                                           \
-             void glue(helper_punpck ## base_name ## qdq, SUFFIX)(      \
+             void HELPER(glue(punpck ## base_name ## qdq, SUFFIX))(     \
                         CPUX86State *env, Reg *d, Reg *v, Reg *s)       \
              {                                                          \
                  uint64_t r[2];                                         \
@@ -1299,25 +1300,25 @@ UNPCK_OP(h, 1)
 
 /* 3DNow! float ops */
 #if SHIFT == 0
-void helper_pi2fd(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pi2fd)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = int32_to_float32(s->MMX_L(0), &env->mmx_status);
     d->MMX_S(1) = int32_to_float32(s->MMX_L(1), &env->mmx_status);
 }
 
-void helper_pi2fw(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pi2fw)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = int32_to_float32((int16_t)s->MMX_W(0), &env->mmx_status);
     d->MMX_S(1) = int32_to_float32((int16_t)s->MMX_W(2), &env->mmx_status);
 }
 
-void helper_pf2id(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pf2id)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(0) = float32_to_int32_round_to_zero(s->MMX_S(0), &env->mmx_status);
     d->MMX_L(1) = float32_to_int32_round_to_zero(s->MMX_S(1), &env->mmx_status);
 }
 
-void helper_pf2iw(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pf2iw)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(0) = satsw(float32_to_int32_round_to_zero(s->MMX_S(0),
                                                        &env->mmx_status));
@@ -1325,7 +1326,7 @@ void helper_pf2iw(CPUX86State *env, MMXReg *d, MMXReg *s)
                                                        &env->mmx_status));
 }
 
-void helper_pfacc(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfacc)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     float32 r;
 
@@ -1334,13 +1335,13 @@ void helper_pfacc(CPUX86State *env, MMXReg *d, MMXReg *s)
     d->MMX_S(0) = r;
 }
 
-void helper_pfadd(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfadd)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = float32_add(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
     d->MMX_S(1) = float32_add(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
 }
 
-void helper_pfcmpeq(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfcmpeq)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(0) = float32_eq_quiet(d->MMX_S(0), s->MMX_S(0),
                                    &env->mmx_status) ? -1 : 0;
@@ -1348,7 +1349,7 @@ void helper_pfcmpeq(CPUX86State *env, MMXReg *d, MMXReg *s)
                                    &env->mmx_status) ? -1 : 0;
 }
 
-void helper_pfcmpge(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfcmpge)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(0) = float32_le(s->MMX_S(0), d->MMX_S(0),
                              &env->mmx_status) ? -1 : 0;
@@ -1356,7 +1357,7 @@ void helper_pfcmpge(CPUX86State *env, MMXReg *d, MMXReg *s)
                              &env->mmx_status) ? -1 : 0;
 }
 
-void helper_pfcmpgt(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfcmpgt)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(0) = float32_lt(s->MMX_S(0), d->MMX_S(0),
                              &env->mmx_status) ? -1 : 0;
@@ -1364,7 +1365,7 @@ void helper_pfcmpgt(CPUX86State *env, MMXReg *d, MMXReg *s)
                              &env->mmx_status) ? -1 : 0;
 }
 
-void helper_pfmax(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfmax)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     if (float32_lt(d->MMX_S(0), s->MMX_S(0), &env->mmx_status)) {
         d->MMX_S(0) = s->MMX_S(0);
@@ -1374,7 +1375,7 @@ void helper_pfmax(CPUX86State *env, MMXReg *d, MMXReg *s)
     }
 }
 
-void helper_pfmin(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfmin)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     if (float32_lt(s->MMX_S(0), d->MMX_S(0), &env->mmx_status)) {
         d->MMX_S(0) = s->MMX_S(0);
@@ -1384,13 +1385,13 @@ void helper_pfmin(CPUX86State *env, MMXReg *d, MMXReg *s)
     }
 }
 
-void helper_pfmul(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfmul)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = float32_mul(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
     d->MMX_S(1) = float32_mul(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
 }
 
-void helper_pfnacc(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfnacc)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     float32 r;
 
@@ -1399,7 +1400,7 @@ void helper_pfnacc(CPUX86State *env, MMXReg *d, MMXReg *s)
     d->MMX_S(0) = r;
 }
 
-void helper_pfpnacc(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfpnacc)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     float32 r;
 
@@ -1408,13 +1409,13 @@ void helper_pfpnacc(CPUX86State *env, MMXReg *d, MMXReg *s)
     d->MMX_S(0) = r;
 }
 
-void helper_pfrcp(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfrcp)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = float32_div(float32_one, s->MMX_S(0), &env->mmx_status);
     d->MMX_S(1) = d->MMX_S(0);
 }
 
-void helper_pfrsqrt(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfrsqrt)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_L(1) = s->MMX_L(0) & 0x7fffffff;
     d->MMX_S(1) = float32_div(float32_one,
@@ -1424,19 +1425,19 @@ void helper_pfrsqrt(CPUX86State *env, MMXReg *d, MMXReg *s)
     d->MMX_L(0) = d->MMX_L(1);
 }
 
-void helper_pfsub(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfsub)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = float32_sub(d->MMX_S(0), s->MMX_S(0), &env->mmx_status);
     d->MMX_S(1) = float32_sub(d->MMX_S(1), s->MMX_S(1), &env->mmx_status);
 }
 
-void helper_pfsubr(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pfsubr)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     d->MMX_S(0) = float32_sub(s->MMX_S(0), d->MMX_S(0), &env->mmx_status);
     d->MMX_S(1) = float32_sub(s->MMX_S(1), d->MMX_S(1), &env->mmx_status);
 }
 
-void helper_pswapd(CPUX86State *env, MMXReg *d, MMXReg *s)
+void HELPER(pswapd)(CPUX86State *env, MMXReg *d, MMXReg *s)
 {
     uint32_t r;
 
@@ -1447,7 +1448,7 @@ void helper_pswapd(CPUX86State *env, MMXReg *d, MMXReg *s)
 #endif
 
 /* SSSE3 op helpers */
-void glue(helper_pshufb, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(pshufb), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 #if SHIFT == 0
@@ -1473,7 +1474,7 @@ void glue(helper_pshufb, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #define SSE_HELPER_HW(name, F)  \
-void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
+void HELPER(glue(name, SUFFIX))(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
 {                                                          \
     uint16_t r[4 << SHIFT];                                \
     int i, j, k;                                           \
@@ -1491,7 +1492,7 @@ void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
 }
 
 #define SSE_HELPER_HL(name, F)  \
-void glue(helper_ ## name, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s) \
+void HELPER(glue(name, SUFFIX))(CPUX86State *env, Reg *d, Reg *v, Reg *s)    \
 {                                                          \
     uint32_t r[2 << SHIFT];                                \
     int i, j, k;                                           \
@@ -1518,7 +1519,7 @@ SSE_HELPER_HL(phsubd, FSUB)
 #undef SSE_HELPER_HW
 #undef SSE_HELPER_HL
 
-void glue(helper_pmaddubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(pmaddubsw), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
     for (i = 0; i < 4 << SHIFT; i++) {
@@ -1528,16 +1529,16 @@ void glue(helper_pmaddubsw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #define FMULHRSW(d, s) (((int16_t) d * (int16_t)s + 0x4000) >> 15)
-SSE_HELPER_W(helper_pmulhrsw, FMULHRSW)
+SSE_HELPER_W(HELPER(pmulhrsw), FMULHRSW)
 
 #define FSIGNB(d, s) (s <= INT8_MAX  ? s ? d : 0 : -(int8_t)d)
 #define FSIGNW(d, s) (s <= INT16_MAX ? s ? d : 0 : -(int16_t)d)
 #define FSIGNL(d, s) (s <= INT32_MAX ? s ? d : 0 : -(int32_t)d)
-SSE_HELPER_B(helper_psignb, FSIGNB)
-SSE_HELPER_W(helper_psignw, FSIGNW)
-SSE_HELPER_L(helper_psignd, FSIGNL)
+SSE_HELPER_B(HELPER(psignb), FSIGNB)
+SSE_HELPER_W(HELPER(psignw), FSIGNW)
+SSE_HELPER_L(HELPER(psignd), FSIGNL)
 
-void glue(helper_palignr, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(palignr), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                   uint32_t imm)
 {
     int i;
@@ -1600,11 +1601,11 @@ void glue(helper_palignr, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
 #define FBLENDVB(v, s, m) ((m & 0x80) ? s : v)
 #define FBLENDVPS(v, s, m) ((m & 0x80000000) ? s : v)
 #define FBLENDVPD(v, s, m) ((m & 0x8000000000000000LL) ? s : v)
-SSE_HELPER_V(helper_pblendvb, B, 8 << SHIFT, FBLENDVB)
-SSE_HELPER_V(helper_blendvps, L, 2 << SHIFT, FBLENDVPS)
-SSE_HELPER_V(helper_blendvpd, Q, 1 << SHIFT, FBLENDVPD)
+SSE_HELPER_V(HELPER(pblendvb), B, 8 << SHIFT, FBLENDVB)
+SSE_HELPER_V(HELPER(blendvps), L, 2 << SHIFT, FBLENDVPS)
+SSE_HELPER_V(HELPER(blendvpd), Q, 1 << SHIFT, FBLENDVPD)
 
-void glue(helper_ptest, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(ptest), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     uint64_t zf = 0, cf = 0;
     int i;
@@ -1631,24 +1632,24 @@ void glue(helper_ptest, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     }
 
 #if SHIFT > 0
-SSE_HELPER_F(helper_pmovsxbw, W, 4 << SHIFT, (int8_t) s->B)
-SSE_HELPER_F(helper_pmovsxbd, L, 2 << SHIFT, (int8_t) s->B)
-SSE_HELPER_F(helper_pmovsxbq, Q, 1 << SHIFT, (int8_t) s->B)
-SSE_HELPER_F(helper_pmovsxwd, L, 2 << SHIFT, (int16_t) s->W)
-SSE_HELPER_F(helper_pmovsxwq, Q, 1 << SHIFT, (int16_t) s->W)
-SSE_HELPER_F(helper_pmovsxdq, Q, 1 << SHIFT, (int32_t) s->L)
-SSE_HELPER_F(helper_pmovzxbw, W, 4 << SHIFT, s->B)
-SSE_HELPER_F(helper_pmovzxbd, L, 2 << SHIFT, s->B)
-SSE_HELPER_F(helper_pmovzxbq, Q, 1 << SHIFT, s->B)
-SSE_HELPER_F(helper_pmovzxwd, L, 2 << SHIFT, s->W)
-SSE_HELPER_F(helper_pmovzxwq, Q, 1 << SHIFT, s->W)
-SSE_HELPER_F(helper_pmovzxdq, Q, 1 << SHIFT, s->L)
-SSE_HELPER_F(helper_pmovsldup, L, 2 << SHIFT, FMOVSLDUP)
-SSE_HELPER_F(helper_pmovshdup, L, 2 << SHIFT, FMOVSHDUP)
-SSE_HELPER_F(helper_pmovdldup, Q, 1 << SHIFT, FMOVDLDUP)
+SSE_HELPER_F(HELPER(pmovsxbw), W, 4 << SHIFT, (int8_t) s->B)
+SSE_HELPER_F(HELPER(pmovsxbd), L, 2 << SHIFT, (int8_t) s->B)
+SSE_HELPER_F(HELPER(pmovsxbq), Q, 1 << SHIFT, (int8_t) s->B)
+SSE_HELPER_F(HELPER(pmovsxwd), L, 2 << SHIFT, (int16_t) s->W)
+SSE_HELPER_F(HELPER(pmovsxwq), Q, 1 << SHIFT, (int16_t) s->W)
+SSE_HELPER_F(HELPER(pmovsxdq), Q, 1 << SHIFT, (int32_t) s->L)
+SSE_HELPER_F(HELPER(pmovzxbw), W, 4 << SHIFT, s->B)
+SSE_HELPER_F(HELPER(pmovzxbd), L, 2 << SHIFT, s->B)
+SSE_HELPER_F(HELPER(pmovzxbq), Q, 1 << SHIFT, s->B)
+SSE_HELPER_F(HELPER(pmovzxwd), L, 2 << SHIFT, s->W)
+SSE_HELPER_F(HELPER(pmovzxwq), Q, 1 << SHIFT, s->W)
+SSE_HELPER_F(HELPER(pmovzxdq), Q, 1 << SHIFT, s->L)
+SSE_HELPER_F(HELPER(pmovsldup), L, 2 << SHIFT, FMOVSLDUP)
+SSE_HELPER_F(HELPER(pmovshdup), L, 2 << SHIFT, FMOVSHDUP)
+SSE_HELPER_F(HELPER(pmovdldup), Q, 1 << SHIFT, FMOVDLDUP)
 #endif
 
-void glue(helper_pmuldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(pmuldq), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -1657,7 +1658,7 @@ void glue(helper_pmuldq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_packusdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(packusdw), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     uint16_t r[8];
     int i, j, k;
@@ -1678,7 +1679,7 @@ void glue(helper_packusdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #if SHIFT == 1
-void glue(helper_phminposuw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(phminposuw), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     int idx = 0;
 
@@ -1711,7 +1712,7 @@ void glue(helper_phminposuw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 }
 #endif
 
-void glue(helper_roundps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(roundps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                   uint32_t mode)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
@@ -1734,7 +1735,7 @@ void glue(helper_roundps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
     set_float_rounding_mode(prev_rounding_mode, &env->sse_status);
 }
 
-void glue(helper_roundpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(roundpd), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                   uint32_t mode)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
@@ -1758,7 +1759,7 @@ void glue(helper_roundpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
 }
 
 #if SHIFT == 1
-void glue(helper_roundss, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(roundss), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                   uint32_t mode)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
@@ -1782,7 +1783,7 @@ void glue(helper_roundss, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
     set_float_rounding_mode(prev_rounding_mode, &env->sse_status);
 }
 
-void glue(helper_roundsd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(roundsd), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                   uint32_t mode)
 {
     int old_flags = get_float_exception_flags(&env->sse_status);
@@ -1808,11 +1809,11 @@ void glue(helper_roundsd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
 #endif
 
 #define FBLENDP(v, s, m) (m ? s : v)
-SSE_HELPER_I(helper_blendps, L, 2 << SHIFT, FBLENDP)
-SSE_HELPER_I(helper_blendpd, Q, 1 << SHIFT, FBLENDP)
-SSE_HELPER_I(helper_pblendw, W, 4 << SHIFT, FBLENDP)
+SSE_HELPER_I(HELPER(blendps), L, 2 << SHIFT, FBLENDP)
+SSE_HELPER_I(HELPER(blendpd), Q, 1 << SHIFT, FBLENDP)
+SSE_HELPER_I(HELPER(pblendw), W, 4 << SHIFT, FBLENDP)
 
-void glue(helper_dpps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(dpps), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                uint32_t mask)
 {
     float32 prod1, prod2, temp2, temp3, temp4;
@@ -1856,7 +1857,7 @@ void glue(helper_dpps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
 
 #if SHIFT == 1
 /* Oddly, there is no ymm version of dppd */
-void glue(helper_dppd, SUFFIX)(CPUX86State *env,
+void glue(HELPER(dppd), SUFFIX)(CPUX86State *env,
                                Reg *d, Reg *v, Reg *s, uint32_t mask)
 {
     float64 prod1, prod2, temp2;
@@ -1877,7 +1878,7 @@ void glue(helper_dppd, SUFFIX)(CPUX86State *env,
 }
 #endif
 
-void glue(helper_mpsadbw, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(mpsadbw), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                   uint32_t offset)
 {
     int i, j;
@@ -2033,7 +2034,7 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s,
     return res;
 }
 
-void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(pcmpestri), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                     uint32_t ctrl)
 {
     unsigned int res = pcmpxstrx(env, d, s, ctrl,
@@ -2047,7 +2048,7 @@ void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
     }
 }
 
-void glue(helper_pcmpestrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(pcmpestrm), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                     uint32_t ctrl)
 {
     int i;
@@ -2071,7 +2072,7 @@ void glue(helper_pcmpestrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
     }
 }
 
-void glue(helper_pcmpistri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(pcmpistri), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                     uint32_t ctrl)
 {
     unsigned int res = pcmpxstrx(env, d, s, ctrl,
@@ -2085,7 +2086,7 @@ void glue(helper_pcmpistri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
     }
 }
 
-void glue(helper_pcmpistrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(pcmpistrm), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                     uint32_t ctrl)
 {
     int i;
@@ -2111,7 +2112,7 @@ void glue(helper_pcmpistrm, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
 
 #define CRCPOLY        0x1edc6f41
 #define CRCPOLY_BITREV 0x82f63b78
-target_ulong helper_crc32(uint32_t crc1, target_ulong msg, uint32_t len)
+target_ulong HELPER(crc32)(uint32_t crc1, target_ulong msg, uint32_t len)
 {
     target_ulong crc = (msg & ((target_ulong) -1 >>
                                (TARGET_LONG_BITS - len))) ^ crc1;
@@ -2125,7 +2126,7 @@ target_ulong helper_crc32(uint32_t crc1, target_ulong msg, uint32_t len)
 
 #endif
 
-void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
+void glue(HELPER(pclmulqdq), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
                                     uint32_t ctrl)
 {
     int a_idx = (ctrl & 1) != 0;
@@ -2140,7 +2141,7 @@ void glue(helper_pclmulqdq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s,
     }
 }
 
-void glue(helper_aesdec, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(aesdec), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     for (int i = 0; i < SHIFT; i++) {
         AESState *ad = (AESState *)&d->ZMM_X(i);
@@ -2151,7 +2152,7 @@ void glue(helper_aesdec, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(aesdeclast), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     for (int i = 0; i < SHIFT; i++) {
         AESState *ad = (AESState *)&d->ZMM_X(i);
@@ -2162,7 +2163,7 @@ void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(aesenc), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     for (int i = 0; i < SHIFT; i++) {
         AESState *ad = (AESState *)&d->ZMM_X(i);
@@ -2173,7 +2174,7 @@ void glue(helper_aesenc, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(aesenclast), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     for (int i = 0; i < SHIFT; i++) {
         AESState *ad = (AESState *)&d->ZMM_X(i);
@@ -2185,7 +2186,7 @@ void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 }
 
 #if SHIFT == 1
-void glue(helper_aesimc, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(aesimc), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     AESState *ad = (AESState *)&d->ZMM_X(0);
     AESState *st = (AESState *)&s->ZMM_X(0);
@@ -2193,7 +2194,7 @@ void glue(helper_aesimc, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     aesdec_IMC(ad, st, false);
 }
 
-void glue(helper_aeskeygenassist, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
+void glue(HELPER(aeskeygenassist), SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
                                           uint32_t ctrl)
 {
     int i;
@@ -2210,7 +2211,7 @@ void glue(helper_aeskeygenassist, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
 #endif
 
 #if SHIFT >= 1
-void glue(helper_vpermilpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(vpermilpd), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     uint64_t r0, r1;
     int i;
@@ -2223,7 +2224,7 @@ void glue(helper_vpermilpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_vpermilps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(vpermilps), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     uint32_t r0, r1, r2, r3;
     int i;
@@ -2240,7 +2241,7 @@ void glue(helper_vpermilps, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_vpermilpd_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order)
+void glue(HELPER(vpermilpd_imm), SUFFIX)(Reg *d, Reg *s, uint32_t order)
 {
     uint64_t r0, r1;
     int i;
@@ -2255,7 +2256,7 @@ void glue(helper_vpermilpd_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order)
     }
 }
 
-void glue(helper_vpermilps_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order)
+void glue(HELPER(vpermilps_imm), SUFFIX)(Reg *d, Reg *s, uint32_t order)
 {
     uint32_t r0, r1, r2, r3;
     int i;
@@ -2281,15 +2282,15 @@ void glue(helper_vpermilps_imm, SUFFIX)(Reg *d, Reg *s, uint32_t order)
 #define FPSLLVQ(x, c) (c < 64 ? ((x) << c) : 0)
 #endif
 
-SSE_HELPER_L(helper_vpsrlvd, FPSRLVD)
-SSE_HELPER_L(helper_vpsravd, FPSRAVD)
-SSE_HELPER_L(helper_vpsllvd, FPSLLVD)
+SSE_HELPER_L(HELPER(vpsrlvd), FPSRLVD)
+SSE_HELPER_L(HELPER(vpsravd), FPSRAVD)
+SSE_HELPER_L(HELPER(vpsllvd), FPSLLVD)
 
-SSE_HELPER_Q(helper_vpsrlvq, FPSRLVQ)
-SSE_HELPER_Q(helper_vpsravq, FPSRAVQ)
-SSE_HELPER_Q(helper_vpsllvq, FPSLLVQ)
+SSE_HELPER_Q(HELPER(vpsrlvq), FPSRLVQ)
+SSE_HELPER_Q(HELPER(vpsravq), FPSRAVQ)
+SSE_HELPER_Q(HELPER(vpsllvq), FPSLLVQ)
 
-void glue(helper_vtestps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(vtestps), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     uint32_t zf = 0, cf = 0;
     int i;
@@ -2302,7 +2303,7 @@ void glue(helper_vtestps, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void glue(helper_vtestpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
+void glue(HELPER(vtestpd), SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
 {
     uint64_t zf = 0, cf = 0;
     int i;
@@ -2315,7 +2316,7 @@ void glue(helper_vtestpd, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void glue(helper_vpmaskmovd_st, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpmaskmovd_st), SUFFIX)(CPUX86State *env,
                                         Reg *v, Reg *s, target_ulong a0)
 {
     int i;
@@ -2327,7 +2328,7 @@ void glue(helper_vpmaskmovd_st, SUFFIX)(CPUX86State *env,
     }
 }
 
-void glue(helper_vpmaskmovq_st, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpmaskmovq_st), SUFFIX)(CPUX86State *env,
                                         Reg *v, Reg *s, target_ulong a0)
 {
     int i;
@@ -2339,7 +2340,7 @@ void glue(helper_vpmaskmovq_st, SUFFIX)(CPUX86State *env,
     }
 }
 
-void glue(helper_vpmaskmovd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(vpmaskmovd), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -2348,7 +2349,7 @@ void glue(helper_vpmaskmovd, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_vpmaskmovq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
+void glue(HELPER(vpmaskmovq), SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
 {
     int i;
 
@@ -2357,7 +2358,7 @@ void glue(helper_vpmaskmovq, SUFFIX)(CPUX86State *env, Reg *d, Reg *v, Reg *s)
     }
 }
 
-void glue(helper_vpgatherdd, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpgatherdd), SUFFIX)(CPUX86State *env,
         Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale, target_ulong amask)
 {
     int i;
@@ -2371,7 +2372,7 @@ void glue(helper_vpgatherdd, SUFFIX)(CPUX86State *env,
     }
 }
 
-void glue(helper_vpgatherdq, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpgatherdq), SUFFIX)(CPUX86State *env,
         Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale, target_ulong amask)
 {
     int i;
@@ -2385,7 +2386,7 @@ void glue(helper_vpgatherdq, SUFFIX)(CPUX86State *env,
     }
 }
 
-void glue(helper_vpgatherqd, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpgatherqd), SUFFIX)(CPUX86State *env,
         Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale, target_ulong amask)
 {
     int i;
@@ -2403,7 +2404,7 @@ void glue(helper_vpgatherqd, SUFFIX)(CPUX86State *env,
     }
 }
 
-void glue(helper_vpgatherqq, SUFFIX)(CPUX86State *env,
+void glue(HELPER(vpgatherqq), SUFFIX)(CPUX86State *env,
         Reg *d, Reg *v, Reg *s, target_ulong a0, unsigned scale, target_ulong amask)
 {
     int i;
@@ -2419,7 +2420,7 @@ void glue(helper_vpgatherqq, SUFFIX)(CPUX86State *env,
 #endif
 
 #if SHIFT >= 2
-void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
+void HELPER(vpermdq_ymm)(Reg *d, Reg *v, Reg *s, uint32_t order)
 {
     uint64_t r0, r1, r2, r3;
 
@@ -2477,7 +2478,7 @@ void helper_vpermdq_ymm(Reg *d, Reg *v, Reg *s, uint32_t order)
     }
 }
 
-void helper_vpermq_ymm(Reg *d, Reg *s, uint32_t order)
+void HELPER(vpermq_ymm)(Reg *d, Reg *s, uint32_t order)
 {
     uint64_t r0, r1, r2, r3;
     r0 = s->Q(order & 3);
@@ -2490,7 +2491,7 @@ void helper_vpermq_ymm(Reg *d, Reg *s, uint32_t order)
     d->Q(3) = r3;
 }
 
-void helper_vpermd_ymm(Reg *d, Reg *v, Reg *s)
+void HELPER(vpermd_ymm)(Reg *d, Reg *v, Reg *s)
 {
     uint32_t r[8];
     int i;
@@ -2522,13 +2523,13 @@ void helper_vpermd_ymm(Reg *d, Reg *v, Reg *s)
         }                                                                      \
     }
 
-SSE_HELPER_FMAS(helper_fma4ss,  ZMM_S, float32_muladd)
-SSE_HELPER_FMAS(helper_fma4sd,  ZMM_D, float64_muladd)
+SSE_HELPER_FMAS(HELPER(fma4ss),  ZMM_S, float32_muladd)
+SSE_HELPER_FMAS(HELPER(fma4sd),  ZMM_D, float64_muladd)
 #endif
 
 #if SHIFT >= 1
-SSE_HELPER_FMAP(helper_fma4ps,  ZMM_S, 2 << SHIFT, float32_muladd)
-SSE_HELPER_FMAP(helper_fma4pd,  ZMM_D, 1 << SHIFT, float64_muladd)
+SSE_HELPER_FMAP(HELPER(fma4ps),  ZMM_S, 2 << SHIFT, float32_muladd)
+SSE_HELPER_FMAP(HELPER(fma4pd),  ZMM_D, 1 << SHIFT, float64_muladd)
 #endif
 
 #if SHIFT == 1
@@ -2562,12 +2563,12 @@ SSE_HELPER_FMAP(helper_fma4pd,  ZMM_D, 1 << SHIFT, float64_muladd)
 #define SHA1_F1(b, c, d) ((b) ^ (c) ^ (d))
 #define SHA1_F2(b, c, d) (((b) & (c)) ^ ((b) & (d)) ^ ((c) & (d)))
 
-SSE_HELPER_SHA1RNDS4(helper_sha1rnds4_f0, SHA1_F0, 0x5A827999)
-SSE_HELPER_SHA1RNDS4(helper_sha1rnds4_f1, SHA1_F1, 0x6ED9EBA1)
-SSE_HELPER_SHA1RNDS4(helper_sha1rnds4_f2, SHA1_F2, 0x8F1BBCDC)
-SSE_HELPER_SHA1RNDS4(helper_sha1rnds4_f3, SHA1_F1, 0xCA62C1D6)
+SSE_HELPER_SHA1RNDS4(HELPER(sha1rnds4_f0), SHA1_F0, 0x5A827999)
+SSE_HELPER_SHA1RNDS4(HELPER(sha1rnds4_f1), SHA1_F1, 0x6ED9EBA1)
+SSE_HELPER_SHA1RNDS4(HELPER(sha1rnds4_f2), SHA1_F2, 0x8F1BBCDC)
+SSE_HELPER_SHA1RNDS4(HELPER(sha1rnds4_f3), SHA1_F1, 0xCA62C1D6)
 
-void helper_sha1nexte(Reg *d, Reg *a, Reg *b)
+void HELPER(sha1nexte)(Reg *d, Reg *a, Reg *b)
 {
     d->L(3) = b->L(3) + rol32(a->L(3), 30);
     d->L(2) = b->L(2);
@@ -2575,7 +2576,7 @@ void helper_sha1nexte(Reg *d, Reg *a, Reg *b)
     d->L(0) = b->L(0);
 }
 
-void helper_sha1msg1(Reg *d, Reg *a, Reg *b)
+void HELPER(sha1msg1)(Reg *d, Reg *a, Reg *b)
 {
     /* These could be overwritten by the first two assignments, save them.  */
     uint32_t b3 = b->L(3);
@@ -2587,7 +2588,7 @@ void helper_sha1msg1(Reg *d, Reg *a, Reg *b)
     d->L(0) = a->L(0) ^ b2;
 }
 
-void helper_sha1msg2(Reg *d, Reg *a, Reg *b)
+void HELPER(sha1msg2)(Reg *d, Reg *a, Reg *b)
 {
     d->L(3) = rol32(a->L(3) ^ b->L(2), 1);
     d->L(2) = rol32(a->L(2) ^ b->L(1), 1);
@@ -2603,7 +2604,7 @@ void helper_sha1msg2(Reg *d, Reg *a, Reg *b)
 #define SHA256_MSGS0(w) (ror32((w), 7) ^ ror32((w), 18) ^ ((w) >> 3))
 #define SHA256_MSGS1(w) (ror32((w), 17) ^ ror32((w), 19) ^ ((w) >> 10))
 
-void helper_sha256rnds2(Reg *d, Reg *a, Reg *b, uint32_t wk0, uint32_t wk1)
+void HELPER(sha256rnds2)(Reg *d, Reg *a, Reg *b, uint32_t wk0, uint32_t wk1)
 {
     uint32_t t, AA, EE;
 
@@ -2637,7 +2638,7 @@ void helper_sha256rnds2(Reg *d, Reg *a, Reg *b, uint32_t wk0, uint32_t wk1)
     d->L(1) = EE;
 }
 
-void helper_sha256msg1(Reg *d, Reg *a, Reg *b)
+void HELPER(sha256msg1)(Reg *d, Reg *a, Reg *b)
 {
     /* b->L(0) could be overwritten by the first assignment, save it.  */
     uint32_t b0 = b->L(0);
@@ -2648,7 +2649,7 @@ void helper_sha256msg1(Reg *d, Reg *a, Reg *b)
     d->L(3) = a->L(3) + SHA256_MSGS0(b0);
 }
 
-void helper_sha256msg2(Reg *d, Reg *a, Reg *b)
+void HELPER(sha256msg2)(Reg *d, Reg *a, Reg *b)
 {
     /* Earlier assignments cannot overwrite any of the two operands.  */
     d->L(0) = a->L(0) + SHA256_MSGS1(b->L(2));
target/i386/tcg/bpt_helper.c +3 -3
index bc34ac27fea..573f74bcb45 100644
@@ -22,7 +22,7 @@
 #include "exec/helper-proto.h"
 #include "helper-tcg.h"
 
-G_NORETURN void helper_single_step(CPUX86State *env)
+G_NORETURN void HELPER(single_step)(CPUX86State *env)
 {
 #ifndef CONFIG_USER_ONLY
     check_hw_breakpoints(env, true);
@@ -31,9 +31,9 @@ G_NORETURN void helper_single_step(CPUX86State *env)
     raise_exception(env, EXCP01_DB);
 }
 
-void helper_rechecking_single_step(CPUX86State *env)
+void HELPER(rechecking_single_step)(CPUX86State *env)
 {
     if ((env->eflags & TF_MASK) != 0) {
-        helper_single_step(env);
+        HELPER(single_step)(env);
     }
 }
target/i386/tcg/cc_helper.c +7 -7
index b868ef2949f..d9fcd2d9203 100644
@@ -60,7 +60,7 @@ static target_ulong compute_all_adcox(target_ulong dst, target_ulong src1,
     return (src1 & ~(CC_C | CC_O)) | (dst * CC_C) | (src2 * CC_O);
 }
 
-target_ulong helper_cc_compute_nz(target_ulong dst, target_ulong src1,
+target_ulong HELPER(cc_compute_nz)(target_ulong dst, target_ulong src1,
                                   int op)
 {
     if (CC_OP_HAS_EFLAGS(op)) {
@@ -86,7 +86,7 @@ static inline uint32_t compute_aco_mul(target_long src1)
     return cf + af + of;
 }
 
-target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,
+target_ulong HELPER(cc_compute_all)(target_ulong dst, target_ulong src1,
                                    target_ulong src2, int op)
 {
     uint32_t flags = 0;
@@ -300,10 +300,10 @@ psz_q:
 
 uint32_t cpu_cc_compute_all(CPUX86State *env)
 {
-    return helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, CC_OP);
+    return HELPER(cc_compute_all)(CC_DST, CC_SRC, CC_SRC2, CC_OP);
 }
 
-target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1,
+target_ulong HELPER(cc_compute_c)(target_ulong dst, target_ulong src1,
                                  target_ulong src2, int op)
 {
     switch (op) {
@@ -418,13 +418,13 @@ target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1,
     }
 }
 
-void helper_write_eflags(CPUX86State *env, target_ulong t0,
+void HELPER(write_eflags)(CPUX86State *env, target_ulong t0,
                          uint32_t update_mask)
 {
     cpu_load_eflags(env, t0, update_mask);
 }
 
-target_ulong helper_read_eflags(CPUX86State *env)
+target_ulong HELPER(read_eflags)(CPUX86State *env)
 {
     uint32_t eflags;
 
@@ -436,7 +436,7 @@ target_ulong helper_read_eflags(CPUX86State *env)
     return eflags;
 }
 
-void helper_clts(CPUX86State *env)
+void HELPER(clts)(CPUX86State *env)
 {
     env->cr[0] &= ~CR0_TS_MASK;
     env->hflags &= ~HF_TS_MASK;
target/i386/tcg/excp_helper.c +4 -4
index f1b9b188ecd..1df380d53a9 100644
@@ -26,18 +26,18 @@
 #include "helper-tcg.h"
 #include "qemu/plugin.h"
 
-G_NORETURN void helper_raise_interrupt(CPUX86State *env, int intno,
+G_NORETURN void HELPER(raise_interrupt)(CPUX86State *env, int intno,
                                           int next_eip_addend)
 {
     raise_interrupt(env, intno, next_eip_addend);
 }
 
-G_NORETURN void helper_raise_exception(CPUX86State *env, int exception_index)
+G_NORETURN void HELPER(raise_exception)(CPUX86State *env, int exception_index)
 {
     raise_exception(env, exception_index);
 }
 
-G_NORETURN void helper_raise_gpf(CPUX86State *env)
+G_NORETURN void HELPER(raise_gpf)(CPUX86State *env)
 {
     raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC());
 }
@@ -151,7 +151,7 @@ G_NORETURN void raise_exception_ra(CPUX86State *env, int exception_index,
     raise_interrupt2(env, exception_index, 0, 0, 0, retaddr);
 }
 
-G_NORETURN void helper_icebp(CPUX86State *env)
+G_NORETURN void HELPER(icebp)(CPUX86State *env)
 {
     CPUState *cs = env_cpu(env);
 
target/i386/tcg/fpu_helper.c +91 -91

686 lines not on this page · raw message

target/i386/tcg/int_helper.c +17 -17
index 46741d9f68a..772e6adcc86 100644
@@ -30,7 +30,7 @@
 
 /* division, flags are undefined */
 
-void helper_divb_AL(CPUX86State *env, target_ulong t0)
+void HELPER(divb_AL)(CPUX86State *env, target_ulong t0)
 {
     unsigned int num, den, q, r;
 
@@ -48,7 +48,7 @@ void helper_divb_AL(CPUX86State *env, target_ulong t0)
     env->regs[R_EAX] = (env->regs[R_EAX] & ~0xffff) | (r << 8) | q;
 }
 
-void helper_idivb_AL(CPUX86State *env, target_ulong t0)
+void HELPER(idivb_AL)(CPUX86State *env, target_ulong t0)
 {
     int num, den, q, r;
 
@@ -66,7 +66,7 @@ void helper_idivb_AL(CPUX86State *env, target_ulong t0)
     env->regs[R_EAX] = (env->regs[R_EAX] & ~0xffff) | (r << 8) | q;
 }
 
-void helper_divw_AX(CPUX86State *env, target_ulong t0)
+void HELPER(divw_AX)(CPUX86State *env, target_ulong t0)
 {
     unsigned int num, den, q, r;
 
@@ -85,7 +85,7 @@ void helper_divw_AX(CPUX86State *env, target_ulong t0)
     env->regs[R_EDX] = (env->regs[R_EDX] & ~0xffff) | r;
 }
 
-void helper_idivw_AX(CPUX86State *env, target_ulong t0)
+void HELPER(idivw_AX)(CPUX86State *env, target_ulong t0)
 {
     int num, den, q, r;
 
@@ -104,7 +104,7 @@ void helper_idivw_AX(CPUX86State *env, target_ulong t0)
     env->regs[R_EDX] = (env->regs[R_EDX] & ~0xffff) | r;
 }
 
-void helper_divl_EAX(CPUX86State *env, target_ulong t0)
+void HELPER(divl_EAX)(CPUX86State *env, target_ulong t0)
 {
     unsigned int den, r;
     uint64_t num, q;
@@ -123,7 +123,7 @@ void helper_divl_EAX(CPUX86State *env, target_ulong t0)
     env->regs[R_EDX] = (uint32_t)r;
 }
 
-void helper_idivl_EAX(CPUX86State *env, target_ulong t0)
+void HELPER(idivl_EAX)(CPUX86State *env, target_ulong t0)
 {
     int den, r;
     int64_t num, q;
@@ -144,7 +144,7 @@ void helper_idivl_EAX(CPUX86State *env, target_ulong t0)
 
 /* bcd */
 
-target_ulong helper_aam(target_ulong al, target_ulong base)
+target_ulong HELPER(aam)(target_ulong al, target_ulong base)
 {
     int ah;
 
@@ -154,7 +154,7 @@ target_ulong helper_aam(target_ulong al, target_ulong base)
     return al | (ah << 8);
 }
 
-target_ulong helper_aad(target_ulong ax, target_ulong base)
+target_ulong HELPER(aad)(target_ulong ax, target_ulong base)
 {
     int al, ah;
 
@@ -164,7 +164,7 @@ target_ulong helper_aad(target_ulong ax, target_ulong base)
     return al;
 }
 
-void helper_aaa(CPUX86State *env)
+void HELPER(aaa)(CPUX86State *env)
 {
     int icarry;
     int al, ah, af;
@@ -189,7 +189,7 @@ void helper_aaa(CPUX86State *env)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_aas(CPUX86State *env)
+void HELPER(aas)(CPUX86State *env)
 {
     int icarry;
     int al, ah, af;
@@ -214,7 +214,7 @@ void helper_aas(CPUX86State *env)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_daa(CPUX86State *env)
+void HELPER(daa)(CPUX86State *env)
 {
     int old_al, al, af, cf;
     int eflags;
@@ -242,7 +242,7 @@ void helper_daa(CPUX86State *env)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_das(CPUX86State *env)
+void HELPER(das)(CPUX86State *env)
 {
     int al, al1, af, cf;
     int eflags;
@@ -364,7 +364,7 @@ static int idiv64(uint64_t *plow, uint64_t *phigh, int64_t b)
     return 0;
 }
 
-void helper_divq_EAX(CPUX86State *env, target_ulong t0)
+void HELPER(divq_EAX)(CPUX86State *env, target_ulong t0)
 {
     uint64_t r0, r1;
 
@@ -380,7 +380,7 @@ void helper_divq_EAX(CPUX86State *env, target_ulong t0)
     env->regs[R_EDX] = r1;
 }
 
-void helper_idivq_EAX(CPUX86State *env, target_ulong t0)
+void HELPER(idivq_EAX)(CPUX86State *env, target_ulong t0)
 {
     uint64_t r0, r1;
 
@@ -405,7 +405,7 @@ void helper_idivq_EAX(CPUX86State *env, target_ulong t0)
 # define clztl  clz64
 #endif
 
-target_ulong helper_pdep(target_ulong src, target_ulong mask)
+target_ulong HELPER(pdep)(target_ulong src, target_ulong mask)
 {
     target_ulong dest = 0;
     int i, o;
@@ -418,7 +418,7 @@ target_ulong helper_pdep(target_ulong src, target_ulong mask)
     return dest;
 }
 
-target_ulong helper_pext(target_ulong src, target_ulong mask)
+target_ulong HELPER(pext)(target_ulong src, target_ulong mask)
 {
     target_ulong dest = 0;
     int i, o;
@@ -434,7 +434,7 @@ target_ulong helper_pext(target_ulong src, target_ulong mask)
 /* Test that BIT is enabled in CR4.  If not, raise an illegal opcode
    exception.  This reduces the requirements for rare CR4 bits being
    mapped into HFLAGS.  */
-void helper_cr4_testbit(CPUX86State *env, uint32_t bit)
+void HELPER(cr4_testbit)(CPUX86State *env, uint32_t bit)
 {
     if (unlikely((env->cr[4] & bit) == 0)) {
         raise_exception_ra(env, EXCP06_ILLOP, GETPC());
target/i386/tcg/mem_helper.c +2 -2
index c15a32d60ad..1ed75a34920 100644
@@ -26,7 +26,7 @@
 #include "tcg/tcg.h"
 #include "helper-tcg.h"
 
-void helper_boundw(CPUX86State *env, target_ulong a0, int v)
+void HELPER(boundw)(CPUX86State *env, target_ulong a0, int v)
 {
     int low, high;
 
@@ -41,7 +41,7 @@ void helper_boundw(CPUX86State *env, target_ulong a0, int v)
     }
 }
 
-void helper_boundl(CPUX86State *env, target_ulong a0, int v)
+void HELPER(boundl)(CPUX86State *env, target_ulong a0, int v)
 {
     int low, high;
 
target/i386/tcg/misc_helper.c +8 -8
index f7342871ded..7c1f15953ac 100644
@@ -38,7 +38,7 @@ void cpu_load_eflags(CPUX86State *env, int eflags, int update_mask)
         (eflags & update_mask) | 0x2;
 }
 
-void helper_into(CPUX86State *env, int next_eip_addend)
+void HELPER(into)(CPUX86State *env, int next_eip_addend)
 {
     int eflags;
 
@@ -48,7 +48,7 @@ void helper_into(CPUX86State *env, int next_eip_addend)
     }
 }
 
-void helper_cpuid(CPUX86State *env)
+void HELPER(cpuid)(CPUX86State *env)
 {
     uint32_t eax, ebx, ecx, edx;
 
@@ -62,7 +62,7 @@ void helper_cpuid(CPUX86State *env)
     env->regs[R_EDX] = edx;
 }
 
-void helper_rdtsc(CPUX86State *env)
+void HELPER(rdtsc)(CPUX86State *env)
 {
     uint64_t val;
 
@@ -76,7 +76,7 @@ void helper_rdtsc(CPUX86State *env)
     env->regs[R_EDX] = (uint32_t)(val >> 32);
 }
 
-G_NORETURN void helper_rdpmc(CPUX86State *env)
+G_NORETURN void HELPER(rdpmc)(CPUX86State *env)
 {
     if (((env->cr[4] & CR4_PCE_MASK) == 0 ) &&
         ((env->hflags & HF_CPL_MASK) != 0)) {
@@ -89,20 +89,20 @@ G_NORETURN void helper_rdpmc(CPUX86State *env)
     raise_exception_err(env, EXCP06_ILLOP, 0);
 }
 
-G_NORETURN void helper_pause(CPUX86State *env)
+G_NORETURN void HELPER(pause)(CPUX86State *env)
 {
     CPUState *cs = env_cpu(env);
 
     /* Do gen_eob() tasks before going back to the main loop.  */
     do_end_instruction(env);
-    helper_rechecking_single_step(env);
+    HELPER(rechecking_single_step)(env);
 
     /* Just let another CPU run.  */
     cs->exception_index = EXCP_INTERRUPT;
     cpu_loop_exit(cs);
 }
 
-uint64_t helper_rdpkru(CPUX86State *env, uint32_t ecx)
+uint64_t HELPER(rdpkru)(CPUX86State *env, uint32_t ecx)
 {
     if ((env->cr[4] & CR4_PKE_MASK) == 0) {
         raise_exception_err_ra(env, EXCP06_ILLOP, 0, GETPC());
@@ -114,7 +114,7 @@ uint64_t helper_rdpkru(CPUX86State *env, uint32_t ecx)
     return env->pkru;
 }
 
-void helper_wrpkru(CPUX86State *env, uint32_t ecx, uint64_t val)
+void HELPER(wrpkru)(CPUX86State *env, uint32_t ecx, uint64_t val)
 {
     CPUState *cs = env_cpu(env);
 
target/i386/tcg/mpx_helper.c +6 -6
index 73d33bf5e4a..bbe2c824be2 100644
@@ -25,7 +25,7 @@
 #include "helper-tcg.h"
 
 
-void helper_bndck(CPUX86State *env, uint32_t fail)
+void HELPER(bndck)(CPUX86State *env, uint32_t fail)
 {
     if (unlikely(fail)) {
         env->bndcs_regs.sts = 1;
@@ -73,7 +73,7 @@ static uint32_t lookup_bte32(CPUX86State *env, uint32_t base, uintptr_t ra)
     return (extract32(base, 2, 10) << 4) + (bt & ~3);
 }
 
-uint64_t helper_bndldx64(CPUX86State *env, target_ulong base, target_ulong ptr)
+uint64_t HELPER(bndldx64)(CPUX86State *env, target_ulong base, target_ulong ptr)
 {
     uintptr_t ra = GETPC();
     uint64_t bte, lb, ub, pt;
@@ -90,7 +90,7 @@ uint64_t helper_bndldx64(CPUX86State *env, target_ulong base, target_ulong ptr)
     return lb;
 }
 
-uint64_t helper_bndldx32(CPUX86State *env, target_ulong base, target_ulong ptr)
+uint64_t HELPER(bndldx32)(CPUX86State *env, target_ulong base, target_ulong ptr)
 {
     uintptr_t ra = GETPC();
     uint32_t bte, lb, ub, pt;
@@ -106,7 +106,7 @@ uint64_t helper_bndldx32(CPUX86State *env, target_ulong base, target_ulong ptr)
     return ((uint64_t)ub << 32) | lb;
 }
 
-void helper_bndstx64(CPUX86State *env, target_ulong base, target_ulong ptr,
+void HELPER(bndstx64)(CPUX86State *env, target_ulong base, target_ulong ptr,
                      uint64_t lb, uint64_t ub)
 {
     uintptr_t ra = GETPC();
@@ -118,7 +118,7 @@ void helper_bndstx64(CPUX86State *env, target_ulong base, target_ulong ptr,
     cpu_stq_le_data_ra(env, bte + 16, ptr, ra);
 }
 
-void helper_bndstx32(CPUX86State *env, target_ulong base, target_ulong ptr,
+void HELPER(bndstx32)(CPUX86State *env, target_ulong base, target_ulong ptr,
                      uint64_t lb, uint64_t ub)
 {
     uintptr_t ra = GETPC();
@@ -130,7 +130,7 @@ void helper_bndstx32(CPUX86State *env, target_ulong base, target_ulong ptr,
     cpu_stl_le_data_ra(env, bte + 8, ptr, ra);
 }
 
-void helper_bnd_jmp(CPUX86State *env)
+void HELPER(bnd_jmp)(CPUX86State *env)
 {
     if (!(env->hflags2 & HF2_MPX_PR_MASK)) {
         memset(env->bnd_regs, 0, sizeof(env->bnd_regs));
target/i386/tcg/seg_helper.c +16 -16
index d75ee54f9e8..45bffcd7380 100644
@@ -1082,7 +1082,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int is_int,
 }
 #endif /* TARGET_X86_64 */
 
-void helper_sysret(CPUX86State *env, int dflag)
+void HELPER(sysret)(CPUX86State *env, int dflag)
 {
     int cpl, selector;
 
@@ -1288,7 +1288,7 @@ void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw)
     do_interrupt_all(env_archcpu(env), intno, 0, 0, 0, is_hw);
 }
 
-void helper_lldt(CPUX86State *env, int selector)
+void HELPER(lldt)(CPUX86State *env, int selector)
 {
     SegmentCache *dt;
     uint32_t e1, e2;
@@ -1342,7 +1342,7 @@ void helper_lldt(CPUX86State *env, int selector)
     env->ldt.selector = selector;
 }
 
-void helper_ltr(CPUX86State *env, int selector)
+void HELPER(ltr)(CPUX86State *env, int selector)
 {
     SegmentCache *dt;
     uint32_t e1, e2;
@@ -1406,7 +1406,7 @@ void helper_ltr(CPUX86State *env, int selector)
 }
 
 /* only works if protected mode and not VM86. seg_reg must be != R_CS */
-void helper_load_seg(CPUX86State *env, int seg_reg, int selector)
+void HELPER(load_seg)(CPUX86State *env, int seg_reg, int selector)
 {
     uint32_t e1, e2;
     int cpl, dpl, rpl;
@@ -1494,7 +1494,7 @@ void helper_load_seg(CPUX86State *env, int seg_reg, int selector)
 }
 
 /* protected mode jump */
-void helper_ljmp_protected(CPUX86State *env, int new_cs, target_ulong new_eip,
+void HELPER(ljmp_protected)(CPUX86State *env, int new_cs, target_ulong new_eip,
                            target_ulong next_eip)
 {
     int gate_cs, type;
@@ -1635,7 +1635,7 @@ void helper_ljmp_protected(CPUX86State *env, int new_cs, target_ulong new_eip,
 }
 
 /* real mode call */
-void helper_lcall_real(CPUX86State *env, uint32_t new_cs, uint32_t new_eip,
+void HELPER(lcall_real)(CPUX86State *env, uint32_t new_cs, uint32_t new_eip,
                        int shift, uint32_t next_eip)
 {
     StackAccess sa;
@@ -1662,7 +1662,7 @@ void helper_lcall_real(CPUX86State *env, uint32_t new_cs, uint32_t new_eip,
 }
 
 /* protected mode call */
-void helper_lcall_protected(CPUX86State *env, int new_cs, target_ulong new_eip,
+void HELPER(lcall_protected)(CPUX86State *env, int new_cs, target_ulong new_eip,
                             int shift, target_ulong next_eip)
 {
     int new_stack, i;
@@ -1969,7 +1969,7 @@ void helper_lcall_protected(CPUX86State *env, int new_cs, target_ulong new_eip,
 }
 
 /* real and vm86 mode iret */
-void helper_iret_real(CPUX86State *env, int shift)
+void HELPER(iret_real)(CPUX86State *env, int shift)
 {
     uint32_t new_cs, new_eip, new_eflags;
     int eflags_mask;
@@ -2261,7 +2261,7 @@ static inline void helper_ret_protected(CPUX86State *env, int shift,
     env->regs[R_ESP] = new_esp;
 }
 
-void helper_iret_protected(CPUX86State *env, int shift, int next_eip)
+void HELPER(iret_protected)(CPUX86State *env, int shift, int next_eip)
 {
     int tss_selector, type;
     uint32_t e1, e2;
@@ -2293,12 +2293,12 @@ void helper_iret_protected(CPUX86State *env, int shift, int next_eip)
     env->hflags2 &= ~HF2_NMI_MASK;
 }
 
-void helper_lret_protected(CPUX86State *env, int shift, int addend)
+void HELPER(lret_protected)(CPUX86State *env, int shift, int addend)
 {
     helper_ret_protected(env, shift, 0, addend, GETPC());
 }
 
-void helper_sysenter(CPUX86State *env)
+void HELPER(sysenter)(CPUX86State *env)
 {
     if (env->sysenter_cs == 0) {
         raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC());
@@ -2331,7 +2331,7 @@ void helper_sysenter(CPUX86State *env)
     env->eip = env->sysenter_eip;
 }
 
-void helper_sysexit(CPUX86State *env, int dflag)
+void HELPER(sysexit)(CPUX86State *env, int dflag)
 {
     int cpl;
 
@@ -2370,7 +2370,7 @@ void helper_sysexit(CPUX86State *env, int dflag)
     env->eip = env->regs[R_EDX];
 }
 
-target_ulong helper_lsl(CPUX86State *env, target_ulong selector1)
+target_ulong HELPER(lsl)(CPUX86State *env, target_ulong selector1)
 {
     unsigned int limit;
     uint32_t e1, e2, selector;
@@ -2418,7 +2418,7 @@ target_ulong helper_lsl(CPUX86State *env, target_ulong selector1)
     return limit;
 }
 
-target_ulong helper_lar(CPUX86State *env, target_ulong selector1)
+target_ulong HELPER(lar)(CPUX86State *env, target_ulong selector1)
 {
     uint32_t e1, e2, selector;
     int rpl, dpl, cpl, type;
@@ -2467,7 +2467,7 @@ target_ulong helper_lar(CPUX86State *env, target_ulong selector1)
     return e2 & 0x00f0ff00;
 }
 
-void helper_verr(CPUX86State *env, target_ulong selector1)
+void HELPER(verr)(CPUX86State *env, target_ulong selector1)
 {
     uint32_t e1, e2, eflags, selector;
     int rpl, dpl, cpl;
@@ -2505,7 +2505,7 @@ void helper_verr(CPUX86State *env, target_ulong selector1)
     CC_OP = CC_OP_EFLAGS;
 }
 
-void helper_verw(CPUX86State *env, target_ulong selector1)
+void HELPER(verw)(CPUX86State *env, target_ulong selector1)
 {
     uint32_t e1, e2, eflags, selector;
     int rpl, dpl, cpl;
target/i386/tcg/system/bpt_helper.c +3 -3
index 2feea69c8a1..5ea229d3b32 100644
@@ -235,7 +235,7 @@ void breakpoint_handler(CPUState *cs)
     }
 }
 
-target_ulong helper_get_dr(CPUX86State *env, int reg)
+target_ulong HELPER(get_dr)(CPUX86State *env, int reg)
 {
     if (reg >= 4 && reg < 6) {
         if (env->cr[4] & CR4_DE_MASK) {
@@ -254,7 +254,7 @@ target_ulong helper_get_dr(CPUX86State *env, int reg)
     return env->dr[reg];
 }
 
-void helper_set_dr(CPUX86State *env, int reg, target_ulong t0)
+void HELPER(set_dr)(CPUX86State *env, int reg, target_ulong t0)
 {
     if (reg >= 4 && reg < 6) {
         if (env->cr[4] & CR4_DE_MASK) {
@@ -292,7 +292,7 @@ void helper_set_dr(CPUX86State *env, int reg, target_ulong t0)
 }
 
 /* Check if Port I/O is trapped by a breakpoint.  */
-void helper_bpt_io(CPUX86State *env, uint32_t port,
+void HELPER(bpt_io)(CPUX86State *env, uint32_t port,
                    uint32_t size, target_ulong next_eip)
 {
     target_ulong dr7 = env->dr[7];
target/i386/tcg/system/misc_helper.c +16 -16
index 2998b1aae75..a77da599da8 100644
@@ -29,43 +29,43 @@
 #include "tcg/helper-tcg.h"
 #include "hw/i386/apic.h"
 
-void helper_outb(CPUX86State *env, uint32_t port, uint32_t data)
+void HELPER(outb)(CPUX86State *env, uint32_t port, uint32_t data)
 {
     address_space_stb(&address_space_io, port, data,
                       cpu_get_mem_attrs(env), NULL);
 }
 
-target_ulong helper_inb(CPUX86State *env, uint32_t port)
+target_ulong HELPER(inb)(CPUX86State *env, uint32_t port)
 {
     return address_space_ldub(&address_space_io, port,
                               cpu_get_mem_attrs(env), NULL);
 }
 
-void helper_outw(CPUX86State *env, uint32_t port, uint32_t data)
+void HELPER(outw)(CPUX86State *env, uint32_t port, uint32_t data)
 {
     address_space_stw_le(&address_space_io, port, data,
                          cpu_get_mem_attrs(env), NULL);
 }
 
-target_ulong helper_inw(CPUX86State *env, uint32_t port)
+target_ulong HELPER(inw)(CPUX86State *env, uint32_t port)
 {
     return address_space_lduw_le(&address_space_io, port,
                                  cpu_get_mem_attrs(env), NULL);
 }
 
-void helper_outl(CPUX86State *env, uint32_t port, uint32_t data)
+void HELPER(outl)(CPUX86State *env, uint32_t port, uint32_t data)
 {
     address_space_stl_le(&address_space_io, port, data,
                          cpu_get_mem_attrs(env), NULL);
 }
 
-target_ulong helper_inl(CPUX86State *env, uint32_t port)
+target_ulong HELPER(inl)(CPUX86State *env, uint32_t port)
 {
     return address_space_ldl_le(&address_space_io, port,
                                 cpu_get_mem_attrs(env), NULL);
 }
 
-target_ulong helper_read_cr8(CPUX86State *env)
+target_ulong HELPER(read_cr8)(CPUX86State *env)
 {
     if (!(env->hflags2 & HF2_VINTR_MASK)) {
         return cpu_get_apic_tpr(env_archcpu(env)->apic_state);
@@ -74,7 +74,7 @@ target_ulong helper_read_cr8(CPUX86State *env)
     }
 }
 
-void helper_write_crN(CPUX86State *env, int reg, target_ulong t0)
+void HELPER(write_crN)(CPUX86State *env, int reg, target_ulong t0)
 {
     switch (reg) {
     case 0:
@@ -130,7 +130,7 @@ void helper_write_crN(CPUX86State *env, int reg, target_ulong t0)
     }
 }
 
-void helper_wrmsr(CPUX86State *env)
+void HELPER(wrmsr)(CPUX86State *env)
 {
     uint64_t val;
     CPUState *cs = env_cpu(env);
@@ -327,7 +327,7 @@ error:
     raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC());
 }
 
-void helper_rdmsr(CPUX86State *env)
+void HELPER(rdmsr)(CPUX86State *env)
 {
     X86CPU *x86_cpu = env_archcpu(env);
     uint64_t val;
@@ -502,12 +502,12 @@ void helper_rdmsr(CPUX86State *env)
     env->regs[R_EDX] = (uint32_t)(val >> 32);
 }
 
-void helper_flush_page(CPUX86State *env, target_ulong addr)
+void HELPER(flush_page)(CPUX86State *env, target_ulong addr)
 {
     tlb_flush_page(env_cpu(env), addr);
 }
 
-G_NORETURN void helper_hlt(CPUX86State *env)
+G_NORETURN void HELPER(hlt)(CPUX86State *env)
 {
     CPUState *cs = env_cpu(env);
 
@@ -517,7 +517,7 @@ G_NORETURN void helper_hlt(CPUX86State *env)
     cpu_loop_exit(cs);
 }
 
-void helper_monitor(CPUX86State *env, target_ulong ptr)
+void HELPER(monitor)(CPUX86State *env, target_ulong ptr)
 {
     if ((uint32_t)env->regs[R_ECX] != 0) {
         raise_exception_ra(env, EXCP0D_GPF, GETPC());
@@ -526,7 +526,7 @@ void helper_monitor(CPUX86State *env, target_ulong ptr)
     cpu_svm_check_intercept_param(env, SVM_EXIT_MONITOR, 0, GETPC());
 }
 
-G_NORETURN void helper_mwait(CPUX86State *env, int next_eip_addend)
+G_NORETURN void HELPER(mwait)(CPUX86State *env, int next_eip_addend)
 {
     CPUState *cs = env_cpu(env);
 
@@ -538,8 +538,8 @@ G_NORETURN void helper_mwait(CPUX86State *env, int next_eip_addend)
 
     /* XXX: not complete but not completely erroneous */
     if (cs->cpu_index != 0 || CPU_NEXT(cs) != NULL) {
-        helper_pause(env);
+        HELPER(pause)(env);
     } else {
-        helper_hlt(env);
+        HELPER(hlt)(env);
     }
 }
target/i386/tcg/system/seg_helper.c +2 -2
index e24d01000ad..f45906b4899 100644
@@ -27,7 +27,7 @@
 #include "tcg/helper-tcg.h"
 #include "../seg_helper.h"
 
-void helper_syscall(CPUX86State *env, int next_eip_addend)
+void HELPER(syscall)(CPUX86State *env, int next_eip_addend)
 {
     int selector;
 
@@ -230,7 +230,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 }
 
 /* check if Port I/O is allowed in TSS */
-void helper_check_io(CPUX86State *env, uint32_t addr, uint32_t size)
+void HELPER(check_io)(CPUX86State *env, uint32_t addr, uint32_t size)
 {
     uintptr_t retaddr = GETPC();
     uint32_t io_offset, val, mask;
target/i386/tcg/system/smm_helper.c +6 -6
index 4bbe18a86fb..ae705752632 100644
@@ -178,7 +178,7 @@ void do_smm_enter(X86CPU *cpu)
                        env->cr[0] & ~(CR0_PE_MASK | CR0_EM_MASK | CR0_TS_MASK |
                                       CR0_PG_MASK));
     cpu_x86_update_cr4(env, 0);
-    helper_set_dr(env, 7, 0x00000400);
+    HELPER(set_dr)(env, 7, 0x00000400);
 
     cpu_x86_load_seg_cache(env, R_CS, (env->smbase >> 4) & 0xffff, env->smbase,
                            0xffffffff,
@@ -243,8 +243,8 @@ static void rsm_load_regs_64(CPUX86State *env)
     env->eip = x86_ldq_phys(cs, sm_state + 0x7f78);
     cpu_load_eflags(env, x86_ldl_phys(cs, sm_state + 0x7f70),
                     ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK));
-    helper_set_dr(env, 6, x86_ldl_phys(cs, sm_state + 0x7f68));
-    helper_set_dr(env, 7, x86_ldl_phys(cs, sm_state + 0x7f60));
+    HELPER(set_dr)(env, 6, x86_ldl_phys(cs, sm_state + 0x7f68));
+    HELPER(set_dr)(env, 7, x86_ldl_phys(cs, sm_state + 0x7f60));
 
     cpu_x86_update_cr4(env, x86_ldl_phys(cs, sm_state + 0x7f48));
     cpu_x86_update_cr3(env, x86_ldq_phys(cs, sm_state + 0x7f50));
@@ -291,8 +291,8 @@ static void rsm_load_regs_32(CPUX86State *env)
     env->regs[R_EDX] = x86_ldl_phys(cs, sm_state + 0x7fd8);
     env->regs[R_ECX] = x86_ldl_phys(cs, sm_state + 0x7fd4);
     env->regs[R_EAX] = x86_ldl_phys(cs, sm_state + 0x7fd0);
-    helper_set_dr(env, 6, x86_ldl_phys(cs, sm_state + 0x7fcc));
-    helper_set_dr(env, 7, x86_ldl_phys(cs, sm_state + 0x7fc8));
+    HELPER(set_dr)(env, 6, x86_ldl_phys(cs, sm_state + 0x7fcc));
+    HELPER(set_dr)(env, 7, x86_ldl_phys(cs, sm_state + 0x7fc8));
 
     env->tr.selector = x86_ldl_phys(cs, sm_state + 0x7fc4) & 0xffff;
     env->tr.base = x86_ldl_phys(cs, sm_state + 0x7f64);
@@ -332,7 +332,7 @@ static void rsm_load_regs_32(CPUX86State *env)
     }
 }
 
-void helper_rsm(CPUX86State *env)
+void HELPER(rsm)(CPUX86State *env)
 {
     X86CPU *cpu = env_archcpu(env);
 
target/i386/tcg/system/svm_helper.c +8 -8
index 52a234e7fac..9c040422c1f 100644
@@ -153,7 +153,7 @@ static inline bool virtual_gif_set(CPUX86State *env)
     return !virtual_gif_enabled(env) || (env->int_ctl & V_GIF_MASK);
 }
 
-void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)
+void HELPER(vmrun)(CPUX86State *env, int aflag, int next_eip_addend)
 {
     CPUState *cs = env_cpu(env);
     X86CPU *cpu = env_archcpu(env);
@@ -469,13 +469,13 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)
     }
 }
 
-void helper_vmmcall(CPUX86State *env)
+void HELPER(vmmcall)(CPUX86State *env)
 {
     cpu_svm_check_intercept_param(env, SVM_EXIT_VMMCALL, 0, GETPC());
     raise_exception(env, EXCP06_ILLOP);
 }
 
-void helper_vmload(CPUX86State *env, int aflag)
+void HELPER(vmload)(CPUX86State *env, int aflag)
 {
     int mmu_idx = MMU_PHYS_IDX;
     target_ulong addr;
@@ -539,7 +539,7 @@ void helper_vmload(CPUX86State *env, int aflag)
                              mmu_idx, 0);
 }
 
-void helper_vmsave(CPUX86State *env, int aflag)
+void HELPER(vmsave)(CPUX86State *env, int aflag)
 {
     int mmu_idx = MMU_PHYS_IDX;
     target_ulong addr;
@@ -590,7 +590,7 @@ void helper_vmsave(CPUX86State *env, int aflag)
                       env->sysenter_eip, mmu_idx, 0);
 }
 
-void helper_stgi(CPUX86State *env)
+void HELPER(stgi)(CPUX86State *env)
 {
     cpu_svm_check_intercept_param(env, SVM_EXIT_STGI, 0, GETPC());
 
@@ -602,7 +602,7 @@ void helper_stgi(CPUX86State *env)
     }
 }
 
-void helper_clgi(CPUX86State *env)
+void HELPER(clgi)(CPUX86State *env)
 {
     cpu_svm_check_intercept_param(env, SVM_EXIT_CLGI, 0, GETPC());
 
@@ -701,12 +701,12 @@ void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type,
     cpu_vmexit(env, type, param, retaddr);
 }
 
-void helper_svm_check_intercept(CPUX86State *env, uint32_t type)
+void HELPER(svm_check_intercept)(CPUX86State *env, uint32_t type)
 {
     cpu_svm_check_intercept_param(env, type, 0, GETPC());
 }
 
-void helper_svm_check_io(CPUX86State *env, uint32_t port, uint32_t param,
+void HELPER(svm_check_io)(CPUX86State *env, uint32_t port, uint32_t param,
                          uint32_t next_eip_addend)
 {
     CPUState *cs = env_cpu(env);
target/i386/tcg/user/seg_helper.c +2 -2
index 3a4a6d5a745..d085b5709b1 100644
@@ -26,7 +26,7 @@
 #include "tcg/helper-tcg.h"
 #include "tcg/seg_helper.h"
 
-void helper_syscall(CPUX86State *env, int next_eip_addend)
+void HELPER(syscall)(CPUX86State *env, int next_eip_addend)
 {
     CPUState *cs = env_cpu(env);
 
@@ -102,6 +102,6 @@ void cpu_x86_load_seg(CPUX86State *env, X86Seg seg_reg, int selector)
                                DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
                                DESC_A_MASK | (dpl << DESC_DPL_SHIFT));
     } else {
-        helper_load_seg(env, seg_reg, selector);
+        HELPER(load_seg)(env, seg_reg, selector);
     }
 }
Signature · 1 line
2.55.0
#75 lore raw

[PULL 81/83] MAINTAINERS: cover m68k GDB XML files

In reply to Philippe Mathieu-Daudé

From: Marc-André Lureau <[email protected]>

Add entries so changes to these files are routed to the m68k maintainers.

Message-ID: <[email protected]>

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index d9209f043f0..b09c54f9ee0 100644
@@ -302,6 +302,8 @@ M: Laurent Vivier <[email protected]>
 S: Maintained
 F: target/m68k/
 F: disas/m68k.c
+F: gdbstub/gdb-xml/cf*.xml
+F: gdbstub/gdb-xml/m68k*.xml
 F: tests/functional/m68k/meson.build
 F: tests/tcg/m68k/
 
Signature · 1 line
2.55.0
#76 lore raw

[PULL 71/83] target/riscv: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/riscv/tcg/debug.c      |   2 +-
 target/riscv/tcg/fpu_helper.c | 196 +++++++++++++++++-----------------
 target/riscv/tcg/op_helper.c  |  74 ++++++-------
 3 files changed, 136 insertions(+), 136 deletions(-)
target/riscv/tcg/debug.c +1 -1
index aaf2dca17e3..8b58cbd07ab 100644
@@ -789,7 +789,7 @@ bool riscv_itrigger_enabled(CPURISCVState *env)
     return false;
 }
 
-void helper_itrigger_match(CPURISCVState *env)
+void HELPER(itrigger_match)(CPURISCVState *env)
 {
     int count;
     for (int i = 0; i < env->num_triggers; i++) {
target/riscv/tcg/fpu_helper.c +98 -98

722 lines not on this page · raw message

target/riscv/tcg/op_helper.c +37 -37

295 lines not on this page · raw message

Signature · 1 line
2.55.0
#77 lore raw

[PULL 72/83] target/s390x: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/s390x/tcg/mem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/tcg/mem_helper.c +1 -1
index 414e6838c87..baf074240fa 100644
@@ -2488,7 +2488,7 @@ void HELPER(ex)(CPUS390XState *env, uint32_t ilen, uint64_t r1, uint64_t addr)
     } else if (opc == 0x0a) {
         env->int_svc_code = extract64(insn, 48, 8);
         env->int_svc_ilen = ilen;
-        helper_exception(env, EXCP_SVC);
+        HELPER(exception)(env, EXCP_SVC);
         g_assert_not_reached();
     }
 
Signature · 1 line
2.55.0
#78 lore raw

[PULL 76/83] target/hexagon: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert hexagon to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/hexagon/cpu.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
target/hexagon/cpu.c +11 -4
index 8df63e43260..ebd77e0f7dd 100644
@@ -646,7 +646,8 @@ static void find_qemu_subpage(vaddr *addr, hwaddr *phys, uint64_t page_size)
     *phys += offset;
 }
 
-static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+static bool hexagon_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                            TranslateForDebugResult *result)
 {
     CPUHexagonState *env = cpu_env(cs);
     hwaddr phys_addr;
@@ -660,10 +661,16 @@ static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
         vaddr page_offset = addr & (TARGET_PAGE_SIZE - 1);
         find_qemu_subpage(&addr, &phys_addr, page_size);
         phys_addr += hexagon_cpu_mmu_enabled(env) ? page_offset : 0;
-        return phys_addr;
+
+        *result = (TranslateForDebugResult) {
+            .physaddr = phys_addr,
+            .lg_page_size = TARGET_PAGE_BITS,
+            .attrs.debug = 1,
+        };
+        return true;
     }
 
-    return -1;
+    return false;
 }
 
 
@@ -789,7 +796,7 @@ static bool hexagon_tlb_fill(CPUState *cs, vaddr address, int size,
 
 static const struct SysemuCPUOps hexagon_sysemu_ops = {
     .has_work = hexagon_cpu_has_work,
-    .get_phys_addr_debug = hexagon_cpu_get_phys_addr_debug,
+    .translate_for_debug = hexagon_cpu_translate_for_debug,
 };
 
 static bool hexagon_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
Signature · 1 line
2.55.0
#79 lore raw

[PULL 80/83] target/mips: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert mips to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/mips/internal.h        |  3 ++-
 target/mips/cpu.c             |  2 +-
 target/mips/system/physaddr.c | 13 ++++++++++---
 3 files changed, 13 insertions(+), 5 deletions(-)
target/mips/internal.h +2 -1
index 0c9b1335ebb..a302fc0c20b 100644
@@ -118,7 +118,8 @@ enum {
 int get_physical_address(CPUMIPSState *env, hwaddr *physical,
                          int *prot, target_ulong real_address,
                          MMUAccessType access_type, int mmu_idx);
-hwaddr mips_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool mips_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                  TranslateForDebugResult *result);
 
 typedef struct r4k_tlb_t r4k_tlb_t;
 struct r4k_tlb_t {
target/mips/cpu.c +1 -1
index 759a4e93a0a..c5193dbc8e3 100644
@@ -659,7 +659,7 @@ static ObjectClass *mips_cpu_class_by_name(const char *cpu_model)
 
 static const struct SysemuCPUOps mips_sysemu_ops = {
     .has_work = mips_cpu_has_work,
-    .get_phys_addr_debug = mips_cpu_get_phys_addr_debug,
+    .translate_for_debug = mips_cpu_translate_for_debug,
     .legacy_vmsd = &vmstate_mips_cpu,
 };
 #endif
target/mips/system/physaddr.c +10 -3
index 746dbf8aa4e..6f11e70ba80 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/page-protection.h"
+#include "exec/target_page.h"
 #include "../internal.h"
 
 static int is_seg_am_mapped(unsigned int am, bool eu, int mmu_idx)
@@ -227,7 +228,8 @@ int get_physical_address(CPUMIPSState *env, hwaddr *physical,
     return ret;
 }
 
-hwaddr mips_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool mips_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                  TranslateForDebugResult *result)
 {
     CPUMIPSState *env = cpu_env(cs);
     hwaddr phys_addr;
@@ -235,7 +237,12 @@ hwaddr mips_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
     if (get_physical_address(env, &phys_addr, &prot, addr, MMU_DATA_LOAD,
                              mips_env_mmu_index(env)) != 0) {
-        return -1;
+        return false;
     }
-    return phys_addr;
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.55.0
#80 lore raw

[PULL 83/83] MAINTAINERS: cover riscv GDB XML files

In reply to Philippe Mathieu-Daudé

From: Marc-André Lureau <[email protected]>

Add an entry so changes to these files are routed to the RISC-V maintainers.

Message-ID: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index de3cb9dcaf2..010539dd358 100644
@@ -372,6 +372,7 @@ F: configs/targets/riscv*
 F: docs/system/target-riscv.rst
 F: docs/specs/riscv-iommu.rst
 F: target/riscv/
+F: gdbstub/gdb-xml/riscv*.xml
 F: hw/char/riscv_htif.c
 F: hw/riscv/
 F: hw/intc/riscv*
Signature · 1 line
2.55.0
#81 lore raw

[PULL 69/83] target/or1k: define and call helpers using HELPER macro

In reply to Philippe Mathieu-Daudé

From: Pierrick Bouvier <[email protected]>

In a upcoming commit, we'll prefix all helpers and helper_info with target prefix, to disambiguate symbols between targets. As a first step, we need to make sure all usages are using the existing HELPER macro.

Message-ID: <[email protected]>

---
 target/or1k/fpu_helper.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
target/or1k/fpu_helper.c +8 -8
index e680606d4da..3c2aff64e9a 100644
@@ -114,10 +114,10 @@ uint32_t HELPER(dtos)(CPUOpenRISCState *env, uint64_t val)
 }
 
 #define FLOAT_CALC(name)                                                  \
-uint64_t helper_float_ ## name ## _d(CPUOpenRISCState *env,               \
+uint64_t HELPER(float_ ## name ## _d)(CPUOpenRISCState *env,              \
                                      uint64_t fdt0, uint64_t fdt1)        \
 { return float64_ ## name(fdt0, fdt1, &env->fp_status); }                 \
-uint32_t helper_float_ ## name ## _s(CPUOpenRISCState *env,               \
+uint32_t HELPER(float_ ## name ## _s)(CPUOpenRISCState *env,              \
                                      uint32_t fdt0, uint32_t fdt1)        \
 { return float32_ ## name(fdt0, fdt1, &env->fp_status); }
 
@@ -129,7 +129,7 @@ FLOAT_CALC(rem)
 #undef FLOAT_CALC
 
 
-uint64_t helper_float_madd_d(CPUOpenRISCState *env, uint64_t a,
+uint64_t HELPER(float_madd_d)(CPUOpenRISCState *env, uint64_t a,
                              uint64_t b, uint64_t c)
 {
     /* Note that or1ksim doesn't use fused operation.  */
@@ -137,7 +137,7 @@ uint64_t helper_float_madd_d(CPUOpenRISCState *env, uint64_t a,
     return float64_add(a, b, &env->fp_status);
 }
 
-uint32_t helper_float_madd_s(CPUOpenRISCState *env, uint32_t a,
+uint32_t HELPER(float_madd_s)(CPUOpenRISCState *env, uint32_t a,
                              uint32_t b, uint32_t c)
 {
     /* Note that or1ksim doesn't use fused operation.  */
@@ -147,10 +147,10 @@ uint32_t helper_float_madd_s(CPUOpenRISCState *env, uint32_t a,
 
 
 #define FLOAT_CMP(name, impl)                                             \
-uint32_t helper_float_ ## name ## _d(CPUOpenRISCState *env,               \
+uint32_t HELPER(float_ ## name ## _d)(CPUOpenRISCState *env,              \
                                          uint64_t fdt0, uint64_t fdt1)    \
 { return float64_ ## impl(fdt0, fdt1, &env->fp_status); }                 \
-uint32_t helper_float_ ## name ## _s(CPUOpenRISCState *env,               \
+uint32_t HELPER(float_ ## name ## _s)(CPUOpenRISCState *env,              \
                                          uint32_t fdt0, uint32_t fdt1)    \
 { return float32_ ## impl(fdt0, fdt1, &env->fp_status); }
 
@@ -161,13 +161,13 @@ FLOAT_CMP(un, unordered_quiet)
 #undef FLOAT_CMP
 
 #define FLOAT_UCMP(name, expr) \
-uint32_t helper_float_ ## name ## _d(CPUOpenRISCState *env,               \
+uint32_t HELPER(float_ ## name ## _d)(CPUOpenRISCState *env,              \
                                          uint64_t fdt0, uint64_t fdt1)    \
 {                                                                         \
     FloatRelation r = float64_compare_quiet(fdt0, fdt1, &env->fp_status); \
     return expr;                                                          \
 }                                                                         \
-uint32_t helper_float_ ## name ## _s(CPUOpenRISCState *env,               \
+uint32_t HELPER(float_ ## name ## _s)(CPUOpenRISCState *env,              \
                                          uint32_t fdt0, uint32_t fdt1)    \
 {                                                                         \
     FloatRelation r = float32_compare_quiet(fdt0, fdt1, &env->fp_status); \
Signature · 1 line
2.55.0
#82 lore raw

[PULL 82/83] MAINTAINERS: cover x86 GDB XML files

In reply to Philippe Mathieu-Daudé

From: Marc-André Lureau <[email protected]>

Add entries so changes to these files are routed to the X86 maintainers.

Message-ID: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index b09c54f9ee0..de3cb9dcaf2 100644
@@ -149,6 +149,7 @@ F: configs/targets/i386-softmmu.mak
 F: configs/targets/x86_64-softmmu.mak
 F: docs/system/i386/
 F: docs/system/target-i386*
+F: gdbstub/gdb-xml/i386-*.xml
 F: stubs/hmp-cmds-target-i386.c
 F: target/i386/*.[ch]
 F: target/i386/Kconfig
Signature · 1 line
2.55.0
#83 lore raw

[PULL 78/83] target/loongarch: Convert to translate_for_debug

In reply to Philippe Mathieu-Daudé

From: Peter Maydell <[email protected]>

Convert loongarch to providing the translate_for_debug method rather than the deprecated get_phys_addr_debug method.

Message-ID: <[email protected]>

---
 target/loongarch/cpu-mmu.h    |  3 ++-
 target/loongarch/cpu.c        |  2 +-
 target/loongarch/cpu_helper.c | 12 +++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)
target/loongarch/cpu-mmu.h +2 -1
index 54fb732d62d..491eb514d9d 100644
@@ -99,7 +99,8 @@ TLBRet loongarch_ptw(CPULoongArchState *env, MMUContext *context,
                      int access_type, int mmu_idx, int debug);
 void get_dir_base_width(CPULoongArchState *env, uint64_t *dir_base,
                         uint64_t *dir_width, unsigned int level);
-hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool loongarch_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                       TranslateForDebugResult *result);
 uint64_t loongarch_palen_mask(CPULoongArchState *env);
 
 #endif  /* LOONGARCH_CPU_MMU_H */
target/loongarch/cpu.c +1 -1
index 9579f4db2a1..de4af284fba 100644
@@ -880,7 +880,7 @@ static const struct SysemuCPUOps loongarch_sysemu_ops = {
     .write_elf64_note = loongarch_cpu_write_elf64_note,
     .get_dump_info = loongarch_get_dump_info,
     .get_note_size = loongarch_get_note_size,
-    .get_phys_addr_debug = loongarch_cpu_get_phys_addr_debug,
+    .translate_for_debug = loongarch_cpu_translate_for_debug,
 };
 
 static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
target/loongarch/cpu_helper.c +9 -3
index 123cad3d930..270917184a6 100644
@@ -363,7 +363,8 @@ TLBRet get_physical_address(CPULoongArchState *env, MMUContext *context,
     return loongarch_map_address(env, context, access_type, mmu_idx, is_debug);
 }
 
-hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool loongarch_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                       TranslateForDebugResult *result)
 {
     CPULoongArchState *env = cpu_env(cs);
     MMUContext context;
@@ -371,9 +372,14 @@ hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
     context.addr = addr;
     if (get_physical_address(env, &context, MMU_DATA_LOAD,
                              cpu_mmu_index(cs, false), 1) != TLBRET_MATCH) {
-        return -1;
+        return false;
     }
-    return context.physical;
+    *result = (TranslateForDebugResult) {
+        .physaddr = context.physical,
+        .attrs.debug = 1,
+        .lg_page_size = TARGET_PAGE_BITS,
+    };
+    return true;
 }
 
 uint64_t loongarch_palen_mask(CPULoongArchState *env)
Signature · 1 line
2.55.0
#84 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 24 lines · Philippe Mathieu-Daudé

The following changes since commit b6c4b7e86dec12d07f5cac65265b986d38ee9002:

   Merge tag 'pbouvier/pr/tcg_tests-20261022' of https://gitlab.com/p-b-o/qemu into staging (2026-10-23 09:09:11 +0200)

are available in the Git repository at:

   https://github.com/philmd/qemu.git tags/target-misc-20261023

for you to fetch changes up to a0deb11baf6e5818ccd641088d9465e0e0eac9b7:

MAINTAINERS: cover riscv GDB XML files (2026-10-23 17:52:30 +0200)

----------------------------------------------------------------
Misc target patches queue

- Make TCG halt-to-exec transition explicit and remove cpu_exec_halt()
- Various conversions to translate_for_debug()
- Add common CPUClass::exception_name() handler
- multi-target: prefix helpers with target prefix
- Remove target_long_bits() from GDB register reads
- MAINTAINERS updates
----------------------------------------------------------------

Quoted 3 lines

Matt Turner (2):
target/alpha: Record masked exceptions in FPCR for /S insns target/alpha: Determine tininess from the delivered result

I tested and dropped these 2 but posted from the incorrect branch :/ Sent v2 rebased.

#85 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 23 lines · Philippe Mathieu-Daudé

The following changes since commit b6c4b7e86dec12d07f5cac65265b986d38ee9002:

   Merge tag 'pbouvier/pr/tcg_tests-20261022' ofhttps://gitlab.com/p-b-o/qemu into staging (2026-10-23 09:09:11 +0200)

are available in the Git repository at:

   https://github.com/philmd/qemu.git tags/target-misc-20261023

for you to fetch changes up to a0deb11baf6e5818ccd641088d9465e0e0eac9b7:

MAINTAINERS: cover riscv GDB XML files (2026-10-23 17:52:30 +0200)

----------------------------------------------------------------
Misc target patches queue

- Make TCG halt-to-exec transition explicit and remove cpu_exec_halt()
- Various conversions to translate_for_debug()
- Add common CPUClass::exception_name() handler
- multi-target: prefix helpers with target prefix
- Remove target_long_bits() from GDB register reads
- MAINTAINERS updates
----------------------------------------------------------------

Quoted 8 lines

Marc-André Lureau (3):
MAINTAINERS: cover m68k GDB XML files
MAINTAINERS: cover x86 GDB XML files
MAINTAINERS: cover riscv GDB XML files

Matt Turner (2):
target/alpha: Record masked exceptions in FPCR for /S insns target/alpha: Determine tininess from the delivered result

This causes failures in the saved float_conv* test results:

https://gitlab.com/qemu-project/qemu/-/jobs/17436241199#L4986

r~