cpu: Turn cpu_paging_enabled() into a CPUState hook

Relocate assignment of x86 get_arch_id to have all hooks in one place.

Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Move MemoryMappingList typedef to qemu/typedefs.h

This will avoid issues with hwaddr and ram_addr_t when including
sysemu/memory_mapping.h for CONFIG_USER_ONLY.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Turn cpu_get_memory_mapping() into a CPUState hook

Change error reporting from return value to Error argument.

Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Drop qemu_get_memory_mapping() stub

dump.c:dump_init() never checked for the return code anyway.
If paging is not enabled, it will fall back to an identity map.
If paging is enabled and getting memory mapping list is not
implemented, qemu_get_guest_memory_mapping() will return an error.

Since the targets not implementing memory mapping also don't implement
dump support, we will not reach this code today and can worry about
changing cpu_paging_enabled() default when the need arises.

This allows us to drop CONFIG_HAVE_GET_MEMORY_SUPPORT.

Signed-off-by: Andreas Färber <afaerber@suse.de>
dump: Unconditionally compile

qmp_dump_guest_memory() calls dump_init() and returns an Error when
cpu_get_dump_info() returns an error, as done by the stub.
So there is no need to have a stub for qmp_dump_guest_memory().

Enable the documentation of the always-present dump-guest-memory command.

That way we can drop CONFIG_HAVE_CORE_DUMP and leave configure
completely out of the picture for target CPU features.

Signed-off-by: Andreas Färber <afaerber@suse.de>
memory_mapping: Change qemu_get_guest_memory_mapping() semantics

Previously it would search for the first CPU with paging enabled and
retrieve memory mappings from this and any following CPUs or return an
error if that fails.

Instead walk all CPUs and if paging is enabled retrieve the memory
mappings. Fail only if retrieving memory mappings on a CPU with paging
enabled fails.

This not only allows to more easily use one qemu_for_each_cpu() instead
of open-coding two CPU loops and drops find_first_paging_enabled_cpu()
but removes the implicit assumption of heterogeneity between CPUs n..N
in having paging enabled.

Cc: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
kvm: Change kvm_cpu_synchronize_state() argument to CPUState

It no longer relies on CPUArchState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
kvm: Change cpu_synchronize_state() argument to CPUState

Change Monitor::mon_cpu to CPUState as well.
In cpu_sychronize_all_states() use qemu_for_each_cpu() now.
In dump_init() use cpu_synchronize_all_states().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify cpu_synchronize_all_post_reset()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify cpu_synchronize_all_post_init()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify pause_all_vcpus()

Use new qemu_for_each_cpu() to pause, stop and kick CPUs.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify resume_all_vcpus()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify set_numa_modes()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify qmp_inject_nmi()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify hw_error()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Simplify qemu_tcg_wait_io_event() and qemu_tcg_cpu_thread_fn()

Use new qemu_for_each_cpu().

Signed-off-by: Andreas Färber <afaerber@suse.de>
monitor: Simplify do_inject_mce()

Use qemu_get_cpu() to avoid open-coded CPU loop.

Signed-off-by: Andreas Färber <afaerber@suse.de>
gdbstub: Simplify find_cpu()

Use qemu_get_cpu() and CPUState::env_ptr.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Change cpu_exit() argument to CPUState

It no longer depends on CPUArchState, so move it to qom/cpu.c.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus: Change cpu_thread_is_idle() argument to CPUState

It no longer needs CPUArchState.

Signed-off-by: Andreas Färber <afaerber@suse.de>