@@ -1288,3 +1288,15 @@ static void *atomic_mmu_lookup(CPUState *cpu, vaddr addr, MemOpIdx oi,
#define DATA_SIZE 16
#include "atomic_template.h"
#endif
+
+int cpu_exec_user(CPUState *cs)
+{
+ int trapnr;
+
+ cpu_exec_start(cs);
+ trapnr = cpu_exec(cs);
+ cpu_exec_end(cs);
+ process_queued_cpu_work(cs);
+
+ return trapnr;
+}
@@ -51,11 +51,7 @@ static inline void target_cpu_loop(CPUARMState *env)
abi_long ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
-
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_SWI:
/* See arm64/arm64/trap.c cpu_fetch_syscall_args() */
@@ -43,10 +43,7 @@ static inline void target_cpu_loop(CPUARMState *env)
CPUState *cs = env_cpu(env);
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_UDEF:
case EXCP_NOCP:
@@ -110,10 +110,7 @@ static inline void target_cpu_loop(CPUX86State *env)
/* target_siginfo_t info; */
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case 0x80: {
@@ -118,10 +118,7 @@ static inline void target_cpu_loop(CPUX86State *env)
/* target_siginfo_t info; */
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_SYSCALL:
@@ -226,6 +226,8 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
/* accel/tcg/cpu-exec.c */
int cpu_exec(CPUState *cpu);
+/* accel/tcg/user-exec.c */
+int cpu_exec_user(CPUState *cs);
/**
* env_archcpu(env)
@@ -83,10 +83,7 @@ void cpu_loop(CPUARMState *env)
abi_long ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_SWI:
@@ -32,10 +32,7 @@ void cpu_loop(CPUAlphaState *env)
while (1) {
bool arch_interrupt = true;
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_RESET:
@@ -325,10 +325,7 @@ void cpu_loop(CPUARMState *env)
abi_ulong ret;
for(;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch(trapnr) {
case EXCP_UDEF:
@@ -33,10 +33,7 @@ void cpu_loop(CPUHexagonState *env)
target_ulong ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
@@ -114,10 +114,7 @@ void cpu_loop(CPUHPPAState *env)
int trapnr;
while (1) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_SYSCALL:
@@ -210,10 +210,7 @@ void cpu_loop(CPUX86State *env)
abi_ulong ret;
for(;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch(trapnr) {
case 0x80:
@@ -18,10 +18,7 @@ void cpu_loop(CPULoongArchState *env)
abi_long ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
@@ -30,10 +30,7 @@ void cpu_loop(CPUM68KState *env)
unsigned int n;
for(;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch(trapnr) {
case EXCP_ILLEGAL:
@@ -29,10 +29,7 @@ void cpu_loop(CPUMBState *env)
CPUState *cs = env_cpu(env);
while (1) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
@@ -71,10 +71,7 @@ void cpu_loop(CPUMIPSState *env)
# endif
for(;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch(trapnr) {
case EXCP_SYSCALL:
@@ -30,10 +30,7 @@ void cpu_loop(CPUOpenRISCState *env)
abi_long ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_SYSCALL:
@@ -74,10 +74,7 @@ void cpu_loop(CPUPPCState *env)
for(;;) {
bool arch_interrupt;
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
arch_interrupt = true;
switch (trapnr) {
@@ -33,10 +33,7 @@ void cpu_loop(CPURISCVState *env)
target_ulong ret;
for (;;) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
@@ -61,10 +61,7 @@ void cpu_loop(CPUS390XState *env)
abi_long ret;
while (1) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case EXCP_INTERRUPT:
@@ -31,10 +31,7 @@ void cpu_loop(CPUSH4State *env)
while (1) {
bool arch_interrupt = true;
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case 0x160:
@@ -217,10 +217,7 @@ void cpu_loop (CPUSPARCState *env)
abi_long ret;
while (1) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
switch (trapnr) {
case TARGET_TT_SYSCALL:
@@ -130,10 +130,7 @@ void cpu_loop(CPUXtensaState *env)
int trapnr;
while (1) {
- cpu_exec_start(cs);
- trapnr = cpu_exec(cs);
- cpu_exec_end(cs);
- process_queued_cpu_work(cs);
+ trapnr = cpu_exec_user(cs);
env->sregs[PS] &= ~PS_EXCM;
switch (trapnr) {
All linux-user cpu_loop() implementations contain the same sequence of function calls. Factor them out so that they can be changed in one place. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- accel/tcg/user-exec.c | 12 ++++++++++++ bsd-user/aarch64/target_arch_cpu.h | 6 +----- bsd-user/arm/target_arch_cpu.h | 5 +---- bsd-user/i386/target_arch_cpu.h | 5 +---- bsd-user/x86_64/target_arch_cpu.h | 5 +---- include/exec/cpu-common.h | 2 ++ linux-user/aarch64/cpu_loop.c | 5 +---- linux-user/alpha/cpu_loop.c | 5 +---- linux-user/arm/cpu_loop.c | 5 +---- linux-user/hexagon/cpu_loop.c | 5 +---- linux-user/hppa/cpu_loop.c | 5 +---- linux-user/i386/cpu_loop.c | 5 +---- linux-user/loongarch64/cpu_loop.c | 5 +---- linux-user/m68k/cpu_loop.c | 5 +---- linux-user/microblaze/cpu_loop.c | 5 +---- linux-user/mips/cpu_loop.c | 5 +---- linux-user/openrisc/cpu_loop.c | 5 +---- linux-user/ppc/cpu_loop.c | 5 +---- linux-user/riscv/cpu_loop.c | 5 +---- linux-user/s390x/cpu_loop.c | 5 +---- linux-user/sh4/cpu_loop.c | 5 +---- linux-user/sparc/cpu_loop.c | 5 +---- linux-user/xtensa/cpu_loop.c | 5 +---- 23 files changed, 35 insertions(+), 85 deletions(-)