softmmu: Make various objects target agnostic
Subsystems (2)
v2 cover softmmu: Make various objects target agnostic
This is a re-org accel/ and softmmu/ to have more target-agnostic objects.
Since RFC:
- Rework accel/meson (Richard)
- Use vaddr in cpu_memory_rw_debug (Richard)
- Introduce CONFIG_HAX_IS_POSSIBLE (Richard)
- Introduce AccelOpsClass::cpu_thread_is_idle (Richard)
- Introduce AccelOpsClass::cpus_are_resettable (Richard)
- Add qemu_init_arch_modules (new)
Philippe Mathieu-Daudé (21):
accel: Restrict sysemu stubs to system emulation accel/meson: Only build hw virtualization with system emulation
exec: Declare vaddr as a generic target-agnostic type
exec: Make cpu_memory_rw_debug() target agnostic sysemu/memory_mapping: Become target-agnostic
sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target
agnostic
accel/kvm: Simplify user-mode #ifdef'ry
accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
softmmu/cpus: Code movement
accel: Introduce AccelOpsClass::cpu_thread_is_idle()
accel: Introduce AccelOpsClass::cpus_are_resettable() softmmu/globals: Remove unused 'hw/i386/*' headers softmmu/runstate: Clean headers
softmmu/physmem: Remove unnecessary include softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header
misc: Remove unnecessary "sysemu/cpu-timers.h" include
misc: Add missing "sysemu/cpu-timers.h" include exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic exec/cpu: Make address_space_init/reloading_memory_map target agnostic
softmmu: Add qemu_init_arch_modules()
softmmu: Build target-agnostic objects once
accel/kvm/kvm-accel-ops.c | 12 ++++++++++ accel/meson.build | 12 ++++++---- accel/qtest/qtest.c | 1 - accel/stubs/hax-stub.c | 2 ++ accel/stubs/kvm-stub.c | 5 ---- accel/stubs/meson.build | 11 +++++---- accel/tcg/tcg-accel-ops-icount.c | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 1 + accel/tcg/tcg-accel-ops-rr.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + cpu.c | 6 ++--- include/exec/cpu-all.h | 4 ---- include/exec/cpu-common.h | 39 +++++++++++++++++++++++++++++++ include/exec/exec-all.h | 26 --------------------- include/exec/gdbstub.h | 23 +++++++++--------- include/hw/core/cpu.h | 13 +---------- include/sysemu/accel-ops.h | 3 +++ include/sysemu/arch_init.h | 2 ++ include/sysemu/hax.h | 18 +++++++++----- include/sysemu/hw_accel.h | 5 ---- include/sysemu/kvm.h | 6 ++--- include/sysemu/memory_mapping.h | 5 ++-- softmmu/arch_init.c | 9 +++++++ softmmu/cpu-timers.c | 1 - softmmu/cpus.c | 23 +++++++++++------- softmmu/globals.c | 2 -- softmmu/memory_mapping.c | 1 + softmmu/meson.build | 24 +++++++++---------- softmmu/physmem.c | 7 +++--- softmmu/runstate.c | 2 +- softmmu/vl.c | 5 +--- target/alpha/translate.c | 1 - target/i386/hax/hax-all.c | 7 +----- target/i386/whpx/whpx-accel-ops.c | 6 +++++ target/riscv/csr.c | 1 + tests/unit/ptimer-test-stubs.c | 1 - 36 files changed, 158 insertions(+), 129 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/21 accel: Restrict sysemu stubs to system emulation
--- accel/stubs/meson.build | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
accel/stubs/meson.build +7 -4
@@ -1,4 +1,7 @@ -specific_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c')) -specific_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) -specific_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -specific_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) +sysemu_stubs_ss = ss.source_set() +sysemu_stubs_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) + +specific_ss.add_all(when: ['CONFIG_SOFTMMU'], if_true: sysemu_stubs_ss)
Signature · 1 line
2.34.1
Re: [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation
Quoted 11 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/stubs/meson.build | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)accel/stubs/meson.build +0
-1@@ -1,4 +1,7 @@ -specific_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c'))
accel/stubs/meson.build line 7
Quoted 10 lines
accel/stubs/meson.build +7
-3-specific_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) -specific_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -specific_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) +sysemu_stubs_ss = ss.source_set() +sysemu_stubs_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) + +specific_ss.add_all(when: ['CONFIG_SOFTMMU'], if_true: sysemu_stubs_ss)
Re: [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation
In reply to Philippe Mathieu-Daudé viaQuoted 11 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/stubs/meson.build | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)accel/stubs/meson.build +0
-1@@ -1,4 +1,7 @@ -specific_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c'))
accel/stubs/meson.build line 7
Quoted 10 lines
accel/stubs/meson.build +7
-3-specific_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) -specific_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -specific_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) +sysemu_stubs_ss = ss.source_set() +sysemu_stubs_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) +sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c')) + +specific_ss.add_all(when: ['CONFIG_SOFTMMU'], if_true: sysemu_stubs_ss)
r~
PATCH v2 2/21 accel/meson: Only build hw virtualization with system emulation
In reply to Philippe Mathieu-Daudé via--- accel/meson.build | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
accel/meson.build +7 -5
@@ -2,12 +2,14 @@ specific_ss.add(files('accel-common.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c')) -subdir('hvf') -subdir('qtest') -subdir('kvm') subdir('tcg') -subdir('xen') -subdir('stubs') +if have_system + subdir('hvf') + subdir('qtest') + subdir('kvm') + subdir('xen') + subdir('stubs') +endif dummy_ss = ss.source_set() dummy_ss.add(files(
Signature · 1 line
2.34.1
Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
Quoted 16 lines · Philippe Mathieu-Daudé
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/meson.build | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)accel/meson.build +0
-2@@ -2,12 +2,14 @@ specific_ss.add(files('accel-common.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c')) -subdir('hvf') -subdir('qtest')
accel/meson.build specific_ss.add(files('accel-common.c')) · line 11
Quoted 10 lines
accel/meson.build +6
-3-subdir('kvm') subdir('tcg') -subdir('xen') -subdir('stubs') +if have_system + subdir('hvf') + subdir('qtest') + subdir('kvm') + subdir('xen') + subdir('stubs')
Doesn't this render your first patch useless?
accel/meson.build specific_ss.add(files('accel-common.c')) · line 15
Quoted 4 lines
accel/meson.build +1
-0+endif dummy_ss = ss.source_set() dummy_ss.add(files(
Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
Quoted 20 lines · Thomas Huth
Quoted 19 lines · Philippe Mathieu-Daudé
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/meson.build | 12 +++++++-----1 file changed, 7 insertions(+), 5 deletions(-)accel/meson.build +0
-5@@ -2,12 +2,14 @@ specific_ss.add(files('accel-common.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c')) -subdir('hvf') -subdir('qtest') -subdir('kvm') subdir('tcg') -subdir('xen') -subdir('stubs')
Quoted 8 lines
accel/meson.build specific_ss.add(files('accel-common.c')) · line 11
Quoted 6 lines
accel/meson.build +6
-0+if have_system + subdir('hvf') + subdir('qtest') + subdir('kvm') + subdir('xen') + subdir('stubs')Doesn't this render your first patch useless?
No, we don't want to build non-TCG stubs in user-mode ;)
Quoted 6 lines
Quoted 3 lines
accel/meson.build +1
-0+endif dummy_ss = ss.source_set()dummy_ss.add(files(
Reviewed-by Thomas Huth <[email protected]>
Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
Quoted 30 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Thomas Huth
Quoted 19 lines · Philippe Mathieu-Daudé
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
accel/meson.build | 12 +++++++-----1 file changed, 7 insertions(+), 5 deletions(-)accel/meson.build +0
-5@@ -2,12 +2,14 @@ specific_ss.add(files('accel-common.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c')) -subdir('hvf') -subdir('qtest') -subdir('kvm') subdir('tcg') -subdir('xen') -subdir('stubs')Quoted 8 lines
accel/meson.build specific_ss.add(files('accel-common.c')) · line 11
Quoted 6 lines
accel/meson.build +6
-0+if have_system + subdir('hvf') + subdir('qtest') + subdir('kvm') + subdir('xen') + subdir('stubs')Doesn't this render your first patch useless?
Quoted 1 line
No, we don't want to build non-TCG stubs in user-mode ;)
Ah, well, looking at this twice, I think it's ok, indeed. I was confused by the fact that "have_system" and the "CONFIG_SOFTMMU" from patch 01 can have two different meanings if the QEMU build has been configured with both, softmmu and user targets. So never mind, please!
Thomas
PATCH v2 3/21 exec: Declare vaddr as a generic target-agnostic type
In reply to Philippe Mathieu-Daudé viaMove vaddr type declaration to the generic "exec/cpu-common.h" header.
--- include/exec/cpu-common.h | 12 ++++++++++++ include/hw/core/cpu.h | 13 +------------ 2 files changed, 13 insertions(+), 12 deletions(-)
include/exec/cpu-common.h +12 -0
@@ -7,6 +7,18 @@#include "exec/hwaddr.h" #endif +/** +* vaddr: +* Type wide enough to contain any #target_ulong virtual address. +*/ +typedef uint64_t vaddr ; +#define VADDR_PRId PRId64 +#define VADDR_PRIu PRIu64 +#define VADDR_PRIo PRIo64 +#define VADDR_PRIx PRIx64 +#define VADDR_PRIX PRIX64 +#define VADDR_MAX UINT64_MAX +/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even * when intptr_t is 32-bit and we are aligning a long long. */
include/hw/core/cpu.h +1 -12
@@ -22,6 +22,7 @@#include "hw/qdev-core.h" #include "disas/dis-asm.h" +#include "exec/cpu-common.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h"
@@ -35,18 +36,6 @@typedef int (*WriteCoreDumpFunction )(const void *buf,size_t size,void *opaque); -/** -* vaddr: -* Type wide enough to contain any #target_ulong virtual address. -*/ -typedef uint64_t vaddr ; -#define VADDR_PRId PRId64 -#define VADDR_PRIu PRIu64 -#define VADDR_PRIo PRIo64 -#define VADDR_PRIx PRIx64 -#define VADDR_PRIX PRIX64 -#define VADDR_MAX UINT64_MAX -/** * SECTION:cpu * @section_id: QEMU-cpu
Signature · 1 line
2.34.1
Re: [PATCH v2 03/21] exec: Declare vaddr as a generic target-agnostic type
Quoted 7 lines · Philippe Mathieu-Daudé
Move vaddr type declaration to the generic "
exec/cpu-common.h" header.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/exec/cpu-common.h | 12 ++++++++++++ include/hw/core/cpu.h | 13 +------------ 2 files changed, 13 insertions(+), 12 deletions(-)
r~
PATCH v2 4/21 exec: Make cpu_memory_rw_debug() target agnostic
In reply to Philippe Mathieu-Daudé viacpu_memory_rw_debug() is declared in "exec/cpu-all.h" which contains target-specific declarations. To be able to use it from target agnostic source, move the declaration to the generic "exec/cpu-common.h" header.
Replace the target-specific 'target_ulong' type by 'vaddr' which better reflects the argument type, and is target agnostic.
--- cpu.c | 6 +++--- include/exec/cpu-all.h | 4 ---- include/exec/cpu-common.h | 4 ++++ softmmu/cpus.c | 2 +- softmmu/physmem.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-)
cpu.c +3 -3
@@ -395,11 +395,11 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)/* physical memory access (slow version, mainly for debug) */ #if defined(CONFIG_USER_ONLY ) -int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr, -void *ptr,target_ulong len,bool is_write) +int cpu_memory_rw_debug (CPUState *cpu,vaddr addr, +void *ptr,size_t len,bool is_write) {int flags; -target_ulong l, page; +vaddr l, page;void * p;uint8_t *buf = ptr;
include/exec/cpu-all.h +0 -4
@@ -433,10 +433,6 @@ int cpu_exec(CPUState *cpu);void tcg_exec_realizefn (CPUState *cpu,Error **errp);void tcg_exec_unrealizefn (CPUState *cpu); -/* Returns: 0 on success, -1 on error */ -int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr, -void *ptr,target_ulong len,bool is_write); -/** * cpu_set_cpustate_pointers(cpu) * @cpu: The cpu object
include/exec/cpu-common.h +4 -0
@@ -128,6 +128,10 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);#endif +/* Returns: 0 on success, -1 on error */ +int cpu_memory_rw_debug (CPUState *cpu,vaddr addr, +void *ptr,size_t len,bool is_write); +/* vl.c */ extern int singlestep;
softmmu/cpus.c +1 -1
@@ -32,7 +32,7 @@#include "qapi/qmp/qerror.h" #include "exec/gdbstub.h" #include "sysemu/hw_accel.h" -#include "exec/exec-all.h" +#include "exec/cpu-common.h" #include "qemu/thread.h" #include "qemu/plugin.h" #include "sysemu/cpus.h"
softmmu/physmem.c +3 -3
@@ -3435,11 +3435,11 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,#include "memory_ldst.c.inc" /* virtual memory access for debug (includes writing to ROM) */ -int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr, -void *ptr,target_ulong len,bool is_write) +int cpu_memory_rw_debug (CPUState *cpu,vaddr addr, +void *ptr,size_t len,bool is_write) {hwaddr phys_addr; -target_ulong l, page; +vaddr l, page;uint8_t *buf = ptr;cpu_synchronize_state (cpu);
Signature · 1 line
2.34.1
Re: [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic
Quoted 10 lines · Philippe Mathieu-Daudé
cpu_memory_rw_debug()is declared in "exec/cpu-all.h" which contains target-specific declarations. To be able to use it from target agnostic source, move the declaration to the generic "exec/cpu-common.h" header.Replace the target-specific '
target_ulong' type by 'vaddr' which better reflects the argument type, and is target agnostic.Suggested-by Richard Henderson<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>
Quoted 7 lines
--- cpu.c | 6 +++--- include/exec/cpu-all.h | 4 ---- include/exec/cpu-common.h | 4 ++++ softmmu/cpus.c | 2 +- softmmu/physmem.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-)
r~
PATCH v2 5/21 sysemu/memory_mapping: Become target-agnostic
In reply to Philippe Mathieu-Daudé viatarget_ulong is target-specific, while vaddr isn't.
Remove the unnecessary "exec/cpu-defs.h" target-speficic header from "memory_mapping.h" and use the target-agnostic "hw/core/cpu.h" locally in memory_mapping.c.
Remove "exec/memory.h" since MemoryRegion is forward-declared in "qemu/typedefs.h".
--- include/sysemu/memory_mapping.h | 5 ++--- softmmu/memory_mapping.c | 1 + 2 files changed, 3 insertions(+), 3 deletions(-)
include/sysemu/memory_mapping.h +2 -3
@@ -15,8 +15,7 @@#define MEMORY_MAPPING_H #include "qemu/queue.h" -#include "exec/cpu-defs.h" -#include "exec/memory.h" +#include "exec/cpu-common.h" typedef struct GuestPhysBlock { /* visible to guest, reflects PCI hole, etc */
@@ -43,7 +42,7 @@ typedef struct GuestPhysBlockList {/* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping {hwaddr phys_addr; -target_ulong virt_addr; +vaddr virt_addr;ram_addr_t length;QTAILQ_ENTRY (MemoryMapping) next; }MemoryMapping ;
softmmu/memory_mapping.c +1 -0
@@ -17,6 +17,7 @@#include "sysemu/memory_mapping.h" #include "exec/memory.h" #include "exec/address-spaces.h" +#include "hw/core/cpu.h" //#define DEBUG_GUEST_PHYS_REGION_ADD
Signature · 1 line
2.34.1
PATCH v2 6/21 sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target agnostic
In reply to Philippe Mathieu-Daudé viakvm_on_sigbus() and kvm_on_sigbus_vcpu() prototypes don't have to be target specific. Remove this limitation to be able to build softmmu/cpus.c once for all targets.
--- include/sysemu/kvm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/sysemu/kvm.h +3 -3
@@ -249,6 +249,9 @@ int kvm_has_intx_set_mask(void);bool kvm_arm_supports_user_irq (void ); +int kvm_on_sigbus_vcpu (CPUState *cpu,int code,void *addr); +int kvm_on_sigbus (int code,void *addr); +#ifdef NEED_CPU_H #include "cpu.h"
@@ -261,9 +264,6 @@ int kvm_remove_breakpoint(CPUState *cpu, target_ulong addr,void kvm_remove_all_breakpoints (CPUState *cpu);int kvm_update_guest_debug (CPUState *cpu,unsigned long reinject_trap); -int kvm_on_sigbus_vcpu (CPUState *cpu,int code,void *addr); -int kvm_on_sigbus (int code,void *addr); -/* internal API */ int kvm_ioctl (KVMState *s,int type, ...);
Signature · 1 line
2.34.1
PATCH v2 7/21 accel/kvm: Simplify user-mode #ifdef'ry
In reply to Philippe Mathieu-Daudé viaNow than we only build this stub with system emulation, remove the user-mode #ifdef'ry.
--- accel/stubs/kvm-stub.c | 5 ----- 1 file changed, 5 deletions(-)
accel/stubs/kvm-stub.c +0 -5
@@ -12,10 +12,7 @@#include "qemu/osdep.h" #include "sysemu/kvm.h" - -#ifndef CONFIG_USER_ONLY #include "hw/pci/msi.h" -#endif KVMState *kvm_state;bool kvm_kernel_irqchip;
@@ -80,7 +77,6 @@ int kvm_on_sigbus(int code, void *addr)return 1 ; } -#ifndef CONFIG_USER_ONLY int kvm_irqchip_add_msi_route (KVMState *s,int vector,PCIDevice *dev) {return -ENOSYS ;
@@ -152,4 +148,3 @@ bool kvm_dirty_ring_enabled(void) {return false; } -#endif
Signature · 1 line
2.34.1
PATCH v2 8/21 accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
In reply to Philippe Mathieu-Daudé viaMirror "sysemu/kvm.h" #ifdef'ry to define CONFIG_HAX_IS_POSSIBLE, expose hax_allowed to hax_enabled() macro.
--- accel/stubs/hax-stub.c | 2 ++ include/sysemu/hax.h | 18 ++++++++++++------ target/i386/hax/hax-all.c | 7 +------ 3 files changed, 15 insertions(+), 12 deletions(-)
accel/stubs/hax-stub.c +2 -0
@@ -16,6 +16,8 @@#include "qemu/osdep.h" #include "sysemu/hax.h" +bool hax_allowed; +int hax_sync_vcpus (void ) {return 0 ;
include/sysemu/hax.h +12 -6
@@ -25,17 +25,23 @@int hax_sync_vcpus (void );#ifdef NEED_CPU_H +# ifdef CONFIG_HAX +# define CONFIG_HAX_IS_POSSIBLE +# endif +#else /* !NEED_CPU_H */ +# define CONFIG_HAX_IS_POSSIBLE +#endif -#ifdef CONFIG_HAX +#ifdef CONFIG_HAX_IS_POSSIBLE -int hax_enabled (void ); +extern bool hax_allowed; -#else /* CONFIG_HAX */ +#define hax_enabled () (hax_allowed) -#define hax_enabled () (0) +#else /* !CONFIG_HAX_IS_POSSIBLE */ -#endif /* CONFIG_HAX */ +#define hax_enabled () (0) -#endif /* NEED_CPU_H */ +#endif /* CONFIG_HAX_IS_POSSIBLE */ #endif /* QEMU_HAX_H */
target/i386/hax/hax-all.c +1 -6
@@ -49,18 +49,13 @@ const uint32_t hax_cur_version = 0x4; /* API v4: unmapping and MMIO moves *//* Minimum HAX kernel version */ const uint32_t hax_min_version =0x4 ;/* API v4: supports unmapping */ -static bool hax_allowed; +bool hax_allowed;struct hax_state hax_global;static void hax_vcpu_sync_state (CPUArchState *env,int modified);static int hax_arch_get_registers (CPUArchState *env); -int hax_enabled (void ) -{ -return hax_allowed; -} -int valid_hax_tunnel_size (uint16_t size) {return size >=sizeof (struct hax_tunnel );
Signature · 1 line
2.34.1
Re: [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
Quoted 10 lines · Philippe Mathieu-Daudé
Mirror "
sysemu/kvm.h" #ifdef'ry to defineCONFIG_HAX_IS_POSSIBLE, exposehax_allowedtohax_enabled()macro.Suggested-by Richard Henderson<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/stubs/hax-stub.c | 2 ++ include/sysemu/hax.h | 18 ++++++++++++------ target/i386/hax/hax-all.c | 7 +------ 3 files changed, 15 insertions(+), 12 deletions(-)
r~
PATCH v2 9/21 softmmu/cpus: Code movement
In reply to Philippe Mathieu-Daudé viaWe want cpu_thread_is_idle() to use cpus_accel, so declare this variable earlier.
--- softmmu/cpus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
softmmu/cpus.c +5 -5
@@ -66,6 +66,11 @@static QemuMutex qemu_global_mutex; +/* +* The chosen accelerator is supposed to register this. +*/ +static const AccelOpsClass *cpus_accel; +bool cpu_is_stopped (CPUState *cpu) {return cpu->stopped || !runstate_is_running ();
@@ -126,11 +131,6 @@ void hw_error(const char *fmt, ...)abort (); } -/* -* The chosen accelerator is supposed to register this. -*/ -static const AccelOpsClass *cpus_accel; -void cpu_synchronize_all_states (void ) {CPUState *cpu;
Signature · 1 line
2.34.1
Re: [PATCH v2 09/21] softmmu/cpus: Code movement
Quoted 7 lines · Philippe Mathieu-Daudé
We want
cpu_thread_is_idle()to usecpus_accel, so declare this variable earlier.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- softmmu/cpus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
r~
PATCH v2 10/21 accel: Introduce AccelOpsClass::cpu_thread_is_idle()
In reply to Philippe Mathieu-Daudé viaAdd cpu_thread_is_idle() to AccelOps, and implement it for the KVM / WHPX accelerators.
--- accel/kvm/kvm-accel-ops.c | 6 ++++++ include/sysemu/accel-ops.h | 1 + softmmu/cpus.c | 6 ++++-- target/i386/whpx/whpx-accel-ops.c | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-)
accel/kvm/kvm-accel-ops.c +6 -0
@@ -74,11 +74,17 @@ static void kvm_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } +static bool kvm_vcpu_thread_is_idle (CPUState *cpu) +{ +return !kvm_halt_in_kernel (); +} +static void kvm_accel_ops_class_init (ObjectClass *oc,void *data) {AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset; ops->synchronize_post_init = kvm_cpu_synchronize_post_init; ops->synchronize_state = kvm_cpu_synchronize_state;
include/sysemu/accel-ops.h +1 -0
@@ -30,6 +30,7 @@ struct AccelOpsClass {void (*create_vcpu_thread)(CPUState *cpu);/* MANDATORY NON-NULL */ void (*kick_vcpu_thread)(CPUState *cpu); +bool (*cpu_thread_is_idle)(CPUState *cpu);void (*synchronize_post_reset)(CPUState *cpu);void (*synchronize_post_init)(CPUState *cpu);
softmmu/cpus.c +4 -2
@@ -94,10 +94,12 @@ bool cpu_thread_is_idle(CPUState *cpu)if (cpu_is_stopped (cpu)) {return true; } -if (!cpu->halted ||cpu_has_work (cpu) || -kvm_halt_in_kernel () ||whpx_apic_in_platform ()) { +if (!cpu->halted ||cpu_has_work (cpu)) {return false; } +if (cpus_accel->cpu_thread_is_idle) { +return cpus_accel->cpu_thread_is_idle (cpu); + }return true; }
target/i386/whpx/whpx-accel-ops.c +6 -0
@@ -83,12 +83,18 @@ static void whpx_kick_vcpu_thread(CPUState *cpu) } } +static bool whpx_vcpu_thread_is_idle (CPUState *cpu) +{ +return !whpx_apic_in_platform (); +} +static void whpx_accel_ops_class_init (ObjectClass *oc,void *data) {AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = whpx_start_vcpu_thread; ops->kick_vcpu_thread = whpx_kick_vcpu_thread; + ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle; ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset; ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
Signature · 1 line
2.34.1
Re: [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle()
Quoted 11 lines · Philippe Mathieu-Daudé
Add
cpu_thread_is_idle()to AccelOps, and implement it for the KVM / WHPX accelerators.Suggested-by Richard Henderson<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/kvm/kvm-accel-ops.c | 6 ++++++ include/sysemu/accel-ops.h | 1 + softmmu/cpus.c | 6 ++++-- target/i386/whpx/whpx-accel-ops.c | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-)
r~
PATCH v2 11/21 accel: Introduce AccelOpsClass::cpus_are_resettable()
In reply to Philippe Mathieu-Daudé viaAdd cpus_are_resettable() to AccelOps, and implement it for the KVM accelerator.
--- accel/kvm/kvm-accel-ops.c | 6 ++++++ include/sysemu/accel-ops.h | 2 ++ include/sysemu/hw_accel.h | 5 ----- softmmu/cpus.c | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-)
accel/kvm/kvm-accel-ops.c +6 -0
@@ -79,12 +79,18 @@ static bool kvm_vcpu_thread_is_idle(CPUState *cpu)return !kvm_halt_in_kernel (); } +static bool kvm_cpus_are_resettable (void ) +{ +return kvm_enabled () ?kvm_cpu_check_are_resettable () : true; +} +static void kvm_accel_ops_class_init (ObjectClass *oc,void *data) {AccelOpsClass *ops =ACCEL_OPS_CLASS (oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; + ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset; ops->synchronize_post_init = kvm_cpu_synchronize_post_init; ops->synchronize_state = kvm_cpu_synchronize_state;
include/sysemu/accel-ops.h +2 -0
@@ -28,6 +28,8 @@ struct AccelOpsClass {/* initialization function called when accel is chosen */ void (*ops_init)(AccelOpsClass *ops); +bool (*cpus_are_resettable)(void ); +void (*create_vcpu_thread)(CPUState *cpu);/* MANDATORY NON-NULL */ void (*kick_vcpu_thread)(CPUState *cpu);bool (*cpu_thread_is_idle)(CPUState *cpu);
include/sysemu/hw_accel.h +0 -5
@@ -23,9 +23,4 @@ void cpu_synchronize_post_reset(CPUState *cpu);void cpu_synchronize_post_init (CPUState *cpu);void cpu_synchronize_pre_loadvm (CPUState *cpu); -static inline bool cpu_check_are_resettable (void ) -{ -return kvm_enabled () ?kvm_cpu_check_are_resettable () : true; -} -#endif /* QEMU_HW_ACCEL_H */
softmmu/cpus.c +4 -1
@@ -199,7 +199,10 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu)bool cpus_are_resettable (void ) { -return cpu_check_are_resettable (); +if (cpus_accel->cpus_are_resettable) { +return cpus_accel->cpus_are_resettable (); + } +return true; }int64_t cpus_get_virtual_clock (void )
Signature · 1 line
2.34.1
Re: [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable()
Quoted 17 lines · Philippe Mathieu-Daudé
Add
cpus_are_resettable()to AccelOps, and implement it for the KVM accelerator.Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/kvm/kvm-accel-ops.c | 6 ++++++ include/sysemu/accel-ops.h | 2 ++ include/sysemu/hw_accel.h | 5 ----- softmmu/cpus.c | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-)accel/kvm/kvm-accel-ops.c +0
-0
accel/kvm/kvm-accel-ops.c static bool kvm_vcpu_thread_is_idle(CPUState *cpu) · line 85
Quoted 7 lines
accel/kvm/kvm-accel-ops.c +4
-0@@ -79,12 +79,18 @@ static bool kvm_vcpu_thread_is_idle(CPUState *cpu)return !kvm_halt_in_kernel (); } +static bool kvm_cpus_are_resettable (void ) +{ +return kvm_enabled () ?kvm_cpu_check_are_resettable () : true; +}
Hrm. This is code movement, but this calls out to be rewritten with proper logical operations:
!kvm_enabled() || kvm_cpu_check_are_resettable();
Anyway,
r~
PATCH v2 12/21 softmmu/globals: Remove unused 'hw/i386/*' headers
In reply to Philippe Mathieu-Daudé via--- softmmu/globals.c | 2 -- 1 file changed, 2 deletions(-)
softmmu/globals.c +0 -2
@@ -25,8 +25,6 @@#include "qemu/osdep.h" #include "exec/cpu-common.h" #include "hw/display/vga.h" -#include "hw/i386/pc.h" -#include "hw/i386/x86.h" #include "hw/loader.h" #include "hw/xen/xen.h" #include "net/net.h"
Signature · 1 line
2.34.1
PATCH v2 13/21 softmmu/runstate: Clean headers
In reply to Philippe Mathieu-Daudé viaAdd the missing 'qemu/log.h' header and remove the unused 'exec/exec-all.h' one.
--- softmmu/runstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/runstate.c +1 -1
@@ -30,7 +30,6 @@#include "crypto/cipher.h" #include "crypto/init.h" #include "exec/cpu-common.h" -#include "exec/exec-all.h" #include "exec/gdbstub.h" #include "hw/boards.h" #include "migration/misc.h"
@@ -44,6 +43,7 @@#include "qemu-common.h" #include "qemu/error-report.h" #include "qemu/job.h" +#include "qemu/log.h" #include "qemu/module.h" #include "qemu/plugin.h" #include "qemu/sockets.h"
Signature · 1 line
2.34.1
PATCH v2 14/21 softmmu/physmem: Remove unnecessary include
In reply to Philippe Mathieu-Daudé via--- softmmu/physmem.c | 1 - 1 file changed, 1 deletion(-)
softmmu/physmem.c +0 -1
@@ -60,7 +60,6 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" -#include "exec/log.h" #include "qemu/pmem.h"
Signature · 1 line
2.34.1
Re: [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include
Quoted 10 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- softmmu/physmem.c | 1 - 1 file changed, 1 deletion(-)softmmu/physmem.c +0
-0
softmmu/physmem.c line 65
Quoted 7 lines
softmmu/physmem.c +0
-1@@ -60,7 +60,6 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" -#include "exec/log.h" #include "qemu/pmem.h"
r~
PATCH v2 15/21 softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header
In reply to Philippe Mathieu-Daudé via--- softmmu/cpu-timers.c | 1 - 1 file changed, 1 deletion(-)
softmmu/cpu-timers.c +0 -1
@@ -28,7 +28,6 @@#include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "exec/exec-all.h" #include "sysemu/cpus.h" #include "qemu/main-loop.h" #include "qemu/option.h"
Signature · 1 line
2.34.1
PATCH v2 16/21 misc: Remove unnecessary "sysemu/cpu-timers.h" include
In reply to Philippe Mathieu-Daudé via--- accel/qtest/qtest.c | 1 - target/alpha/translate.c | 1 - tests/unit/ptimer-test-stubs.c | 1 - 3 files changed, 3 deletions(-)
accel/qtest/qtest.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/accel.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" -#include "sysemu/cpu-timers.h" #include "qemu/guest-random.h" #include "qemu/main-loop.h" #include "hw/core/cpu.h"
target/alpha/translate.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/osdep.h" #include "cpu.h" #include "sysemu/cpus.h" -#include "sysemu/cpu-timers.h" #include "disas/disas.h" #include "qemu/host-utils.h" #include "exec/exec-all.h"
tests/unit/ptimer-test-stubs.c +0 -1
@@ -12,7 +12,6 @@#include "qemu/main-loop.h" #include "sysemu/replay.h" #include "migration/vmstate.h" -#include "sysemu/cpu-timers.h" #include "ptimer-test.h"
Signature · 1 line
2.34.1
Re: [PATCH v2 16/21] misc: Remove unnecessary "sysemu/cpu-timers.h" include
Quoted 6 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/qtest/qtest.c | 1 - target/alpha/translate.c | 1 - tests/unit/ptimer-test-stubs.c | 1 - 3 files changed, 3 deletions(-)
r~
PATCH v2 17/21 misc: Add missing "sysemu/cpu-timers.h" include
In reply to Philippe Mathieu-Daudé via--- accel/tcg/tcg-accel-ops-icount.c | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 1 + accel/tcg/tcg-accel-ops-rr.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + include/exec/exec-all.h | 1 - target/riscv/csr.c | 1 + 6 files changed, 5 insertions(+), 1 deletion(-)
accel/tcg/tcg-accel-ops-icount.c +1 -0
@@ -27,6 +27,7 @@#include "qemu-common.h" #include "sysemu/tcg.h" #include "sysemu/replay.h" +#include "sysemu/cpu-timers.h" #include "qemu/main-loop.h" #include "qemu/guest-random.h" #include "exec/exec-all.h"
accel/tcg/tcg-accel-ops-mttcg.c +1 -0
@@ -27,6 +27,7 @@#include "qemu-common.h" #include "sysemu/tcg.h" #include "sysemu/replay.h" +#include "sysemu/cpu-timers.h" #include "qemu/main-loop.h" #include "qemu/notify.h" #include "qemu/guest-random.h"
accel/tcg/tcg-accel-ops-rr.c +1 -0
@@ -27,6 +27,7 @@#include "qemu-common.h" #include "sysemu/tcg.h" #include "sysemu/replay.h" +#include "sysemu/cpu-timers.h" #include "qemu/main-loop.h" #include "qemu/notify.h" #include "qemu/guest-random.h"
accel/tcg/tcg-accel-ops.c +1 -0
@@ -29,6 +29,7 @@#include "qemu-common.h" #include "sysemu/tcg.h" #include "sysemu/replay.h" +#include "sysemu/cpu-timers.h" #include "qemu/main-loop.h" #include "qemu/guest-random.h" #include "exec/exec-all.h"
include/exec/exec-all.h +0 -1
@@ -24,7 +24,6 @@#ifdef CONFIG_TCG #include "exec/cpu_ldst.h" #endif -#include "sysemu/cpu-timers.h" /* allow to see translation results - the slowdown should be negligible, so we leave it */ #define DEBUG_DISAS
target/riscv/csr.c +1 -0
@@ -22,6 +22,7 @@#include "cpu.h" #include "qemu/main-loop.h" #include "exec/exec-all.h" +#include "sysemu/cpu-timers.h" /* CSR function table public API */ void riscv_get_csr_ops (int csrno,riscv_csr_operations *ops)
Signature · 1 line
2.34.1
Re: [PATCH v2 17/21] misc: Add missing "sysemu/cpu-timers.h" include
Quoted 9 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- accel/tcg/tcg-accel-ops-icount.c | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 1 + accel/tcg/tcg-accel-ops-rr.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + include/exec/exec-all.h | 1 - target/riscv/csr.c | 1 + 6 files changed, 5 insertions(+), 1 deletion(-)
r~
PATCH v2 18/21 exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic
In reply to Philippe Mathieu-Daudé viagdb_exit() and gdb_set_stop_cpu() prototypes don't have to be target specific. Remove this limitation to be able to build softmmu/cpus.c and softmmu/runstate.c once for all targets.
--- include/exec/gdbstub.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
include/exec/gdbstub.h +12 -11
@@ -45,17 +45,6 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);*/ void gdb_do_syscallv (gdb_syscall_complete_cb cb,const char *fmt,va_list va);int use_gdb_syscalls (void ); -void gdb_set_stop_cpu (CPUState *cpu); - -/** -* gdb_exit: exit gdb session, reporting inferior status -* @code: exit code reported -* -* This closes the session and sends a final packet to GDB reporting -* the exit status of the program. It also cleans up any connections -* detritus before returning. -*/ -void gdb_exit (int code);#ifdef CONFIG_USER_ONLY /**
@@ -177,6 +166,18 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len)*/ int gdbserver_start (const char *port_or_device); +/** +* gdb_exit: exit gdb session, reporting inferior status +* @code: exit code reported +* +* This closes the session and sends a final packet to GDB reporting +* the exit status of the program. It also cleans up any connections +* detritus before returning. +*/ +void gdb_exit (int code); + +void gdb_set_stop_cpu (CPUState *cpu); +/** * gdb_has_xml: * This is an ugly hack to cope with both new and old gdb.
Signature · 1 line
2.34.1
PATCH v2 19/21 exec/cpu: Make address_space_init/reloading_memory_map target agnostic
In reply to Philippe Mathieu-Daudé viacpu_address_space_init() and cpu_reloading_memory_map() are target-agnostic, but are declared in "exec/exec-all.h" which contains target-specific declarations. Any target-agnostic source including "exec/exec-all.h" becomes target-specific and we have to compile it N times for the N targets built. In order to avoid that, move the declarations to "exec/cpu-common.h" which only contains target-agnostic declarations.
--- include/exec/cpu-common.h | 23 +++++++++++++++++++++++ include/exec/exec-all.h | 25 ------------------------- 2 files changed, 23 insertions(+), 25 deletions(-)
include/exec/cpu-common.h +23 -0
@@ -90,6 +90,28 @@ void qemu_ram_unset_migratable(RAMBlock *rb);size_t qemu_ram_pagesize (RAMBlock *block);size_t qemu_ram_pagesize_largest (void ); +/** +* cpu_address_space_init: +* @cpu: CPU to add this address space to +* @asidx: integer index of this address space +* @prefix: prefix to be used as name of address space +* @mr: the root memory region of address space +* +* Add the specified address space to the CPU's cpu_ases list. +* The address space added with @asidx 0 is the one used for the +* convenience pointer cpu->as. +* The target-specific code which registers ASes is responsible +* for defining what semantics address space 0, 1, 2, etc have. +* +* Before the first call to this function, the caller must set +* cpu->num_ases to the total number of address spaces it needs +* to support. +* +* Note that with KVM only one address space is supported. +*/ +void cpu_address_space_init (CPUState *cpu,int asidx, +const char *prefix,MemoryRegion *mr); +void cpu_physical_memory_rw (hwaddr addr,void *buf,hwaddr len,bool is_write); static inline void cpu_physical_memory_read(hwaddr addr,
@@ -102,6 +124,7 @@ static inline void cpu_physical_memory_write(hwaddr addr, {cpu_physical_memory_rw (addr, (void *)buf, len, true); } +void cpu_reloading_memory_map (void );void *cpu_physical_memory_map (hwaddr addr,hwaddr *plen,bool is_write);
include/exec/exec-all.h +0 -25
@@ -82,31 +82,6 @@ static inline bool cpu_loop_exit_requested(CPUState *cpu)return (int32_t )qatomic_read (&cpu_neg (cpu)->icount_decr.u32) <0 ; } -#if !defined(CONFIG_USER_ONLY ) -void cpu_reloading_memory_map (void ); -/** -* cpu_address_space_init: -* @cpu: CPU to add this address space to -* @asidx: integer index of this address space -* @prefix: prefix to be used as name of address space -* @mr: the root memory region of address space -* -* Add the specified address space to the CPU's cpu_ases list. -* The address space added with @asidx 0 is the one used for the -* convenience pointer cpu->as. -* The target-specific code which registers ASes is responsible -* for defining what semantics address space 0, 1, 2, etc have. -* -* Before the first call to this function, the caller must set -* cpu->num_ases to the total number of address spaces it needs -* to support. -* -* Note that with KVM only one address space is supported. -*/ -void cpu_address_space_init (CPUState *cpu,int asidx, -const char *prefix,MemoryRegion *mr); -#endif -#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG )/* cputlb.c */ /**
Signature · 1 line
2.34.1
Re: [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map target agnostic
Quoted 8 lines · Philippe Mathieu-Daudé
cpu_address_space_init()andcpu_reloading_memory_map()are target-agnostic, but are declared in "exec/exec-all.h" which contains target-specific declarations. Any target-agnostic source including "exec/exec-all.h" becomes target-specific and we have to compile it N times for the N targets built. In order to avoid that, move the declarations to "exec/cpu-common.h" which only contains target-agnostic declarations.
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/exec/cpu-common.h | 23 +++++++++++++++++++++++ include/exec/exec-all.h | 25 ------------------------- 2 files changed, 23 insertions(+), 25 deletions(-)
r~
PATCH v2 20/21 softmmu: Add qemu_init_arch_modules()
In reply to Philippe Mathieu-Daudé viamodule_allow_arch() is the single target-specific call in the whole vl.c file. Move the module initialization out to arch_init.c, that way we'll be able to build vl.o once for all targets (the next commit).
--- include/sysemu/arch_init.h | 2 ++ softmmu/arch_init.c | 9 +++++++++ softmmu/vl.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-)
include/sysemu/arch_init.h +2 -0
@@ -28,4 +28,6 @@ enum {extern const uint32_t arch_type; +void qemu_init_arch_modules (void ); +#endif
softmmu/arch_init.c +9 -0
@@ -22,6 +22,7 @@* THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/module.h" #include "sysemu/arch_init.h" #ifdef TARGET_SPARC
@@ -39,3 +40,11 @@ int graphic_depth = 32;#endif const uint32_t arch_type =QEMU_ARCH ; + +void qemu_init_arch_modules (void ) +{ +#ifdef CONFIG_MODULES +module_init_info (qemu_modinfo); +module_allow_arch (TARGET_NAME ); +#endif +}
softmmu/vl.c +1 -4
@@ -2814,10 +2814,7 @@ void qemu_init(int argc, char **argv, char **envp)error_init (argv[0 ]);qemu_init_exec_dir (argv[0 ]); -#ifdef CONFIG_MODULES -module_init_info (qemu_modinfo); -module_allow_arch (TARGET_NAME ); -#endif +qemu_init_arch_modules ();qemu_init_subsystems ();
Signature · 1 line
2.34.1
Re: [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules()
Quoted 11 lines · Philippe Mathieu-Daudé
module_allow_arch()is the single target-specific call in the wholevl.cfile. Move the module initialization out toarch_init.c, that way we'll be able to build vl.o once for all targets (the next commit).Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/sysemu/arch_init.h | 2 ++ softmmu/arch_init.c | 9 +++++++++ softmmu/vl.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-)
r~
PATCH v2 21/21 softmmu: Build target-agnostic objects once
In reply to Philippe Mathieu-Daudé viaVarious softmmu objects aren't target specific. Move them to the generic softmmu source set.
For our 31 softmmu targets, this is in total 330 objects less to build!
--- softmmu/meson.build | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
softmmu/meson.build +12 -12
@@ -1,20 +1,9 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'arch_init.c', - 'balloon.c', - 'cpus.c', - 'cpu-throttle.c', - 'datadir.c', - 'globals.c', - 'physmem.c', 'ioport.c', - 'rtc.c', - 'runstate.c', 'memory.c', - 'memory_mapping.c', + 'physmem.c', 'qtest.c', - 'vl.c', - 'cpu-timers.c', - 'runstate-action.c', )]) specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: [files(
@@ -22,9 +11,20 @@ specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: [files( )]) softmmu_ss.add(files( + 'balloon.c', 'bootdevice.c', + 'cpus.c', + 'cpu-throttle.c', + 'cpu-timers.c', + 'datadir.c', 'dma-helpers.c', + 'globals.c', + 'memory_mapping.c', 'qdev-monitor.c', + 'rtc.c', + 'runstate-action.c', + 'runstate.c', + 'vl.c', ), sdl, libpmem, libdaxctl) softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
Signature · 1 line
2.34.1
Quoted 2 lines · Philippe Mathieu-Daudé via
This is a re-org accel/ and softmmu/ to have more target-agnostic objects.
Neat! vl.c in particular bothered me.
Paolo
Quoted 70 lines
Since RFC:
- Rework accel/meson (Richard)
- Use vaddr incpu_memory_rw_debug(Richard)
- IntroduceCONFIG_HAX_IS_POSSIBLE(Richard)
- IntroduceAccelOpsClass::cpu_thread_is_idle(Richard)
- IntroduceAccelOpsClass::cpus_are_resettable(Richard)
- Addqemu_init_arch_modules(new)Philippe Mathieu-Daudé (21):
accel: Restrict sysemu stubs to system emulation accel/meson: Only build hw virtualization with system emulation
exec: Declare vaddr as a generic target-agnostic type
exec: Makecpu_memory_rw_debug()target agnostic sysemu/memory_mapping: Become target-agnostic
sysemu/kvm: Makekvm_on_sigbus()/kvm_on_sigbus_vcpu()target
agnostic
accel/kvm: Simplify user-mode #ifdef'ry
accel/hax: IntroduceCONFIG_HAX_IS_POSSIBLE
softmmu/cpus: Code movement
accel: IntroduceAccelOpsClass::cpu_thread_is_idle()
accel: IntroduceAccelOpsClass::cpus_are_resettable()softmmu/globals: Remove unused 'hw/i386/*' headers softmmu/runstate: Clean headers
softmmu/physmem: Remove unnecessary include softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header
misc: Remove unnecessary "sysemu/cpu-timers.h" include
misc: Add missing "sysemu/cpu-timers.h" include exec/gdbstub: Makegdb_exit()/gdb_set_stop_cpu()target agnostic exec/cpu: Make address_space_init/reloading_memory_map target agnostic
softmmu: Addqemu_init_arch_modules()
softmmu: Build target-agnostic objects onceaccel/kvm/kvm-accel-ops.c | 12 ++++++++++ accel/meson.build | 12 ++++++---- accel/qtest/qtest.c | 1 - accel/stubs/hax-stub.c | 2 ++ accel/stubs/kvm-stub.c | 5 ---- accel/stubs/meson.build | 11 +++++---- accel/tcg/tcg-accel-ops-icount.c | 1 + accel/tcg/tcg-accel-ops-mttcg.c | 1 + accel/tcg/tcg-accel-ops-rr.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + cpu.c | 6 ++--- include/exec/cpu-all.h | 4 ---- include/exec/cpu-common.h | 39 +++++++++++++++++++++++++++++++ include/exec/exec-all.h | 26 --------------------- include/exec/gdbstub.h | 23 +++++++++--------- include/hw/core/cpu.h | 13 +---------- include/sysemu/accel-ops.h | 3 +++ include/sysemu/arch_init.h | 2 ++ include/sysemu/hax.h | 18 +++++++++----- include/sysemu/hw_accel.h | 5 ---- include/sysemu/kvm.h | 6 ++--- include/sysemu/memory_mapping.h | 5 ++-- softmmu/arch_init.c | 9 +++++++ softmmu/cpu-timers.c | 1 - softmmu/cpus.c | 23 +++++++++++------- softmmu/globals.c | 2 -- softmmu/memory_mapping.c | 1 + softmmu/meson.build | 24 +++++++++---------- softmmu/physmem.c | 7 +++--- softmmu/runstate.c | 2 +- softmmu/vl.c | 5 +--- target/alpha/translate.c | 1 - target/i386/hax/hax-all.c | 7 +----- target/i386/whpx/whpx-accel-ops.c | 6 +++++ target/riscv/csr.c | 1 + tests/unit/ptimer-test-stubs.c | 1 - 36 files changed, 158 insertions(+), 129 deletions(-)