* [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-04 8:04 ` Thomas Huth
2022-02-05 23:04 ` Richard Henderson
2022-02-03 19:17 ` [PATCH v2 02/21] accel/meson: Only build hw virtualization with " Philippe Mathieu-Daudé via
` (20 subsequent siblings)
21 siblings, 2 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
accel/stubs/meson.build | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
index 12dd1539af..0249b9258f 100644
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -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)
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation
2022-02-03 19:17 ` [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation Philippe Mathieu-Daudé via
@ 2022-02-04 8:04 ` Thomas Huth
2022-02-05 23:04 ` Richard Henderson
1 sibling, 0 replies; 39+ messages in thread
From: Thomas Huth @ 2022-02-04 8:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Richard Henderson
On 03/02/2022 20.17, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> accel/stubs/meson.build | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
> index 12dd1539af..0249b9258f 100644
> --- a/accel/stubs/meson.build
> +++ b/accel/stubs/meson.build
> @@ -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)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation
2022-02-03 19:17 ` [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation Philippe Mathieu-Daudé via
2022-02-04 8:04 ` Thomas Huth
@ 2022-02-05 23:04 ` Richard Henderson
1 sibling, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:17, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> accel/stubs/meson.build | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
> index 12dd1539af..0249b9258f 100644
> --- a/accel/stubs/meson.build
> +++ b/accel/stubs/meson.build
> @@ -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)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
2022-02-03 19:17 ` [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-04 7:37 ` Thomas Huth
2022-02-03 19:17 ` [PATCH v2 03/21] exec: Declare vaddr as a generic target-agnostic type Philippe Mathieu-Daudé via
` (19 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
accel/meson.build | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/accel/meson.build b/accel/meson.build
index dfd808d2c8..b9a963cf80 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -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(
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
2022-02-03 19:17 ` [PATCH v2 02/21] accel/meson: Only build hw virtualization with " Philippe Mathieu-Daudé via
@ 2022-02-04 7:37 ` Thomas Huth
2022-02-04 7:51 ` Philippe Mathieu-Daudé via
0 siblings, 1 reply; 39+ messages in thread
From: Thomas Huth @ 2022-02-04 7:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Richard Henderson
On 03/02/2022 20.17, Philippe Mathieu-Daudé wrote:
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> accel/meson.build | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/accel/meson.build b/accel/meson.build
> index dfd808d2c8..b9a963cf80 100644
> --- a/accel/meson.build
> +++ b/accel/meson.build
> @@ -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')
Doesn't this render your first patch useless?
> +endif
>
> dummy_ss = ss.source_set()
> dummy_ss.add(files(
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
2022-02-04 7:37 ` Thomas Huth
@ 2022-02-04 7:51 ` Philippe Mathieu-Daudé via
2022-02-04 8:00 ` Thomas Huth
0 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-04 7:51 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Richard Henderson, Paolo Bonzini
On 4/2/22 08:37, Thomas Huth wrote:
> On 03/02/2022 20.17, Philippe Mathieu-Daudé wrote:
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> accel/meson.build | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/accel/meson.build b/accel/meson.build
>> index dfd808d2c8..b9a963cf80 100644
>> --- a/accel/meson.build
>> +++ b/accel/meson.build
>> @@ -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')
>
> Doesn't this render your first patch useless?
No, we don't want to build non-TCG stubs in user-mode ;)
>> +endif
>> dummy_ss = ss.source_set()
>> dummy_ss.add(files(
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH v2 02/21] accel/meson: Only build hw virtualization with system emulation
2022-02-04 7:51 ` Philippe Mathieu-Daudé via
@ 2022-02-04 8:00 ` Thomas Huth
0 siblings, 0 replies; 39+ messages in thread
From: Thomas Huth @ 2022-02-04 8:00 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Richard Henderson
On 04/02/2022 08.51, Philippe Mathieu-Daudé wrote:
> On 4/2/22 08:37, Thomas Huth wrote:
>> On 03/02/2022 20.17, Philippe Mathieu-Daudé wrote:
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>> accel/meson.build | 12 +++++++-----
>>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/accel/meson.build b/accel/meson.build
>>> index dfd808d2c8..b9a963cf80 100644
>>> --- a/accel/meson.build
>>> +++ b/accel/meson.build
>>> @@ -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')
>>
>> Doesn't this render your first patch useless?
>
> 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
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 03/21] exec: Declare vaddr as a generic target-agnostic type
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
2022-02-03 19:17 ` [PATCH v2 01/21] accel: Restrict sysemu stubs to system emulation Philippe Mathieu-Daudé via
2022-02-03 19:17 ` [PATCH v2 02/21] accel/meson: Only build hw virtualization with " Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-05 23:12 ` Richard Henderson
2022-02-03 19:17 ` [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic Philippe Mathieu-Daudé via
` (18 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Move vaddr type declaration to the generic "exec/cpu-common.h" header.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/exec/cpu-common.h | 12 ++++++++++++
include/hw/core/cpu.h | 13 +------------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index de5f444b19..cd1d7328a1 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -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.
*/
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 76ab3b851c..3f2b681281 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (2 preceding siblings ...)
2022-02-03 19:17 ` [PATCH v2 03/21] exec: Declare vaddr as a generic target-agnostic type Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-05 23:13 ` Richard Henderson
2022-02-03 19:17 ` [PATCH v2 05/21] sysemu/memory_mapping: Become target-agnostic Philippe Mathieu-Daudé via
` (17 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
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 <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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(-)
diff --git a/cpu.c b/cpu.c
index 016bf06a1a..97d42b6b2a 100644
--- a/cpu.c
+++ b/cpu.c
@@ -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;
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 84caf5c3d9..c0f0fab28a 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -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
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index cd1d7328a1..8031ebc680 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -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;
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 23bca46b07..7f15106dd9 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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"
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index dddf70edf5..eb4b3bcae7 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic
2022-02-03 19:17 ` [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic Philippe Mathieu-Daudé via
@ 2022-02-05 23:13 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:17, Philippe Mathieu-Daudé wrote:
> 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<richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 05/21] sysemu/memory_mapping: Become target-agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (3 preceding siblings ...)
2022-02-03 19:17 ` [PATCH v2 04/21] exec: Make cpu_memory_rw_debug() target agnostic Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-03 19:17 ` [PATCH v2 06/21] sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target agnostic Philippe Mathieu-Daudé via
` (16 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
target_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".
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/sysemu/memory_mapping.h | 5 ++---
softmmu/memory_mapping.c | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 4b20f1a639..3bbeb1bcb4 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -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;
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index a62eaa49cc..8320165ea2 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 06/21] sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (4 preceding siblings ...)
2022-02-03 19:17 ` [PATCH v2 05/21] sysemu/memory_mapping: Become target-agnostic Philippe Mathieu-Daudé via
@ 2022-02-03 19:17 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 07/21] accel/kvm: Simplify user-mode #ifdef'ry Philippe Mathieu-Daudé via
` (15 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:17 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
kvm_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.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/sysemu/kvm.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 6eb39a088b..a5bec96fb0 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -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, ...);
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 07/21] accel/kvm: Simplify user-mode #ifdef'ry
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (5 preceding siblings ...)
2022-02-03 19:17 ` [PATCH v2 06/21] sysemu/kvm: Make kvm_on_sigbus() / kvm_on_sigbus_vcpu() target agnostic Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE Philippe Mathieu-Daudé via
` (14 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Now than we only build this stub with system emulation,
remove the user-mode #ifdef'ry.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
accel/stubs/kvm-stub.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index 5319573e00..7e0fb884b9 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (6 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 07/21] accel/kvm: Simplify user-mode #ifdef'ry Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:15 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 09/21] softmmu/cpus: Code movement Philippe Mathieu-Daudé via
` (13 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Mirror "sysemu/kvm.h" #ifdef'ry to define CONFIG_HAX_IS_POSSIBLE,
expose hax_allowed to hax_enabled() macro.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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(-)
diff --git a/accel/stubs/hax-stub.c b/accel/stubs/hax-stub.c
index 49077f88e3..2fe31aaa9a 100644
--- a/accel/stubs/hax-stub.c
+++ b/accel/stubs/hax-stub.c
@@ -16,6 +16,8 @@
#include "qemu/osdep.h"
#include "sysemu/hax.h"
+bool hax_allowed;
+
int hax_sync_vcpus(void)
{
return 0;
diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
index 247f0661d1..bf8f99a824 100644
--- a/include/sysemu/hax.h
+++ b/include/sysemu/hax.h
@@ -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 */
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index bf65ed6fa9..ccdcb6afab 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE
2022-02-03 19:18 ` [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE Philippe Mathieu-Daudé via
@ 2022-02-05 23:15 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> Mirror "sysemu/kvm.h" #ifdef'ry to define CONFIG_HAX_IS_POSSIBLE,
> expose hax_allowed to hax_enabled() macro.
>
> Suggested-by: Richard Henderson<richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 09/21] softmmu/cpus: Code movement
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (7 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 08/21] accel/hax: Introduce CONFIG_HAX_IS_POSSIBLE Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:16 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle() Philippe Mathieu-Daudé via
` (12 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
We want cpu_thread_is_idle() to use cpus_accel, so declare this
variable earlier.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/cpus.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 7f15106dd9..538e1714af 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 09/21] softmmu/cpus: Code movement
2022-02-03 19:18 ` [PATCH v2 09/21] softmmu/cpus: Code movement Philippe Mathieu-Daudé via
@ 2022-02-05 23:16 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> We want cpu_thread_is_idle() to use cpus_accel, so declare this
> variable earlier.
>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> softmmu/cpus.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle()
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (8 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 09/21] softmmu/cpus: Code movement Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:22 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable() Philippe Mathieu-Daudé via
` (11 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Add cpu_thread_is_idle() to AccelOps, and implement it for the
KVM / WHPX accelerators.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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(-)
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 7516c67a3f..95b7b08020 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -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;
diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 032f6979d7..50c72540c7 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -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);
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 538e1714af..5b0bcb8c65 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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;
}
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 6bc47c5309..1d30e4e2ed 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle()
2022-02-03 19:18 ` [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle() Philippe Mathieu-Daudé via
@ 2022-02-05 23:22 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> Add cpu_thread_is_idle() to AccelOps, and implement it for the
> KVM / WHPX accelerators.
>
> Suggested-by: Richard Henderson<richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable()
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (9 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 10/21] accel: Introduce AccelOpsClass::cpu_thread_is_idle() Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:25 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 12/21] softmmu/globals: Remove unused 'hw/i386/*' headers Philippe Mathieu-Daudé via
` (10 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Add cpus_are_resettable() to AccelOps, and implement it for the
KVM accelerator.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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(-)
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 95b7b08020..cd4d4a06a7 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -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;
diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 50c72540c7..6013c9444c 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -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);
diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h
index 01b5ebf442..22903a55f7 100644
--- a/include/sysemu/hw_accel.h
+++ b/include/sysemu/hw_accel.h
@@ -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 */
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 5b0bcb8c65..79e7d7a608 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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)
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable()
2022-02-03 19:18 ` [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable() Philippe Mathieu-Daudé via
@ 2022-02-05 23:25 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> Add cpus_are_resettable() to AccelOps, and implement it for the
> KVM accelerator.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> 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(-)
>
> diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
> index 95b7b08020..cd4d4a06a7 100644
> --- a/accel/kvm/kvm-accel-ops.c
> +++ b/accel/kvm/kvm-accel-ops.c
> @@ -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,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 12/21] softmmu/globals: Remove unused 'hw/i386/*' headers
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (10 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 11/21] accel: Introduce AccelOpsClass::cpus_are_resettable() Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 13/21] softmmu/runstate: Clean headers Philippe Mathieu-Daudé via
` (9 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/globals.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/softmmu/globals.c b/softmmu/globals.c
index 7d0fc81183..3ebd718e35 100644
--- a/softmmu/globals.c
+++ b/softmmu/globals.c
@@ -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"
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 13/21] softmmu/runstate: Clean headers
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (11 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 12/21] softmmu/globals: Remove unused 'hw/i386/*' headers Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include Philippe Mathieu-Daudé via
` (8 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Add the missing 'qemu/log.h' header and remove the
unused 'exec/exec-all.h' one.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/runstate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index 10d9b7365a..3cb2758b33 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -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"
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (12 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 13/21] softmmu/runstate: Clean headers Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:26 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 15/21] softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header Philippe Mathieu-Daudé via
` (7 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/physmem.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index eb4b3bcae7..09951c0996 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -60,7 +60,6 @@
#include "exec/memory-internal.h"
#include "exec/ram_addr.h"
-#include "exec/log.h"
#include "qemu/pmem.h"
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include
2022-02-03 19:18 ` [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include Philippe Mathieu-Daudé via
@ 2022-02-05 23:26 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> softmmu/physmem.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index eb4b3bcae7..09951c0996 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -60,7 +60,6 @@
>
> #include "exec/memory-internal.h"
> #include "exec/ram_addr.h"
> -#include "exec/log.h"
>
> #include "qemu/pmem.h"
>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 15/21] softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (13 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 14/21] softmmu/physmem: Remove unnecessary include Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 16/21] misc: Remove unnecessary "sysemu/cpu-timers.h" include Philippe Mathieu-Daudé via
` (6 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/cpu-timers.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/softmmu/cpu-timers.c b/softmmu/cpu-timers.c
index 34ddfa02f1..204d946a17 100644
--- a/softmmu/cpu-timers.c
+++ b/softmmu/cpu-timers.c
@@ -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"
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 16/21] misc: Remove unnecessary "sysemu/cpu-timers.h" include
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (14 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 15/21] softmmu/cpu-timers: Remove unused 'exec/exec-all.h' header Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:29 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 17/21] misc: Add missing " Philippe Mathieu-Daudé via
` (5 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
accel/qtest/qtest.c | 1 -
target/alpha/translate.c | 1 -
tests/unit/ptimer-test-stubs.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 7e6b8110d5..f6056ac836 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -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"
diff --git a/target/alpha/translate.c b/target/alpha/translate.c
index ca78a0faed..66768ab47a 100644
--- a/target/alpha/translate.c
+++ b/target/alpha/translate.c
@@ -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"
diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c
index 2a3ef58799..f5e75a96b6 100644
--- a/tests/unit/ptimer-test-stubs.c
+++ b/tests/unit/ptimer-test-stubs.c
@@ -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"
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 17/21] misc: Add missing "sysemu/cpu-timers.h" include
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (15 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 16/21] misc: Remove unnecessary "sysemu/cpu-timers.h" include Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:30 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 18/21] exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic Philippe Mathieu-Daudé via
` (4 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
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(-)
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c
index ea42d1d51b..bdaf2c943b 100644
--- a/accel/tcg/tcg-accel-ops-icount.c
+++ b/accel/tcg/tcg-accel-ops-icount.c
@@ -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"
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index 29632bd4c0..dc421c8fd7 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -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"
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index bf59f53dbc..a805fb6bdd 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -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"
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 1a8e8390bd..ea7dcad674 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -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"
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 35d8e93976..87df70fa8f 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -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
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index e5f9d4ef93..a4db40769b 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -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)
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 17/21] misc: Add missing "sysemu/cpu-timers.h" include
2022-02-03 19:18 ` [PATCH v2 17/21] misc: Add missing " Philippe Mathieu-Daudé via
@ 2022-02-05 23:30 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> 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(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 18/21] exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (16 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 17/21] misc: Add missing " Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-03 19:18 ` [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map " Philippe Mathieu-Daudé via
` (3 subsequent siblings)
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
gdb_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.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/exec/gdbstub.h | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index a024a0350d..84b1f2ff2a 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -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.
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map target agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (17 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 18/21] exec/gdbstub: Make gdb_exit() / gdb_set_stop_cpu() target agnostic Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:31 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules() Philippe Mathieu-Daudé via
` (2 subsequent siblings)
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
cpu_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.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/exec/cpu-common.h | 23 +++++++++++++++++++++++
include/exec/exec-all.h | 25 -------------------------
2 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 8031ebc680..7f7b5943c7 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -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);
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 87df70fa8f..199fd49e5d 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -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 */
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map target agnostic
2022-02-03 19:18 ` [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map " Philippe Mathieu-Daudé via
@ 2022-02-05 23:31 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> cpu_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.
>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> include/exec/cpu-common.h | 23 +++++++++++++++++++++++
> include/exec/exec-all.h | 25 -------------------------
> 2 files changed, 23 insertions(+), 25 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules()
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (18 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 19/21] exec/cpu: Make address_space_init/reloading_memory_map " Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-05 23:32 ` Richard Henderson
2022-02-03 19:18 ` [PATCH v2 21/21] softmmu: Build target-agnostic objects once Philippe Mathieu-Daudé via
2022-02-04 12:21 ` [PATCH v2 00/21] softmmu: Make various objects target agnostic Paolo Bonzini
21 siblings, 1 reply; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
module_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).
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/sysemu/arch_init.h | 2 ++
softmmu/arch_init.c | 9 +++++++++
softmmu/vl.c | 5 +----
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 70c579560a..79c2591425 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -28,4 +28,6 @@ enum {
extern const uint32_t arch_type;
+void qemu_init_arch_modules(void);
+
#endif
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 8919405c7b..79716f959b 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -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
+}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5e1b35ba48..08ff97f4e0 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -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();
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules()
2022-02-03 19:18 ` [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules() Philippe Mathieu-Daudé via
@ 2022-02-05 23:32 ` Richard Henderson
0 siblings, 0 replies; 39+ messages in thread
From: Richard Henderson @ 2022-02-05 23:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Paolo Bonzini, Thomas Huth
On 2/4/22 06:18, Philippe Mathieu-Daudé wrote:
> module_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).
>
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> include/sysemu/arch_init.h | 2 ++
> softmmu/arch_init.c | 9 +++++++++
> softmmu/vl.c | 5 +----
> 3 files changed, 12 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH v2 21/21] softmmu: Build target-agnostic objects once
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (19 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 20/21] softmmu: Add qemu_init_arch_modules() Philippe Mathieu-Daudé via
@ 2022-02-03 19:18 ` Philippe Mathieu-Daudé via
2022-02-04 12:21 ` [PATCH v2 00/21] softmmu: Make various objects target agnostic Paolo Bonzini
21 siblings, 0 replies; 39+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-03 19:18 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
Various 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!
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/meson.build | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/softmmu/meson.build b/softmmu/meson.build
index d8e03018ab..d2badf203b 100644
--- a/softmmu/meson.build
+++ b/softmmu/meson.build
@@ -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'))
--
2.34.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH v2 00/21] softmmu: Make various objects target agnostic
2022-02-03 19:17 [PATCH v2 00/21] softmmu: Make various objects target agnostic Philippe Mathieu-Daudé via
` (20 preceding siblings ...)
2022-02-03 19:18 ` [PATCH v2 21/21] softmmu: Build target-agnostic objects once Philippe Mathieu-Daudé via
@ 2022-02-04 12:21 ` Paolo Bonzini
21 siblings, 0 replies; 39+ messages in thread
From: Paolo Bonzini @ 2022-02-04 12:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Thomas Huth, Richard Henderson
On 2/3/22 20:17, Philippe Mathieu-Daudé via wrote:
> This is a re-org accel/ and softmmu/ to have more target-agnostic
> objects.
Neat! vl.c in particular bothered me.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
> 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(-)
>
^ permalink raw reply [flat|nested] 39+ messages in thread