qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu
@ 2024-05-03 12:34 Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[] Philippe Mathieu-Daudé
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe =?unknown-8bit?q?Mathieu-Daud=C3=A9?=

Since v2:
- Introduce softmmu_specific_ss[]
- Fix broken rebased meson in patch 2

Since v1:
- Dropped patch #1 (use meson subdir_done)

Fix a bug introduced during a refactor in commit bb6cf6f016
("accel/tcg: Factor tcg_cpu_reset_hold() out"), affecting
user emulation. (cpu_reset is called during thread creation,
after cpu_realize).

This issue was noticed by Ilya when running WASM:
https://lore.kernel.org/qemu-devel/20221027141856.w5umjgklawgu7pqv@heavy/

Philippe Mathieu-Daudé (5):
  accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[]
  accel/tcg: Move system emulation files under sysemu/ subdirectory
  accel/tcg: Do not define cpu_exec_reset_hold() as stub
  accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method
  accel/tcg: Always call tcg_flush_jmp_cache() on reset

 accel/tcg/internal-common.h                   |  2 ++
 accel/tcg/{ => sysemu}/tcg-accel-ops-icount.h |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.h  |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-rr.h     |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops.h        |  0
 accel/tcg/cpu-exec.c                          |  6 ++++++
 accel/tcg/{ => sysemu}/icount-common.c        |  0
 accel/tcg/{ => sysemu}/monitor.c              |  4 ++--
 accel/tcg/{ => sysemu}/tcg-accel-ops-icount.c |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.c  |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-rr.c     |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops.c        |  5 ++---
 accel/tcg/translate-all.c                     |  5 -----
 accel/tcg/user-exec-stub.c                    |  4 ----
 accel/tcg/user-exec.c                         |  5 +++++
 accel/tcg/meson.build                         | 17 ++++-------------
 accel/tcg/sysemu/meson.build                  | 11 +++++++++++
 17 files changed, 32 insertions(+), 27 deletions(-)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-icount.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-rr.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops.h (100%)
 rename accel/tcg/{ => sysemu}/icount-common.c (100%)
 rename accel/tcg/{ => sysemu}/monitor.c (99%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-icount.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-rr.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops.c (99%)
 create mode 100644 accel/tcg/sysemu/meson.build

-- 
2.41.0



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

* [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[]
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
@ 2024-05-03 12:34 ` Philippe Mathieu-Daudé
  2024-05-06 15:40   ` Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 2/5] accel/tcg: Move system emulation files under sysemu/ subdirectory Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Currently these files are only used in system emulation,
but could eventually be used by user emulation. Use the
"softmmu_specific_ss" to express they are related to
SoftMMU.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/meson.build | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index aef80de967..84826f043a 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -16,12 +16,13 @@ tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.
 if get_option('plugins')
   tcg_specific_ss.add(files('plugin-gen.c'))
 endif
-specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
 
-specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
+softmmu_specific_ss = ss.source_set()
+softmmu_specific_ss.add(files(
   'cputlb.c',
   'watchpoint.c',
 ))
+tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: softmmu_specific_ss)
 
 system_ss.add(when: ['CONFIG_TCG'], if_true: files(
   'icount-common.c',
@@ -34,3 +35,5 @@ tcg_module_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
   'tcg-accel-ops-icount.c',
   'tcg-accel-ops-rr.c',
 ))
+
+specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
-- 
2.41.0



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

* [PATCH v3 2/5] accel/tcg: Move system emulation files under sysemu/ subdirectory
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[] Philippe Mathieu-Daudé
@ 2024-05-03 12:34 ` Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 3/5] accel/tcg: Do not define cpu_exec_reset_hold() as stub Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Some files are specific to system emulation. Move them under
their own sysemu/ directory. This might help to notice what
is affected (user, system or both) when doing global refactors.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/{ => sysemu}/tcg-accel-ops-icount.h |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.h  |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-rr.h     |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops.h        |  0
 accel/tcg/{ => sysemu}/icount-common.c        |  0
 accel/tcg/{ => sysemu}/monitor.c              |  4 ++--
 accel/tcg/{ => sysemu}/tcg-accel-ops-icount.c |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.c  |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops-rr.c     |  0
 accel/tcg/{ => sysemu}/tcg-accel-ops.c        |  0
 accel/tcg/meson.build                         | 12 ------------
 accel/tcg/sysemu/meson.build                  | 11 +++++++++++
 12 files changed, 13 insertions(+), 14 deletions(-)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-icount.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-rr.h (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops.h (100%)
 rename accel/tcg/{ => sysemu}/icount-common.c (100%)
 rename accel/tcg/{ => sysemu}/monitor.c (99%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-icount.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-mttcg.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops-rr.c (100%)
 rename accel/tcg/{ => sysemu}/tcg-accel-ops.c (100%)
 create mode 100644 accel/tcg/sysemu/meson.build

diff --git a/accel/tcg/tcg-accel-ops-icount.h b/accel/tcg/sysemu/tcg-accel-ops-icount.h
similarity index 100%
rename from accel/tcg/tcg-accel-ops-icount.h
rename to accel/tcg/sysemu/tcg-accel-ops-icount.h
diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/sysemu/tcg-accel-ops-mttcg.h
similarity index 100%
rename from accel/tcg/tcg-accel-ops-mttcg.h
rename to accel/tcg/sysemu/tcg-accel-ops-mttcg.h
diff --git a/accel/tcg/tcg-accel-ops-rr.h b/accel/tcg/sysemu/tcg-accel-ops-rr.h
similarity index 100%
rename from accel/tcg/tcg-accel-ops-rr.h
rename to accel/tcg/sysemu/tcg-accel-ops-rr.h
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/sysemu/tcg-accel-ops.h
similarity index 100%
rename from accel/tcg/tcg-accel-ops.h
rename to accel/tcg/sysemu/tcg-accel-ops.h
diff --git a/accel/tcg/icount-common.c b/accel/tcg/sysemu/icount-common.c
similarity index 100%
rename from accel/tcg/icount-common.c
rename to accel/tcg/sysemu/icount-common.c
diff --git a/accel/tcg/monitor.c b/accel/tcg/sysemu/monitor.c
similarity index 99%
rename from accel/tcg/monitor.c
rename to accel/tcg/sysemu/monitor.c
index 093efe9714..620c18d267 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/sysemu/monitor.c
@@ -17,8 +17,8 @@
 #include "sysemu/cpu-timers.h"
 #include "sysemu/tcg.h"
 #include "tcg/tcg.h"
-#include "internal-common.h"
-#include "tb-context.h"
+#include "../internal-common.h"
+#include "../tb-context.h"
 
 
 static void dump_drift_info(GString *buf)
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/sysemu/tcg-accel-ops-icount.c
similarity index 100%
rename from accel/tcg/tcg-accel-ops-icount.c
rename to accel/tcg/sysemu/tcg-accel-ops-icount.c
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/sysemu/tcg-accel-ops-mttcg.c
similarity index 100%
rename from accel/tcg/tcg-accel-ops-mttcg.c
rename to accel/tcg/sysemu/tcg-accel-ops-mttcg.c
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/sysemu/tcg-accel-ops-rr.c
similarity index 100%
rename from accel/tcg/tcg-accel-ops-rr.c
rename to accel/tcg/sysemu/tcg-accel-ops-rr.c
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/sysemu/tcg-accel-ops.c
similarity index 100%
rename from accel/tcg/tcg-accel-ops.c
rename to accel/tcg/sysemu/tcg-accel-ops.c
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 84826f043a..3539b0b799 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -24,16 +24,4 @@ softmmu_specific_ss.add(files(
 ))
 tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: softmmu_specific_ss)
 
-system_ss.add(when: ['CONFIG_TCG'], if_true: files(
-  'icount-common.c',
-  'monitor.c',
-))
-
-tcg_module_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
-  'tcg-accel-ops.c',
-  'tcg-accel-ops-mttcg.c',
-  'tcg-accel-ops-icount.c',
-  'tcg-accel-ops-rr.c',
-))
-
 specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
diff --git a/accel/tcg/sysemu/meson.build b/accel/tcg/sysemu/meson.build
new file mode 100644
index 0000000000..5a97cabe7b
--- /dev/null
+++ b/accel/tcg/sysemu/meson.build
@@ -0,0 +1,11 @@
+system_ss.add(when: ['CONFIG_TCG'], if_true: files(
+  'icount-common.c',
+  'monitor.c',
+))
+
+tcg_module_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
+  'tcg-accel-ops.c',
+  'tcg-accel-ops-mttcg.c',
+  'tcg-accel-ops-icount.c',
+  'tcg-accel-ops-rr.c',
+))
-- 
2.41.0



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

* [PATCH v3 3/5] accel/tcg: Do not define cpu_exec_reset_hold() as stub
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[] Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 2/5] accel/tcg: Move system emulation files under sysemu/ subdirectory Philippe Mathieu-Daudé
@ 2024-05-03 12:34 ` Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 4/5] accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

In commit 1b5120d74b ("accel: Introduce cpu_exec_reset_hold()")
we defined the user emulation backend cpu_exec_reset_hold() as
a stub. This was a mistake, since common fields are set in
CPU reset, and user emulation needs these fields to be resetted.
Move cpu_exec_reset_hold() back.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/user-exec-stub.c | 4 ----
 accel/tcg/user-exec.c      | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c
index 4fbe2dbdc8..2dc6fd9c4e 100644
--- a/accel/tcg/user-exec-stub.c
+++ b/accel/tcg/user-exec-stub.c
@@ -14,10 +14,6 @@ void qemu_init_vcpu(CPUState *cpu)
 {
 }
 
-void cpu_exec_reset_hold(CPUState *cpu)
-{
-}
-
 /* User mode emulation does not support record/replay yet.  */
 
 bool replay_exception(void)
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 1c621477ad..6a108eb212 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -37,6 +37,10 @@ __thread uintptr_t helper_retaddr;
 
 //#define DEBUG_SIGNAL
 
+void cpu_exec_reset_hold(CPUState *cpu)
+{
+}
+
 /*
  * Adjust the pc to pass to cpu_restore_state; return the memop type.
  */
-- 
2.41.0



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

* [PATCH v3 4/5] accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-05-03 12:34 ` [PATCH v3 3/5] accel/tcg: Do not define cpu_exec_reset_hold() as stub Philippe Mathieu-Daudé
@ 2024-05-03 12:34 ` Philippe Mathieu-Daudé
  2024-05-03 12:34 ` [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Philippe Mathieu-Daudé
  2024-05-03 15:10 ` [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
  5 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé

Introduce a method called by cpu_reset(), common
to both system and user emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/internal-common.h      | 2 ++
 accel/tcg/cpu-exec.c             | 4 ++++
 accel/tcg/sysemu/tcg-accel-ops.c | 3 ++-
 accel/tcg/user-exec.c            | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index edefd0dcb7..b85285e2ff 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -23,4 +23,6 @@ static inline bool cpu_in_serial_context(CPUState *cs)
     return !(cs->tcg_cflags & CF_PARALLEL) || cpu_in_exclusive_context(cs);
 }
 
+void tcg_exec_cpu_reset_hold(CPUState *cpu);
+
 #endif
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 225e5fbd3e..1bf85c324d 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1096,3 +1096,7 @@ void tcg_exec_unrealizefn(CPUState *cpu)
     tlb_destroy(cpu);
     g_free_rcu(cpu->tb_jmp_cache, rcu);
 }
+
+void tcg_exec_cpu_reset_hold(CPUState *cpu)
+{
+}
diff --git a/accel/tcg/sysemu/tcg-accel-ops.c b/accel/tcg/sysemu/tcg-accel-ops.c
index 2c7b0cc09e..82c8368f87 100644
--- a/accel/tcg/sysemu/tcg-accel-ops.c
+++ b/accel/tcg/sysemu/tcg-accel-ops.c
@@ -36,7 +36,7 @@
 #include "exec/hwaddr.h"
 #include "exec/tb-flush.h"
 #include "exec/gdbstub.h"
-
+#include "../internal-common.h"
 #include "hw/core/cpu.h"
 
 #include "tcg-accel-ops.h"
@@ -82,6 +82,7 @@ int tcg_cpu_exec(CPUState *cpu)
 
 static void tcg_cpu_reset_hold(CPUState *cpu)
 {
+    tcg_exec_cpu_reset_hold(cpu);
     tcg_flush_jmp_cache(cpu);
 
     tlb_flush(cpu);
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 6a108eb212..85e92ec8f2 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -39,6 +39,7 @@ __thread uintptr_t helper_retaddr;
 
 void cpu_exec_reset_hold(CPUState *cpu)
 {
+    tcg_exec_cpu_reset_hold(cpu);
 }
 
 /*
-- 
2.41.0



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

* [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2024-05-03 12:34 ` [PATCH v3 4/5] accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method Philippe Mathieu-Daudé
@ 2024-05-03 12:34 ` Philippe Mathieu-Daudé
  2024-05-16 11:17   ` Fiona Ebner
  2024-08-11 17:43   ` Michael Tokarev
  2024-05-03 15:10 ` [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
  5 siblings, 2 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 12:34 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier,
	Philippe Mathieu-Daudé, qemu-stable

In commit bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
we unfortunately restricted the tcg_flush_jmp_cache() to system
emulation. Move it to the common tcg_exec_cpu_reset_hold() handler
so user emulation gets the jmp_cache initialized when threads
are created.

Remove the NULL check in tcg_flush_jmp_cache() from commit 4e4fa6c12d
("accel/tcg: Complete cpu initialization before registration") which
was a band-aid fix for incorrect commit bb6cf6f016.

Cc: qemu-stable@nongnu.org
Fixes: bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/cpu-exec.c             | 2 ++
 accel/tcg/sysemu/tcg-accel-ops.c | 2 --
 accel/tcg/translate-all.c        | 5 -----
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 1bf85c324d..7e04df2902 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -36,6 +36,7 @@
 #include "exec/replay-core.h"
 #include "sysemu/tcg.h"
 #include "exec/helper-proto-common.h"
+#include "exec/tb-flush.h"
 #include "tb-jmp-cache.h"
 #include "tb-hash.h"
 #include "tb-context.h"
@@ -1099,4 +1100,5 @@ void tcg_exec_unrealizefn(CPUState *cpu)
 
 void tcg_exec_cpu_reset_hold(CPUState *cpu)
 {
+    tcg_flush_jmp_cache(cpu);
 }
diff --git a/accel/tcg/sysemu/tcg-accel-ops.c b/accel/tcg/sysemu/tcg-accel-ops.c
index 82c8368f87..13e450c088 100644
--- a/accel/tcg/sysemu/tcg-accel-ops.c
+++ b/accel/tcg/sysemu/tcg-accel-ops.c
@@ -34,7 +34,6 @@
 #include "qemu/timer.h"
 #include "exec/exec-all.h"
 #include "exec/hwaddr.h"
-#include "exec/tb-flush.h"
 #include "exec/gdbstub.h"
 #include "../internal-common.h"
 #include "hw/core/cpu.h"
@@ -83,7 +82,6 @@ int tcg_cpu_exec(CPUState *cpu)
 static void tcg_cpu_reset_hold(CPUState *cpu)
 {
     tcg_exec_cpu_reset_hold(cpu);
-    tcg_flush_jmp_cache(cpu);
 
     tlb_flush(cpu);
 }
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 83cc14fbde..93202fa3c1 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -663,11 +663,6 @@ void tcg_flush_jmp_cache(CPUState *cpu)
 {
     CPUJumpCache *jc = cpu->tb_jmp_cache;
 
-    /* During early initialization, the cache may not yet be allocated. */
-    if (unlikely(jc == NULL)) {
-        return;
-    }
-
     for (int i = 0; i < TB_JMP_CACHE_SIZE; i++) {
         qatomic_set(&jc->array[i].tb, NULL);
     }
-- 
2.41.0



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

* Re: [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu
  2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2024-05-03 12:34 ` [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Philippe Mathieu-Daudé
@ 2024-05-03 15:10 ` Philippe Mathieu-Daudé
  5 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:10 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell, Claudio Fontana
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier

+Claudio & Peter

On 3/5/24 14:34, Philippe Mathieu-Daudé wrote:

> Philippe Mathieu-Daudé (5):
>    accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[]
>    accel/tcg: Move system emulation files under sysemu/ subdirectory
>    accel/tcg: Do not define cpu_exec_reset_hold() as stub
>    accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method

Richard raised this question: Why AccelOpsClass is system-only?
(also related, why "sysemu/cpus.h" is).


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

* Re: [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[]
  2024-05-03 12:34 ` [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[] Philippe Mathieu-Daudé
@ 2024-05-06 15:40   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-06 15:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier

On 3/5/24 14:34, Philippe Mathieu-Daudé wrote:
> Currently these files are only used in system emulation,
> but could eventually be used by user emulation. Use the
> "softmmu_specific_ss" to express they are related to
> SoftMMU.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/meson.build | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
> index aef80de967..84826f043a 100644
> --- a/accel/tcg/meson.build
> +++ b/accel/tcg/meson.build
> @@ -16,12 +16,13 @@ tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.
>   if get_option('plugins')
>     tcg_specific_ss.add(files('plugin-gen.c'))
>   endif
> -specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)
>   
> -specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
> +softmmu_specific_ss = ss.source_set()
> +softmmu_specific_ss.add(files(
>     'cputlb.c',
>     'watchpoint.c',
>   ))
> +tcg_specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: softmmu_specific_ss)

Should be .add_all() here.

>   system_ss.add(when: ['CONFIG_TCG'], if_true: files(
>     'icount-common.c',
> @@ -34,3 +35,5 @@ tcg_module_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
>     'tcg-accel-ops-icount.c',
>     'tcg-accel-ops-rr.c',
>   ))
> +
> +specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_specific_ss)



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

* Re: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-05-03 12:34 ` [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Philippe Mathieu-Daudé
@ 2024-05-16 11:17   ` Fiona Ebner
  2024-08-11 17:43   ` Michael Tokarev
  1 sibling, 0 replies; 13+ messages in thread
From: Fiona Ebner @ 2024-05-16 11:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier, qemu-stable

Hi,

Am 03.05.24 um 14:34 schrieb Philippe Mathieu-Daudé:
> In commit bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
> we unfortunately restricted the tcg_flush_jmp_cache() to system
> emulation. Move it to the common tcg_exec_cpu_reset_hold() handler
> so user emulation gets the jmp_cache initialized when threads
> are created.
> 
> Remove the NULL check in tcg_flush_jmp_cache() from commit 4e4fa6c12d
> ("accel/tcg: Complete cpu initialization before registration") which
> was a band-aid fix for incorrect commit bb6cf6f016.
> 

AFAICT, commit 4e4fa6c12d was already present in v7.2.0, while commit
bb6cf6f016 only later in v8.2.0. So is it really fine to remove the NULL
check?

Best Regards,
Fiona



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

* Re: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-05-03 12:34 ` [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Philippe Mathieu-Daudé
  2024-05-16 11:17   ` Fiona Ebner
@ 2024-08-11 17:43   ` Michael Tokarev
  2024-08-13 15:10     ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 13+ messages in thread
From: Michael Tokarev @ 2024-08-11 17:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier, qemu-stable,
	Fiona Ebner

03.05.2024 15:34, Philippe Mathieu-Daudé wrote:
> In commit bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
> we unfortunately restricted the tcg_flush_jmp_cache() to system
> emulation. Move it to the common tcg_exec_cpu_reset_hold() handler
> so user emulation gets the jmp_cache initialized when threads
> are created.
> 
> Remove the NULL check in tcg_flush_jmp_cache() from commit 4e4fa6c12d
> ("accel/tcg: Complete cpu initialization before registration") which
> was a band-aid fix for incorrect commit bb6cf6f016.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Hi!

Has this change been forgotten, or is it not appropriate anymore?

Thanks,

/mjt

-- 
GPG Key transition (from rsa2048 to rsa4096) since 2024-04-24.
New key: rsa4096/61AD3D98ECDF2C8E  9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
Old key: rsa2048/457CE0A0804465C5  6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
Transition statement: http://www.corpit.ru/mjt/gpg-transition-2024.txt



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

* Re: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-08-11 17:43   ` Michael Tokarev
@ 2024-08-13 15:10     ` Philippe Mathieu-Daudé
  2024-12-20 21:08       ` Michael Tokarev
  0 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-13 15:10 UTC (permalink / raw)
  To: Michael Tokarev, qemu-devel, Pierrick Bouvier
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier, qemu-stable,
	Fiona Ebner

Hi Michael,

On 11/8/24 19:43, Michael Tokarev wrote:
> 03.05.2024 15:34, Philippe Mathieu-Daudé wrote:
>> In commit bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
>> we unfortunately restricted the tcg_flush_jmp_cache() to system
>> emulation. Move it to the common tcg_exec_cpu_reset_hold() handler
>> so user emulation gets the jmp_cache initialized when threads
>> are created.
>>
>> Remove the NULL check in tcg_flush_jmp_cache() from commit 4e4fa6c12d
>> ("accel/tcg: Complete cpu initialization before registration") which
>> was a band-aid fix for incorrect commit bb6cf6f016.
>>
>> Cc: qemu-stable@nongnu.org
>> Fixes: bb6cf6f016 ("accel/tcg: Factor tcg_cpu_reset_hold() out")
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> Hi!
> 
> Has this change been forgotten, or is it not appropriate anymore?

Not forgotten and still need to be fixed, however unfortunately
this exposed a bug in user-mode SYS_exit_group when using plugins
(see qemu_plugin_disable_mem_helpers call in qemu_plugin_user_exit).

Pierrick is working on it, and I'll rebase this series once his
work gets merged. Next release :/

Regards,

Phil.


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

* Re: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-08-13 15:10     ` Philippe Mathieu-Daudé
@ 2024-12-20 21:08       ` Michael Tokarev
  2024-12-20 21:33         ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Tokarev @ 2024-12-20 21:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel, Pierrick Bouvier
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier, qemu-stable,
	Fiona Ebner

13.08.2024 18:10, Philippe Mathieu-Daudé wrote:

>> Has this change been forgotten, or is it not appropriate anymore?
> 
> Not forgotten and still need to be fixed, however unfortunately
> this exposed a bug in user-mode SYS_exit_group when using plugins
> (see qemu_plugin_disable_mem_helpers call in qemu_plugin_user_exit).
> 
> Pierrick is working on it, and I'll rebase this series once his
> work gets merged. Next release :/

Hm.. Do we have an idea *which* next release it will be? ;))

Thanks,

/mjt


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

* Re: [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset
  2024-12-20 21:08       ` Michael Tokarev
@ 2024-12-20 21:33         ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-12-20 21:33 UTC (permalink / raw)
  To: Michael Tokarev, qemu-devel, Pierrick Bouvier
  Cc: Paolo Bonzini, Warner Losh, Richard Henderson, Kyle Evans,
	Ilya Leoshkevich, Riku Voipio, Laurent Vivier, qemu-stable,
	Fiona Ebner

On 20/12/24 22:08, Michael Tokarev wrote:
> 13.08.2024 18:10, Philippe Mathieu-Daudé wrote:
> 
>>> Has this change been forgotten, or is it not appropriate anymore?
>>
>> Not forgotten and still need to be fixed, however unfortunately
>> this exposed a bug in user-mode SYS_exit_group when using plugins
>> (see qemu_plugin_disable_mem_helpers call in qemu_plugin_user_exit).
>>
>> Pierrick is working on it, and I'll rebase this series once his
>> work gets merged. Next release :/
> 
> Hm.. Do we have an idea *which* next release it will be? ;))

Hopefully 10.0, otherwise 10.1.



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

end of thread, other threads:[~2024-12-20 21:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-03 12:34 [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu Philippe Mathieu-Daudé
2024-05-03 12:34 ` [PATCH v3 1/5] accel/tcg: Move SoftMMU specific units to softmmu_specific_ss[] Philippe Mathieu-Daudé
2024-05-06 15:40   ` Philippe Mathieu-Daudé
2024-05-03 12:34 ` [PATCH v3 2/5] accel/tcg: Move system emulation files under sysemu/ subdirectory Philippe Mathieu-Daudé
2024-05-03 12:34 ` [PATCH v3 3/5] accel/tcg: Do not define cpu_exec_reset_hold() as stub Philippe Mathieu-Daudé
2024-05-03 12:34 ` [PATCH v3 4/5] accel/tcg: Introduce common tcg_exec_cpu_reset_hold() method Philippe Mathieu-Daudé
2024-05-03 12:34 ` [PATCH v3 5/5] accel/tcg: Always call tcg_flush_jmp_cache() on reset Philippe Mathieu-Daudé
2024-05-16 11:17   ` Fiona Ebner
2024-08-11 17:43   ` Michael Tokarev
2024-08-13 15:10     ` Philippe Mathieu-Daudé
2024-12-20 21:08       ` Michael Tokarev
2024-12-20 21:33         ` Philippe Mathieu-Daudé
2024-05-03 15:10 ` [PATCH v3 0/5] accel/tcg: Call tcg_flush_jmp_cache() again when creating user-mode cpu 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).