qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/18] accel/tcg: Compile more files once
@ 2025-03-08  7:23 Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 15/18] accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h' Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Richard Henderson, Philippe Mathieu-Daudé

Since v1:
- Patches 1-13,16 unmodified
- Restrict GETPC_ADJ()
- Rename accel/tcg/getpc.h
- Guard GETPC() within CONFIG_TCG

Take care of some easy cases in accel/tcg/.
From here it starts getting harder.  🙂

Philippe Mathieu-Daudé (7):
  exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
  exec: Declare tlb_set_page_full() in 'exec/cputlb.h'
  exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h'
  exec: Declare tlb_set_page() in 'exec/cputlb.h'
  exec: Declare tlb_hit*() in 'exec/cputlb.h'
  exec: Declare tlb_flush*() in 'exec/cputlb.h'
  accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h'

Richard Henderson (11):
  include/exec: Move TARGET_PAGE_{SIZE,MASK,BITS} to target_page.h
  include/exec: Split out exec/cpu-interrupt.h
  accel/tcg: Compile watchpoint.c once
  system: Build watchpoint.c once
  accel/tcg: Build tcg-accel-ops.c once
  accel/tcg: Build tcg-accel-ops-icount.c once
  accel/tcg: Build tcg-accel-ops-rr.c once
  accel/tcg: Build tcg-accel-ops-mttcg.c once
  accel/tcg: Split out getpc.h
  accel/tcg: Build tcg-runtime.c once
  accel/tcg: Build tcg-runtime-gvec.c once

 accel/tcg/internal-common.h          |   2 +
 accel/tcg/tb-internal.h              |  13 +-
 include/accel/tcg/getpc.h            |  24 +++
 include/exec/cpu-all.h               |  97 +---------
 include/exec/cpu-interrupt.h         |  70 +++++++
 include/exec/cputlb.h                | 263 ++++++++++++++++++++++++++-
 include/exec/exec-all.h              | 263 +--------------------------
 include/exec/poison.h                |  17 --
 include/exec/ram_addr.h              |   1 +
 include/exec/target_page.h           |  58 +++++-
 accel/tcg/cputlb.c                   |  23 +++
 accel/tcg/tcg-accel-ops-icount.c     |   2 +-
 accel/tcg/tcg-accel-ops-mttcg.c      |   1 -
 accel/tcg/tcg-accel-ops-rr.c         |   2 +-
 accel/tcg/tcg-accel-ops.c            |   2 +-
 accel/tcg/tcg-runtime-gvec.c         |   1 -
 accel/tcg/tcg-runtime.c              |   8 +-
 accel/tcg/watchpoint.c               |   5 +-
 cpu-target.c                         |   1 +
 hw/intc/armv7m_nvic.c                |   2 +-
 hw/ppc/spapr_nested.c                |   1 +
 hw/sh4/sh7750.c                      |   1 +
 page-target.c                        |  18 --
 page-vary-target.c                   |   2 -
 system/physmem.c                     |   1 +
 system/watchpoint.c                  |   3 +-
 target/alpha/helper.c                |   2 +-
 target/alpha/sys_helper.c            |   2 +-
 target/arm/helper.c                  |   1 +
 target/arm/tcg/tlb-insns.c           |   2 +-
 target/avr/helper.c                  |   2 +-
 target/hppa/mem_helper.c             |   1 +
 target/i386/helper.c                 |   2 +-
 target/i386/machine.c                |   2 +-
 target/i386/tcg/fpu_helper.c         |   2 +-
 target/i386/tcg/misc_helper.c        |   2 +-
 target/i386/tcg/system/excp_helper.c |   2 +-
 target/i386/tcg/system/misc_helper.c |   2 +-
 target/i386/tcg/system/svm_helper.c  |   2 +-
 target/loongarch/tcg/csr_helper.c    |   2 +-
 target/loongarch/tcg/tlb_helper.c    |   1 +
 target/m68k/helper.c                 |   1 +
 target/microblaze/helper.c           |   2 +-
 target/microblaze/mmu.c              |   2 +-
 target/mips/system/cp0.c             |   2 +-
 target/mips/tcg/system/cp0_helper.c  |   2 +-
 target/mips/tcg/system/tlb_helper.c  |   1 +
 target/openrisc/mmu.c                |   2 +-
 target/openrisc/sys_helper.c         |   1 +
 target/ppc/helper_regs.c             |   2 +-
 target/ppc/misc_helper.c             |   1 +
 target/ppc/mmu_helper.c              |   1 +
 target/riscv/cpu_helper.c            |   1 +
 target/riscv/csr.c                   |   1 +
 target/riscv/op_helper.c             |   1 +
 target/riscv/pmp.c                   |   2 +-
 target/rx/cpu.c                      |   2 +-
 target/s390x/gdbstub.c               |   2 +-
 target/s390x/sigp.c                  |   1 +
 target/s390x/tcg/excp_helper.c       |   1 +
 target/s390x/tcg/mem_helper.c        |   1 +
 target/s390x/tcg/misc_helper.c       |   1 +
 target/sh4/helper.c                  |   1 +
 target/sparc/ldst_helper.c           |   1 +
 target/sparc/mmu_helper.c            |   2 +-
 target/tricore/helper.c              |   2 +-
 target/xtensa/helper.c               |   2 +-
 target/xtensa/mmu_helper.c           |   1 +
 accel/tcg/meson.build                |  14 +-
 system/meson.build                   |   2 +-
 70 files changed, 508 insertions(+), 455 deletions(-)
 create mode 100644 include/accel/tcg/getpc.h
 create mode 100644 include/exec/cpu-interrupt.h

-- 
2.47.1



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

* [PATCH v2 15/18] accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h'
  2025-03-08  7:23 [PATCH v2 00/18] accel/tcg: Compile more files once Philippe Mathieu-Daudé
@ 2025-03-08  7:23 ` Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 16/18] accel/tcg: Split out getpc.h Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 17/18] accel/tcg: Build tcg-runtime.c once Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Richard Henderson, Philippe Mathieu-Daudé

GETPC_ADJ() is only used within accel/tcg/, no need to
expose it to all the code base.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/tb-internal.h | 11 +++++++++++
 include/exec/exec-all.h |  9 ---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/accel/tcg/tb-internal.h b/accel/tcg/tb-internal.h
index 62a59a5307e..68aa8d17f41 100644
--- a/accel/tcg/tb-internal.h
+++ b/accel/tcg/tb-internal.h
@@ -13,6 +13,17 @@
 #include "exec/exec-all.h"
 #include "exec/translation-block.h"
 
+/*
+ * The true return address will often point to a host insn that is part of
+ * the next translated guest insn.  Adjust the address backward to point to
+ * the middle of the call insn.  Subtracting one would do the job except for
+ * several compressed mode architectures (arm, mips) which set the low bit
+ * to indicate the compressed mode; subtracting two works around that.  It
+ * is also the case that there are no host isas that contain a call insn
+ * smaller than 4 bytes, so we don't worry about special-casing this.
+ */
+#define GETPC_ADJ   2
+
 #ifdef CONFIG_SOFTMMU
 
 #define CPU_TLB_DYN_MIN_BITS 6
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index a758b7a8438..2ac98e56c41 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -186,15 +186,6 @@ extern __thread uintptr_t tci_tb_ptr;
     ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
 #endif
 
-/* The true return address will often point to a host insn that is part of
-   the next translated guest insn.  Adjust the address backward to point to
-   the middle of the call insn.  Subtracting one would do the job except for
-   several compressed mode architectures (arm, mips) which set the low bit
-   to indicate the compressed mode; subtracting two works around that.  It
-   is also the case that there are no host isas that contain a call insn
-   smaller than 4 bytes, so we don't worry about special-casing this.  */
-#define GETPC_ADJ   2
-
 #if !defined(CONFIG_USER_ONLY)
 
 /**
-- 
2.47.1



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

* [PATCH v2 16/18] accel/tcg: Split out getpc.h
  2025-03-08  7:23 [PATCH v2 00/18] accel/tcg: Compile more files once Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 15/18] accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h' Philippe Mathieu-Daudé
@ 2025-03-08  7:23 ` Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 17/18] accel/tcg: Build tcg-runtime.c once Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Richard Henderson, Philippe Mathieu-Daudé

From: Richard Henderson <richard.henderson@linaro.org>

Split out GETPC to a target-independent header.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/accel/tcg/getpc.h | 24 ++++++++++++++++++++++++
 include/exec/exec-all.h   | 11 ++---------
 accel/tcg/tcg-runtime.c   |  1 +
 3 files changed, 27 insertions(+), 9 deletions(-)
 create mode 100644 include/accel/tcg/getpc.h

diff --git a/include/accel/tcg/getpc.h b/include/accel/tcg/getpc.h
new file mode 100644
index 00000000000..4bb5f7b15cd
--- /dev/null
+++ b/include/accel/tcg/getpc.h
@@ -0,0 +1,24 @@
+/*
+ * Get host pc for helper unwinding.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef ACCEL_TCG_GETPC_H
+#define ACCEL_TCG_GETPC_H
+
+#ifndef CONFIG_TCG
+#error Can only include this header with TCG
+#endif
+
+/* GETPC is the true target of the return instruction that we'll execute.  */
+#if defined(CONFIG_TCG_INTERPRETER)
+extern __thread uintptr_t tci_tb_ptr;
+# define GETPC() tci_tb_ptr
+#else
+# define GETPC() \
+    ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
+#endif
+
+#endif /* HELPER_GETPC_H */
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 2ac98e56c41..ce303de8486 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -29,6 +29,8 @@
 
 #if defined(CONFIG_TCG)
 
+#include "accel/tcg/getpc.h"
+
 /**
  * probe_access:
  * @env: CPUArchState
@@ -177,15 +179,6 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
 void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t last);
 void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
 
-/* GETPC is the true target of the return instruction that we'll execute.  */
-#if defined(CONFIG_TCG_INTERPRETER)
-extern __thread uintptr_t tci_tb_ptr;
-# define GETPC() tci_tb_ptr
-#else
-# define GETPC() \
-    ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
-#endif
-
 #if !defined(CONFIG_USER_ONLY)
 
 /**
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 9fa539ad3d7..3d4651b4012 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -30,6 +30,7 @@
 #include "disas/disas.h"
 #include "exec/log.h"
 #include "tcg/tcg.h"
+#include "accel/tcg/getpc.h"
 
 #define HELPER_H  "accel/tcg/tcg-runtime.h"
 #include "exec/helper-info.c.inc"
-- 
2.47.1



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

* [PATCH v2 17/18] accel/tcg: Build tcg-runtime.c once
  2025-03-08  7:23 [PATCH v2 00/18] accel/tcg: Compile more files once Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 15/18] accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h' Philippe Mathieu-Daudé
  2025-03-08  7:23 ` [PATCH v2 16/18] accel/tcg: Split out getpc.h Philippe Mathieu-Daudé
@ 2025-03-08  7:23 ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-08  7:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Richard Henderson, Philippe Mathieu-Daudé

From: Richard Henderson <richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/tcg-runtime.c | 7 +------
 accel/tcg/meson.build   | 2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 3d4651b4012..fa7ed9739c7 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -23,13 +23,8 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/host-utils.h"
-#include "cpu.h"
+#include "exec/cpu-common.h"
 #include "exec/helper-proto-common.h"
-#include "exec/cpu_ldst.h"
-#include "exec/exec-all.h"
-#include "disas/disas.h"
-#include "exec/log.h"
-#include "tcg/tcg.h"
 #include "accel/tcg/getpc.h"
 
 #define HELPER_H  "accel/tcg/tcg-runtime.h"
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 81fb25da5cc..411fe28deac 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -1,5 +1,6 @@
 common_ss.add(when: 'CONFIG_TCG', if_true: files(
   'cpu-exec-common.c',
+  'tcg-runtime.c',
 ))
 tcg_specific_ss = ss.source_set()
 tcg_specific_ss.add(files(
@@ -7,7 +8,6 @@ tcg_specific_ss.add(files(
   'cpu-exec.c',
   'tb-maint.c',
   'tcg-runtime-gvec.c',
-  'tcg-runtime.c',
   'translate-all.c',
   'translator.c',
 ))
-- 
2.47.1



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

end of thread, other threads:[~2025-03-08  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-08  7:23 [PATCH v2 00/18] accel/tcg: Compile more files once Philippe Mathieu-Daudé
2025-03-08  7:23 ` [PATCH v2 15/18] accel/tcg: Restrict GETPC_ADJ() to 'tb-internal.h' Philippe Mathieu-Daudé
2025-03-08  7:23 ` [PATCH v2 16/18] accel/tcg: Split out getpc.h Philippe Mathieu-Daudé
2025-03-08  7:23 ` [PATCH v2 17/18] accel/tcg: Build tcg-runtime.c once Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).