accel: Simplify cpu-target.c (omnibus)
Subsystems (4)
cover accel: Simplify cpu-target.c (omnibus)
Yet another cleanup series before respining the "extract TCG fields from CPUState" series. Before that, we try to clarify a bit the code around CPU creation. Target specific code is reduced further. Some intermixed User/System is separated, making maintenance simpler IMHO. Since my local branch is quite big, I tried to group here all the generic patches.
Regards,
Phil.
Based-on: <[email protected]>
"target/ppc: Move TCG code from excp_helper.c to tcg-excp_helper.c"
Philippe Mathieu-Daudé (20):
qemu/compiler: Absorb 'clang-tsa.h'
user: Extract common MMAP API to 'user/mmap.h'
gdbstub: Check for TCG before calling tb_flush()
cpus: Cache CPUClass early in instance_init() handler
cpus: Keep default fields initialization in cpu_common_initfn() accel/kvm: Remove unused 'system/cpus.h' header in kvm-cpus.h accel/tcg: Build tcg_flags helpers as common code accel/tcg: Restrict tlb_init() / destroy() to TCG accel/tcg: Restrict 'icount_align_option' global to TCG accel/tcg: Rename 'hw/core/tcg-cpu-ops.h' -> 'accel/tcg/cpu-ops.h'
accel: Rename 'hw/core/accel-cpu.h' -> 'accel/accel-cpu-target.h' accel/accel-cpu-target.h: Include missing 'cpu.h' header
accel: Forward-declare AccelOpsClass in 'qemu/typedefs.h' accel/tcg: Move cpu_memory_rw_debug() user implementation to
user-exec.c
cpus: Fix style in cpu-target.c
cpus: Restrict cpu_common_post_load() code to TCG
cpus: Have cpu_class_init_props() per user / system emulation
cpus: Have cpu_exec_initfn() per user / system emulation
cpus: Register VMState per user / system emulation
cpus: Build cpu_exec_[un]realizefn() methods once
MAINTAINERS | 4 +-
accel/kvm/kvm-cpus.h | 2 -
accel/tcg/internal-common.h | 13 +
bsd-user/qemu.h | 13 +-
.../accel-cpu.h => accel/accel-cpu-target.h} | 7 +-
.../tcg-cpu-ops.h => accel/tcg/cpu-ops.h} | 0
include/block/block_int-common.h | 1 -
include/block/graph-lock.h | 2 -
include/exec/exec-all.h | 16 -
include/exec/page-protection.h | 2 -
include/hw/core/cpu.h | 2 +
include/qemu/clang-tsa.h | 114 -------
include/qemu/compiler.h | 87 +++++
include/qemu/thread.h | 1 -
include/qemu/typedefs.h | 1 +
include/system/accel-ops.h | 1 -
include/system/cpus.h | 4 -
include/user/mmap.h | 32 ++
linux-user/user-mmap.h | 19 +-
accel/accel-system.c | 1 +
accel/accel-target.c | 2 +-
accel/hvf/hvf-accel-ops.c | 1 +
accel/kvm/kvm-accel-ops.c | 1 +
accel/qtest/qtest.c | 1 +
accel/stubs/tcg-stub.c | 4 -
accel/tcg/cpu-exec-common.c | 34 +-
accel/tcg/cpu-exec.c | 37 +--
accel/tcg/cputlb.c | 2 +-
accel/tcg/icount-common.c | 2 +
accel/tcg/monitor.c | 1 -
accel/tcg/tcg-accel-ops.c | 1 +
accel/tcg/translate-all.c | 3 +-
accel/tcg/user-exec-stub.c | 11 +
accel/tcg/user-exec.c | 94 +++++-
accel/tcg/watchpoint.c | 2 +-
accel/xen/xen-all.c | 1 +
block/create.c | 1 -
bsd-user/signal.c | 2 +-
cpu-common.c | 1 -
cpu-target.c | 314 +-----------------
gdbstub/system.c | 6 +-
hw/core/cpu-common.c | 31 ++
hw/core/cpu-system.c | 170 ++++++++++
hw/core/cpu-user.c | 44 +++
hw/mips/jazz.c | 2 +-
linux-user/signal.c | 2 +-
system/cpus.c | 1 +
system/globals.c | 1 -
system/physmem.c | 2 +-
target/alpha/cpu.c | 2 +-
target/arm/cpu.c | 2 +-
target/arm/tcg/cpu-v7m.c | 2 +-
target/arm/tcg/cpu32.c | 2 +-
target/arm/tcg/mte_helper.c | 2 +-
target/arm/tcg/sve_helper.c | 2 +-
target/avr/cpu.c | 2 +-
target/avr/helper.c | 2 +-
target/hexagon/cpu.c | 2 +-
target/hppa/cpu.c | 2 +-
target/i386/hvf/hvf-cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 2 +-
target/i386/nvmm/nvmm-accel-ops.c | 1 +
target/i386/tcg/tcg-cpu.c | 4 +-
target/i386/whpx/whpx-accel-ops.c | 1 +
target/loongarch/cpu.c | 2 +-
target/m68k/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/mips/cpu.c | 2 +-
target/openrisc/cpu.c | 2 +-
target/ppc/cpu_init.c | 2 +-
target/ppc/kvm.c | 2 +-
target/riscv/kvm/kvm-cpu.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 4 +-
target/rx/cpu.c | 2 +-
target/s390x/cpu.c | 2 +-
target/s390x/tcg/mem_helper.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 2 +-
target/tricore/cpu.c | 2 +-
target/xtensa/cpu.c | 2 +-
tests/unit/test-bdrv-drain.c | 1 -
tests/unit/test-block-iothread.c | 1 -
util/qemu-thread-posix.c | 1 -
hw/core/meson.build | 5 +-
84 files changed, 590 insertions(+), 578 deletions(-)
rename include/{hw/core/accel-cpu.h => accel/accel-cpu-target.h} (92%)
rename include/{hw/core/tcg-cpu-ops.h => accel/tcg/cpu-ops.h} (100%)
delete mode 100644 include/qemu/clang-tsa.h
create mode 100644 include/user/mmap.h
create mode 100644 hw/core/cpu-user.cSignature · 1 line
2.47.1
PATCH 1/20 qemu/compiler: Absorb 'clang-tsa.h'
We already have "qemu/compiler.h" for compiler-specific arrangements, automatically included by "qemu/osdep.h" for each source file. No need to explicitly include a header for a Clang particularity.
--- bsd-user/qemu.h | 1 - include/block/block_int-common.h | 1 - include/block/graph-lock.h | 2 - include/exec/page-protection.h | 2 - include/qemu/clang-tsa.h | 114 ------------------------------- include/qemu/compiler.h | 87 +++++++++++++++++++++++ include/qemu/thread.h | 1 - block/create.c | 1 - tests/unit/test-bdrv-drain.c | 1 - tests/unit/test-block-iothread.c | 1 - util/qemu-thread-posix.c | 1 - 11 files changed, 87 insertions(+), 125 deletions(-) delete mode 100644 include/qemu/clang-tsa.h
bsd-user/qemu.h +0 -1
@@ -40,7 +40,6 @@ extern char **environ;#include "target.h" #include "exec/gdbstub.h" #include "exec/page-protection.h" -#include "qemu/clang-tsa.h" #include "accel/tcg/vcpu-state.h" #include "qemu-os.h"
include/block/block_int-common.h +0 -1
@@ -28,7 +28,6 @@#include "block/block-common.h" #include "block/block-global-state.h" #include "block/snapshot.h" -#include "qemu/clang-tsa.h" #include "qemu/iov.h" #include "qemu/rcu.h" #include "qemu/stats64.h"
include/block/graph-lock.h +0 -2
@@ -20,8 +20,6 @@#ifndef GRAPH_LOCK_H #define GRAPH_LOCK_H -#include "qemu/clang-tsa.h" -/** * Graph Lock API * This API provides a rwlock used to protect block layer
include/exec/page-protection.h +0 -2
@@ -40,8 +40,6 @@#ifdef CONFIG_USER_ONLY -#include "qemu/clang-tsa.h" - void TSA_NO_TSA mmap_lock(void); void TSA_NO_TSA mmap_unlock(void);bool have_mmap_lock (void );
include/qemu/clang-tsa.h deleted +0 -114
114 lines not on this page · raw message
include/qemu/compiler.h +87 -0
93 lines not on this page · raw message
include/qemu/thread.h +0 -1
@@ -3,7 +3,6 @@#include "qemu/processor.h" #include "qemu/atomic.h" -#include "qemu/clang-tsa.h" typedef struct QemuCond QemuCond ;typedef struct QemuSemaphore QemuSemaphore ;
block/create.c +0 -1
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "block/block_int.h" -#include "qemu/clang-tsa.h" #include "qemu/job.h" #include "qemu/main-loop.h" #include "qapi/qapi-commands-block-core.h"
tests/unit/test-bdrv-drain.c +0 -1
@@ -28,7 +28,6 @@#include "system/block-backend.h" #include "qapi/error.h" #include "qemu/main-loop.h" -#include "qemu/clang-tsa.h" #include "iothread.h" static QemuEvent done_event;
tests/unit/test-block-iothread.c +0 -1
@@ -29,7 +29,6 @@#include "system/block-backend.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qemu/clang-tsa.h" #include "qemu/main-loop.h" #include "iothread.h"
util/qemu-thread-posix.c +0 -1
@@ -17,7 +17,6 @@#include "qemu-thread-common.h" #include "qemu/tsan.h" #include "qemu/bitmap.h" -#include "qemu/clang-tsa.h" #ifdef CONFIG_PTHREAD_SET_NAME_NP #include <pthread_np.h>
Signature · 1 line
2.47.1
PATCH 2/20 user: Extract common MMAP API to 'user/mmap.h'
In reply to Philippe Mathieu-DaudéKeep common MMAP-related declarations in a single place.
Note, this disable ThreadSafetyAnalysis on Linux for:
- mmap_fork_start()
- mmap_fork_end().
--- bsd-user/qemu.h | 12 +----------- include/user/mmap.h | 32 ++++++++++++++++++++++++++++++++ linux-user/user-mmap.h | 19 ++----------------- 3 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 include/user/mmap.h
bsd-user/qemu.h +1 -11
@@ -32,6 +32,7 @@extern char **environ;#include "user/thunk.h" +#include "user/mmap.h" #include "target_arch.h" #include "syscall_defs.h" #include "target_syscall.h"
@@ -233,19 +234,8 @@ void print_taken_signal(int target_signum, const target_siginfo_t *tinfo);extern int do_strace;/* mmap.c */ -int target_mprotect (abi_ulong start,abi_ulong len,int prot); -abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, -int flags,int fd,off_t offset); -int target_munmap (abi_ulong start,abi_ulong len); -abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, -abi_ulong new_size,unsigned long flags, -abi_ulong new_addr);int target_msync (abi_ulong start,abi_ulong len,int flags); -extern abi_ulong mmap_next_start; -abi_ulong mmap_find_vma (abi_ulong start,abi_ulong size);void mmap_reserve (abi_ulong start,abi_ulong size); -void TSA_NO_TSA mmap_fork_start(void); -void TSA_NO_TSA mmap_fork_end(int child);/* main.c */ extern char qemu_proc_pathname[];
include/user/mmap.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* MMAP declarations for QEMU user emulation +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef USER_MMAP_H +#define USER_MMAP_H + +#include "user/abitypes.h" + +/* +* mmap_next_start: The base address for the next mmap without hint, +* increased after each successful map, starting at task_unmapped_base. +* This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT. +*/ +extern abi_ulong mmap_next_start; + +int target_mprotect (abi_ulong start,abi_ulong len,int prot); + +abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, +int flags,int fd,off_t offset); +int target_munmap (abi_ulong start,abi_ulong len); +abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, +abi_ulong new_size,unsigned long flags, +abi_ulong new_addr); + +abi_ulong mmap_find_vma (abi_ulong ,abi_ulong ,abi_ulong ); + +void TSA_NO_TSA mmap_fork_start(void); +void TSA_NO_TSA mmap_fork_end(int child); + +#endif
linux-user/user-mmap.h +2 -17
@@ -18,6 +18,8 @@#ifndef LINUX_USER_USER_MMAP_H #define LINUX_USER_USER_MMAP_H +#include "user/mmap.h" +/* * Guest parameters for the ADDR_COMPAT_LAYOUT personality * (at present this is the only layout supported by QEMU).
@@ -39,24 +41,7 @@extern abi_ulong task_unmapped_base;extern abi_ulong elf_et_dyn_base; -/* -* mmap_next_start: The base address for the next mmap without hint, -* increased after each successful map, starting at task_unmapped_base. -* This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT. -*/ -extern abi_ulong mmap_next_start; - -int target_mprotect (abi_ulong start,abi_ulong len,int prot); -abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, -int flags,int fd,off_t offset); -int target_munmap (abi_ulong start,abi_ulong len); -abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, -abi_ulong new_size,unsigned long flags, -abi_ulong new_addr);abi_long target_madvise (abi_ulong start,abi_ulong len_in,int advice); -abi_ulong mmap_find_vma (abi_ulong ,abi_ulong ,abi_ulong ); -void mmap_fork_start (void ); -void mmap_fork_end (int child);abi_ulong target_shmat (CPUArchState *cpu_env,int shmid,abi_ulong shmaddr,int shmflg);
Signature · 1 line
2.47.1
Re: [PATCH 02/20] user: Extract common MMAP API to 'user/mmap.h'
Quoted 7 lines · Philippe Mathieu-Daudé
Keep common MMAP-related declarations in a single place.
Note, this disable ThreadSafetyAnalysis on Linux for:
-mmap_fork_start()
-mmap_fork_end().Signed-off-by Philippe Mathieu-Daudé <[email protected]>
I forgot to include:
Quoted 6 lines
--- bsd-user/qemu.h | 12 +----------- include/user/mmap.h | 32 ++++++++++++++++++++++++++++++++ linux-user/user-mmap.h | 19 ++----------------- 3 files changed, 35 insertions(+), 28 deletions(-)create mode 100644
include/user/mmap.h
Re: [PATCH 02/20] user: Extract common MMAP API to 'user/mmap.h'
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
Keep common MMAP-related declarations in a single place.
Note, this disable ThreadSafetyAnalysis on Linux for:
-mmap_fork_start()
-mmap_fork_end().
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- bsd-user/qemu.h | 12 +----------- include/user/mmap.h | 32 ++++++++++++++++++++++++++++++++ linux-user/user-mmap.h | 19 ++----------------- 3 files changed, 35 insertions(+), 28 deletions(-)create mode 100644
include/user/mmap.h
r~
PATCH 3/20 gdbstub: Check for TCG before calling tb_flush()
In reply to Philippe Mathieu-DaudéUse the tcg_enabled() check so the compiler can elide the call when TCG isn't available, allowing to remove the tb_flush() stub.
--- accel/stubs/tcg-stub.c | 4 ---- gdbstub/system.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-)
accel/stubs/tcg-stub.c +0 -4
@@ -14,10 +14,6 @@#include "exec/tb-flush.h" #include "exec/exec-all.h" -void tb_flush (CPUState *cpu) -{ -} - G_NORETURN void cpu_loop_exit(CPUState *cpu) {g_assert_not_reached ();
gdbstub/system.c +4 -1
@@ -22,6 +22,7 @@#include "system/cpus.h" #include "system/runstate.h" #include "system/replay.h" +#include "system/tcg.h" #include "hw/core/cpu.h" #include "hw/cpu/cluster.h" #include "hw/boards.h"
@@ -171,7 +172,9 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) }else {trace_gdbstub_hit_break (); } -tb_flush (cpu); +if (tcg_enabled ()) { +tb_flush (cpu); + } ret =GDB_SIGNAL_TRAP ;break ;case RUN_STATE_PAUSED :
Signature · 1 line
2.47.1
Re: [PATCH 03/20] gdbstub: Check for TCG before calling tb_flush()
Quoted 5 lines · Philippe Mathieu-Daudé
Use the
tcg_enabled()check so the compiler can elide the call when TCG isn't available, allowing to remove thetb_flush()stub.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 03/20] gdbstub: Check for TCG before calling tb_flush()
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Use the
tcg_enabled()check so the compiler can elide the call when TCG isn't available, allowing to remove thetb_flush()stub.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/stubs/tcg-stub.c | 4 ---- gdbstub/system.c | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-)
r~
PATCH 4/20 cpus: Cache CPUClass early in instance_init() handler
In reply to Philippe Mathieu-DaudéCache CPUClass as early as possible, when the instance is initialized.
--- cpu-target.c | 3 --- hw/core/cpu-common.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
cpu-target.c +0 -3
@@ -134,9 +134,6 @@ const VMStateDescription vmstate_cpu_common = {bool cpu_exec_realizefn (CPUState *cpu,Error **errp) { -/* cache the cpu class for the hotpath */ - cpu->cc =CPU_GET_CLASS (cpu); -if (!accel_cpu_common_realize (cpu, errp)) {return false; }
hw/core/cpu-common.c +3 -0
@@ -238,6 +238,9 @@ static void cpu_common_initfn(Object *obj) {CPUState *cpu =CPU (obj); +/* cache the cpu class for the hotpath */ + cpu->cc =CPU_GET_CLASS (cpu); +gdb_init_cpu (cpu); cpu->cpu_index =UNASSIGNED_CPU_INDEX ; cpu->cluster_index =UNASSIGNED_CLUSTER_INDEX ;
Signature · 1 line
2.47.1
PATCH 5/20 cpus: Keep default fields initialization in cpu_common_initfn()
In reply to Philippe Mathieu-Daudécpu_common_initfn() is our target agnostic initializer, while cpu_exec_initfn() is the target specific one.
The %as and %num_ases fields are not target specific, so initialize them in the common helper.
--- cpu-target.c | 3 --- hw/core/cpu-common.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
cpu-target.c +0 -3
@@ -234,9 +234,6 @@ void cpu_class_init_props(DeviceClass *dc)void cpu_exec_initfn (CPUState *cpu) { - cpu->as =NULL ; - cpu->num_ases =0 ; -#ifndef CONFIG_USER_ONLY cpu->memory =get_system_memory ();object_ref (OBJECT (cpu->memory));
hw/core/cpu-common.c +2 -0
@@ -244,6 +244,8 @@ static void cpu_common_initfn(Object *obj)gdb_init_cpu (cpu); cpu->cpu_index =UNASSIGNED_CPU_INDEX ; cpu->cluster_index =UNASSIGNED_CLUSTER_INDEX ; + cpu->as =NULL ; + cpu->num_ases =0 ;/* user-mode doesn't have configurable SMP topology */ /* the default value is changed by qemu_init_vcpu() for system-mode */ cpu->nr_threads =1 ;
Signature · 1 line
2.47.1
Re: [PATCH 05/20] cpus: Keep default fields initialization in cpu_common_initfn()
Quoted 11 lines · Philippe Mathieu-Daudé
cpu_common_initfn()is our target agnostic initializer, whilecpu_exec_initfn()is the target specific one.The %as and %num_ases fields are not target specific, so initialize them in the common helper.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- cpu-target.c | 3 --- hw/core/cpu-common.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
r~
PATCH 6/20 accel/kvm: Remove unused 'system/cpus.h' header in kvm-cpus.h
In reply to Philippe Mathieu-DaudéMissed in commit b86f59c7155 ("accel: replace struct CpusAccel with AccelOpsClass") which removed the single CpusAccel use.
--- accel/kvm/kvm-cpus.h | 2 -- 1 file changed, 2 deletions(-)
accel/kvm/kvm-cpus.h +0 -2
@@ -10,8 +10,6 @@#ifndef KVM_CPUS_H #define KVM_CPUS_H -#include "system/cpus.h" -int kvm_init_vcpu (CPUState *cpu,Error **errp);int kvm_cpu_exec (CPUState *cpu);void kvm_destroy_vcpu (CPUState *cpu);
Signature · 1 line
2.47.1
Re: [PATCH 06/20] accel/kvm: Remove unused 'system/cpus.h' header in kvm-cpus.h
Quoted 13 lines · Philippe Mathieu-Daudé
Missed in commit
b86f59c7155("accel: replace struct CpusAccel with AccelOpsClass") which removed the single CpusAccel use.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/kvm/kvm-cpus.h | 2 -- 1 file changed, 2 deletions(-)accel/kvm/kvm-cpus.h +0
-0
accel/kvm/kvm-cpus.h line 15
Quoted 8 lines
accel/kvm/kvm-cpus.h +0
-2@@ -10,8 +10,6 @@#ifndef KVM_CPUS_H #define KVM_CPUS_H -#include "system/cpus.h" -int kvm_init_vcpu (CPUState *cpu,Error **errp);int kvm_cpu_exec (CPUState *cpu);void kvm_destroy_vcpu (CPUState *cpu);
r~
PATCH 7/20 accel/tcg: Build tcg_flags helpers as common code
In reply to Philippe Mathieu-DaudéWhile cpu-exec.c is build for each target,tcg_flags helpers aren't target specific. Move them to cpu-exec-common.c to build them once.
--- accel/tcg/cpu-exec-common.c | 33 +++++++++++++++++++++++++++++++++ accel/tcg/cpu-exec.c | 32 -------------------------------- 2 files changed, 33 insertions(+), 32 deletions(-)
accel/tcg/cpu-exec-common.c +33 -0
@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" +#include "exec/log.h" #include "system/cpus.h" #include "system/tcg.h" #include "qemu/plugin.h"
@@ -25,6 +26,38 @@bool tcg_allowed; +bool tcg_cflags_has (CPUState *cpu,uint32_t flags) +{ +return cpu->tcg_cflags & flags; +} + +void tcg_cflags_set (CPUState *cpu,uint32_t flags) +{ + cpu->tcg_cflags |= flags; +} + +uint32_t curr_cflags (CPUState *cpu) +{ +uint32_t cflags = cpu->tcg_cflags; + +/* +* Record gdb single-step. We should be exiting the TB by raising +* EXCP_DEBUG, but to simplify other tests, disable chaining too. +* +* For singlestep and -d nochain, suppress goto_tb so that +* we can log -d cpu,exec after every TB. +*/ +if (unlikely (cpu->singlestep_enabled)) { + cflags |=CF_NO_GOTO_TB |CF_NO_GOTO_PTR |CF_SINGLE_STEP |1 ; + }else if (qatomic_read (&one_insn_per_tb)) { + cflags |=CF_NO_GOTO_TB |1 ; + }else if (qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { + cflags |=CF_NO_GOTO_TB ; + } + +return cflags; +} +/* exit the current TB, but without causing any exception to be raised */ void cpu_loop_exit_noexc (CPUState *cpu) {
accel/tcg/cpu-exec.c +0 -32
@@ -148,38 +148,6 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu) }#endif /* CONFIG USER ONLY */ -bool tcg_cflags_has (CPUState *cpu,uint32_t flags) -{ -return cpu->tcg_cflags & flags; -} - -void tcg_cflags_set (CPUState *cpu,uint32_t flags) -{ - cpu->tcg_cflags |= flags; -} - -uint32_t curr_cflags (CPUState *cpu) -{ -uint32_t cflags = cpu->tcg_cflags; - -/* -* Record gdb single-step. We should be exiting the TB by raising -* EXCP_DEBUG, but to simplify other tests, disable chaining too. -* -* For singlestep and -d nochain, suppress goto_tb so that -* we can log -d cpu,exec after every TB. -*/ -if (unlikely (cpu->singlestep_enabled)) { - cflags |=CF_NO_GOTO_TB |CF_NO_GOTO_PTR |CF_SINGLE_STEP |1 ; - }else if (qatomic_read (&one_insn_per_tb)) { - cflags |=CF_NO_GOTO_TB |1 ; - }else if (qemu_loglevel_mask (CPU_LOG_TB_NOCHAIN )) { - cflags |=CF_NO_GOTO_TB ; - } - -return cflags; -} -struct tb_desc {vaddr pc;uint64_t cs_base;
Signature · 1 line
2.47.1
Re: [PATCH 07/20] accel/tcg: Build tcg_flags helpers as common code
Quoted 9 lines · Philippe Mathieu-Daudé
While
cpu-exec.cis build for each target,tcg_flags helpers aren't target specific. Move them tocpu-exec-common.cto build them once.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/tcg/cpu-exec-common.c | 33 +++++++++++++++++++++++++++++++++ accel/tcg/cpu-exec.c | 32 -------------------------------- 2 files changed, 33 insertions(+), 32 deletions(-)
r~
PATCH 8/20 accel/tcg: Restrict tlb_init() / destroy() to TCG
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to accel/tcg/ scope,
in "internal-common.h".
--- accel/tcg/internal-common.h | 11 +++++++++++ include/exec/exec-all.h | 16 ---------------- accel/tcg/user-exec-stub.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-)
accel/tcg/internal-common.h +11 -0
@@ -53,6 +53,17 @@ TranslationBlock *tb_link_page(TranslationBlock *tb);void cpu_restore_state_from_tb (CPUState *cpu,TranslationBlock *tb,uintptr_t host_pc); +/** +* tlb_init - initialize a CPU's TLB +* @cpu: CPU whose TLB should be initialized +*/ +void tlb_init (CPUState *cpu); +/** +* tlb_destroy - destroy a CPU's TLB +* @cpu: CPU whose TLB should be destroyed +*/ +void tlb_destroy (CPUState *cpu); +bool tcg_exec_realizefn (CPUState *cpu,Error **errp);void tcg_exec_unrealizefn (CPUState *cpu);
include/exec/exec-all.h +0 -16
@@ -29,16 +29,6 @@#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG )/* cputlb.c */ -/** -* tlb_init - initialize a CPU's TLB -* @cpu: CPU whose TLB should be initialized -*/ -void tlb_init (CPUState *cpu); -/** -* tlb_destroy - destroy a CPU's TLB -* @cpu: CPU whose TLB should be destroyed -*/ -void tlb_destroy (CPUState *cpu);/** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed
@@ -223,12 +213,6 @@ void tlb_set_page(CPUState *cpu, vaddr addr, hwaddr paddr, int prot, int mmu_idx, vaddr size);#else -static inline void tlb_init (CPUState *cpu) -{ -} -static inline void tlb_destroy (CPUState *cpu) -{ -}static inline void tlb_flush_page (CPUState *cpu,vaddr addr) { }
accel/tcg/user-exec-stub.c +11 -0
@@ -1,6 +1,7 @@#include "qemu/osdep.h" #include "hw/core/cpu.h" #include "exec/replay-core.h" +#include "internal-common.h" void cpu_resume (CPUState *cpu) {
@@ -18,6 +19,16 @@ void cpu_exec_reset_hold(CPUState *cpu) { } +/* User mode emulation does not support softmmu yet. */ + +void tlb_init (CPUState *cpu) +{ +} + +void tlb_destroy (CPUState *cpu) +{ +} +/* User mode emulation does not support record/replay yet. */ bool replay_exception (void )
Signature · 1 line
2.47.1
Re: [PATCH 08/20] accel/tcg: Restrict tlb_init() / destroy() to TCG
Quoted 11 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to accel/tcg/ scope,
in "internal-common.h".Suggested-by Richard Henderson<[email protected]>Reviewed-by Pierrick Bouvier<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/tcg/internal-common.h | 11 +++++++++++ include/exec/exec-all.h | 16 ---------------- accel/tcg/user-exec-stub.c | 11 +++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-)
r~
PATCH 9/20 accel/tcg: Restrict 'icount_align_option' global to TCG
In reply to Philippe Mathieu-DaudéSince commit 740b1759734 ("cpu-timers, icount: new modules") we don't need to expose icount_align_option to all the system code, we can restrict it to TCG. Since it is used as a boolean, declare it as 'bool' type.
--- accel/tcg/internal-common.h | 2 ++ include/system/cpus.h | 2 -- accel/tcg/icount-common.c | 2 ++ system/globals.c | 1 - 4 files changed, 4 insertions(+), 3 deletions(-)
accel/tcg/internal-common.h +2 -0
@@ -17,6 +17,8 @@ extern int64_t max_advance;extern bool one_insn_per_tb; +extern bool icount_align_option; +/* * Return true if CS is not running in parallel with other cpus, either * because there are no other cpus or we are within an exclusive context.
include/system/cpus.h +0 -2
@@ -38,8 +38,6 @@ void resume_all_vcpus(void);void pause_all_vcpus (void );void cpu_stop_current (void ); -extern int icount_align_option; -/* Unblock cpu */ void qemu_cpu_kick_self (void );
accel/tcg/icount-common.c +2 -0
@@ -48,6 +48,8 @@ static bool icount_sleep = true;/* Arbitrarily pick 1MIPS as the minimum allowable speed. */ #define MAX_ICOUNT_SHIFT 10 +bool icount_align_option; +/* Do not count executed instructions */ ICountMode use_icount =ICOUNT_DISABLED ;
system/globals.c +0 -1
@@ -48,7 +48,6 @@ unsigned int nb_prom_envs;const char *prom_envs[MAX_PROM_ENVS ];uint8_t *boot_splash_filedata;int only_migratable;/* turn it off unless user states otherwise */ -int icount_align_option;/* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in the * little-endian "wire format" described in the SMBIOS 2.6 specification.
Signature · 1 line
2.47.1
Re: [PATCH 09/20] accel/tcg: Restrict 'icount_align_option' global to TCG
Quoted 5 lines · Philippe Mathieu-Daudé
Since commit
740b1759734("cpu-timers, icount: new modules") we don't need to exposeicount_align_optionto all the system code, we can restrict it to TCG. Since it is used as a boolean, declare it as 'bool' type.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/tcg/internal-common.h | 2 ++ include/system/cpus.h | 2 -- accel/tcg/icount-common.c | 2 ++ system/globals.c | 1 - 4 files changed, 4 insertions(+), 3 deletions(-)
r~
PATCH 10/20 accel/tcg: Rename 'hw/core/tcg-cpu-ops.h' -> 'accel/tcg/cpu-ops.h'
In reply to Philippe Mathieu-DaudéTCGCPUOps structure makes more sense in the accelerator context rather than hardware emulation. Move it under the accel/tcg/ scope.
Mechanical change doing:
$ sed -i -e 's,hw/core/tcg-cpu-ops.h,accel/tcg/cpu-ops.h,g' \ $(git grep -l hw/core/tcg-cpu-ops.h)
---
MAINTAINERS | 2 +-
include/{hw/core/tcg-cpu-ops.h => accel/tcg/cpu-ops.h} | 0
accel/tcg/cpu-exec.c | 4 ++--
accel/tcg/cputlb.c | 2 +-
accel/tcg/translate-all.c | 2 +-
accel/tcg/user-exec.c | 2 +-
accel/tcg/watchpoint.c | 2 +-
bsd-user/signal.c | 2 +-
hw/mips/jazz.c | 2 +-
linux-user/signal.c | 2 +-
system/physmem.c | 2 +-
target/alpha/cpu.c | 2 +-
target/arm/cpu.c | 2 +-
target/arm/tcg/cpu-v7m.c | 2 +-
target/arm/tcg/cpu32.c | 2 +-
target/arm/tcg/mte_helper.c | 2 +-
target/arm/tcg/sve_helper.c | 2 +-
target/avr/cpu.c | 2 +-
target/avr/helper.c | 2 +-
target/hexagon/cpu.c | 2 +-
target/hppa/cpu.c | 2 +-
target/i386/tcg/tcg-cpu.c | 2 +-
target/loongarch/cpu.c | 2 +-
target/m68k/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/mips/cpu.c | 2 +-
target/openrisc/cpu.c | 2 +-
target/ppc/cpu_init.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 2 +-
target/rx/cpu.c | 2 +-
target/s390x/cpu.c | 2 +-
target/s390x/tcg/mem_helper.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 2 +-
target/tricore/cpu.c | 2 +-
target/xtensa/cpu.c | 2 +-
36 files changed, 36 insertions(+), 36 deletions(-)
rename include/{hw/core/tcg-cpu-ops.h => accel/tcg/cpu-ops.h} (100%)MAINTAINERS +1 -1
@@ -175,7 +175,7 @@ F: include/exec/helper-info.c.inc F: include/exec/page-protection.h F: include/system/cpus.h F: include/system/tcg.h -F: include/hw/core/tcg-cpu-ops.h +F: include/accel/tcg/cpu-ops.h F: host/include/*/host/cpuinfo.h F: util/cpuinfo-*.c F: include/tcg/
include/accel/tcg/cpu-ops.h renamed from include/hw/core/tcg-cpu-ops.h +0 -0
accel/tcg/cpu-exec.c +2 -2
@@ -22,7 +22,7 @@#include "qapi/error.h" #include "qapi/type-helpers.h" #include "hw/core/cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "trace.h" #include "disas/disas.h" #include "exec/cpu-common.h"
@@ -39,7 +39,7 @@#include "exec/replay-core.h" #include "system/tcg.h" #include "exec/helper-proto-common.h" -#include "tb-jmp-cache.h" +//#include "tb-jmp-cache.h" #include "tb-hash.h" #include "tb-context.h" #include "tb-internal.h"
accel/tcg/cputlb.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "qemu/main-loop.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "exec/exec-all.h" #include "exec/page-protection.h" #include "exec/memory.h"
accel/tcg/translate-all.c +1 -1
@@ -58,7 +58,7 @@#include "system/cpu-timers.h" #include "system/tcg.h" #include "qapi/error.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "tb-jmp-cache.h" #include "tb-hash.h" #include "tb-context.h"
accel/tcg/user-exec.c +1 -1
@@ -17,7 +17,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "disas/disas.h" #include "exec/exec-all.h" #include "tcg/tcg.h"
accel/tcg/watchpoint.c +1 -1
@@ -26,7 +26,7 @@#include "tb-internal.h" #include "system/tcg.h" #include "system/replay.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "hw/core/cpu.h" #include "internal-common.h"
bsd-user/signal.c +1 -1
@@ -28,7 +28,7 @@#include "gdbstub/user.h" #include "signal-common.h" #include "trace.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "host-signal.h" /* target_siginfo_t must fit in gdbstub's siginfo save area. */
hw/mips/jazz.c +1 -1
@@ -50,7 +50,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #endif /* CONFIG_TCG */ #include "cpu.h"
linux-user/signal.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/cutils.h" #include "gdbstub/user.h" #include "exec/page-protection.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include <sys/ucontext.h> #include <sys/resource.h>
system/physmem.c +1 -1
@@ -28,7 +28,7 @@#include "qemu/lockable.h" #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #endif /* CONFIG_TCG */ #include "exec/exec-all.h"
target/alpha/cpu.c +1 -1
@@ -220,7 +220,7 @@ static const struct SysemuCPUOps alpha_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps alpha_tcg_ops = { .initialize = alpha_translate_init,
target/arm/cpu.c +1 -1
@@ -29,7 +29,7 @@#include "cpu.h" #ifdef CONFIG_TCG #include "exec/translation-block.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #endif /* CONFIG_TCG */ #include "internals.h" #include "cpu-features.h"
target/arm/tcg/cpu-v7m.c +1 -1
@@ -10,7 +10,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "internals.h" #if !defined(CONFIG_USER_ONLY )
target/arm/tcg/cpu32.c +1 -1
@@ -10,7 +10,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "internals.h" #include "target/arm/idau.h" #if !defined(CONFIG_USER_ONLY )
target/arm/tcg/mte_helper.c +1 -1
@@ -31,7 +31,7 @@#endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "qapi/error.h" #include "qemu/guest-random.h" #include "mte_helper.h"
target/arm/tcg/sve_helper.c +1 -1
@@ -28,7 +28,7 @@#include "tcg/tcg.h" #include "vec_internal.h" #include "sve_ldst_internal.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #ifdef CONFIG_USER_ONLY #include "user/page-protection.h" #endif
target/avr/cpu.c +1 -1
@@ -203,7 +203,7 @@ static const struct SysemuCPUOps avr_sysemu_ops = { .get_phys_page_debug = avr_cpu_get_phys_page_debug, }; -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps avr_tcg_ops = { .initialize = avr_cpu_tcg_init,
target/avr/helper.c +1 -1
@@ -22,7 +22,7 @@#include "qemu/log.h" #include "qemu/error-report.h" #include "cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "exec/exec-all.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h"
target/hexagon/cpu.c +1 -1
@@ -321,7 +321,7 @@ static void hexagon_cpu_init(Object *obj) { } -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps hexagon_tcg_ops = { .initialize = hexagon_translate_init,
target/hppa/cpu.c +1 -1
@@ -235,7 +235,7 @@ static const struct SysemuCPUOps hppa_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps hppa_tcg_ops = { .initialize = hppa_translate_init,
target/i386/tcg/tcg-cpu.c +1 -1
@@ -105,7 +105,7 @@ static bool x86_debug_check_breakpoint(CPUState *cs) }#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps x86_tcg_ops = { .initialize = tcg_x86_init,
target/loongarch/cpu.c +1 -1
@@ -813,7 +813,7 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) }#ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps loongarch_tcg_ops = { .initialize = loongarch_translate_init,
target/m68k/cpu.c +1 -1
@@ -547,7 +547,7 @@ static const struct SysemuCPUOps m68k_sysemu_ops = { };#endif /* !CONFIG_USER_ONLY */ -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps m68k_tcg_ops = { .initialize = m68k_tcg_init,
target/microblaze/cpu.c +1 -1
@@ -419,7 +419,7 @@ static const struct SysemuCPUOps mb_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps mb_tcg_ops = { .initialize = mb_tcg_init,
target/mips/cpu.c +1 -1
@@ -544,7 +544,7 @@ static const Property mips_cpu_properties[] = { };#ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps mips_tcg_ops = { .initialize = mips_tcg_init, .translate_code = mips_translate_code,
target/openrisc/cpu.c +1 -1
@@ -232,7 +232,7 @@ static const struct SysemuCPUOps openrisc_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps openrisc_tcg_ops = { .initialize = openrisc_translate_init,
target/ppc/cpu_init.c +1 -1
@@ -7427,7 +7427,7 @@ static const struct SysemuCPUOps ppc_sysemu_ops = {#endif #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps ppc_tcg_ops = { .initialize = ppc_translate_init,
target/riscv/tcg/tcg-cpu.c +1 -1
@@ -31,7 +31,7 @@#include "qemu/error-report.h" #include "qemu/log.h" #include "hw/core/accel-cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "tcg/tcg.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h"
target/rx/cpu.c +1 -1
@@ -192,7 +192,7 @@ static const struct SysemuCPUOps rx_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps rx_tcg_ops = { .initialize = rx_translate_init,
target/s390x/cpu.c +1 -1
@@ -322,7 +322,7 @@ static const Property s390x_cpu_properties[] = {#endif #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" void cpu_get_tb_cpu_state (CPUS390XState *env,vaddr *pc,uint64_t *cs_base,uint32_t *pflags)
target/s390x/tcg/mem_helper.c +1 -1
@@ -28,7 +28,7 @@#include "exec/exec-all.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "qemu/int128.h" #include "qemu/atomic128.h"
target/sh4/cpu.c +1 -1
@@ -247,7 +247,7 @@ static const struct SysemuCPUOps sh4_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps superh_tcg_ops = { .initialize = sh4_translate_init,
target/sparc/cpu.c +1 -1
@@ -992,7 +992,7 @@ static const struct SysemuCPUOps sparc_sysemu_ops = {#endif #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps sparc_tcg_ops = { .initialize = sparc_tcg_init,
target/tricore/cpu.c +1 -1
@@ -168,7 +168,7 @@ static const struct SysemuCPUOps tricore_sysemu_ops = { .get_phys_page_debug = tricore_cpu_get_phys_page_debug, }; -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps tricore_tcg_ops = { .initialize = tricore_tcg_init,
target/xtensa/cpu.c +1 -1
@@ -228,7 +228,7 @@ static const struct SysemuCPUOps xtensa_sysemu_ops = { };#endif -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" static const TCGCPUOps xtensa_tcg_ops = { .initialize = xtensa_translate_init,
Signature · 1 line
2.47.1
Re: [PATCH 10/20] accel/tcg: Rename 'hw/core/tcg-cpu-ops.h' -> 'accel/tcg/cpu-ops.h'
Quoted 80 lines · Philippe Mathieu-Daudé
TCGCPUOps structure makes more sense in the accelerator context rather than hardware emulation. Move it under the accel/tcg/ scope.
Mechanical change doing:
$ sed -i -e 's,hw/core/tcg-cpu-ops.h,accel/tcg/cpu-ops.h,g' \ $(git grep -l hw/core/tcg-cpu-ops.h)Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 2 +- include/{hw/core/tcg-cpu-ops.h => accel/tcg/cpu-ops.h} | 0 accel/tcg/cpu-exec.c | 4 ++-- accel/tcg/cputlb.c | 2 +- accel/tcg/translate-all.c | 2 +- accel/tcg/user-exec.c | 2 +- accel/tcg/watchpoint.c | 2 +- bsd-user/signal.c | 2 +- hw/mips/jazz.c | 2 +- linux-user/signal.c | 2 +- system/physmem.c | 2 +- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/arm/tcg/cpu-v7m.c | 2 +- target/arm/tcg/cpu32.c | 2 +- target/arm/tcg/mte_helper.c | 2 +- target/arm/tcg/sve_helper.c | 2 +- target/avr/cpu.c | 2 +- target/avr/helper.c | 2 +- target/hexagon/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/tcg/mem_helper.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-)rename
include/{hw/core/tcg-cpu-ops.h=>accel/tcg/cpu-ops.h} (100%)MAINTAINERS +1
-1@@ -175,7 +175,7 @@ F: include/exec/helper-info.c.inc F: include/exec/page-protection.h F: include/system/cpus.h F: include/system/tcg.h -F: include/hw/core/tcg-cpu-ops.h +F: include/accel/tcg/cpu-ops.h F: host/include/*/host/cpuinfo.h F: util/cpuinfo-*.c F: include/tcg/include/accel/tcg/cpu-ops.h renamed from include/hw/core/tcg-cpu-ops.h +0
-0accel/tcg/cpu-exec.c +1
-1@@ -22,7 +22,7 @@#include "qapi/error.h" #include "qapi/type-helpers.h" #include "hw/core/cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "trace.h" #include "disas/disas.h" #include "exec/cpu-common.h"
accel/tcg/cpu-exec.c line 42
Quoted 5 lines
accel/tcg/cpu-exec.c +1
-1@@ -39,7 +39,7 @@#include "exec/replay-core.h" #include "system/tcg.h" #include "exec/helper-proto-common.h" -#include "tb-jmp-cache.h" +//#include "tb-jmp-cache.h"
What's this?
r~
Richard Henderson
Reviewed-byRe: [PATCH 10/20] accel/tcg: Rename 'hw/core/tcg-cpu-ops.h' -> 'accel/tcg/cpu-ops.h'
Quoted 80 lines · Richard Henderson
Quoted 79 lines · Philippe Mathieu-Daudé
TCGCPUOps structure makes more sense in the accelerator context rather than hardware emulation. Move it under the accel/tcg/ scope.
Mechanical change doing:
$ sed -i -e 's,hw/core/tcg-cpu-ops.h,accel/tcg/cpu-ops.h,g' \
$(git grep -lhw/core/tcg-cpu-ops.h)Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
MAINTAINERS | 2 +-include/{hw/core/tcg-cpu-ops.h=>accel/tcg/cpu-ops.h} | 0 accel/tcg/cpu-exec.c | 4 ++-- accel/tcg/cputlb.c | 2 +- accel/tcg/translate-all.c | 2 +- accel/tcg/user-exec.c | 2 +- accel/tcg/watchpoint.c | 2 +- bsd-user/signal.c | 2 +- hw/mips/jazz.c | 2 +- linux-user/signal.c | 2 +- system/physmem.c | 2 +- target/alpha/cpu.c | 2 +- target/arm/cpu.c | 2 +- target/arm/tcg/cpu-v7m.c | 2 +- target/arm/tcg/cpu32.c | 2 +- target/arm/tcg/mte_helper.c | 2 +- target/arm/tcg/sve_helper.c | 2 +- target/avr/cpu.c | 2 +- target/avr/helper.c | 2 +- target/hexagon/cpu.c | 2 +- target/hppa/cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/loongarch/cpu.c | 2 +- target/m68k/cpu.c | 2 +- target/microblaze/cpu.c | 2 +- target/mips/cpu.c | 2 +- target/openrisc/cpu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/cpu.c | 2 +- target/s390x/tcg/mem_helper.c | 2 +- target/sh4/cpu.c | 2 +- target/sparc/cpu.c | 2 +- target/tricore/cpu.c | 2 +- target/xtensa/cpu.c | 2 +-36 files changed, 36 insertions(+), 36 deletions(-)rename
include/{hw/core/tcg-cpu-ops.h=>accel/tcg/cpu-ops.h} (100%)MAINTAINERS +0
-0@@ -175,7 +175,7 @@ F: include/exec/helper-info.c.incF:
include/exec/page-protection.h
F:include/system/cpus.h
F:include/system/tcg.hMAINTAINERS +1
-1-F: include/hw/core/tcg-cpu-ops.h +F: include/accel/tcg/cpu-ops.hF:
host/include/*/host/cpuinfo.h
F:util/cpuinfo-*.c
F:include/tcg/include/accel/tcg/cpu-ops.h renamed from include/hw/core/tcg-cpu-ops.h +0
-0accel/tcg/cpu-exec.c +1
-1@@ -22,7 +22,7 @@ #include "qapi/error.h" #include "qapi/type-helpers.h" #include "hw/core/cpu.h" -#include "hw/core/tcg-cpu-ops.h" +#include "accel/tcg/cpu-ops.h" #include "trace.h" #include "disas/disas.h" #include "exec/cpu-common.h"
Quoted 8 lines
accel/tcg/cpu-exec.c line 42
Quoted 6 lines
accel/tcg/cpu-exec.c +1
-1@@ -39,7 +39,7 @@ #include "exec/replay-core.h" #include "system/tcg.h" #include "exec/helper-proto-common.h" -#include "tb-jmp-cache.h" +//#include "tb-jmp-cache.h" What's this?
Aside from this,
r~
PATCH 11/20 accel: Rename 'hw/core/accel-cpu.h' -> 'accel/accel-cpu-target.h'
In reply to Philippe Mathieu-DaudéAccelCPUClass is for accelerator to initialize target specific features of a vCPU. Not really related to hardware emulation, rename "hw/core/accel-cpu.h" as "accel/accel-cpu-target.h" (using the explicit -target suffix).
More importantly, target specific header often access the target specific definitions which are in each target/FOO/cpu.h header, usually included generically as "cpu.h" relative to target/FOO/. However, there is already a "cpu.h" in hw/core/ which takes precedence. This change allows "accel-cpu-target.h" to include a target "cpu.h".
Mechanical change doing:
$ git mv include/hw/core/accel-cpu.h \
include/accel/accel-cpu-target.h
$ sed -i -e 's,hw/core/accel-cpu.h,accel/accel-cpu-target.h,' \
$(git grep -l hw/core/accel-cpu.h)and renaming header guard 'ACCEL_CPU_TARGET_H'.
---
MAINTAINERS | 2 +-
include/{hw/core/accel-cpu.h => accel/accel-cpu-target.h} | 4 ++--
accel/accel-target.c | 2 +-
cpu-target.c | 2 +-
target/i386/hvf/hvf-cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 2 +-
target/i386/tcg/tcg-cpu.c | 2 +-
target/ppc/kvm.c | 2 +-
target/riscv/kvm/kvm-cpu.c | 2 +-
target/riscv/tcg/tcg-cpu.c | 2 +-
10 files changed, 11 insertions(+), 11 deletions(-)
rename include/{hw/core/accel-cpu.h => accel/accel-cpu-target.h} (95%)MAINTAINERS +1 -1
@@ -499,7 +499,7 @@ R: Paolo Bonzini <[email protected]> S: Maintained F: include/qemu/accel.h F: include/system/accel-*.h -F: include/hw/core/accel-cpu.h +F: include/accel/accel-cpu-target.h F: accel/accel-*.c F: accel/Makefile.objs F: accel/stubs/Makefile.objs
include/accel/accel-cpu-target.h renamed from include/hw/core/accel-cpu.h +2 -2
@@ -8,8 +8,8 @@* See the COPYING file in the top-level directory. */ -#ifndef ACCEL_CPU_H -#define ACCEL_CPU_H +#ifndef ACCEL_CPU_TARGET_H +#define ACCEL_CPU_TARGET_H /* * This header is used to define new accelerator-specific target-specific
accel/accel-target.c +1 -1
@@ -27,7 +27,7 @@#include "qemu/accel.h" #include "cpu.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #ifndef CONFIG_USER_ONLY #include "accel-system.h"
cpu-target.c +1 -1
@@ -44,7 +44,7 @@#include "exec/tb-flush.h" #include "exec/translation-block.h" #include "exec/log.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include "trace/trace-root.h" #include "qemu/accel.h"
target/i386/hvf/hvf-cpu.c +1 -1
@@ -14,7 +14,7 @@#include "system/system.h" #include "hw/boards.h" #include "system/hvf.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include "hvf-i386.h" static void hvf_cpu_max_instance_init (X86CPU *cpu)
target/i386/kvm/kvm-cpu.c +1 -1
@@ -15,7 +15,7 @@#include "hw/boards.h" #include "kvm_i386.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" static void kvm_set_guest_phys_bits (CPUState *cs) {
target/i386/tcg/tcg-cpu.c +1 -1
@@ -21,7 +21,7 @@#include "cpu.h" #include "helper-tcg.h" #include "qemu/accel.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include "exec/translation-block.h" #include "tcg-cpu.h"
target/ppc/kvm.c +1 -1
@@ -49,7 +49,7 @@#include "elf.h" #include "system/kvm_int.h" #include "system/kvm.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include CONFIG_DEVICES
target/riscv/kvm/kvm-cpu.c +1 -1
@@ -32,7 +32,7 @@#include "system/kvm_int.h" #include "cpu.h" #include "trace.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include "hw/pci/pci.h" #include "exec/memattrs.h" #include "exec/address-spaces.h"
target/riscv/tcg/tcg-cpu.c +1 -1
@@ -30,7 +30,7 @@#include "qemu/accel.h" #include "qemu/error-report.h" #include "qemu/log.h" -#include "hw/core/accel-cpu.h" +#include "accel/accel-cpu-target.h" #include "accel/tcg/cpu-ops.h" #include "tcg/tcg.h" #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.47.1
Re: [PATCH 11/20] accel: Rename 'hw/core/accel-cpu.h' -> 'accel/accel-cpu-target.h'
Quoted 34 lines · Philippe Mathieu-Daudé
AccelCPUClass is for accelerator to initialize target specific features of a vCPU. Not really related to hardware emulation, rename "
hw/core/accel-cpu.h" as "accel/accel-cpu-target.h" (using the explicit -target suffix).More importantly, target specific header often access the target specific definitions which are in each
target/FOO/cpu.hheader, usually included generically as "cpu.h" relative to target/FOO/. However, there is already a "cpu.h" in hw/core/ which takes precedence. This change allows "accel-cpu-target.h" to include a target "cpu.h".Mechanical change doing:
$ git mv include/hw/core/accel-cpu.h \ include/accel/accel-cpu-target.h $ sed -i -e 's,hw/core/accel-cpu.h,accel/accel-cpu-target.h,' \ $(git grep -l hw/core/accel-cpu.h)and renaming header guard '
ACCEL_CPU_TARGET_H'.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- MAINTAINERS | 2 +- include/{hw/core/accel-cpu.h => accel/accel-cpu-target.h} | 4 ++-- accel/accel-target.c | 2 +- cpu-target.c | 2 +- target/i386/hvf/hvf-cpu.c | 2 +- target/i386/kvm/kvm-cpu.c | 2 +- target/i386/tcg/tcg-cpu.c | 2 +- target/ppc/kvm.c | 2 +- target/riscv/kvm/kvm-cpu.c | 2 +- target/riscv/tcg/tcg-cpu.c | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-)
Quoted 1 line
rename
include/{hw/core/accel-cpu.h=>accel/accel-cpu-target.h} (95%)
r~
PATCH 12/20 accel/accel-cpu-target.h: Include missing 'cpu.h' header
In reply to Philippe Mathieu-DaudéCPU_RESOLVING_TYPE is declared per target in "cpu.h". Include it (along with "qom/object.h") to avoid when moving code around:
include/accel/accel-cpu-target.h:26:50: error: expected ')'
26 | DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU)
| ^
include/accel/accel-cpu-target.h:23:33: note: expanded from macro 'TYPE_ACCEL_CPU'
23 | #define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE
| ^
include/accel/accel-cpu-target.h:26:1: note: to match this '('
26 | DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU)
| ^
include/qom/object.h:196:14: note: expanded from macro 'DECLARE_CLASS_CHECKERS'
196 | { return OBJECT_GET_CLASS(ClassType, obj, TYPENAME); } \
| ^
include/qom/object.h:558:5: note: expanded from macro 'OBJECT_GET_CLASS'
558 | OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name)
| ^
include/qom/object.h:544:74: note: expanded from macro 'OBJECT_CLASS_CHECK'
544 | ((class_type *)object_class_dynamic_cast_assert(OBJECT_CLASS(class), (name), \
| ^--- include/accel/accel-cpu-target.h | 3 +++ 1 file changed, 3 insertions(+)
include/accel/accel-cpu-target.h +3 -0
@@ -20,6 +20,9 @@* subclasses in target/, or the accel implementation itself in accel/ */ +#include "qom/object.h" +#include "cpu.h" +#define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE#define ACCEL_CPU_NAME (name) (name "-" TYPE_ACCEL_CPU)typedef struct AccelCPUClass AccelCPUClass ;
Signature · 1 line
2.47.1
Re: [PATCH 12/20] accel/accel-cpu-target.h: Include missing 'cpu.h' header
Quoted 22 lines · Philippe Mathieu-Daudé
CPU_RESOLVING_TYPEis declared per target in "cpu.h". Include it (along with "qom/object.h") to avoid when moving code around:include/accel/accel-cpu-target.h:26:50: error: expected ')' 26 | DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) | ^ include/accel/accel-cpu-target.h:23:33: note: expanded from macro 'TYPE_ACCEL_CPU' 23 | #define TYPE_ACCEL_CPU "accel-" CPU_RESOLVING_TYPE | ^ include/accel/accel-cpu-target.h:26:1: note: to match this '(' 26 | DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) | ^ include/qom/object.h:196:14: note: expanded from macro 'DECLARE_CLASS_CHECKERS' 196 | { return OBJECT_GET_CLASS(ClassType, obj, TYPENAME); } \ | ^ include/qom/object.h:558:5: note: expanded from macro 'OBJECT_GET_CLASS' 558 | OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name) | ^ include/qom/object.h:544:74: note: expanded from macro 'OBJECT_CLASS_CHECK' 544 | ((class_type *)object_class_dynamic_cast_assert(OBJECT_CLASS(class), (name), \ | ^
Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/accel/accel-cpu-target.h | 3 +++ 1 file changed, 3 insertions(+)
r~
PATCH 13/20 accel: Forward-declare AccelOpsClass in 'qemu/typedefs.h'
In reply to Philippe Mathieu-DaudéThe heavily imported "system/cpus.h" header includes "accel-ops.h" to get AccelOpsClass type declaration. Reduce headers pressure by forward declaring it in "qemu/typedefs.h", where we already declare the AccelCPUState type.
Reduce "system/cpus.h" inclusions by only including "system/accel-ops.h" when necessary.
--- include/qemu/typedefs.h | 1 + include/system/accel-ops.h | 1 - include/system/cpus.h | 2 -- accel/accel-system.c | 1 + accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-accel-ops.c | 1 + accel/qtest/qtest.c | 1 + accel/tcg/cpu-exec-common.c | 1 - accel/tcg/cpu-exec.c | 1 - accel/tcg/monitor.c | 1 - accel/tcg/tcg-accel-ops.c | 1 + accel/tcg/translate-all.c | 1 - accel/xen/xen-all.c | 1 + cpu-common.c | 1 - cpu-target.c | 1 + gdbstub/system.c | 1 + system/cpus.c | 1 + target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 19 files changed, 12 insertions(+), 8 deletions(-)
include/qemu/typedefs.h +1 -0
@@ -22,6 +22,7 @@* Please keep this list in case-insensitive alphabetical order. */ typedef struct AccelCPUState AccelCPUState ; +typedef struct AccelOpsClass AccelOpsClass ;typedef struct AccelState AccelState ;typedef struct AddressSpace AddressSpace ;typedef struct AioContext AioContext ;
include/system/accel-ops.h +0 -1
@@ -17,7 +17,6 @@#define TYPE_ACCEL_OPS "accel" ACCEL_OPS_SUFFIX#define ACCEL_OPS_NAME (name) (name "-" TYPE_ACCEL_OPS) -typedef struct AccelOpsClass AccelOpsClass ;DECLARE_CLASS_CHECKERS (AccelOpsClass,ACCEL_OPS ,TYPE_ACCEL_OPS )/**
include/system/cpus.h +0 -2
@@ -1,8 +1,6 @@#ifndef QEMU_CPUS_H #define QEMU_CPUS_H -#include "system/accel-ops.h" -/* register accel-specific operations */ void cpus_register_accel (const AccelOpsClass *i);
accel/accel-system.c +1 -0
@@ -26,6 +26,7 @@#include "qemu/osdep.h" #include "qemu/accel.h" #include "hw/boards.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "qemu/error-report.h" #include "accel-system.h"
accel/hvf/hvf-accel-ops.c +1 -0
@@ -54,6 +54,7 @@#include "exec/exec-all.h" #include "gdbstub/enums.h" #include "hw/boards.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "system/hvf.h" #include "system/hvf_int.h"
accel/kvm/kvm-accel-ops.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "system/accel-ops.h" #include "system/kvm.h" #include "system/kvm_int.h" #include "system/runstate.h"
accel/qtest/qtest.c +1 -0
@@ -18,6 +18,7 @@#include "qemu/option.h" #include "qemu/config-file.h" #include "qemu/accel.h" +#include "system/accel-ops.h" #include "system/qtest.h" #include "system/cpus.h" #include "qemu/guest-random.h"
accel/tcg/cpu-exec-common.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/osdep.h" #include "exec/log.h" -#include "system/cpus.h" #include "system/tcg.h" #include "qemu/plugin.h" #include "internal-common.h"
accel/tcg/cpu-exec.c +0 -1
@@ -33,7 +33,6 @@#include "qemu/rcu.h" #include "exec/log.h" #include "qemu/main-loop.h" -#include "system/cpus.h" #include "exec/cpu-all.h" #include "system/cpu-timers.h" #include "exec/replay-core.h"
accel/tcg/monitor.c +0 -1
@@ -13,7 +13,6 @@#include "qapi/type-helpers.h" #include "qapi/qapi-commands-machine.h" #include "monitor/monitor.h" -#include "system/cpus.h" #include "system/cpu-timers.h" #include "system/tcg.h" #include "tcg/tcg.h"
accel/tcg/tcg-accel-ops.c +1 -0
@@ -26,6 +26,7 @@*/ #include "qemu/osdep.h" +#include "system/accel-ops.h" #include "system/tcg.h" #include "system/replay.h" #include "system/cpu-timers.h"
accel/tcg/translate-all.c +0 -1
@@ -54,7 +54,6 @@#include "qemu/cacheinfo.h" #include "qemu/timer.h" #include "exec/log.h" -#include "system/cpus.h" #include "system/cpu-timers.h" #include "system/tcg.h" #include "qapi/error.h"
accel/xen/xen-all.c +1 -0
@@ -18,6 +18,7 @@#include "hw/xen/xen_igd.h" #include "chardev/char.h" #include "qemu/accel.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "system/xen.h" #include "system/runstate.h"
cpu-common.c +0 -1
@@ -21,7 +21,6 @@#include "qemu/main-loop.h" #include "exec/cpu-common.h" #include "hw/core/cpu.h" -#include "system/cpus.h" #include "qemu/lockable.h" #include "trace/trace-root.h"
cpu-target.c +1 -0
@@ -35,6 +35,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #endif +#include "system/accel-ops.h" #include "system/cpus.h" #include "system/tcg.h" #include "exec/tswap.h"
gdbstub/system.c +1 -0
@@ -19,6 +19,7 @@#include "gdbstub/commands.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "system/runstate.h" #include "system/replay.h"
system/cpus.c +1 -0
@@ -31,6 +31,7 @@#include "qapi/qapi-events-run-state.h" #include "qapi/qmp/qerror.h" #include "exec/gdbstub.h" +#include "system/accel-ops.h" #include "system/hw_accel.h" #include "exec/cpu-common.h" #include "qemu/thread.h"
target/i386/nvmm/nvmm-accel-ops.c +1 -0
@@ -10,6 +10,7 @@#include "qemu/osdep.h" #include "system/kvm_int.h" #include "qemu/main-loop.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "qemu/guest-random.h"
target/i386/whpx/whpx-accel-ops.c +1 -0
@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "system/kvm_int.h" #include "qemu/main-loop.h" +#include "system/accel-ops.h" #include "system/cpus.h" #include "qemu/guest-random.h"
Signature · 1 line
2.47.1
Re: [PATCH 13/20] accel: Forward-declare AccelOpsClass in 'qemu/typedefs.h'
Quoted 22 lines · Philippe Mathieu-Daudé
The heavily imported "
system/cpus.h" header includes "accel-ops.h" to get AccelOpsClass type declaration. Reduce headers pressure by forward declaring it in "qemu/typedefs.h", where we already declare the AccelCPUState type.Reduce "
system/cpus.h" inclusions by only including "system/accel-ops.h" when necessary.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/qemu/typedefs.h | 1 + include/system/accel-ops.h | 1 - include/system/cpus.h | 2 -- accel/accel-system.c | 1 + accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-accel-ops.c | 1 + accel/qtest/qtest.c | 1 + accel/tcg/cpu-exec-common.c | 1 - accel/tcg/cpu-exec.c | 1 - accel/tcg/monitor.c | 1 - accel/tcg/tcg-accel-ops.c | 1 + accel/tcg/translate-all.c | 1 -
Quoted 8 lines
accel/xen/xen-all.c | 1 + cpu-common.c | 1 - cpu-target.c | 1 + gdbstub/system.c | 1 + system/cpus.c | 1 + target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 19 files changed, 12 insertions(+), 8 deletions(-)
r~
PATCH 14/20 accel/tcg: Move cpu_memory_rw_debug() user implementation to user-exec.c
In reply to Philippe Mathieu-Daudécpu_memory_rw_debug() system implementation is defined in system/physmem.c. Move the user one to accel/tcg/user-exec.c to simplify cpu-target.c maintenance.
--- accel/tcg/user-exec.c | 92 +++++++++++++++++++++++++++++++++++++ cpu-target.c | 102 +----------------------------------------- 2 files changed, 94 insertions(+), 100 deletions(-)
accel/tcg/user-exec.c +92 -0
@@ -19,6 +19,8 @@#include "qemu/osdep.h" #include "accel/tcg/cpu-ops.h" #include "disas/disas.h" +#include "exec/vaddr.h" +#include "exec/tswap.h" #include "exec/exec-all.h" #include "tcg/tcg.h" #include "qemu/bitops.h"
@@ -35,6 +37,7 @@#include "internal-common.h" #include "internal-target.h" #include "tb-internal.h" +#include "qemu.h" __threaduintptr_t helper_retaddr;
@@ -969,6 +972,95 @@ static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr,return ret; } +/* physical memory access (slow version, mainly for debug) */ +int cpu_memory_rw_debug (CPUState *cpu,vaddr addr, +void *ptr,size_t len,bool is_write) +{ +int flags; +vaddr l, page; +void * p; +uint8_t *buf = ptr; +ssize_t written; +int ret =-1 ; +int fd =-1 ; + +while (len >0 ) { + page = addr &TARGET_PAGE_MASK ; + l = (page +TARGET_PAGE_SIZE ) - addr; +if (l > len) + l = len; + flags =page_get_flags (page); +if (!(flags &PAGE_VALID )) { + goto out_close; + } +if (is_write) { +if (flags &PAGE_WRITE ) { +/* XXX: this code should not depend on lock_user */ + p =lock_user (VERIFY_WRITE , addr, l,0 ); +if (!p) { + goto out_close; + } +memcpy (p, buf, l); +unlock_user (p, addr, l); + }else { +/* Bypass the host page protection using ptrace. */ +if (fd ==-1 ) { + fd =open ("/proc/self/mem" ,O_WRONLY ); +if (fd ==-1 ) { + goto out; + } + } +/* +* If there is a TranslationBlock and we weren't bypassing the +* host page protection, the memcpy() above would SEGV, +* ultimately leading to page_unprotect(). So invalidate the +* translations manually. Both invalidation and pwrite() must +* be under mmap_lock() in order to prevent the creation of +* another TranslationBlock in between. +*/ +mmap_lock (); +tb_invalidate_phys_range (addr, addr + l -1 ); + written =pwrite (fd, buf, l, + (off_t )(uintptr_t )g2h_untagged (addr)); +mmap_unlock (); +if (written != l) { + goto out_close; + } + } + }else if (flags &PAGE_READ ) { +/* XXX: this code should not depend on lock_user */ + p =lock_user (VERIFY_READ , addr, l,1 ); +if (!p) { + goto out_close; + } +memcpy (buf, p, l); +unlock_user (p, addr,0 ); + }else { +/* Bypass the host page protection using ptrace. */ +if (fd ==-1 ) { + fd =open ("/proc/self/mem" ,O_RDONLY ); +if (fd ==-1 ) { + goto out; + } + } +if (pread (fd, buf, l, + (off_t )(uintptr_t )g2h_untagged (addr)) != l) { + goto out_close; + } + } + len -= l; + buf += l; + addr += l; + } + ret =0 ; +out_close: +if (fd !=-1 ) { +close (fd); + } +out: +return ret; +} +#include "ldst_atomicity.c.inc" static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi,
cpu-target.c +2 -100
133 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH 14/20] accel/tcg: Move cpu_memory_rw_debug() user implementation to user-exec.c
Quoted 24 lines · Philippe Mathieu-Daudé
cpu_memory_rw_debug()system implementation is defined insystem/physmem.c. Move the user one toaccel/tcg/user-exec.cto simplifycpu-target.cmaintenance.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/user-exec.c | 92 +++++++++++++++++++++++++++++++++++++ cpu-target.c | 102 +----------------------------------------- 2 files changed, 94 insertions(+), 100 deletions(-)accel/tcg/user-exec.c +2
-0@@ -19,6 +19,8 @@#include "qemu/osdep.h" #include "accel/tcg/cpu-ops.h" #include "disas/disas.h" +#include "exec/vaddr.h" +#include "exec/tswap.h" #include "exec/exec-all.h" #include "tcg/tcg.h" #include "qemu/bitops.h"
accel/tcg/user-exec.c line 40
Quoted 4 lines
accel/tcg/user-exec.c +1
-0@@ -35,6 +37,7 @@#include "internal-common.h" #include "internal-target.h" #include "tb-internal.h" +#include "qemu.h"
What is required from *-user/qemu.h?
We really should not be including that in accel/tcg/.
accel/tcg/user-exec.c static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr, · line 999
Quoted 3 lines
accel/tcg/user-exec.c +3
-0+if (flags &PAGE_WRITE ) { +/* XXX: this code should not depend on lock_user */ + p =lock_user (VERIFY_WRITE , addr, l,0 );
Ah, here it is, complete with comment.
Indeed, I don't think lock_user is required at all. page_get_flags() and g2h() are sufficient.
accel/tcg/user-exec.c static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr, · line 1025
Quoted 5 lines
accel/tcg/user-exec.c +5
-0+mmap_lock (); +tb_invalidate_phys_range (addr, addr + l -1 ); + written =pwrite (fd, buf, l, + (off_t )(uintptr_t )g2h_untagged (addr)); +mmap_unlock ();
We probably want to own mmap_lock for the entire function.
r~
PATCH 15/20 cpus: Fix style in cpu-target.c
In reply to Philippe Mathieu-DaudéFix style on code we are going to modify.
--- cpu-target.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
cpu-target.c +6 -3
@@ -47,12 +47,15 @@ static int cpu_common_post_load(void *opaque, int version_id) {CPUState *cpu = opaque; -/* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the -version_id is increased. */ +/* +* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the +* version_id is increased. +*/ cpu->interrupt_request &= ~0x01 ;tlb_flush (cpu); -/* loadvm has just updated the content of RAM, bypassing the +/* +* loadvm has just updated the content of RAM, bypassing the * usual mechanisms that ensure we flush TBs for writes to * memory we've translated code from. So we must flush all TBs, * which will now be stale.
Signature · 1 line
2.47.1
Re: [PATCH 15/20] cpus: Fix style in cpu-target.c
Quoted 20 lines · Philippe Mathieu-Daudé
Fix style on code we are going to modify.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- cpu-target.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)cpu-target.c +3
-2@@ -47,12 +47,15 @@ static int cpu_common_post_load(void *opaque, int version_id) {CPUState *cpu = opaque; -/* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the -version_id is increased. */ +/* +* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the +* version_id is increased.
cpu-target.c static int cpu_common_post_load(void *opaque, int version_id) · line 61
Quoted 10 lines
cpu-target.c +3
-1+*/ cpu->interrupt_request &= ~0x01 ;tlb_flush (cpu); -/* loadvm has just updated the content of RAM, bypassing the +/* +* loadvm has just updated the content of RAM, bypassing the * usual mechanisms that ensure we flush TBs for writes to * memory we've translated code from. So we must flush all TBs, * which will now be stale.
r~
PATCH 16/20 cpus: Restrict cpu_common_post_load() code to TCG
In reply to Philippe Mathieu-DaudéCPU_INTERRUPT_EXIT was removed in commit 3098dba01c7 ("Use a dedicated function to request exit from execution loop"), tlb_flush() and tb_flush() are related to TCG accelerator.
--- cpu-target.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
cpu-target.c +19 -14
@@ -45,22 +45,27 @@#ifndef CONFIG_USER_ONLY static int cpu_common_post_load (void *opaque,int version_id) { -CPUState *cpu = opaque; +#ifdef CONFIG_TCG +if (tcg_enabled ()) { +CPUState *cpu = opaque; -/* -* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the -* version_id is increased. -*/ - cpu->interrupt_request &= ~0x01 ; -tlb_flush (cpu); +/* +* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the +* version_id is increased. +*/ + cpu->interrupt_request &= ~0x01 ; -/* -* loadvm has just updated the content of RAM, bypassing the -* usual mechanisms that ensure we flush TBs for writes to -* memory we've translated code from. So we must flush all TBs, -* which will now be stale. -*/ -tb_flush (cpu); +tlb_flush (cpu); + +/* +* loadvm has just updated the content of RAM, bypassing the +* usual mechanisms that ensure we flush TBs for writes to +* memory we've translated code from. So we must flush all TBs, +* which will now be stale. +*/ +tb_flush (cpu); + } +#endif return 0 ; }
Signature · 1 line
2.47.1
Re: [PATCH 16/20] cpus: Restrict cpu_common_post_load() code to TCG
Quoted 15 lines · Philippe Mathieu-Daudé
CPU_INTERRUPT_EXITwas removed in commit3098dba01c7("Use a dedicated function to request exit from execution loop"),tlb_flush()andtb_flush()are related to TCG accelerator.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- cpu-target.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)cpu-target.c +0
-0
cpu-target.c line 49
Quoted 6 lines
cpu-target.c +2
-1@@ -45,22 +45,27 @@#ifndef CONFIG_USER_ONLY static int cpu_common_post_load (void *opaque,int version_id) { -CPUState *cpu = opaque; +#ifdef CONFIG_TCG +if (tcg_enabled ()) {
Why do you need both ifdef and tcg_enabled()? I would have thought just tcg_enabled().
Are there declarations that are (unnecessarily?) protected?
r~
Re: [PATCH 16/20] cpus: Restrict cpu_common_post_load() code to TCG
Quoted 25 lines · Richard Henderson
Quoted 15 lines · Philippe Mathieu-Daudé
CPU_INTERRUPT_EXITwas removed in commit3098dba01c7("Use a dedicated function to request exit from execution loop"),tlb_flush()andtb_flush()are related to TCG accelerator.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
cpu-target.c| 33 +++++++++++++++++++--------------1 file changed, 19 insertions(+), 14 deletions(-)cpu-target.c +0
-0cpu-target.c line 49
Quoted 6 lines
cpu-target.c +2
-1@@ -45,22 +45,27 @@ #ifndef CONFIG_USER_ONLY static int cpu_common_post_load(void *opaque, int version_id) { - CPUState *cpu = opaque; +#ifdef CONFIG_TCG + if (tcg_enabled()) {Why do you need both ifdef and tcg_enabled()? I would have thought just
tcg_enabled().
Quoted 1 line
Are there declarations that are (unnecessarily?) protected?
No, you are right, tcg_enabled() is sufficient, I don't remember why I added the #ifdef.
Could I include your R-b tag without the #ifdef lines?
Richard Henderson
Reviewed-byRe: [PATCH 16/20] cpus: Restrict cpu_common_post_load() code to TCG
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 25 lines · Richard Henderson
Quoted 15 lines · Philippe Mathieu-Daudé
CPU_INTERRUPT_EXITwas removed in commit3098dba01c7("Use a dedicated function to request exit from execution loop"),tlb_flush()andtb_flush()are related to TCG accelerator.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
cpu-target.c| 33 +++++++++++++++++++--------------1 file changed, 19 insertions(+), 14 deletions(-)cpu-target.c +0
-0cpu-target.c line 49
Quoted 6 lines
cpu-target.c +2
-1@@ -45,22 +45,27 @@ #ifndef CONFIG_USER_ONLY static int cpu_common_post_load(void *opaque, int version_id) { - CPUState *cpu = opaque; +#ifdef CONFIG_TCG + if (tcg_enabled()) {Why do you need both ifdef and tcg_enabled()? I would have thought just
tcg_enabled().
Quoted 6 lines
Quoted 1 line
Are there declarations that are (unnecessarily?) protected?
No, you are right,
tcg_enabled()is sufficient, I don't remember why I added the #ifdef.Could I include your R-b tag without the #ifdef lines?
Yes.
r~
PATCH 17/20 cpus: Have cpu_class_init_props() per user / system emulation
In reply to Philippe Mathieu-DaudéRather than maintaining a mix of system / user code for CPU class properties, move system properties to cpu-system.c and user ones to the new cpu-user.c unit.
--- cpu-target.c | 58 -------------------------------------------- hw/core/cpu-system.c | 40 ++++++++++++++++++++++++++++++ hw/core/cpu-user.c | 27 +++++++++++++++++++++ hw/core/meson.build | 5 +++- 4 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 hw/core/cpu-user.c
cpu-target.c +0 -58
@@ -19,15 +19,12 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "hw/qdev-core.h" -#include "hw/qdev-properties.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "migration/vmstate.h" #ifndef CONFIG_USER_ONLY #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" -#include "exec/memory.h" #endif #include "system/accel-ops.h" #include "system/cpus.h"
@@ -179,61 +176,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)accel_cpu_common_unrealize (cpu); } -/* -* This can't go in hw/core/cpu.c because that file is compiled only -* once for both user-mode and system builds. -*/ -static const Property cpu_common_props[] = { -#ifdef CONFIG_USER_ONLY -/* -* Create a property for the user-only object, so users can -* adjust prctl(PR_SET_UNALIGN) from the command-line. -* Has no effect if the target does not support the feature. -*/ -DEFINE_PROP_BOOL ("prctl-unalign-sigbus" , CPUState, - prctl_unalign_sigbus, false), -#else -/* -* Create a memory property for system CPU object, so users can -* wire up its memory. The default if no link is set up is to use -* the system address space. -*/ -DEFINE_PROP_LINK ("memory" , CPUState, memory,TYPE_MEMORY_REGION , - MemoryRegion *), -#endif -}; - -#ifndef CONFIG_USER_ONLY -static bool cpu_get_start_powered_off (Object *obj,Error **errp) -{ -CPUState *cpu =CPU (obj); -return cpu->start_powered_off; -} - -static void cpu_set_start_powered_off (Object *obj,bool value,Error **errp) -{ -CPUState *cpu =CPU (obj); - cpu->start_powered_off = value; -} -#endif - -void cpu_class_init_props (DeviceClass *dc) -{ -#ifndef CONFIG_USER_ONLY -ObjectClass *oc =OBJECT_CLASS (dc); - -/* -* We can't use DEFINE_PROP_BOOL in the Property array for this -* property, because we want this to be settable after realize. -*/ -object_class_property_add_bool (oc,"start-powered-off" , - cpu_get_start_powered_off, - cpu_set_start_powered_off); -#endif - -device_class_set_props (dc, cpu_common_props); -} -void cpu_exec_initfn (CPUState *cpu) {#ifndef CONFIG_USER_ONLY
hw/core/cpu-system.c +40 -0
@@ -20,7 +20,10 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "exec/memory.h" #include "exec/tswap.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" #include "hw/core/sysemu-cpu-ops.h" bool cpu_paging_enabled (const CPUState *cpu)
@@ -142,3 +145,40 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) }return res; } + +static const Property cpu_system_props[] = { +/* +* Create a memory property for system CPU object, so users can +* wire up its memory. The default if no link is set up is to use +* the system address space. +*/ +DEFINE_PROP_LINK ("memory" , CPUState, memory,TYPE_MEMORY_REGION , + MemoryRegion *), +}; + +static bool cpu_get_start_powered_off (Object *obj,Error **errp) +{ +CPUState *cpu =CPU (obj); +return cpu->start_powered_off; +} + +static void cpu_set_start_powered_off (Object *obj,bool value,Error **errp) +{ +CPUState *cpu =CPU (obj); + cpu->start_powered_off = value; +} + +void cpu_class_init_props (DeviceClass *dc) +{ +ObjectClass *oc =OBJECT_CLASS (dc); + +/* +* We can't use DEFINE_PROP_BOOL in the Property array for this +* property, because we want this to be settable after realize. +*/ +object_class_property_add_bool (oc,"start-powered-off" , + cpu_get_start_powered_off, + cpu_set_start_powered_off); + +device_class_set_props (dc, cpu_system_props); +}
hw/core/cpu-user.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* QEMU CPU model (user specific) +* +* Copyright (c) Linaro, Ltd. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" +#include "hw/core/cpu.h" + +static const Property cpu_user_props[] = { +/* +* Create a property for the user-only object, so users can +* adjust prctl(PR_SET_UNALIGN) from the command-line. +* Has no effect if the target does not support the feature. +*/ +DEFINE_PROP_BOOL ("prctl-unalign-sigbus" , CPUState, + prctl_unalign_sigbus, false), +}; + +void cpu_class_init_props (DeviceClass *dc) +{ +device_class_set_props (dc, cpu_user_props); +}
hw/core/meson.build +4 -1
@@ -46,4 +46,7 @@ system_ss.add(files( 'vm-change-state-handler.c', 'clock-vmstate.c', )) -user_ss.add(files('qdev-user.c')) +user_ss.add(files( + 'cpu-user.c', + 'qdev-user.c', +))
Signature · 1 line
2.47.1
Re: [PATCH 17/20] cpus: Have cpu_class_init_props() per user / system emulation
Quoted 4 lines · Philippe Mathieu-Daudé
Rather than maintaining a mix of system / user code for CPU class properties, move system properties to
cpu-system.cand user ones to the newcpu-user.cunit.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- cpu-target.c | 58 -------------------------------------------- hw/core/cpu-system.c | 40 ++++++++++++++++++++++++++++++ hw/core/cpu-user.c | 27 +++++++++++++++++++++ hw/core/meson.build | 5 +++- 4 files changed, 71 insertions(+), 59 deletions(-)create mode 100644
hw/core/cpu-user.c
r~
PATCH 18/20 cpus: Have cpu_exec_initfn() per user / system emulation
In reply to Philippe Mathieu-DaudéSlighly simplify cpu-target.c again by extracting cpu_exec_initfn() to cpu-{system,user}.c, adding an empty stub for user emulation.
---
Good enough for now...
--- cpu-target.c | 9 --------- hw/core/cpu-system.c | 7 +++++++ hw/core/cpu-user.c | 5 +++++ 3 files changed, 12 insertions(+), 9 deletions(-)
cpu-target.c +0 -9
@@ -24,7 +24,6 @@#include "migration/vmstate.h" #ifndef CONFIG_USER_ONLY #include "hw/core/sysemu-cpu-ops.h" -#include "exec/address-spaces.h" #endif #include "system/accel-ops.h" #include "system/cpus.h"
@@ -176,14 +175,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)accel_cpu_common_unrealize (cpu); } -void cpu_exec_initfn (CPUState *cpu) -{ -#ifndef CONFIG_USER_ONLY - cpu->memory =get_system_memory (); -object_ref (OBJECT (cpu->memory)); -#endif -} -char *cpu_model_from_type (const char *typename) {const char *suffix ="-" CPU_RESOLVING_TYPE ;
hw/core/cpu-system.c +7 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/tswap.h" #include "hw/qdev-core.h"
@@ -182,3 +183,9 @@ void cpu_class_init_props(DeviceClass *dc)device_class_set_props (dc, cpu_system_props); } + +void cpu_exec_initfn (CPUState *cpu) +{ + cpu->memory =get_system_memory (); +object_ref (OBJECT (cpu->memory)); +}
hw/core/cpu-user.c +5 -0
@@ -25,3 +25,8 @@ void cpu_class_init_props(DeviceClass *dc) {device_class_set_props (dc, cpu_user_props); } + +void cpu_exec_initfn (CPUState *cpu) +{ +/* nothing to do */ +}
Signature · 1 line
2.47.1
Re: [PATCH 18/20] cpus: Have cpu_exec_initfn() per user / system emulation
Quoted 11 lines · Philippe Mathieu-Daudé
Slighly simplify
cpu-target.cagain by extractingcpu_exec_initfn()to cpu-{system,user}.c, adding an empty stub for user emulation.Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Good enough for now...--- cpu-target.c | 9 --------- hw/core/cpu-system.c | 7 +++++++ hw/core/cpu-user.c | 5 +++++ 3 files changed, 12 insertions(+), 9 deletions(-)
r~
PATCH 19/20 cpus: Register VMState per user / system emulation
In reply to Philippe Mathieu-DaudéSimplify cpu-target.c by extracting mixed vmstate code into the cpu_vmstate_register() / cpu_vmstate_unregister() helpers, implemented in cpu-user.c and cpu-system.c.
---
XXX: tlb_flush() temporary declared manually.
Only 2 more CONFIG_USER_ONLY to go.
--- include/hw/core/cpu.h | 2 + cpu-target.c | 122 +---------------------------------------- hw/core/cpu-system.c | 123 ++++++++++++++++++++++++++++++++++++++++++ hw/core/cpu-user.c | 12 +++++ 4 files changed, 139 insertions(+), 120 deletions(-)
include/hw/core/cpu.h +2 -0
@@ -1163,6 +1163,8 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)/* $(top_srcdir)/cpu.c */ void cpu_class_init_props (DeviceClass *dc);void cpu_exec_initfn (CPUState *cpu); +void cpu_vmstate_register (CPUState *cpu); +void cpu_vmstate_unregister (CPUState *cpu);bool cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu);void cpu_exec_reset_hold (CPUState *cpu);
cpu-target.c +2 -120
150 lines not on this page · raw message
hw/core/cpu-system.c +123 -0
136 lines not on this page · raw message
hw/core/cpu-user.c +12 -0
@@ -10,6 +10,7 @@#include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/core/cpu.h" +#include "migration/vmstate.h" static const Property cpu_user_props[] = {/*
@@ -30,3 +31,14 @@ void cpu_exec_initfn(CPUState *cpu) {/* nothing to do */ } + +void cpu_vmstate_register (CPUState *cpu) +{ +assert (qdev_get_vmsd (DEVICE (cpu)) ==NULL || +qdev_get_vmsd (DEVICE (cpu))->unmigratable); +} + +void cpu_vmstate_unregister (CPUState *cpu) +{ +/* nothing to do */ +}
Signature · 1 line
2.47.1
Re: [PATCH 19/20] cpus: Register VMState per user / system emulation
Quoted 9 lines · Philippe Mathieu-Daudé
Simplify
cpu-target.cby extracting mixed vmstate code into thecpu_vmstate_register()/cpu_vmstate_unregister()helpers, implemented incpu-user.candcpu-system.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
XXX:tlb_flush()temporary declared manually.Only 2 more
CONFIG_USER_ONLYto go.
Quoted 11 lines
hw/core/cpu-system.c +1
-0@@ -22,10 +22,21 @@#include "qapi/error.h" #include "exec/address-spaces.h" #include "exec/memory.h" +#include "exec/tb-flush.h" #include "exec/tswap.h" #include "hw/qdev-core.h" #include "hw/qdev-properties.h" #include "hw/core/sysemu-cpu-ops.h"
hw/core/cpu-system.c line 39
Quoted 10 lines
hw/core/cpu-system.c +10
-0+#include "migration/vmstate.h" +#include "system/tcg.h" + +/* +* XXX this series plan is to be applied on top on my exec/cputlb rework series, +* then tlb_flush() won't be declared target-specific in exec-all.h. +* Meanwhile, declare locally. +* XXX +*/ +void tlb_flush (CPUState *cs);
Ack.
r~
PATCH 20/20 cpus: Build cpu_exec_[un]realizefn() methods once
In reply to Philippe Mathieu-DaudéNow that cpu_exec_realizefn() and cpu_exec_unrealizefn() methods don't use any target specific definition anymore, we can move them to cpu-common.c to be able to build them once.
---
Eventually they'll be absorbed within cpu_common_[un]realizefn().
--- cpu-target.c | 30 ------------------------------ hw/core/cpu-common.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 30 deletions(-)
cpu-target.c +0 -30
@@ -19,43 +19,13 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "system/accel-ops.h" #include "system/cpus.h" #include "exec/replay-core.h" -#include "exec/cpu-common.h" #include "exec/log.h" #include "accel/accel-cpu-target.h" #include "trace/trace-root.h" -#include "qemu/accel.h" -#include "hw/core/cpu.h" - -bool cpu_exec_realizefn (CPUState *cpu,Error **errp) -{ -if (!accel_cpu_common_realize (cpu, errp)) { -return false; - } - -/* Wait until cpu initialization complete before exposing cpu. */ -cpu_list_add (cpu); - -cpu_vmstate_register (cpu); - -return true; -} - -void cpu_exec_unrealizefn (CPUState *cpu) -{ -cpu_vmstate_unregister (cpu); - -cpu_list_remove (cpu); -/* -* Now that the vCPU has been removed from the RCU list, we can call -* accel_cpu_common_unrealize, which may free fields using call_rcu. -*/ -accel_cpu_common_unrealize (cpu); -}char *cpu_model_from_type (const char *typename) {
hw/core/cpu-common.c +26 -0
@@ -193,6 +193,20 @@ static void cpu_common_parse_features(const char *typename, char *features, } } +bool cpu_exec_realizefn (CPUState *cpu,Error **errp) +{ +if (!accel_cpu_common_realize (cpu, errp)) { +return false; + } + +/* Wait until cpu initialization complete before exposing cpu. */ +cpu_list_add (cpu); + +cpu_vmstate_register (cpu); + +return true; +} +static void cpu_common_realizefn (DeviceState *dev,Error **errp) {CPUState *cpu =CPU (dev);
@@ -234,6 +248,18 @@ static void cpu_common_unrealizefn(DeviceState *dev)cpu_exec_unrealizefn (cpu); } +void cpu_exec_unrealizefn (CPUState *cpu) +{ +cpu_vmstate_unregister (cpu); + +cpu_list_remove (cpu); +/* +* Now that the vCPU has been removed from the RCU list, we can call +* accel_cpu_common_unrealize, which may free fields using call_rcu. +*/ +accel_cpu_common_unrealize (cpu); +} +static void cpu_common_initfn (Object *obj) {CPUState *cpu =CPU (obj);
Signature · 1 line
2.47.1
Re: [PATCH 20/20] cpus: Build cpu_exec_[un]realizefn() methods once
Quoted 5 lines · Philippe Mathieu-Daudé
Now that
cpu_exec_realizefn()andcpu_exec_unrealizefn()methods don't use any target specific definition anymore, we can move them tocpu-common.cto be able to build them once.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>---
Eventually they'll be absorbed within cpu_common_[un]realizefn().--- cpu-target.c | 30 ------------------------------ hw/core/cpu-common.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 30 deletions(-)
r~