* [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG
@ 2023-10-03 12:30 Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 1/7] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Philippe Mathieu-Daudé
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
Since v1:
- Use 'target'/'common' in function names (Claudio)
- Added Claudio R-b tags
From v1:
- Add missing accel_cpu_common_unrealize()
- Add AccelClass::cpu_common_[un]realize handlers
- Use tcg_exec_[un]realizefn as AccelClass handlers
Philippe Mathieu-Daudé (7):
accel: Rename accel_cpu_realizefn() -> accel_cpu_realize()
accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize()
accel: Rename accel_cpu_realize() -> accel_cpu_common_realize()
accel: Introduce accel_cpu_common_unrealize() stub
accel: Declare AccelClass::cpu_common_[un]realize() handlers
accel/tcg: Have tcg_exec_realizefn() return a boolean
accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG
accel/tcg/internal.h | 3 +++
include/exec/cpu-all.h | 2 --
include/hw/core/accel-cpu.h | 2 +-
include/qemu/accel.h | 12 ++++++++++--
accel/accel-common.c | 27 ++++++++++++++++++++++++---
accel/tcg/cpu-exec.c | 4 +++-
accel/tcg/tcg-all.c | 2 ++
cpu.c | 13 +++----------
target/i386/hvf/hvf-cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 4 ++--
target/i386/tcg/tcg-cpu.c | 2 +-
11 files changed, 50 insertions(+), 23 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/7] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize()
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 2/7] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize() Philippe Mathieu-Daudé
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
We use the '*fn' suffix for handlers, this is a public method.
Drop the suffix.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
---
include/qemu/accel.h | 4 ++--
accel/accel-common.c | 2 +-
cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index e84db2e3e5..cb64a07b84 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -90,11 +90,11 @@ void accel_setup_post(MachineState *ms);
void accel_cpu_instance_init(CPUState *cpu);
/**
- * accel_cpu_realizefn:
+ * accel_cpu_realize:
* @cpu: The CPU that needs to call accel-specific cpu realization.
* @errp: currently unused.
*/
-bool accel_cpu_realizefn(CPUState *cpu, Error **errp);
+bool accel_cpu_realize(CPUState *cpu, Error **errp);
/**
* accel_supported_gdbstub_sstep_flags:
diff --git a/accel/accel-common.c b/accel/accel-common.c
index df72cc989a..b953855e8b 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -119,7 +119,7 @@ void accel_cpu_instance_init(CPUState *cpu)
}
}
-bool accel_cpu_realizefn(CPUState *cpu, Error **errp)
+bool accel_cpu_realize(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
diff --git a/cpu.c b/cpu.c
index 0769b0b153..61c9760e62 100644
--- a/cpu.c
+++ b/cpu.c
@@ -136,7 +136,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
/* cache the cpu class for the hotpath */
cpu->cc = CPU_GET_CLASS(cpu);
- if (!accel_cpu_realizefn(cpu, errp)) {
+ if (!accel_cpu_realize(cpu, errp)) {
return;
}
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index 7237378a7d..4474689f81 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -35,7 +35,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
* x86_cpu_realize():
* -> x86_cpu_expand_features()
* -> cpu_exec_realizefn():
- * -> accel_cpu_realizefn()
+ * -> accel_cpu_realize()
* kvm_cpu_realizefn() -> host_cpu_realizefn()
* -> check/update ucode_rev, phys_bits, mwait
*/
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/7] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize()
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 1/7] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 3/7] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize() Philippe Mathieu-Daudé
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
The AccelCPUClass::cpu_realizefn handler is meant for target
specific code, rename it using '_target_' to emphasis it.
Suggested-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/accel-cpu.h | 2 +-
accel/accel-common.c | 4 ++--
target/i386/hvf/hvf-cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 2 +-
target/i386/tcg/tcg-cpu.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/hw/core/accel-cpu.h b/include/hw/core/accel-cpu.h
index 5dbfd79955..24dad45ab9 100644
--- a/include/hw/core/accel-cpu.h
+++ b/include/hw/core/accel-cpu.h
@@ -32,7 +32,7 @@ typedef struct AccelCPUClass {
void (*cpu_class_init)(CPUClass *cc);
void (*cpu_instance_init)(CPUState *cpu);
- bool (*cpu_realizefn)(CPUState *cpu, Error **errp);
+ bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
} AccelCPUClass;
#endif /* ACCEL_CPU_H */
diff --git a/accel/accel-common.c b/accel/accel-common.c
index b953855e8b..2e30b9d8f0 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -123,8 +123,8 @@ bool accel_cpu_realize(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
- if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) {
- return cc->accel_cpu->cpu_realizefn(cpu, errp);
+ if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize) {
+ return cc->accel_cpu->cpu_target_realize(cpu, errp);
}
return true;
}
diff --git a/target/i386/hvf/hvf-cpu.c b/target/i386/hvf/hvf-cpu.c
index 333db59898..bb0da3947a 100644
--- a/target/i386/hvf/hvf-cpu.c
+++ b/target/i386/hvf/hvf-cpu.c
@@ -77,7 +77,7 @@ static void hvf_cpu_accel_class_init(ObjectClass *oc, void *data)
{
AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
- acc->cpu_realizefn = host_cpu_realizefn;
+ acc->cpu_target_realize = host_cpu_realizefn;
acc->cpu_instance_init = hvf_cpu_instance_init;
}
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index 4474689f81..9a5e105e4e 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -190,7 +190,7 @@ static void kvm_cpu_accel_class_init(ObjectClass *oc, void *data)
{
AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
- acc->cpu_realizefn = kvm_cpu_realizefn;
+ acc->cpu_target_realize = kvm_cpu_realizefn;
acc->cpu_instance_init = kvm_cpu_instance_init;
}
static const TypeInfo kvm_cpu_accel_type_info = {
diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c
index b942c306d6..5c3a508ddc 100644
--- a/target/i386/tcg/tcg-cpu.c
+++ b/target/i386/tcg/tcg-cpu.c
@@ -163,7 +163,7 @@ static void tcg_cpu_accel_class_init(ObjectClass *oc, void *data)
AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
#ifndef CONFIG_USER_ONLY
- acc->cpu_realizefn = tcg_cpu_realizefn;
+ acc->cpu_target_realize = tcg_cpu_realizefn;
#endif /* CONFIG_USER_ONLY */
acc->cpu_class_init = tcg_cpu_class_init;
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/7] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize()
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 1/7] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 2/7] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize() Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 4/7] accel: Introduce accel_cpu_common_unrealize() stub Philippe Mathieu-Daudé
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
accel_cpu_realize() is a generic function working with CPUs
from any target. Rename it using '_common_' to emphasis it is
not target specific.
Suggested-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/accel.h | 4 ++--
accel/accel-common.c | 2 +-
cpu.c | 2 +-
target/i386/kvm/kvm-cpu.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index cb64a07b84..898159c001 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -90,11 +90,11 @@ void accel_setup_post(MachineState *ms);
void accel_cpu_instance_init(CPUState *cpu);
/**
- * accel_cpu_realize:
+ * accel_cpu_common_realize:
* @cpu: The CPU that needs to call accel-specific cpu realization.
* @errp: currently unused.
*/
-bool accel_cpu_realize(CPUState *cpu, Error **errp);
+bool accel_cpu_common_realize(CPUState *cpu, Error **errp);
/**
* accel_supported_gdbstub_sstep_flags:
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 2e30b9d8f0..53cf08a89a 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -119,7 +119,7 @@ void accel_cpu_instance_init(CPUState *cpu)
}
}
-bool accel_cpu_realize(CPUState *cpu, Error **errp)
+bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
diff --git a/cpu.c b/cpu.c
index 61c9760e62..1e2649a706 100644
--- a/cpu.c
+++ b/cpu.c
@@ -136,7 +136,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
/* cache the cpu class for the hotpath */
cpu->cc = CPU_GET_CLASS(cpu);
- if (!accel_cpu_realize(cpu, errp)) {
+ if (!accel_cpu_common_realize(cpu, errp)) {
return;
}
diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c
index 9a5e105e4e..56c72f3c45 100644
--- a/target/i386/kvm/kvm-cpu.c
+++ b/target/i386/kvm/kvm-cpu.c
@@ -35,7 +35,7 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
* x86_cpu_realize():
* -> x86_cpu_expand_features()
* -> cpu_exec_realizefn():
- * -> accel_cpu_realize()
+ * -> accel_cpu_common_realize()
* kvm_cpu_realizefn() -> host_cpu_realizefn()
* -> check/update ucode_rev, phys_bits, mwait
*/
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/7] accel: Introduce accel_cpu_common_unrealize() stub
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-10-03 12:30 ` [PATCH v2 3/7] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize() Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 5/7] accel: Declare AccelClass::cpu_common_[un]realize() handlers Philippe Mathieu-Daudé
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
Prepare the stub for parity with accel_cpu_common_realize().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/accel.h | 6 ++++++
accel/accel-common.c | 4 ++++
cpu.c | 4 +++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 898159c001..446153b145 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -96,6 +96,12 @@ void accel_cpu_instance_init(CPUState *cpu);
*/
bool accel_cpu_common_realize(CPUState *cpu, Error **errp);
+/**
+ * accel_cpu_common_unrealize:
+ * @cpu: The CPU that needs to call accel-specific cpu unrealization.
+ */
+void accel_cpu_common_unrealize(CPUState *cpu);
+
/**
* accel_supported_gdbstub_sstep_flags:
*
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 53cf08a89a..e9548eac29 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -129,6 +129,10 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
return true;
}
+void accel_cpu_common_unrealize(CPUState *cpu)
+{
+}
+
int accel_supported_gdbstub_sstep_flags(void)
{
AccelState *accel = current_accel();
diff --git a/cpu.c b/cpu.c
index 1e2649a706..2a1eff948b 100644
--- a/cpu.c
+++ b/cpu.c
@@ -187,8 +187,10 @@ void cpu_exec_unrealizefn(CPUState *cpu)
cpu_list_remove(cpu);
/*
* Now that the vCPU has been removed from the RCU list, we can call
- * tcg_exec_unrealizefn, which may free fields using call_rcu.
+ * tcg_exec_unrealizefn and
+ * accel_cpu_common_unrealize, which may free fields using call_rcu.
*/
+ accel_cpu_common_unrealize(cpu);
if (tcg_enabled()) {
tcg_exec_unrealizefn(cpu);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 5/7] accel: Declare AccelClass::cpu_common_[un]realize() handlers
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-10-03 12:30 ` [PATCH v2 4/7] accel: Introduce accel_cpu_common_unrealize() stub Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 6/7] accel/tcg: Have tcg_exec_realizefn() return a boolean Philippe Mathieu-Daudé
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
Currently accel_cpu_realize() only performs target-specific
realization. Introduce the cpu_common_[un]realize fields in
the base AccelClass to be able to perform target-agnostic
[un]realization of vCPUs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/accel.h | 2 ++
accel/accel-common.c | 21 +++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 446153b145..972a849a2b 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -43,6 +43,8 @@ typedef struct AccelClass {
bool (*has_memory)(MachineState *ms, AddressSpace *as,
hwaddr start_addr, hwaddr size);
#endif
+ bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
+ void (*cpu_common_unrealize)(CPUState *cpu);
/* gdbstub related hooks */
int (*gdbstub_supported_sstep_flags)(void);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index e9548eac29..11d74b4ad7 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -122,15 +122,32 @@ void accel_cpu_instance_init(CPUState *cpu)
bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
- if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize) {
- return cc->accel_cpu->cpu_target_realize(cpu, errp);
+ /* target specific realization */
+ if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize
+ && !cc->accel_cpu->cpu_target_realize(cpu, errp)) {
+ return false;
}
+
+ /* generic realization */
+ if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
+ return false;
+ }
+
return true;
}
void accel_cpu_common_unrealize(CPUState *cpu)
{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+
+ /* generic unrealization */
+ if (acc->cpu_common_unrealize) {
+ acc->cpu_common_unrealize(cpu);
+ }
}
int accel_supported_gdbstub_sstep_flags(void)
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 6/7] accel/tcg: Have tcg_exec_realizefn() return a boolean
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-10-03 12:30 ` [PATCH v2 5/7] accel: Declare AccelClass::cpu_common_[un]realize() handlers Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 7/7] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
Following the example documented since commit e3fe3988d7 ("error:
Document Error API usage rules"), have tcg_exec_realizefn() return
a boolean indicating whether an error is set or not.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
---
include/exec/cpu-all.h | 2 +-
accel/tcg/cpu-exec.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index c2c62160c6..1e5c530ee1 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -422,7 +422,7 @@ void dump_exec_info(GString *buf);
/* accel/tcg/cpu-exec.c */
int cpu_exec(CPUState *cpu);
-void tcg_exec_realizefn(CPUState *cpu, Error **errp);
+bool tcg_exec_realizefn(CPUState *cpu, Error **errp);
void tcg_exec_unrealizefn(CPUState *cpu);
/**
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index c724e8b6f1..60f1986b85 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1088,7 +1088,7 @@ int cpu_exec(CPUState *cpu)
return ret;
}
-void tcg_exec_realizefn(CPUState *cpu, Error **errp)
+bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
{
static bool tcg_target_initialized;
CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -1104,6 +1104,8 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp)
tcg_iommu_init_notifier_list(cpu);
#endif /* !CONFIG_USER_ONLY */
/* qemu_plugin_vcpu_init_hook delayed until cpu_index assigned. */
+
+ return true;
}
/* undo the initializations in reverse order */
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 7/7] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-10-03 12:30 ` [PATCH v2 6/7] accel/tcg: Have tcg_exec_realizefn() return a boolean Philippe Mathieu-Daudé
@ 2023-10-03 12:30 ` Philippe Mathieu-Daudé
2023-10-03 14:06 ` [PATCH v2 0/7] accel: " Claudio Fontana
2023-10-03 16:02 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-03 12:30 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Richard Henderson, Marcelo Tosatti,
Roman Bolshakov, Fabiano Rosas, Philippe Mathieu-Daudé,
Marcel Apfelbaum, Cameron Esfahani
We don't need to expose these TCG-specific methods to the
whole code base. Register them as AccelClass handlers, they
will be called by the generic accel_cpu_[un]realize() methods.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
---
accel/tcg/internal.h | 3 +++
include/exec/cpu-all.h | 2 --
accel/tcg/tcg-all.c | 2 ++
cpu.c | 9 ---------
4 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h
index e8cbbde581..57ab397df1 100644
--- a/accel/tcg/internal.h
+++ b/accel/tcg/internal.h
@@ -80,6 +80,9 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
uintptr_t host_pc);
+bool tcg_exec_realizefn(CPUState *cpu, Error **errp);
+void tcg_exec_unrealizefn(CPUState *cpu);
+
/* Return the current PC from CPU, which may be cached in TB. */
static inline vaddr log_pc(CPUState *cpu, const TranslationBlock *tb)
{
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 1e5c530ee1..230525ebf7 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -422,8 +422,6 @@ void dump_exec_info(GString *buf);
/* accel/tcg/cpu-exec.c */
int cpu_exec(CPUState *cpu);
-bool tcg_exec_realizefn(CPUState *cpu, Error **errp);
-void tcg_exec_unrealizefn(CPUState *cpu);
/**
* cpu_set_cpustate_pointers(cpu)
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 03dfd67e9e..8ab873a5ab 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -227,6 +227,8 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "tcg";
ac->init_machine = tcg_init_machine;
+ ac->cpu_common_realize = tcg_exec_realizefn;
+ ac->cpu_common_unrealize = tcg_exec_unrealizefn;
ac->allowed = &tcg_allowed;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
diff --git a/cpu.c b/cpu.c
index 2a1eff948b..658d179582 100644
--- a/cpu.c
+++ b/cpu.c
@@ -140,11 +140,6 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
return;
}
- /* NB: errp parameter is unused currently */
- if (tcg_enabled()) {
- tcg_exec_realizefn(cpu, errp);
- }
-
/* Wait until cpu initialization complete before exposing cpu. */
cpu_list_add(cpu);
@@ -187,13 +182,9 @@ void cpu_exec_unrealizefn(CPUState *cpu)
cpu_list_remove(cpu);
/*
* Now that the vCPU has been removed from the RCU list, we can call
- * tcg_exec_unrealizefn and
* accel_cpu_common_unrealize, which may free fields using call_rcu.
*/
accel_cpu_common_unrealize(cpu);
- if (tcg_enabled()) {
- tcg_exec_unrealizefn(cpu);
- }
}
/*
--
2.41.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2023-10-03 12:30 ` [PATCH v2 7/7] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
@ 2023-10-03 14:06 ` Claudio Fontana
2023-10-03 16:02 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Claudio Fontana @ 2023-10-03 14:06 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Richard Henderson, Marcelo Tosatti, Roman Bolshakov,
Fabiano Rosas, Marcel Apfelbaum, Cameron Esfahani
Nice. I build-tested and make checked this as well,
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Tested-by: Claudio Fontana <cfontana@suse.de>
On 10/3/23 14:30, Philippe Mathieu-Daudé wrote:
> Since v1:
> - Use 'target'/'common' in function names (Claudio)
> - Added Claudio R-b tags
>
> From v1:
> - Add missing accel_cpu_common_unrealize()
> - Add AccelClass::cpu_common_[un]realize handlers
> - Use tcg_exec_[un]realizefn as AccelClass handlers
>
> Philippe Mathieu-Daudé (7):
> accel: Rename accel_cpu_realizefn() -> accel_cpu_realize()
> accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize()
> accel: Rename accel_cpu_realize() -> accel_cpu_common_realize()
> accel: Introduce accel_cpu_common_unrealize() stub
> accel: Declare AccelClass::cpu_common_[un]realize() handlers
> accel/tcg: Have tcg_exec_realizefn() return a boolean
> accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG
>
> accel/tcg/internal.h | 3 +++
> include/exec/cpu-all.h | 2 --
> include/hw/core/accel-cpu.h | 2 +-
> include/qemu/accel.h | 12 ++++++++++--
> accel/accel-common.c | 27 ++++++++++++++++++++++++---
> accel/tcg/cpu-exec.c | 4 +++-
> accel/tcg/tcg-all.c | 2 ++
> cpu.c | 13 +++----------
> target/i386/hvf/hvf-cpu.c | 2 +-
> target/i386/kvm/kvm-cpu.c | 4 ++--
> target/i386/tcg/tcg-cpu.c | 2 +-
> 11 files changed, 50 insertions(+), 23 deletions(-)
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2023-10-03 14:06 ` [PATCH v2 0/7] accel: " Claudio Fontana
@ 2023-10-03 16:02 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2023-10-03 16:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Eduardo Habkost, Yanan Wang, Paolo Bonzini, kvm, Alex Bennée,
Claudio Fontana, Marcelo Tosatti, Roman Bolshakov, Fabiano Rosas,
Marcel Apfelbaum, Cameron Esfahani
On 10/3/23 05:30, Philippe Mathieu-Daudé wrote:
> Since v1:
> - Use 'target'/'common' in function names (Claudio)
> - Added Claudio R-b tags
>
> From v1:
> - Add missing accel_cpu_common_unrealize()
> - Add AccelClass::cpu_common_[un]realize handlers
> - Use tcg_exec_[un]realizefn as AccelClass handlers
Thanks, queued to tcg-next, replacing v1 that I queued before my holiday. :-)
r~
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-10-03 16:03 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 12:30 [PATCH v2 0/7] accel: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 1/7] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 2/7] accel: Rename AccelCPUClass::cpu_realizefn() -> cpu_target_realize() Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 3/7] accel: Rename accel_cpu_realize() -> accel_cpu_common_realize() Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 4/7] accel: Introduce accel_cpu_common_unrealize() stub Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 5/7] accel: Declare AccelClass::cpu_common_[un]realize() handlers Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 6/7] accel/tcg: Have tcg_exec_realizefn() return a boolean Philippe Mathieu-Daudé
2023-10-03 12:30 ` [PATCH v2 7/7] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG Philippe Mathieu-Daudé
2023-10-03 14:06 ` [PATCH v2 0/7] accel: " Claudio Fontana
2023-10-03 16:02 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).