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>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 05/13] accel/tcg: Restrict cpu_loop_exit_requested() to TCG
Date: Tue, 30 Apr 2024 14:27:59 +0200	[thread overview]
Message-ID: <20240430122808.72025-6-philmd@linaro.org> (raw)
In-Reply-To: <20240430122808.72025-1-philmd@linaro.org>

Next commit will restrict IcountDecr to TCG, so the
inlined cpu_loop_exit_requested(), which is specific
to TCG, won't compile when TCG is disabled. Move it
to the new "exec/cpu-loop.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240428221450.26460-12-philmd@linaro.org>
---
 include/exec/cpu-loop.h       | 35 +++++++++++++++++++++++++++++++++++
 include/exec/exec-all.h       | 17 -----------------
 accel/tcg/cpu-exec.c          |  1 +
 target/arm/tcg/helper-a64.c   |  1 +
 target/s390x/tcg/mem_helper.c |  1 +
 5 files changed, 38 insertions(+), 17 deletions(-)
 create mode 100644 include/exec/cpu-loop.h

diff --git a/include/exec/cpu-loop.h b/include/exec/cpu-loop.h
new file mode 100644
index 0000000000..36ce4064fd
--- /dev/null
+++ b/include/exec/cpu-loop.h
@@ -0,0 +1,35 @@
+/*
+ *  Translation CPU loop (target agnostic)
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef TRANSLATION_CPU_LOOP_H
+#define TRANSLATION_CPU_LOOP_H
+
+#ifndef CONFIG_TCG
+#error Can only include this header with TCG
+#endif
+
+#include "qemu/atomic.h"
+#include "hw/core/cpu.h"
+
+/**
+ * cpu_loop_exit_requested:
+ * @cpu: The CPU state to be tested
+ *
+ * Indicate if somebody asked for a return of the CPU to the main loop
+ * (e.g., via cpu_exit() or cpu_interrupt()).
+ *
+ * This is helpful for architectures that support interruptible
+ * instructions. After writing back all state to registers/memory, this
+ * call can be used to check if it makes sense to return to the main loop
+ * or to continue executing the interruptible instruction.
+ */
+static inline bool cpu_loop_exit_requested(CPUState *cpu)
+{
+    return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0;
+}
+
+#endif
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 2cd7b8f61b..544e35dd24 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -29,23 +29,6 @@
 #include "exec/translation-block.h"
 #include "qemu/clang-tsa.h"
 
-/**
- * cpu_loop_exit_requested:
- * @cpu: The CPU state to be tested
- *
- * Indicate if somebody asked for a return of the CPU to the main loop
- * (e.g., via cpu_exit() or cpu_interrupt()).
- *
- * This is helpful for architectures that support interruptible
- * instructions. After writing back all state to registers/memory, this
- * call can be used to check if it makes sense to return to the main loop
- * or to continue executing the interruptible instruction.
- */
-static inline bool cpu_loop_exit_requested(CPUState *cpu)
-{
-    return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0;
-}
-
 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
 /* cputlb.c */
 /**
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 9af66bc191..eedba056ba 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -32,6 +32,7 @@
 #include "qemu/main-loop.h"
 #include "sysemu/cpus.h"
 #include "exec/cpu-all.h"
+#include "exec/cpu-loop.h"
 #include "sysemu/cpu-timers.h"
 #include "exec/replay-core.h"
 #include "sysemu/tcg.h"
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
index 0ea8668ab4..b294f6bfd0 100644
--- a/target/arm/tcg/helper-a64.c
+++ b/target/arm/tcg/helper-a64.c
@@ -29,6 +29,7 @@
 #include "internals.h"
 #include "qemu/crc32c.h"
 #include "exec/exec-all.h"
+#include "exec/cpu-loop.h"
 #include "exec/cpu_ldst.h"
 #include "qemu/int128.h"
 #include "qemu/atomic128.h"
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 6a308c5553..8435825fa5 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -26,6 +26,7 @@
 #include "exec/helper-proto.h"
 #include "exec/exec-all.h"
 #include "exec/page-protection.h"
+#include "exec/cpu-loop.h"
 #include "exec/cpu_ldst.h"
 #include "hw/core/tcg-cpu-ops.h"
 #include "qemu/int128.h"
-- 
2.41.0



  parent reply	other threads:[~2024-04-30 12:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 12:27 [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2) Philippe Mathieu-Daudé
2024-04-30 12:27 ` [PATCH v3 01/13] accel/tcg: Restrict qemu_plugin_vcpu_exit_hook() to TCG plugins Philippe Mathieu-Daudé
2024-04-30 12:27 ` [PATCH v3 02/13] accel/tcg: Restrict cpu_plugin_mem_cbs_enabled() to TCG Philippe Mathieu-Daudé
2024-04-30 12:27 ` [PATCH v3 03/13] accel/tcg: Move @plugin_mem_cbs from CPUState to CPUNegativeOffsetState Philippe Mathieu-Daudé
2024-04-30 12:27 ` [PATCH v3 04/13] accel/tcg: Move @plugin_state from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-30 12:27 ` Philippe Mathieu-Daudé [this message]
2024-04-30 12:28 ` [PATCH v3 06/13] accel/tcg: Restrict IcountDecr / can_do_io / CPUTLB to TCG Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 07/13] accel/tcg: Move @jmp_env from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 08/13] accel/tcg: Move @cflags_next_tb " Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 09/13] accel/tcg: Move @iommu_notifiers " Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 10/13] accel/tcg: Move @tcg_cflags " Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 11/13] accel/tcg: Restrict icount to system emulation Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 12/13] accel/tcg: Move icount fields from CPUState to TCG AccelCPUState Philippe Mathieu-Daudé
2024-04-30 12:28 ` [PATCH v3 13/13] accel/tcg: Move @tb_jmp_cache " Philippe Mathieu-Daudé
2024-04-30 17:55 ` [PATCH v3 00/13] exec: Rework around CPUState user fields (part 2) Ilya Leoshkevich
2024-04-30 18:45   ` Philippe Mathieu-Daudé
2024-04-30 19:00     ` Philippe Mathieu-Daudé
2024-04-30 21:42       ` Ilya Leoshkevich
2024-05-02 10:27         ` Philippe Mathieu-Daudé
2024-05-02 13:35           ` 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=20240430122808.72025-6-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=iii@linux.ibm.com \
    --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).