Skip to contentSkip to conversation

accel/tcg: Finish replacing SOFTMMU -> SYSTEM

PATCH In review Philippe Mathieu-Daudé 4 participants 27 messages Mar 13, 2024 – Mar 15, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover accel/tcg: Finish replacing SOFTMMU -> SYSTEM

Finish the softmmu/system clarification.

Poison CONFIG_SOFTMMU at the end, we can still
check for system mode with !CONFIG_USER_ONLY.

Philippe Mathieu-Daudé (12):
accel/tcg/plugin: Remove CONFIG_SOFTMMU_GATE definition
travis-ci: Rename SOFTMMU -> SYSTEM
gdbstub: Correct invalid mentions of 'softmmu' by 'system' gdbstub/system: Rename 'user_ctx' argument as 'ctx' target/ppc: Rename init_excp_4xx_softmmu() -> init_excp_4xx() tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one plugins/api: Check for USER_ONLY definition instead of SOFTMMU one accel/tcg/tb-maint: Add comments around system emulation accel/tcg/internal: Check for USER_ONLY definition instead of SOFTMMU exec/cpu-defs: Restrict SOFTMMU specific definitions to accel/tcg/
tcg: Remove unused CONFIG_SOFTMMU definition from libtcg_system.fa exec/poison: Poison CONFIG_SOFTMMU again

 accel/tcg/internal-target.h   | 32 +++++++++++++++++++++++++++++---
 accel/tcg/tb-hash.h           |  4 ++--
 gdbstub/internals.h           | 26 +++++++++++++-------------
 include/exec/cpu-defs.h       | 26 --------------------------
 include/exec/poison.h         |  1 +
 accel/tcg/plugin-gen.c        |  6 ------
 accel/tcg/tb-maint.c          |  7 ++++---
 accel/tcg/tcg-all.c           |  2 +-
 gdbstub/system.c              | 10 +++++-----
 plugins/api.c                 | 10 +++++-----
 target/ppc/cpu_init.c         |  4 ++--
 tcg/sparc64/tcg-target.c.inc  |  8 ++++----
 .travis.yml                   |  8 ++++----
 scripts/make-config-poison.sh |  1 -
 tcg/meson.build               |  1 -
 15 files changed, 70 insertions(+), 76 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/12 accel/tcg/plugin: Remove CONFIG_SOFTMMU_GATE definition

The CONFIG_SOFTMMU_GATE definition was never used, remove it.

---
 accel/tcg/plugin-gen.c | 6 ------
 1 file changed, 6 deletions(-)
accel/tcg/plugin-gen.c +0 -6
index 8028786c7b..cd78ef94a1 100644
@@ -57,12 +57,6 @@
 #include "exec/helper-info.c.inc"
 #undef  HELPER_H
 
-#ifdef CONFIG_SOFTMMU
-# define CONFIG_SOFTMMU_GATE 1
-#else
-# define CONFIG_SOFTMMU_GATE 0
-#endif
-
 /*
  * plugin_cb_start TCG op args[]:
  * 0: enum plugin_gen_from
Signature · 1 line
2.41.0
Reviewed-by on v1 1/12
#2 lore raw

Re: [PATCH-for-9.0? 01/12] accel/tcg/plugin: Remove CONFIG_SOFTMMU_GATE definition

Quoted 14 lines · Philippe Mathieu-Daudé

The CONFIG_SOFTMMU_GATE definition was never used, remove it.

---
  accel/tcg/plugin-gen.c | 6 ------
  1 file changed, 6 deletions(-)
accel/tcg/plugin-gen.c +0 -0
index 8028786c7b..cd78ef94a1 100644
@@ -57,12 +57,6 @@
  #include "exec/helper-info.c.inc"
  #undef  HELPER_H

accel/tcg/plugin-gen.c line 62

Quoted 10 lines
accel/tcg/plugin-gen.c +0 -6
 
-#ifdef CONFIG_SOFTMMU
-# define CONFIG_SOFTMMU_GATE 1
-#else
-# define CONFIG_SOFTMMU_GATE 0
-#endif
-
  /*
   * plugin_cb_start TCG op args[]:
   * 0: enum plugin_gen_from
#4 lore raw

PATCH 2/12 travis-ci: Rename SOFTMMU -> SYSTEM

In reply to Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, rename MAIN_SOFTMMU_TARGETS as MAIN_SYSTEM_TARGETS to express 'system emulation targets'.

---
 .travis.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
.travis.yml +4 -4
index 76859d48da..597d151b80 100644
@@ -35,7 +35,7 @@ env:
     - TEST_BUILD_CMD=""
     - TEST_CMD="make check V=1"
     # This is broadly a list of "mainline" system targets which have support across the major distros
-    - MAIN_SOFTMMU_TARGETS="aarch64-softmmu,mips64-softmmu,ppc64-softmmu,riscv64-softmmu,s390x-softmmu,x86_64-softmmu"
+    - MAIN_SYSTEM_TARGETS="aarch64-softmmu,mips64-softmmu,ppc64-softmmu,riscv64-softmmu,s390x-softmmu,x86_64-softmmu"
     - CCACHE_SLOPPINESS="include_file_ctime,include_file_mtime"
     - CCACHE_MAXSIZE=1G
     - G_MESSAGES_DEBUG=error
@@ -114,7 +114,7 @@ jobs:
       env:
         - TEST_CMD="make check check-tcg V=1"
         - CONFIG="--disable-containers --enable-fdt=system
-                  --target-list=${MAIN_SOFTMMU_TARGETS} --cxx=/bin/false"
+                  --target-list=${MAIN_SYSTEM_TARGETS} --cxx=/bin/false"
         - UNRELIABLE=true
 
     - name: "[ppc64] GCC check-tcg"
@@ -185,7 +185,7 @@ jobs:
       env:
         - TEST_CMD="make check check-tcg V=1"
         - CONFIG="--disable-containers --enable-fdt=system
-                  --target-list=${MAIN_SOFTMMU_TARGETS},s390x-linux-user"
+                  --target-list=${MAIN_SYSTEM_TARGETS},s390x-linux-user"
         - UNRELIABLE=true
       script:
         - BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$?
@@ -226,7 +226,7 @@ jobs:
           - genisoimage
       env:
         - CONFIG="--disable-containers --enable-fdt=system --audio-drv-list=sdl
-                  --disable-user --target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
+                  --disable-user --target-list-exclude=${MAIN_SYSTEM_TARGETS}"
 
     - name: "[s390x] GCC (user)"
       arch: s390x
Signature · 1 line
2.41.0
Reviewed-by on v1 2/12
#5 lore raw

Re: [PATCH-for-9.0? 02/12] travis-ci: Rename SOFTMMU -> SYSTEM

Quoted 8 lines · Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, rename MAIN_SOFTMMU_TARGETS as MAIN_SYSTEM_TARGETS to express 'system emulation targets'.

---
  .travis.yml | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by on v1 2/12
#6 lore raw

Re: [PATCH-for-9.0? 02/12] travis-ci: Rename SOFTMMU -> SYSTEM

In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Since we*might* have user emulation with softmmu, rename MAIN_SOFTMMU_TARGETS as MAIN_SYSTEM_TARGETS to express 'system emulation targets'.

---
  .travis.yml | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

r~

#7 lore raw

PATCH 3/12 gdbstub: Correct invalid mentions of 'softmmu' by 'system'

In reply to Philippe Mathieu-Daudé
---
 gdbstub/internals.h | 20 ++++++++++----------
 gdbstub/system.c    |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
gdbstub/internals.h +10 -10
index b472459838..7055138dee 100644
@@ -115,7 +115,7 @@ void gdb_read_byte(uint8_t ch);
 
 /*
  * Packet acknowledgement - we handle this slightly differently
- * between user and softmmu mode, mainly to deal with the differences
+ * between user and system mode, mainly to deal with the differences
  * between the flexible chardev and the direct fd approaches.
  *
  * We currently don't support a negotiated QStartNoAckMode
@@ -125,7 +125,7 @@ void gdb_read_byte(uint8_t ch);
  * gdb_got_immediate_ack() - check ok to continue
  *
  * Returns true to continue, false to re-transmit for user only, the
- * softmmu stub always returns true.
+ * system stub always returns true.
  */
 bool gdb_got_immediate_ack(void);
 /* utility helpers */
@@ -135,12 +135,12 @@ CPUState *gdb_first_attached_cpu(void);
 void gdb_append_thread_id(CPUState *cpu, GString *buf);
 int gdb_get_cpu_index(CPUState *cpu);
 unsigned int gdb_get_max_cpus(void); /* both */
-bool gdb_can_reverse(void); /* softmmu, stub for user */
+bool gdb_can_reverse(void); /* system emulation, stub for user */
 int gdb_target_sigtrap(void); /* user */
 
 void gdb_create_default_process(GDBState *s);
 
-/* signal mapping, common for softmmu, specialised for user-mode */
+/* signal mapping, common for system, specialised for user-mode */
 int gdb_signal_to_target(int sig);
 int gdb_target_signal_to_gdb(int sig);
 
@@ -157,12 +157,12 @@ void gdb_continue(void);
 int gdb_continue_partial(char *newstates);
 
 /*
- * Helpers with separate softmmu and user implementations
+ * Helpers with separate system and user implementations
  */
 void gdb_put_buffer(const uint8_t *buf, int len);
 
 /*
- * Command handlers - either specialised or softmmu or user only
+ * Command handlers - either specialised or system or user only
  */
 void gdb_init_gdbserver_state(void);
 
@@ -187,7 +187,7 @@ typedef union GdbCmdVariant {
 
 #define get_param(p, i)    (&g_array_index(p, GdbCmdVariant, i))
 
-void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */
+void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* system */
 void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */
 void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */
 void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */
@@ -202,7 +202,7 @@ bool gdb_handle_detach_user(uint32_t pid); /* user */
 
 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */
 
-/* softmmu only */
+/* system only */
 void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx);
 void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx);
 
@@ -212,11 +212,11 @@ bool gdb_handled_syscall(void);
 void gdb_disable_syscalls(void);
 void gdb_syscall_reset(void);
 
-/* user/softmmu specific syscall handling */
+/* user/system specific syscall handling */
 void gdb_syscall_handling(const char *syscall_packet);
 
 /*
- * Break/Watch point support - there is an implementation for softmmu
+ * Break/Watch point support - there is an implementation for system
  * and user mode.
  */
 bool gdb_supports_guest_debug(void);
gdbstub/system.c +1 -1
index 83fd452800..a3ce384cd1 100644
@@ -1,5 +1,5 @@
 /*
- * gdb server stub - softmmu specific bits
+ * gdb server stub - system specific bits
  *
  * Debug integration depends on support from the individual
  * accelerators so most of this involves calling the ops helpers.
Signature · 1 line
2.41.0
#9 lore raw

PATCH 4/12 gdbstub/system: Rename 'user_ctx' argument as 'ctx'

In reply to Philippe Mathieu-Daudé
---
 gdbstub/internals.h | 8 ++++----
 gdbstub/system.c    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
gdbstub/internals.h +4 -4
index 7055138dee..e39c4b113c 100644
@@ -187,7 +187,7 @@ typedef union GdbCmdVariant {
 
 #define get_param(p, i)    (&g_array_index(p, GdbCmdVariant, i))
 
-void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* system */
+void gdb_handle_query_rcmd(GArray *params, void *ctx); /* system */
 void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */
 void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */
 void gdb_handle_v_file_open(GArray *params, void *user_ctx); /* user */
@@ -200,11 +200,11 @@ void gdb_handle_query_supported_user(const char *gdb_supported); /* user */
 bool gdb_handle_set_thread_user(uint32_t pid, uint32_t tid); /* user */
 bool gdb_handle_detach_user(uint32_t pid); /* user */
 
-void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */
+void gdb_handle_query_attached(GArray *params, void *ctx); /* both */
 
 /* system only */
-void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx);
-void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx);
+void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *ctx);
+void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *ctx);
 
 /* sycall handling */
 void gdb_handle_file_io(GArray *params, void *user_ctx);
gdbstub/system.c +4 -4
index a3ce384cd1..d235403855 100644
@@ -488,13 +488,13 @@ bool gdb_can_reverse(void)
  */
 
 void gdb_handle_query_qemu_phy_mem_mode(GArray *params,
-                                        void *user_ctx)
+                                        void *ctx)
 {
     g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode);
     gdb_put_strbuf();
 }
 
-void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx)
+void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *ctx)
 {
     if (!params->len) {
         gdb_put_packet("E22");
@@ -509,7 +509,7 @@ void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx)
     gdb_put_packet("OK");
 }
 
-void gdb_handle_query_rcmd(GArray *params, void *user_ctx)
+void gdb_handle_query_rcmd(GArray *params, void *ctx)
 {
     const guint8 zero = 0;
     int len;
@@ -539,7 +539,7 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx)
  * Execution state helpers
  */
 
-void gdb_handle_query_attached(GArray *params, void *user_ctx)
+void gdb_handle_query_attached(GArray *params, void *ctx)
 {
     gdb_put_packet("1");
 }
Signature · 1 line
2.41.0
#11 lore raw

PATCH 5/12 target/ppc: Rename init_excp_4xx_softmmu() -> init_excp_4xx()

In reply to Philippe Mathieu-Daudé

Unify with other init_excp_FOO() in the same file.

---
 target/ppc/cpu_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +2 -2
index 7e65f08147..b208bd91a0 100644
@@ -1642,7 +1642,7 @@ static void register_8xx_sprs(CPUPPCState *env)
 
 /*****************************************************************************/
 /* Exception vectors models                                                  */
-static void init_excp_4xx_softmmu(CPUPPCState *env)
+static void init_excp_4xx(CPUPPCState *env)
 {
 #if !defined(CONFIG_USER_ONLY)
     env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100;
@@ -2120,7 +2120,7 @@ static void init_proc_405(CPUPPCState *env)
     env->id_tlbs = 0;
     env->tlb_type = TLB_EMB;
 #endif
-    init_excp_4xx_softmmu(env);
+    init_excp_4xx(env);
     env->dcache_line_size = 32;
     env->icache_line_size = 32;
     /* Allocate hardware IRQ controller */
Signature · 1 line
2.41.0
Acked-by on v1 5/12
#12 lore raw

Re: [PATCH-for-9.0? 05/12] target/ppc: Rename init_excp_4xx_softmmu() -> init_excp_4xx()

Quoted 3 lines · Philippe Mathieu-Daudé

Unify with other init_excp_FOO() in the same file.

Quoted 26 lines
---
 target/ppc/cpu_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/cpu_init.c +2 -2
index 7e65f08147..b208bd91a0 100644
@@ -1642,7 +1642,7 @@ static void register_8xx_sprs(CPUPPCState *env)
 
 /*****************************************************************************/
 /* Exception vectors models                                                  */
-static void init_excp_4xx_softmmu(CPUPPCState *env)
+static void init_excp_4xx(CPUPPCState *env)
 {
 #if !defined(CONFIG_USER_ONLY)
     env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100;
@@ -2120,7 +2120,7 @@ static void init_proc_405(CPUPPCState *env)
     env->id_tlbs = 0;
     env->tlb_type = TLB_EMB;
 #endif
-    init_excp_4xx_softmmu(env);
+    init_excp_4xx(env);
     env->dcache_line_size = 32;
     env->icache_line_size = 32;
     /* Allocate hardware IRQ controller */
#13 lore raw

PATCH 6/12 tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one

In reply to Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
 tcg/sparc64/tcg-target.c.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tcg/sparc64/tcg-target.c.inc +4 -4
index 176c98740b..56915a913b 100644
@@ -78,7 +78,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
 #define TCG_REG_T2  TCG_REG_G2
 #define TCG_REG_T3  TCG_REG_O7
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
 # define TCG_GUEST_BASE_REG TCG_REG_I5
 #endif
 
@@ -961,7 +961,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
     tcg_out32(s, SAVE | INSN_RD(TCG_REG_O6) | INSN_RS1(TCG_REG_O6) |
               INSN_IMM13(-frame_size));
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
     if (guest_base != 0) {
         tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG,
                          guest_base, true, TCG_REG_T1);
@@ -1075,7 +1075,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
     h->aa.align = MAX(h->aa.align, s_bits);
     a_mask = (1u << h->aa.align) - 1;
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     int mem_index = get_mmuidx(oi);
     int fast_off = tlb_mask_table_ofs(s, mem_index);
     int mask_off = fast_off + offsetof(CPUTLBDescFast, mask);
@@ -1147,7 +1147,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
         tcg_out_bpcc0(s, COND_NE, BPCC_PN | BPCC_ICC, 0);
     }
     h->base = guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0;
-#endif
+#endif /* CONFIG_USER_ONLY */
 
     /* If the guest address must be zero-extended, do in the delay slot.  */
     if (addr_type == TCG_TYPE_I32) {
Signature · 1 line
2.41.0
#14 lore raw

Re: [PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one

Quoted 7 lines · Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
  tcg/sparc64/tcg-target.c.inc | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

This is all really softmmu.

If we ever grow user-only softmmu support, these will have to be runtime tests. But until then the ifdefs are really pointing out softmmu uses.

r~

Quoted 41 lines
tcg/sparc64/tcg-target.c.inc +4 -4
index 176c98740b..56915a913b 100644
@@ -78,7 +78,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
  #define TCG_REG_T2  TCG_REG_G2
  #define TCG_REG_T3  TCG_REG_O7
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
  # define TCG_GUEST_BASE_REG TCG_REG_I5
  #endif
 
@@ -961,7 +961,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
      tcg_out32(s, SAVE | INSN_RD(TCG_REG_O6) | INSN_RS1(TCG_REG_O6) |
                INSN_IMM13(-frame_size));
 
-#ifndef CONFIG_SOFTMMU
+#ifdef CONFIG_USER_ONLY
      if (guest_base != 0) {
          tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG,
                           guest_base, true, TCG_REG_T1);
@@ -1075,7 +1075,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
      h->aa.align = MAX(h->aa.align, s_bits);
      a_mask = (1u << h->aa.align) - 1;
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
      int mem_index = get_mmuidx(oi);
      int fast_off = tlb_mask_table_ofs(s, mem_index);
      int mask_off = fast_off + offsetof(CPUTLBDescFast, mask);
@@ -1147,7 +1147,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
          tcg_out_bpcc0(s, COND_NE, BPCC_PN | BPCC_ICC, 0);
      }
      h->base = guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0;
-#endif
+#endif /* CONFIG_USER_ONLY */
 
      /* If the guest address must be zero-extended, do in the delay slot.  */
      if (addr_type == TCG_TYPE_I32) {
Reviewed-by on v1 6/12
#15 lore raw

Re: [PATCH-for-9.1 06/12] tcg/sparc64: Check for USER_ONLY definition instead of SOFTMMU one

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
  tcg/sparc64/tcg-target.c.inc | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

Having read further, the ultimate goal is worthwhile. It'll be easy to turn these into runtime tests when we get there.

r~

#16 lore raw

PATCH 7/12 plugins/api: Check for USER_ONLY definition instead of SOFTMMU one

In reply to Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
 plugins/api.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
plugins/api.c +5 -5
index 8fa5a600ac..06d3e95da2 100644
@@ -294,14 +294,14 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info)
  * Virtual Memory queries
  */
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
 static __thread struct qemu_plugin_hwaddr hwaddr_info;
 #endif
 
 struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
                                                   uint64_t vaddr)
 {
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     CPUState *cpu = current_cpu;
     unsigned int mmu_idx = get_mmuidx(info);
     enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info);
@@ -323,7 +323,7 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
 
 bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr)
 {
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     return haddr->is_io;
 #else
     return false;
@@ -332,7 +332,7 @@ bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr)
 
 uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
 {
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     if (haddr) {
         return haddr->phys_addr;
     }
@@ -342,7 +342,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
 
 const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h)
 {
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
     if (h && h->is_io) {
         MemoryRegion *mr = h->mr;
         if (!mr->name) {
Signature · 1 line
2.41.0
Reviewed-by on v1 7/12
#17 lore raw

Re: [PATCH-for-9.1 07/12] plugins/api: Check for USER_ONLY definition instead of SOFTMMU one

Quoted 7 lines · Philippe Mathieu-Daudé

Since we*might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
  plugins/api.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

r~

#18 lore raw

PATCH 8/12 accel/tcg/tb-maint: Add comments around system emulation

In reply to Philippe Mathieu-Daudé
---
 accel/tcg/tb-maint.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
accel/tcg/tb-maint.c +4 -3
index da39a43bd8..2fef7db9e1 100644
@@ -147,7 +147,8 @@ static PageForEachNext foreach_tb_next(PageForEachNext tb,
     return NULL;
 }
 
-#else
+#else /* !CONFIG_USER_ONLY */
+
 /*
  * In system mode we want L1_MAP to be based on ram offsets.
  */
@@ -1088,7 +1089,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
     }
     return false;
 }
-#else
+#else /* !CONFIG_USER_ONLY */
 /*
  * @p must be non-NULL.
  * Call with all @pages locked.
@@ -1226,4 +1227,4 @@ void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
     page_collection_unlock(pages);
 }
 
-#endif /* CONFIG_USER_ONLY */
+#endif /* !CONFIG_USER_ONLY */
Signature · 1 line
2.41.0
#19 lore raw

PATCH 9/12 accel/tcg/internal: Check for USER_ONLY definition instead of SOFTMMU

In reply to Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
 accel/tcg/internal-target.h | 6 +++---
 accel/tcg/tb-hash.h         | 4 ++--
 accel/tcg/tcg-all.c         | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
accel/tcg/internal-target.h +3 -3
index 4e36cf858e..b22b29c461 100644
@@ -24,7 +24,7 @@
 #define assert_memory_lock()
 #endif
 
-#if defined(CONFIG_SOFTMMU) && defined(CONFIG_DEBUG_TCG)
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_DEBUG_TCG)
 void assert_no_pages_locked(void);
 #else
 static inline void assert_no_pages_locked(void) { }
@@ -62,12 +62,12 @@ void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
 void tb_unlock_pages(TranslationBlock *);
 #endif
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
 void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
                                    unsigned size,
                                    uintptr_t retaddr);
 G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
-#endif /* CONFIG_SOFTMMU */
+#endif /* !CONFIG_USER_ONLY */
 
 TranslationBlock *tb_gen_code(CPUState *cpu, vaddr pc,
                               uint64_t cs_base, uint32_t flags,
accel/tcg/tb-hash.h +2 -2
index a0c61f25cd..45a484ce82 100644
@@ -25,7 +25,7 @@
 #include "qemu/xxhash.h"
 #include "tb-jmp-cache.h"
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
 
 /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
    addresses on the same page.  The top bits are the same.  This allows
@@ -58,7 +58,7 @@ static inline unsigned int tb_jmp_cache_hash_func(vaddr pc)
     return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1);
 }
 
-#endif /* CONFIG_SOFTMMU */
+#endif /* CONFIG_USER_ONLY */
 
 static inline
 uint32_t tb_hash_func(tb_page_addr_t phys_pc, vaddr pc,
accel/tcg/tcg-all.c +1 -1
index c6619f5b98..929af1f64c 100644
@@ -116,7 +116,7 @@ static int tcg_init_machine(MachineState *ms)
     tb_htable_init();
     tcg_init(s->tb_size * MiB, s->splitwx_enabled, max_cpus);
 
-#if defined(CONFIG_SOFTMMU)
+#if !defined(CONFIG_USER_ONLY)
     /*
      * There's no guest base to take into account, so go ahead and
      * initialize the prologue now.
Signature · 1 line
2.41.0
#20 lore raw

Re: [PATCH-for-9.1 09/12] accel/tcg/internal: Check for USER_ONLY definition instead of SOFTMMU

Quoted 28 lines · Philippe Mathieu-Daudé

Since we *might* have user emulation with softmmu, replace the system emulation check by !user emulation one.

---
  accel/tcg/internal-target.h | 6 +++---
  accel/tcg/tb-hash.h         | 4 ++--
  accel/tcg/tcg-all.c         | 2 +-
  3 files changed, 6 insertions(+), 6 deletions(-)
accel/tcg/internal-target.h +1 -2
index 4e36cf858e..b22b29c461 100644
@@ -24,7 +24,7 @@
  #define assert_memory_lock()
  #endif
 
-#if defined(CONFIG_SOFTMMU) && defined(CONFIG_DEBUG_TCG)
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_DEBUG_TCG)
  void assert_no_pages_locked(void);
  #else
  static inline void assert_no_pages_locked(void) { }
@@ -62,12 +62,12 @@ void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
  void tb_unlock_pages(TranslationBlock *);
  #endif
 
-#ifdef CONFIG_SOFTMMU

accel/tcg/internal-target.h void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t); · line 73

Quoted 10 lines
accel/tcg/internal-target.h +2 -1
+#ifndef CONFIG_USER_ONLY
  void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
                                     unsigned size,
                                     uintptr_t retaddr);
  G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
-#endif /* CONFIG_SOFTMMU */
+#endif /* !CONFIG_USER_ONLY */
 
  TranslationBlock *tb_gen_code(CPUState *cpu, vaddr pc,
                                uint64_t cs_base, uint32_t flags,

Ok.

Quoted 14 lines
accel/tcg/tb-hash.h +1 -1
index a0c61f25cd..45a484ce82 100644
@@ -25,7 +25,7 @@
  #include "qemu/xxhash.h"
  #include "tb-jmp-cache.h"
 
-#ifdef CONFIG_SOFTMMU
+#ifndef CONFIG_USER_ONLY
 
  /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
     addresses on the same page.  The top bits are the same.  This allows

accel/tcg/tb-hash.h static inline unsigned int tb_jmp_cache_hash_func(vaddr pc) · line 64

Quoted 8 lines
accel/tcg/tb-hash.h +1 -1
@@ -58,7 +58,7 @@ static inline unsigned int tb_jmp_cache_hash_func(vaddr pc)
      return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1);
  }
 
-#endif /* CONFIG_SOFTMMU */
+#endif /* CONFIG_USER_ONLY */
 
  static inline
  uint32_t tb_hash_func(tb_page_addr_t phys_pc, vaddr pc,

Not ok, this is really softmmu related. If we have user-only softmmu, then we'll need to take multiple mappings into account, just like this.

Perhaps add a comment so it's easy to see this (and whichever else) have already been audited?

accel/tcg/tcg-all.c static int tcg_init_machine(MachineState *ms) · line 122

Quoted 13 lines
accel/tcg/tcg-all.c +1 -1
index c6619f5b98..929af1f64c 100644
@@ -116,7 +116,7 @@ static int tcg_init_machine(MachineState *ms)
      tb_htable_init();
      tcg_init(s->tb_size * MiB, s->splitwx_enabled, max_cpus);
 
-#if defined(CONFIG_SOFTMMU)
+#if !defined(CONFIG_USER_ONLY)
      /*
       * There's no guest base to take into account, so go ahead and
       * initialize the prologue now.

With system, we *know* softmmu must be used.
With user-only, we will want to wait until after command-line processing.

Ok with comment change to "never a guest base".

r~

#21 lore raw

PATCH 10/12 exec/cpu-defs: Restrict SOFTMMU specific definitions to accel/tcg/

In reply to Philippe Mathieu-Daudé

CPU_TLB_foo definitions are specific to SoftMMU and only used in accel/tcg/.

---
 accel/tcg/internal-target.h | 26 ++++++++++++++++++++++++++
 include/exec/cpu-defs.h     | 26 --------------------------
 2 files changed, 26 insertions(+), 26 deletions(-)
accel/tcg/internal-target.h +26 -0
index b22b29c461..9b5cc9168b 100644
@@ -12,6 +12,32 @@
 #include "exec/exec-all.h"
 #include "exec/translate-all.h"
 
+#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG)
+#define CPU_TLB_DYN_MIN_BITS 6
+#define CPU_TLB_DYN_DEFAULT_BITS 8
+
+# if HOST_LONG_BITS == 32
+/* Make sure we do not require a double-word shift for the TLB load */
+#  define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS)
+# else /* HOST_LONG_BITS == 64 */
+/*
+ * Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) ==
+ * 2**34 == 16G of address space. This is roughly what one would expect a
+ * TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel
+ * Skylake's Level-2 STLB has 16 1G entries.
+ * Also, make sure we do not size the TLB past the guest's address space.
+ */
+#  ifdef TARGET_PAGE_BITS_VARY
+#   define CPU_TLB_DYN_MAX_BITS                                  \
+    MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
+#  else
+#   define CPU_TLB_DYN_MAX_BITS                                  \
+    MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
+#  endif
+# endif
+
+#endif /* CONFIG_SOFTMMU && CONFIG_TCG */
+
 /*
  * Access to the various translations structures need to be serialised
  * via locks for consistency.  In user-mode emulation access to the
include/exec/cpu-defs.h +0 -26
index 3915438b83..955cbefe81 100644
@@ -54,30 +54,4 @@
 
 #include "exec/target_long.h"
 
-#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG)
-#define CPU_TLB_DYN_MIN_BITS 6
-#define CPU_TLB_DYN_DEFAULT_BITS 8
-
-# if HOST_LONG_BITS == 32
-/* Make sure we do not require a double-word shift for the TLB load */
-#  define CPU_TLB_DYN_MAX_BITS (32 - TARGET_PAGE_BITS)
-# else /* HOST_LONG_BITS == 64 */
-/*
- * Assuming TARGET_PAGE_BITS==12, with 2**22 entries we can cover 2**(22+12) ==
- * 2**34 == 16G of address space. This is roughly what one would expect a
- * TLB to cover in a modern (as of 2018) x86_64 CPU. For instance, Intel
- * Skylake's Level-2 STLB has 16 1G entries.
- * Also, make sure we do not size the TLB past the guest's address space.
- */
-#  ifdef TARGET_PAGE_BITS_VARY
-#   define CPU_TLB_DYN_MAX_BITS                                  \
-    MIN(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
-#  else
-#   define CPU_TLB_DYN_MAX_BITS                                  \
-    MIN_CONST(22, TARGET_VIRT_ADDR_SPACE_BITS - TARGET_PAGE_BITS)
-#  endif
-# endif
-
-#endif /* CONFIG_SOFTMMU && CONFIG_TCG */
-
 #endif
Signature · 1 line
2.41.0
Reviewed-by on v1 10/12
#22 lore raw

Re: [PATCH-for-9.1 10/12] exec/cpu-defs: Restrict SOFTMMU specific definitions to accel/tcg/

Quoted 14 lines · Philippe Mathieu-Daudé

CPU_TLB_foo definitions are specific to SoftMMU and only used in accel/tcg/.

---
  accel/tcg/internal-target.h | 26 ++++++++++++++++++++++++++
  include/exec/cpu-defs.h     | 26 --------------------------
  2 files changed, 26 insertions(+), 26 deletions(-)
accel/tcg/internal-target.h +0 -0
index b22b29c461..9b5cc9168b 100644

accel/tcg/internal-target.h line 15

Quoted 4 lines
accel/tcg/internal-target.h +1 -0
@@ -12,6 +12,32 @@
  #include "exec/exec-all.h"
  #include "exec/translate-all.h"
 
+#if defined(CONFIG_SOFTMMU) && defined(CONFIG_TCG)

I see this is moved intact, but drop the CONFIG_TCG ifdef within accel/tcg/. With that change,

r~

#23 lore raw

PATCH 11/12 tcg: Remove unused CONFIG_SOFTMMU definition from libtcg_system.fa

In reply to Philippe Mathieu-Daudé
---
 tcg/meson.build | 1 -
 1 file changed, 1 deletion(-)
tcg/meson.build +0 -1
index 8251589fd4..b5246676c6 100644
@@ -42,7 +42,6 @@ user_ss.add(tcg_user)
 libtcg_system = static_library('tcg_system',
                                 tcg_ss.sources() + genh,
                                 name_suffix: 'fa',
-                                c_args: '-DCONFIG_SOFTMMU',
                                 build_by_default: false)
 
 tcg_system = declare_dependency(link_with: libtcg_system,
Signature · 1 line
2.41.0
Reviewed-by on v1 11/12
#24 lore raw

Re: [PATCH-for-9.1 11/12] tcg: Remove unused CONFIG_SOFTMMU definition from libtcg_system.fa

Quoted 10 lines · Philippe Mathieu-Daudé
---
  tcg/meson.build | 1 -
  1 file changed, 1 deletion(-)
tcg/meson.build +0 -0
index 8251589fd4..b5246676c6 100644

tcg/meson.build user_ss.add(tcg_user) · line 47

Quoted 7 lines
tcg/meson.build +0 -1
@@ -42,7 +42,6 @@ user_ss.add(tcg_user)
  libtcg_system = static_library('tcg_system',
                                  tcg_ss.sources() + genh,
                                  name_suffix: 'fa',
-                                c_args: '-DCONFIG_SOFTMMU',
                                  build_by_default: false)
 
  tcg_system = declare_dependency(link_with: libtcg_system,

r~

#25 lore raw

PATCH 12/12 exec/poison: Poison CONFIG_SOFTMMU again

In reply to Philippe Mathieu-Daudé

Now that the confusion around SOFTMMU vs SYSTEM emulation was clarified, we can restore the CONFIG_SOFTMMU poison pragma.

This reverts commit d31b84041d4353ef310ffde23c87b78c2aa32ead ("exec/poison: Do not poison CONFIG_SOFTMMU").

---
 include/exec/poison.h         | 1 +
 scripts/make-config-poison.sh | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
include/exec/poison.h +1 -0
index 1ea5633eb3..fbec710f6c 100644
@@ -84,6 +84,7 @@
 #pragma GCC poison CONFIG_HVF
 #pragma GCC poison CONFIG_LINUX_USER
 #pragma GCC poison CONFIG_KVM
+#pragma GCC poison CONFIG_SOFTMMU
 #pragma GCC poison CONFIG_WHPX
 #pragma GCC poison CONFIG_XEN
 
scripts/make-config-poison.sh +0 -1
index 2b36907e23..6ef5580f84 100755
@@ -9,7 +9,6 @@ fi
 exec sed -n \
   -e' /CONFIG_TCG/d' \
   -e '/CONFIG_USER_ONLY/d' \
-  -e '/CONFIG_SOFTMMU/d' \
   -e '/^#define / {' \
   -e    's///' \
   -e    's/ .*//' \
Signature · 1 line
2.41.0
Reviewed-by on v1 12/12
#26 lore raw

Re: [PATCH-for-9.1 12/12] exec/poison: Poison CONFIG_SOFTMMU again

Quoted 30 lines · Philippe Mathieu-Daudé

Now that the confusion around SOFTMMU vs SYSTEM emulation was clarified, we can restore the CONFIG_SOFTMMU poison pragma.

This reverts commit d31b84041d4353ef310ffde23c87b78c2aa32ead ("exec/poison: Do not poison CONFIG_SOFTMMU").

---
  include/exec/poison.h         | 1 +
  scripts/make-config-poison.sh | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
include/exec/poison.h +1 -0
index 1ea5633eb3..fbec710f6c 100644
@@ -84,6 +84,7 @@
  #pragma GCC poison CONFIG_HVF
  #pragma GCC poison CONFIG_LINUX_USER
  #pragma GCC poison CONFIG_KVM
+#pragma GCC poison CONFIG_SOFTMMU
  #pragma GCC poison CONFIG_WHPX
  #pragma GCC poison CONFIG_XEN
 
scripts/make-config-poison.sh +0 -0
index 2b36907e23..6ef5580f84 100755

scripts/make-config-poison.sh fi · line 14

Quoted 7 lines
scripts/make-config-poison.sh +0 -1
@@ -9,7 +9,6 @@ fi
  exec sed -n \
    -e' /CONFIG_TCG/d' \
    -e '/CONFIG_USER_ONLY/d' \
-  -e '/CONFIG_SOFTMMU/d' \
    -e '/^#define / {' \
    -e    's///' \
    -e    's/ .*//' \

r~