Move various declarations related to user emulation
from "exec/exec-all.h" to "user/cpu_loop.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/exec-all.h | 55 +------------------------------------
include/user/cpu_loop.h | 54 ++++++++++++++++++++++++++++++++++++
accel/tcg/user-exec.c | 1 +
bsd-user/signal.c | 1 +
linux-user/signal.c | 1 +
target/arm/tcg/mte_helper.c | 1 +
6 files changed, 59 insertions(+), 54 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index b5ea607cf45..c4a6ad3af2d 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -22,7 +22,6 @@
#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
-#include "exec/abi_ptr.h"
#include "exec/cpu_ldst.h"
#endif
#include "exec/mmu-access-type.h"
@@ -518,60 +517,8 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
return get_page_addr_code_hostp(env, addr, NULL);
}
-#if defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
-/**
- * adjust_signal_pc:
- * @pc: raw pc from the host signal ucontext_t.
- * @is_write: host memory operation was write, or read-modify-write.
- *
- * Alter @pc as required for unwinding. Return the type of the
- * guest memory access -- host reads may be for guest execution.
- */
-MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
-
-/**
- * handle_sigsegv_accerr_write:
- * @cpu: the cpu context
- * @old_set: the sigset_t from the signal ucontext_t
- * @host_pc: the host pc, adjusted for the signal
- * @host_addr: the host address of the fault
- *
- * Return true if the write fault has been handled, and should be re-tried.
- */
-bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
- uintptr_t host_pc, abi_ptr guest_addr);
-
-/**
- * cpu_loop_exit_sigsegv:
- * @cpu: the cpu context
- * @addr: the guest address of the fault
- * @access_type: access was read/write/execute
- * @maperr: true for invalid page, false for permission fault
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGSEGV, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
- MMUAccessType access_type,
- bool maperr, uintptr_t ra);
-
-/**
- * cpu_loop_exit_sigbus:
- * @cpu: the cpu context
- * @addr: the guest address of the alignment fault
- * @access_type: access was read/write/execute
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGBUS, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
- MMUAccessType access_type,
- uintptr_t ra);
-
-#else
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
diff --git a/include/user/cpu_loop.h b/include/user/cpu_loop.h
index b0d4704018d..2f93575e2f4 100644
--- a/include/user/cpu_loop.h
+++ b/include/user/cpu_loop.h
@@ -20,7 +20,10 @@
#ifndef USER_CPU_LOOP_H
#define USER_CPU_LOOP_H
+#include "exec/abi_ptr.h"
+#include "exec/mmu-access-type.h"
#include "exec/log.h"
+#include "exec/target_long.h"
#include "special-errno.h"
G_NORETURN void cpu_loop(CPUArchState *env);
@@ -33,4 +36,55 @@ typedef struct target_pt_regs target_pt_regs;
void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs);
+/**
+ * adjust_signal_pc:
+ * @pc: raw pc from the host signal ucontext_t.
+ * @is_write: host memory operation was write, or read-modify-write.
+ *
+ * Alter @pc as required for unwinding. Return the type of the
+ * guest memory access -- host reads may be for guest execution.
+ */
+MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
+
+/**
+ * handle_sigsegv_accerr_write:
+ * @cpu: the cpu context
+ * @old_set: the sigset_t from the signal ucontext_t
+ * @host_pc: the host pc, adjusted for the signal
+ * @host_addr: the host address of the fault
+ *
+ * Return true if the write fault has been handled, and should be re-tried.
+ */
+bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
+ uintptr_t host_pc, abi_ptr guest_addr);
+
+/**
+ * cpu_loop_exit_sigsegv:
+ * @cpu: the cpu context
+ * @addr: the guest address of the fault
+ * @access_type: access was read/write/execute
+ * @maperr: true for invalid page, false for permission fault
+ * @ra: host pc for unwinding
+ *
+ * Use the TCGCPUOps hook to record cpu state, do guest operating system
+ * specific things to raise SIGSEGV, and jump to the main cpu loop.
+ */
+G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
+ MMUAccessType access_type,
+ bool maperr, uintptr_t ra);
+
+/**
+ * cpu_loop_exit_sigbus:
+ * @cpu: the cpu context
+ * @addr: the guest address of the alignment fault
+ * @access_type: access was read/write/execute
+ * @ra: host pc for unwinding
+ *
+ * Use the TCGCPUOps hook to record cpu state, do guest operating system
+ * specific things to raise SIGBUS, and jump to the main cpu loop.
+ */
+G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
+ MMUAccessType access_type,
+ uintptr_t ra);
+
#endif
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 815a39503f3..0561c4f6dc7 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -24,6 +24,7 @@
#include "qemu/bitops.h"
#include "qemu/rcu.h"
#include "exec/cpu_ldst.h"
+#include "user/cpu_loop.h"
#include "qemu/main-loop.h"
#include "user/page-protection.h"
#include "exec/page-protection.h"
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index edbcd461bfa..b4e1458237a 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu.h"
+#include "user/cpu_loop.h"
#include "exec/page-protection.h"
#include "user/page-protection.h"
#include "user/tswap-target.h"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index a191e9b26f2..087c4d270e4 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -33,6 +33,7 @@
#include "trace.h"
#include "signal-common.h"
#include "host-signal.h"
+#include "user/cpu_loop.h"
#include "user/page-protection.h"
#include "user/safe-syscall.h"
#include "tcg/tcg.h"
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index ae037dc9143..846d659ff77 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -25,6 +25,7 @@
#include "exec/page-protection.h"
#ifdef CONFIG_USER_ONLY
#include "user/page-protection.h"
+#include "user/cpu_loop.h"
#endif
#include "exec/ram_addr.h"
#include "exec/cpu_ldst.h"
--
2.45.2
On 12/12/24 10:53, Philippe Mathieu-Daudé wrote: > Move various declarations related to user emulation > from "exec/exec-all.h" to "user/cpu_loop.h". > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > include/exec/exec-all.h | 55 +------------------------------------ > include/user/cpu_loop.h | 54 ++++++++++++++++++++++++++++++++++++ > accel/tcg/user-exec.c | 1 + > bsd-user/signal.c | 1 + > linux-user/signal.c | 1 + > target/arm/tcg/mte_helper.c | 1 + > 6 files changed, 59 insertions(+), 54 deletions(-) > > diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h > index b5ea607cf45..c4a6ad3af2d 100644 > --- a/include/exec/exec-all.h > +++ b/include/exec/exec-all.h > @@ -22,7 +22,6 @@ > > #include "cpu.h" > #if defined(CONFIG_USER_ONLY) > -#include "exec/abi_ptr.h" > #include "exec/cpu_ldst.h" > #endif > #include "exec/mmu-access-type.h" > @@ -518,60 +517,8 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, > return get_page_addr_code_hostp(env, addr, NULL); > } > > -#if defined(CONFIG_USER_ONLY) > +#if !defined(CONFIG_USER_ONLY) > > -/** > - * adjust_signal_pc: > - * @pc: raw pc from the host signal ucontext_t. > - * @is_write: host memory operation was write, or read-modify-write. > - * > - * Alter @pc as required for unwinding. Return the type of the > - * guest memory access -- host reads may be for guest execution. > - */ > -MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); > - > -/** > - * handle_sigsegv_accerr_write: > - * @cpu: the cpu context > - * @old_set: the sigset_t from the signal ucontext_t > - * @host_pc: the host pc, adjusted for the signal > - * @host_addr: the host address of the fault > - * > - * Return true if the write fault has been handled, and should be re-tried. > - */ > -bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, > - uintptr_t host_pc, abi_ptr guest_addr); > - > -/** > - * cpu_loop_exit_sigsegv: > - * @cpu: the cpu context > - * @addr: the guest address of the fault > - * @access_type: access was read/write/execute > - * @maperr: true for invalid page, false for permission fault > - * @ra: host pc for unwinding > - * > - * Use the TCGCPUOps hook to record cpu state, do guest operating system > - * specific things to raise SIGSEGV, and jump to the main cpu loop. > - */ > -G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, > - MMUAccessType access_type, > - bool maperr, uintptr_t ra); > - > -/** > - * cpu_loop_exit_sigbus: > - * @cpu: the cpu context > - * @addr: the guest address of the alignment fault > - * @access_type: access was read/write/execute > - * @ra: host pc for unwinding > - * > - * Use the TCGCPUOps hook to record cpu state, do guest operating system > - * specific things to raise SIGBUS, and jump to the main cpu loop. > - */ > -G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, > - MMUAccessType access_type, > - uintptr_t ra); > - > -#else > void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); > void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); > > diff --git a/include/user/cpu_loop.h b/include/user/cpu_loop.h > index b0d4704018d..2f93575e2f4 100644 > --- a/include/user/cpu_loop.h > +++ b/include/user/cpu_loop.h > @@ -20,7 +20,10 @@ > #ifndef USER_CPU_LOOP_H > #define USER_CPU_LOOP_H > > +#include "exec/abi_ptr.h" > +#include "exec/mmu-access-type.h" > #include "exec/log.h" > +#include "exec/target_long.h" > #include "special-errno.h" > > G_NORETURN void cpu_loop(CPUArchState *env); > @@ -33,4 +36,55 @@ typedef struct target_pt_regs target_pt_regs; > > void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs); > > +/** > + * adjust_signal_pc: > + * @pc: raw pc from the host signal ucontext_t. > + * @is_write: host memory operation was write, or read-modify-write. > + * > + * Alter @pc as required for unwinding. Return the type of the > + * guest memory access -- host reads may be for guest execution. > + */ > +MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); > + > +/** > + * handle_sigsegv_accerr_write: > + * @cpu: the cpu context > + * @old_set: the sigset_t from the signal ucontext_t > + * @host_pc: the host pc, adjusted for the signal > + * @host_addr: the host address of the fault > + * > + * Return true if the write fault has been handled, and should be re-tried. > + */ > +bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, > + uintptr_t host_pc, abi_ptr guest_addr); > + > +/** > + * cpu_loop_exit_sigsegv: > + * @cpu: the cpu context > + * @addr: the guest address of the fault > + * @access_type: access was read/write/execute > + * @maperr: true for invalid page, false for permission fault > + * @ra: host pc for unwinding > + * > + * Use the TCGCPUOps hook to record cpu state, do guest operating system > + * specific things to raise SIGSEGV, and jump to the main cpu loop. > + */ > +G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, > + MMUAccessType access_type, > + bool maperr, uintptr_t ra); > + > +/** > + * cpu_loop_exit_sigbus: > + * @cpu: the cpu context > + * @addr: the guest address of the alignment fault > + * @access_type: access was read/write/execute > + * @ra: host pc for unwinding > + * > + * Use the TCGCPUOps hook to record cpu state, do guest operating system > + * specific things to raise SIGBUS, and jump to the main cpu loop. > + */ > +G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, > + MMUAccessType access_type, > + uintptr_t ra); > + > #endif > diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c > index 815a39503f3..0561c4f6dc7 100644 > --- a/accel/tcg/user-exec.c > +++ b/accel/tcg/user-exec.c > @@ -24,6 +24,7 @@ > #include "qemu/bitops.h" > #include "qemu/rcu.h" > #include "exec/cpu_ldst.h" > +#include "user/cpu_loop.h" > #include "qemu/main-loop.h" > #include "user/page-protection.h" > #include "exec/page-protection.h" > diff --git a/bsd-user/signal.c b/bsd-user/signal.c > index edbcd461bfa..b4e1458237a 100644 > --- a/bsd-user/signal.c > +++ b/bsd-user/signal.c > @@ -21,6 +21,7 @@ > #include "qemu/osdep.h" > #include "qemu/log.h" > #include "qemu.h" > +#include "user/cpu_loop.h" > #include "exec/page-protection.h" > #include "user/page-protection.h" > #include "user/tswap-target.h" > diff --git a/linux-user/signal.c b/linux-user/signal.c > index a191e9b26f2..087c4d270e4 100644 > --- a/linux-user/signal.c > +++ b/linux-user/signal.c > @@ -33,6 +33,7 @@ > #include "trace.h" > #include "signal-common.h" > #include "host-signal.h" > +#include "user/cpu_loop.h" > #include "user/page-protection.h" > #include "user/safe-syscall.h" > #include "tcg/tcg.h" > diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c > index ae037dc9143..846d659ff77 100644 > --- a/target/arm/tcg/mte_helper.c > +++ b/target/arm/tcg/mte_helper.c > @@ -25,6 +25,7 @@ > #include "exec/page-protection.h" > #ifdef CONFIG_USER_ONLY > #include "user/page-protection.h" > +#include "user/cpu_loop.h" > #endif > #include "exec/ram_addr.h" > #include "exec/cpu_ldst.h" Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
© 2016 - 2025 Red Hat, Inc.