qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Anton Johansson" <anjo@rev.ng>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 18/24] accel/tcg: Move @cflags_next_tb from CPUState to TCG AccelCPUState
Date: Mon, 29 Apr 2024 00:14:44 +0200	[thread overview]
Message-ID: <20240428221450.26460-19-philmd@linaro.org> (raw)
In-Reply-To: <20240428221450.26460-1-philmd@linaro.org>

@cflags_next_tb is specific to TCG accelerator, move it to
its AccelCPUState.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/vcpu-state.h    |  2 ++
 include/hw/core/cpu.h     |  1 -
 accel/tcg/cpu-exec.c      | 12 ++++++------
 accel/tcg/tb-maint.c      |  4 ++--
 accel/tcg/tcg-accel-ops.c |  1 +
 accel/tcg/translate-all.c |  2 +-
 accel/tcg/watchpoint.c    |  5 +++--
 hw/core/cpu-common.c      |  1 -
 8 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h
index d1f989c625..79e1490631 100644
--- a/accel/tcg/vcpu-state.h
+++ b/accel/tcg/vcpu-state.h
@@ -13,6 +13,8 @@
  * @mem_io_pc: Host Program Counter at which the memory was accessed.
  */
 struct AccelCPUState {
+    uint32_t cflags_next_tb;
+
     sigjmp_buf jmp_env;
 
 #ifdef CONFIG_USER_ONLY
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 4df9bfeba9..a8b4ae25f1 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -469,7 +469,6 @@ struct CPUState {
     bool crash_occurred;
     bool exit_request;
     int exclusive_context_count;
-    uint32_t cflags_next_tb;
     /* updates protected by BQL */
     uint32_t interrupt_request;
     int singlestep_enabled;
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 46ad16f911..55235d3e5e 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -720,7 +720,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
         if (replay_has_exception()
             && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0) {
             /* Execute just one insn to trigger exception pending in the log */
-            cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT)
+            cpu->accel->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT)
                 | CF_NOIRQ | 1;
         }
 #endif
@@ -783,7 +783,7 @@ static inline bool icount_exit_request(CPUState *cpu)
     if (!icount_enabled()) {
         return false;
     }
-    if (cpu->cflags_next_tb != -1 && !(cpu->cflags_next_tb & CF_USE_ICOUNT)) {
+    if (!(cpu->accel->cflags_next_tb == -1 || cpu->accel->cflags_next_tb & CF_USE_ICOUNT)) {
         return false;
     }
     return cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0;
@@ -797,7 +797,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
      * skip checking here. Any pending interrupts will get picked up
      * by the next TB we execute under normal cflags.
      */
-    if (cpu->cflags_next_tb != -1 && cpu->cflags_next_tb & CF_NOIRQ) {
+    if (cpu->accel->cflags_next_tb != -1 && cpu->accel->cflags_next_tb & CF_NOIRQ) {
         return false;
     }
 
@@ -947,7 +947,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
     if (insns_left > 0 && insns_left < tb->icount)  {
         assert(insns_left <= CF_COUNT_MASK);
         assert(cpu->icount_extra == 0);
-        cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left;
+        cpu->accel->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left;
     }
 #endif
 }
@@ -979,11 +979,11 @@ cpu_exec_loop(CPUState *cpu, SyncClocks *sc)
              * have CF_INVALID set, -1 is a convenient invalid value that
              * does not require tcg headers for cpu_common_reset.
              */
-            cflags = cpu->cflags_next_tb;
+            cflags = cpu->accel->cflags_next_tb;
             if (cflags == -1) {
                 cflags = curr_cflags(cpu);
             } else {
-                cpu->cflags_next_tb = -1;
+                cpu->accel->cflags_next_tb = -1;
             }
 
             if (check_for_breakpoints(cpu, pc, &cflags)) {
diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
index 19ae6793f3..2d5faca9fd 100644
--- a/accel/tcg/tb-maint.c
+++ b/accel/tcg/tb-maint.c
@@ -1084,7 +1084,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc)
     if (current_tb_modified) {
         /* Force execution of one insn next time.  */
         CPUState *cpu = current_cpu;
-        cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
+        cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
         return true;
     }
     return false;
@@ -1154,7 +1154,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
     if (current_tb_modified) {
         page_collection_unlock(pages);
         /* Force execution of one insn next time.  */
-        current_cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
+        current_cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu);
         mmap_unlock();
         cpu_loop_exit_noexc(current_cpu);
     }
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index dfa0357558..5429e2d219 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -90,6 +90,7 @@ static void tcg_cpu_reset_hold(CPUState *cpu)
     qatomic_set(&cpu->neg.icount_decr.u32, 0);
     cpu->neg.can_do_io = true;
     cpu->accel->mem_io_pc = 0;
+    cpu->accel->cflags_next_tb = -1;
 }
 
 /* mask must never be zero, except for A20 change call */
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index b67adce20e..3a8199a761 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -631,7 +631,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
      * operations only (which execute after completion) so we don't
      * double instrument the instruction.
      */
-    cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
+    cpu->accel->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
 
     if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
         vaddr pc = cpu->cc->get_pc(cpu);
diff --git a/accel/tcg/watchpoint.c b/accel/tcg/watchpoint.c
index d3aab11458..0a40bfdc85 100644
--- a/accel/tcg/watchpoint.c
+++ b/accel/tcg/watchpoint.c
@@ -26,6 +26,7 @@
 #include "sysemu/replay.h"
 #include "hw/core/tcg-cpu-ops.h"
 #include "hw/core/cpu.h"
+#include "accel/tcg/vcpu-state.h"
 
 /*
  * Return true if this watchpoint address matches the specified
@@ -100,7 +101,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
                  */
                 if (!cpu->neg.can_do_io) {
                     /* Force execution of one insn next time.  */
-                    cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu);
+                    cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu);
                     cpu_loop_exit_restore(cpu, ra);
                 }
                 /*
@@ -132,7 +133,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
                 cpu_loop_exit(cpu);
             } else {
                 /* Force execution of one insn next time.  */
-                cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu);
+                cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu);
                 mmap_unlock();
                 cpu_loop_exit_noexc(cpu);
             }
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 21151f5634..684422991c 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -120,7 +120,6 @@ static void cpu_common_reset_hold(Object *obj, ResetType type)
     cpu->icount_extra = 0;
     cpu->exception_index = -1;
     cpu->crash_occurred = false;
-    cpu->cflags_next_tb = -1;
 
     cpu_exec_reset_hold(cpu);
 }
-- 
2.41.0



  parent reply	other threads:[~2024-04-28 22:17 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-28 22:14 [PATCH 00/24] exec: Rework around CPUState user fields (part 2) Philippe Mathieu-Daudé
2024-04-28 22:14 ` [PATCH 01/24] exec/user: Move 'thunk.h' from 'exec/user' to 'user' Philippe Mathieu-Daudé
2024-04-29  0:49   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 02/24] coverity: Update user emulation regexp Philippe Mathieu-Daudé
2024-04-29  0:52   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 03/24] accel/tcg: Move user definition of cpu_interrupt() to user-exec.c Philippe Mathieu-Daudé
2024-04-29  0:54   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 04/24] accel/tcg: Duplicate cpu_exit() for user / system Philippe Mathieu-Daudé
2024-04-29  0:58   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 05/24] accel/tcg: Extract tcg_cpu_exit() from cpu_exit() Philippe Mathieu-Daudé
2024-04-29  1:02   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 06/24] accel: Introduce AccelOpsClass::exit_vcpu_thread() handler Philippe Mathieu-Daudé
2024-04-29  1:05   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 07/24] accel/tcg: Implement " Philippe Mathieu-Daudé
2024-04-29  1:09   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 08/24] user: Forward declare TaskState type definition Philippe Mathieu-Daudé
2024-04-29  1:13   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 09/24] user: Declare get_task_state() once in 'accel/tcg/vcpu-state.h' Philippe Mathieu-Daudé
2024-04-29  1:19   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 10/24] user: Use get_task_state() helper Philippe Mathieu-Daudé
2024-04-29  1:27   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 11/24] accel/tcg: Allocate per-vCPU accel state in create_vcpu_thread() Philippe Mathieu-Daudé
2024-04-29 14:23   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 12/24] accel/tcg: Move TaskState from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-29 14:31   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 13/24] accel/tcg: Update CPUNegativeOffsetState::can_do_io field documentation Philippe Mathieu-Daudé
2024-04-29 14:33   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 14/24] accel/tcg: Move plugin fields to CPUNegativeOffsetState Philippe Mathieu-Daudé
2024-04-29 14:42   ` Richard Henderson
2024-04-29 20:54     ` Philippe Mathieu-Daudé
2024-04-28 22:14 ` [PATCH 15/24] accel/tcg: Restrict IcountDecr and CPUTLB to TCG Philippe Mathieu-Daudé
2024-04-29 14:03   ` Philippe Mathieu-Daudé
2024-04-29 14:46     ` Richard Henderson
2024-04-29 14:48   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 16/24] accel/tcg: Move @jmp_env from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-29 14:51   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 17/24] accel/tcg: Move @mem_io_pc " Philippe Mathieu-Daudé
2024-04-29 15:02   ` Richard Henderson
2024-04-28 22:14 ` Philippe Mathieu-Daudé [this message]
2024-04-29 15:22   ` [PATCH 18/24] accel/tcg: Move @cflags_next_tb " Richard Henderson
2024-04-28 22:14 ` [PATCH 19/24] accel/tcg: Move @iommu_notifiers " Philippe Mathieu-Daudé
2024-04-29 15:25   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 20/24] accel/tcg: Move @tb_jmp_cache " Philippe Mathieu-Daudé
2024-04-29 19:15   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 21/24] accel/tcg: Remove NULL check in tcg_flush_jmp_cache() Philippe Mathieu-Daudé
2024-04-28 22:14 ` [PATCH 22/24] accel/tcg: Move @tcg_cflags from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-29 19:30   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 23/24] accel/tcg: Restrict icount to system emulation Philippe Mathieu-Daudé
2024-04-29 21:07   ` Richard Henderson
2024-04-28 22:14 ` [PATCH 24/24] accel/tcg: Move icount fields from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-29 21:08   ` Richard Henderson
2024-04-28 22:22 ` [PATCH 00/24] exec: Rework around CPUState user fields (part 2) Philippe Mathieu-Daudé
2024-04-29 21:04 ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240428221450.26460-19-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).