* [PATCH 00/24] target/arm/hvf: Consolidate
@ 2025-09-03 10:06 Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create() Philippe Mathieu-Daudé
` (23 more replies)
0 siblings, 24 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
- Fix a pair of memory leak
- Check a pair of return values
- Mention calls which must be run on vCPU thread
- Force MIDR
- Use hv_vcpu_config_create/hv_vcpu_config_get_feature_reg
when not running on vCPU thread
- Factor hvf_handle_vmexit() / hvf_handle_exception(() out
- Call hv_vcpu_run() in loop
- Guard hv_vcpu_run() between cpu_exec_start/end()
- Restrict ARM specific in AccelCPUState
Based-on: <20250829152909.1589668-14-pbonzini@redhat.com>
Mohamed Mediouni (2):
target/arm/hvf: Hardcode Apple MIDR
target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a
vCPU
Philippe Mathieu-Daudé (22):
target/arm/hvf: Release memory allocated by hv_vcpu_config_create()
target/arm/hvf: Check hv_vcpus_exit() returned value
target/arm/hvf: Check hv_vcpu_set_vtimer_mask() returned value
accel/hvf: Rename hvf_vcpu_exec() -> hvf_arch_vcpu_exec()
accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers
target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread
accel/hvf: Mention hvf_arch_init_vcpu() must run on vCPU thread
target/arm/hvf: Mention hvf_wfi() must run on vCPU thread
target/arm/hvf: Mention hvf_sync_vtimer() must run on vCPU thread
target/arm/hvf: Mention hvf_arch_set_traps() must run on vCPU thread
accel/hvf: Mention hvf_arch_update_guest_debug() must run on vCPU
target/arm/hvf: Mention hvf_inject_interrupts() must run on vCPU
thread
accel/hvf: Implement hvf_arch_vcpu_destroy()
target/arm/hvf: Factor hvf_handle_exception() out
target/arm/hvf: Factor hvf_handle_vmexit() out
target/arm/hvf: Keep calling hv_vcpu_run() in loop
cpus: Trace cpu_exec_start() and cpu_exec_end() calls
accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls
target/arm: Call aarch64_add_pauth_properties() once in host_initfn()
accel/hvf: Restrict ARM specific fields of AccelCPUState
target/arm: Rename init_cpreg_list() -> arm_init_cpreg_list()
target/arm: Add arm_destroy_cpreg_list() helper
include/system/hvf_int.h | 23 ++--
target/arm/internals.h | 4 +-
accel/hvf/hvf-accel-ops.c | 4 +-
cpu-common.c | 3 +
target/arm/cpu.c | 2 +-
target/arm/cpu64.c | 8 +-
target/arm/helper.c | 10 +-
target/arm/hvf/hvf.c | 206 ++++++++++++++++++++++--------------
target/i386/hvf/hvf.c | 8 +-
target/i386/hvf/x86hvf.c | 4 +-
target/arm/hvf/trace-events | 1 +
trace-events | 2 +
12 files changed, 173 insertions(+), 102 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 45+ messages in thread
* [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create()
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:22 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value Philippe Mathieu-Daudé
` (22 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
hv_vcpu_config_create() is documented in <Hypervisor/hv_vcpu_config.h>
as:
/*!
@abstract Creates a vcpu configuration object.
@result A new vcpu configuration object. This should be released with os_release when no longer used.
*/
OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT
hv_vcpu_config_t hv_vcpu_config_create(void);
Release the memory allocated by hv_vcpu_config_create() with
os_release().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index b77db99079e..d67372218de 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -150,6 +150,8 @@ void hvf_arm_init_debug(void)
max_hw_wps = hvf_arm_num_wrps(config);
hw_watchpoints =
g_array_sized_new(true, true, sizeof(HWWatchpoint), max_hw_wps);
+
+ os_release(config);
}
#define HVF_SYSREG(crn, crm, op0, op1, op2) \
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create() Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:23 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() " Philippe Mathieu-Daudé
` (21 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini, Alex Bennée
hv_vcpus_exit() returns a hv_return_t enum type (defined
in <Hypervisor/hv_error.h>). Assert we succeeded, as we
are not ready to handle any error path.
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 5 ++++-
target/arm/hvf/trace-events | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index d67372218de..65ac0bd71aa 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1086,8 +1086,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
void hvf_kick_vcpu_thread(CPUState *cpu)
{
+ hv_return_t ret;
+ trace_hvf_kick_vcpu_thread(cpu->cpu_index, cpu->stop);
cpus_kick_thread(cpu);
- hv_vcpus_exit(&cpu->accel->fd, 1);
+ ret = hv_vcpus_exit(&cpu->accel->fd, 1);
+ assert_hvf_ok(ret);
}
static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events
index b29a995f3d3..538af6e0707 100644
--- a/target/arm/hvf/trace-events
+++ b/target/arm/hvf/trace-events
@@ -12,3 +12,4 @@ hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid
hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]"
hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
hvf_illegal_guest_state(void) "HV_ILLEGAL_GUEST_STATE"
+hvf_kick_vcpu_thread(unsigned cpuidx, bool stop) "cpu:%u stop:%u"
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() returned value
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create() Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:30 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 04/24] accel/hvf: Rename hvf_vcpu_exec() -> hvf_arch_vcpu_exec() Philippe Mathieu-Daudé
` (20 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
hv_vcpu_set_vtimer_mask() returns a hv_return_t enum type
(defined in <Hypervisor/hv_error.h>). Assert we succeeded,
as we are not ready to handle any error path.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 65ac0bd71aa..1b59cc0eb04 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1906,7 +1906,8 @@ static void hvf_sync_vtimer(CPUState *cpu)
if (!irq_state) {
/* Timer no longer asserting, we can unmask it */
- hv_vcpu_set_vtimer_mask(cpu->accel->fd, false);
+ r = hv_vcpu_set_vtimer_mask(cpu->accel->fd, false);
+ assert_hvf_ok(r);
cpu->accel->vtimer_masked = false;
}
}
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 04/24] accel/hvf: Rename hvf_vcpu_exec() -> hvf_arch_vcpu_exec()
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() " Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers Philippe Mathieu-Daudé
` (19 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
hvf_vcpu_exec() is implemented per target, rename it as
hvf_arch_vcpu_exec(), following the per target pattern.
Since it calls hv_vcpu_run(), mention it must be called
on the vCPU.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 4 +++-
accel/hvf/hvf-accel-ops.c | 2 +-
target/arm/hvf/hvf.c | 2 +-
target/i386/hvf/hvf.c | 2 +-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index a3b06a3e75b..32b32e1d024 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -73,12 +73,14 @@ int hvf_arch_init(void);
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
int hvf_arch_init_vcpu(CPUState *cpu);
void hvf_arch_vcpu_destroy(CPUState *cpu);
-int hvf_vcpu_exec(CPUState *);
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
int hvf_put_registers(CPUState *);
int hvf_get_registers(CPUState *);
void hvf_kick_vcpu_thread(CPUState *cpu);
+/* Must be called by the owning thread */
+int hvf_arch_vcpu_exec(CPUState *);
+
struct hvf_sw_breakpoint {
vaddr pc;
vaddr saved_insn;
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 4ba3e40831f..c1415b0949a 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -194,7 +194,7 @@ static void *hvf_cpu_thread_fn(void *arg)
do {
qemu_wait_io_event(cpu);
if (cpu_can_run(cpu)) {
- r = hvf_vcpu_exec(cpu);
+ r = hvf_arch_vcpu_exec(cpu);
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
}
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 1b59cc0eb04..7427ac240fb 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1912,7 +1912,7 @@ static void hvf_sync_vtimer(CPUState *cpu)
}
}
-int hvf_vcpu_exec(CPUState *cpu)
+int hvf_arch_vcpu_exec(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
CPUARMState *env = &arm_cpu->env;
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 8445cadecec..15f79e523e6 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -721,7 +721,7 @@ void hvf_simulate_wrmsr(CPUState *cs)
printf("write msr %llx\n", RCX(cs));*/
}
-int hvf_vcpu_exec(CPUState *cpu)
+int hvf_arch_vcpu_exec(CPUState *cpu)
{
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 04/24] accel/hvf: Rename hvf_vcpu_exec() -> hvf_arch_vcpu_exec() Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:31 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread Philippe Mathieu-Daudé
` (18 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
hvf_put_registers() and hvf_get_registers() are implemented per
target, rename them using the 'hvf_arch_' prefix following the
per target pattern.
Since they call hv_vcpu_set_reg() / hv_vcpu_get_reg(), mention
they must be called on the vCPU.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 6 ++++--
accel/hvf/hvf-accel-ops.c | 2 +-
target/arm/hvf/hvf.c | 8 +++++---
target/i386/hvf/hvf.c | 2 +-
target/i386/hvf/x86hvf.c | 4 ++--
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index 32b32e1d024..8fce627b08c 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -74,12 +74,14 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
int hvf_arch_init_vcpu(CPUState *cpu);
void hvf_arch_vcpu_destroy(CPUState *cpu);
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
-int hvf_put_registers(CPUState *);
-int hvf_get_registers(CPUState *);
void hvf_kick_vcpu_thread(CPUState *cpu);
/* Must be called by the owning thread */
int hvf_arch_vcpu_exec(CPUState *);
+/* Must be called by the owning thread */
+int hvf_arch_put_registers(CPUState *);
+/* Must be called by the owning thread */
+int hvf_arch_get_registers(CPUState *);
struct hvf_sw_breakpoint {
vaddr pc;
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index c1415b0949a..b6b7b462144 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -81,7 +81,7 @@ hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->vcpu_dirty) {
- hvf_get_registers(cpu);
+ hvf_arch_get_registers(cpu);
cpu->vcpu_dirty = true;
}
}
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 7427ac240fb..21002f419f5 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -549,7 +549,7 @@ static struct hvf_sreg_match hvf_sreg_match[] = {
{ HV_SYS_REG_SP_EL1, HVF_SYSREG(4, 1, 3, 4, 0) },
};
-int hvf_get_registers(CPUState *cpu)
+int hvf_arch_get_registers(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
CPUARMState *env = &arm_cpu->env;
@@ -688,7 +688,7 @@ int hvf_get_registers(CPUState *cpu)
return 0;
}
-int hvf_put_registers(CPUState *cpu)
+int hvf_arch_put_registers(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
CPUARMState *env = &arm_cpu->env;
@@ -817,11 +817,12 @@ int hvf_put_registers(CPUState *cpu)
static void flush_cpu_state(CPUState *cpu)
{
if (cpu->vcpu_dirty) {
- hvf_put_registers(cpu);
+ hvf_arch_put_registers(cpu);
cpu->vcpu_dirty = false;
}
}
+/* Must be called by the owning thread */
static void hvf_set_reg(CPUState *cpu, int rt, uint64_t val)
{
hv_return_t r;
@@ -834,6 +835,7 @@ static void hvf_set_reg(CPUState *cpu, int rt, uint64_t val)
}
}
+/* Must be called by the owning thread */
static uint64_t hvf_get_reg(CPUState *cpu, int rt)
{
uint64_t val = 0;
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 15f79e523e6..73c50175048 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -734,7 +734,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
do {
if (cpu->vcpu_dirty) {
- hvf_put_registers(cpu);
+ hvf_arch_put_registers(cpu);
cpu->vcpu_dirty = false;
}
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index a502437c303..afcf737759b 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -236,7 +236,7 @@ void hvf_get_msrs(CPUState *cs)
env->tsc = rdtscp() + rvmcs(cs->accel->fd, VMCS_TSC_OFFSET);
}
-int hvf_put_registers(CPUState *cs)
+int hvf_arch_put_registers(CPUState *cs)
{
X86CPU *x86cpu = X86_CPU(cs);
CPUX86State *env = &x86cpu->env;
@@ -280,7 +280,7 @@ int hvf_put_registers(CPUState *cs)
return 0;
}
-int hvf_get_registers(CPUState *cs)
+int hvf_arch_get_registers(CPUState *cs)
{
X86CPU *x86cpu = X86_CPU(cs);
CPUX86State *env = &x86cpu->env;
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:31 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() " Philippe Mathieu-Daudé
` (17 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since flush_cpu_state() calls hvf_arch_put_registers(),
which must run on a vCPU, it also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 21002f419f5..58934953c4a 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -814,6 +814,7 @@ int hvf_arch_put_registers(CPUState *cpu)
return 0;
}
+/* Must be called by the owning thread */
static void flush_cpu_state(CPUState *cpu)
{
if (cpu->vcpu_dirty) {
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:33 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() " Philippe Mathieu-Daudé
` (16 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
hvf_arch_init_vcpu(), along with hvf_put_guest_debug_registers()
and hvf_put_gdbstub_debug_registers(), calls hv_vcpu_set_sys_reg(),
which must run on a vCPU. Mention they also must.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 3 ++-
target/arm/hvf/hvf.c | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index 8fce627b08c..0c335facc3b 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -71,11 +71,12 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
const char *hvf_return_string(hv_return_t ret);
int hvf_arch_init(void);
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
-int hvf_arch_init_vcpu(CPUState *cpu);
void hvf_arch_vcpu_destroy(CPUState *cpu);
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
void hvf_kick_vcpu_thread(CPUState *cpu);
+/* Must be called by the owning thread */
+int hvf_arch_init_vcpu(CPUState *cpu);
/* Must be called by the owning thread */
int hvf_arch_vcpu_exec(CPUState *);
/* Must be called by the owning thread */
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 58934953c4a..d87a41bcc53 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2244,6 +2244,7 @@ void hvf_arch_remove_all_hw_breakpoints(void)
* consists of all hardware breakpoints and watchpoints inserted so far while
* debugging the guest.
*/
+/* Must be called by the owning thread */
static void hvf_put_gdbstub_debug_registers(CPUState *cpu)
{
hv_return_t r = HV_SUCCESS;
@@ -2282,6 +2283,7 @@ static void hvf_put_gdbstub_debug_registers(CPUState *cpu)
* Update the vCPU with the guest's view of debug registers. This view is kept
* in the environment at all times.
*/
+/* Must be called by the owning thread */
static void hvf_put_guest_debug_registers(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() " Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:34 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 09/24] target/arm/hvf: Mention hvf_sync_vtimer() " Philippe Mathieu-Daudé
` (15 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since hvf_wfi() calls hv_vcpu_get_sys_reg(), which
must run on a vCPU, it also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index d87a41bcc53..05fc591b523 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1836,6 +1836,7 @@ static void hvf_wait_for_ipi(CPUState *cpu, struct timespec *ts)
bql_lock();
}
+/* Must be called by the owning thread */
static void hvf_wfi(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 09/24] target/arm/hvf: Mention hvf_sync_vtimer() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() " Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 10/24] target/arm/hvf: Mention hvf_arch_set_traps() " Philippe Mathieu-Daudé
` (14 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since hvf_sync_vtimer() calls hv_vcpu_get_sys_reg(),
which must run on a vCPU, it also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 05fc591b523..a7e4b869b04 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1889,6 +1889,7 @@ static void hvf_wfi(CPUState *cpu)
hvf_wait_for_ipi(cpu, &ts);
}
+/* Must be called by the owning thread */
static void hvf_sync_vtimer(CPUState *cpu)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 10/24] target/arm/hvf: Mention hvf_arch_set_traps() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 09/24] target/arm/hvf: Mention hvf_sync_vtimer() " Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 11/24] accel/hvf: Mention hvf_arch_update_guest_debug() must run on vCPU Philippe Mathieu-Daudé
` (13 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since hvf_arch_set_traps() calls hv_vcpu_set_trap_debug_exceptions()
and hv_vcpu_set_trap_debug_reg_accesses(), which must run on a vCPU,
it also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index a7e4b869b04..a9793060579 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2317,6 +2317,7 @@ static inline bool hvf_arm_hw_debug_active(CPUState *cpu)
return ((cur_hw_wps > 0) || (cur_hw_bps > 0));
}
+/* Must be called by the owning thread */
static void hvf_arch_set_traps(CPUState *cpu)
{
bool should_enable_traps = false;
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 11/24] accel/hvf: Mention hvf_arch_update_guest_debug() must run on vCPU
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 10/24] target/arm/hvf: Mention hvf_arch_set_traps() " Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 12/24] target/arm/hvf: Mention hvf_inject_interrupts() must run on vCPU thread Philippe Mathieu-Daudé
` (12 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since hvf_arch_update_guest_debug() calls hvf_arch_set_traps()
and hvf_arch_update_guest_debug(), which must run on a vCPU, it
also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index 0c335facc3b..241c668795e 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -83,6 +83,8 @@ int hvf_arch_vcpu_exec(CPUState *);
int hvf_arch_put_registers(CPUState *);
/* Must be called by the owning thread */
int hvf_arch_get_registers(CPUState *);
+/* Must be called by the owning thread */
+void hvf_arch_update_guest_debug(CPUState *cpu);
struct hvf_sw_breakpoint {
vaddr pc;
@@ -109,7 +111,6 @@ void hvf_arch_remove_all_hw_breakpoints(void);
* handled by calling down to hvf_arch_update_guest_debug.
*/
int hvf_update_guest_debug(CPUState *cpu);
-void hvf_arch_update_guest_debug(CPUState *cpu);
/*
* Return whether the guest supports debugging.
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 12/24] target/arm/hvf: Mention hvf_inject_interrupts() must run on vCPU thread
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 11/24] accel/hvf: Mention hvf_arch_update_guest_debug() must run on vCPU Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy() Philippe Mathieu-Daudé
` (11 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Since hvf_inject_interrupts() calls hv_vcpu_set_pending_interrupt(),
which must run on a vCPU, it also must. Mention it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index a9793060579..4a535d65b7e 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1788,6 +1788,7 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)
return 1;
}
+/* Must be called by the owning thread */
static int hvf_inject_interrupts(CPUState *cpu)
{
if (cpu_test_interrupt(cpu, CPU_INTERRUPT_FIQ)) {
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy()
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 12/24] target/arm/hvf: Mention hvf_inject_interrupts() must run on vCPU thread Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:35 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 14/24] target/arm/hvf: Hardcode Apple MIDR Philippe Mathieu-Daudé
` (10 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Call hv_vcpu_destroy() to destroy our vCPU context.
As hv_vcpu_destroy() must be called by the owning thread,
document hvf_arch_vcpu_destroy() also does.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 3 ++-
target/arm/hvf/hvf.c | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index 241c668795e..195d64dcf18 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -71,13 +71,14 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
const char *hvf_return_string(hv_return_t ret);
int hvf_arch_init(void);
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
-void hvf_arch_vcpu_destroy(CPUState *cpu);
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
void hvf_kick_vcpu_thread(CPUState *cpu);
/* Must be called by the owning thread */
int hvf_arch_init_vcpu(CPUState *cpu);
/* Must be called by the owning thread */
+void hvf_arch_vcpu_destroy(CPUState *cpu);
+/* Must be called by the owning thread */
int hvf_arch_vcpu_exec(CPUState *);
/* Must be called by the owning thread */
int hvf_arch_put_registers(CPUState *);
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 4a535d65b7e..5b3c34014a5 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -992,6 +992,10 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu)
void hvf_arch_vcpu_destroy(CPUState *cpu)
{
+ hv_return_t ret;
+
+ ret = hv_vcpu_destroy(cpu->accel->fd);
+ assert_hvf_ok(ret);
}
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 14/24] target/arm/hvf: Hardcode Apple MIDR
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy() Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU Philippe Mathieu-Daudé
` (9 subsequent siblings)
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
From: Mohamed Mediouni <mohamed@unpredictable.fr>
Hardcode MIDR because Apple deliberately doesn't expose
a divergent MIDR across systems.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 5b3c34014a5..3039c0987dc 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -887,6 +887,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
hv_vcpu_t fd;
hv_return_t r = HV_SUCCESS;
hv_vcpu_exit_t *exit;
+ uint64_t t;
int i;
ahcf->dtb_compatible = "arm,armv8";
@@ -908,6 +909,17 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr);
r |= hv_vcpu_destroy(fd);
+ /*
+ * Hardcode MIDR because Apple deliberately doesn't expose a divergent
+ * MIDR across systems.
+ */
+ t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0x61); /* Apple */
+ t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); /* v7 or later */
+ t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 0);
+ t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0);
+ t = FIELD_DP64(t, MIDR_EL1, REVISION, 0);
+ ahcf->midr = t;
+
clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar);
/*
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 14/24] target/arm/hvf: Hardcode Apple MIDR Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:13 ` Philippe Mathieu-Daudé
2025-09-03 12:03 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out Philippe Mathieu-Daudé
` (8 subsequent siblings)
23 siblings, 2 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
From: Mohamed Mediouni <mohamed@unpredictable.fr>
Creating a vCPU locks out APIs such as hv_gic_create().
As a result, switch to using the hv_vcpu_config_get_feature_reg interface.
Besides, all the following methods must be run on a vCPU thread:
- hv_vcpu_create()
- hv_vcpu_get_sys_reg()
- hv_vcpu_destroy()
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250808070137.48716-3-mohamed@unpredictable.fr>
[PMD: Release config calling os_release()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 3039c0987dc..fd209d23c1e 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -869,24 +869,25 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
{
ARMISARegisters host_isar = {};
const struct isar_regs {
- int reg;
+ hv_feature_reg_t reg;
uint64_t *val;
} regs[] = {
- { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
- { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] },
- { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] },
- { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] },
- { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
- { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },
/* Add ID_AA64ISAR2_EL1 here when HVF supports it */
- { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.idregs[ID_AA64MMFR0_EL1_IDX] },
- { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.idregs[ID_AA64MMFR1_EL1_IDX] },
- { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.idregs[ID_AA64MMFR2_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64MMFR0_EL1, &host_isar.idregs[ID_AA64MMFR0_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64MMFR1_EL1, &host_isar.idregs[ID_AA64MMFR1_EL1_IDX] },
+ { HV_FEATURE_REG_ID_AA64MMFR2_EL1, &host_isar.idregs[ID_AA64MMFR2_EL1_IDX] },
/* Add ID_AA64MMFR3_EL1 here when HVF supports it */
+ { HV_FEATURE_REG_CTR_EL0, &host_isar.idregs[CTR_EL0_IDX] },
+ { HV_FEATURE_REG_CLIDR_EL1, &host_isar.idregs[CLIDR_EL1_IDX] },
};
- hv_vcpu_t fd;
hv_return_t r = HV_SUCCESS;
- hv_vcpu_exit_t *exit;
+ hv_vcpu_config_t config = hv_vcpu_config_create();
uint64_t t;
int i;
@@ -897,17 +898,10 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
(1ULL << ARM_FEATURE_PMU) |
(1ULL << ARM_FEATURE_GENERIC_TIMER);
- /* We set up a small vcpu to extract host registers */
-
- if (hv_vcpu_create(&fd, &exit, NULL) != HV_SUCCESS) {
- return false;
- }
-
for (i = 0; i < ARRAY_SIZE(regs); i++) {
- r |= hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val);
+ r |= hv_vcpu_config_get_feature_reg(config, regs[i].reg, regs[i].val);
}
- r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr);
- r |= hv_vcpu_destroy(fd);
+ os_release(config);
/*
* Hardcode MIDR because Apple deliberately doesn't expose a divergent
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:46 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out Philippe Mathieu-Daudé
` (7 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Factor hvf_handle_exception() out of hvf_vcpu_exec().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 120 +++++++++++++++++++++++--------------------
1 file changed, 64 insertions(+), 56 deletions(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index fd209d23c1e..3db0a8e288c 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1928,61 +1928,16 @@ static void hvf_sync_vtimer(CPUState *cpu)
}
}
-int hvf_arch_vcpu_exec(CPUState *cpu)
+/* Must be called by the owning thread */
+static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
CPUARMState *env = &arm_cpu->env;
- int ret;
- hv_vcpu_exit_t *hvf_exit = cpu->accel->exit;
- hv_return_t r;
- bool advance_pc = false;
-
- if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
- hvf_inject_interrupts(cpu)) {
- return EXCP_INTERRUPT;
- }
-
- if (cpu->halted) {
- return EXCP_HLT;
- }
-
- flush_cpu_state(cpu);
-
- bql_unlock();
- r = hv_vcpu_run(cpu->accel->fd);
- bql_lock();
- switch (r) {
- case HV_SUCCESS:
- break;
- case HV_ILLEGAL_GUEST_STATE:
- trace_hvf_illegal_guest_state();
- /* fall through */
- default:
- g_assert_not_reached();
- }
-
- /* handle VMEXIT */
- uint64_t exit_reason = hvf_exit->reason;
- uint64_t syndrome = hvf_exit->exception.syndrome;
+ uint64_t syndrome = excp->syndrome;
uint32_t ec = syn_get_ec(syndrome);
-
- ret = 0;
- switch (exit_reason) {
- case HV_EXIT_REASON_EXCEPTION:
- /* This is the main one, handle below. */
- break;
- case HV_EXIT_REASON_VTIMER_ACTIVATED:
- qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1);
- cpu->accel->vtimer_masked = true;
- return 0;
- case HV_EXIT_REASON_CANCELED:
- /* we got kicked, no exit to process */
- return 0;
- default:
- g_assert_not_reached();
- }
-
- hvf_sync_vtimer(cpu);
+ bool advance_pc = false;
+ hv_return_t r;
+ int ret = 0;
switch (ec) {
case EC_SOFTWARESTEP: {
@@ -2021,7 +1976,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
cpu_synchronize_state(cpu);
CPUWatchpoint *wp =
- find_hw_watchpoint(cpu, hvf_exit->exception.virtual_address);
+ find_hw_watchpoint(cpu, excp->virtual_address);
if (!wp) {
error_report("EXCP_DEBUG but unknown hw watchpoint");
}
@@ -2039,8 +1994,8 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
uint32_t cm = (syndrome >> 8) & 0x1;
uint64_t val = 0;
- trace_hvf_data_abort(hvf_exit->exception.virtual_address,
- hvf_exit->exception.physical_address, isv,
+ trace_hvf_data_abort(excp->virtual_address,
+ excp->physical_address, isv,
iswrite, s1ptw, len, srt);
if (cm) {
@@ -2054,11 +2009,11 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
if (iswrite) {
val = hvf_get_reg(cpu, srt);
address_space_write(&address_space_memory,
- hvf_exit->exception.physical_address,
+ excp->physical_address,
MEMTXATTRS_UNSPECIFIED, &val, len);
} else {
address_space_read(&address_space_memory,
- hvf_exit->exception.physical_address,
+ excp->physical_address,
MEMTXATTRS_UNSPECIFIED, &val, len);
if (sse) {
val = sextract64(val, 0, len * 8);
@@ -2156,6 +2111,59 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
return ret;
}
+int hvf_arch_vcpu_exec(CPUState *cpu)
+{
+ ARMCPU *arm_cpu = ARM_CPU(cpu);
+ hv_vcpu_exit_t *hvf_exit = cpu->accel->exit;
+ hv_return_t r;
+
+ if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
+ hvf_inject_interrupts(cpu)) {
+ return EXCP_INTERRUPT;
+ }
+
+ if (cpu->halted) {
+ return EXCP_HLT;
+ }
+
+ flush_cpu_state(cpu);
+
+ bql_unlock();
+ r = hv_vcpu_run(cpu->accel->fd);
+ bql_lock();
+ switch (r) {
+ case HV_SUCCESS:
+ break;
+ case HV_ILLEGAL_GUEST_STATE:
+ trace_hvf_illegal_guest_state();
+ /* fall through */
+ default:
+ g_assert_not_reached();
+ }
+
+ /* handle VMEXIT */
+ uint64_t exit_reason = hvf_exit->reason;
+
+ switch (exit_reason) {
+ case HV_EXIT_REASON_EXCEPTION:
+ /* This is the main one, handle below. */
+ break;
+ case HV_EXIT_REASON_VTIMER_ACTIVATED:
+ qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1);
+ cpu->accel->vtimer_masked = true;
+ return 0;
+ case HV_EXIT_REASON_CANCELED:
+ /* we got kicked, no exit to process */
+ return 0;
+ default:
+ g_assert_not_reached();
+ }
+
+ hvf_sync_vtimer(cpu);
+
+ return hvf_handle_exception(cpu, &hvf_exit->exception);
+}
+
static const VMStateDescription vmstate_hvf_vtimer = {
.name = "hvf-vtimer",
.version_id = 1,
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:47 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop Philippe Mathieu-Daudé
` (6 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Factor hvf_handle_vmexit() out of hvf_vcpu_exec().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 51 ++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 3db0a8e288c..0cfe3066c23 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2111,10 +2111,34 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)
return ret;
}
-int hvf_arch_vcpu_exec(CPUState *cpu)
+/* Must be called by the owning thread */
+static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
- hv_vcpu_exit_t *hvf_exit = cpu->accel->exit;
+ int ret = 0;
+
+ switch (exit->reason) {
+ case HV_EXIT_REASON_EXCEPTION:
+ hvf_sync_vtimer(cpu);
+ ret = hvf_handle_exception(cpu, &exit->exception);
+ break;
+ case HV_EXIT_REASON_VTIMER_ACTIVATED:
+ qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1);
+ cpu->accel->vtimer_masked = true;
+ break;
+ case HV_EXIT_REASON_CANCELED:
+ /* we got kicked, no exit to process */
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ return ret;
+}
+
+int hvf_arch_vcpu_exec(CPUState *cpu)
+{
+ int ret;
hv_return_t r;
if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
@@ -2133,6 +2157,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
bql_lock();
switch (r) {
case HV_SUCCESS:
+ ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
break;
case HV_ILLEGAL_GUEST_STATE:
trace_hvf_illegal_guest_state();
@@ -2141,27 +2166,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
g_assert_not_reached();
}
- /* handle VMEXIT */
- uint64_t exit_reason = hvf_exit->reason;
-
- switch (exit_reason) {
- case HV_EXIT_REASON_EXCEPTION:
- /* This is the main one, handle below. */
- break;
- case HV_EXIT_REASON_VTIMER_ACTIVATED:
- qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1);
- cpu->accel->vtimer_masked = true;
- return 0;
- case HV_EXIT_REASON_CANCELED:
- /* we got kicked, no exit to process */
- return 0;
- default:
- g_assert_not_reached();
- }
-
- hvf_sync_vtimer(cpu);
-
- return hvf_handle_exception(cpu, &hvf_exit->exception);
+ return ret;
}
static const VMStateDescription vmstate_hvf_vtimer = {
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:47 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls Philippe Mathieu-Daudé
` (5 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 0cfe3066c23..b60efdc1769 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2141,30 +2141,32 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
int ret;
hv_return_t r;
- if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
- hvf_inject_interrupts(cpu)) {
- return EXCP_INTERRUPT;
- }
-
if (cpu->halted) {
return EXCP_HLT;
}
- flush_cpu_state(cpu);
+ do {
+ if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
+ hvf_inject_interrupts(cpu)) {
+ return EXCP_INTERRUPT;
+ }
- bql_unlock();
- r = hv_vcpu_run(cpu->accel->fd);
- bql_lock();
- switch (r) {
- case HV_SUCCESS:
- ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
- break;
- case HV_ILLEGAL_GUEST_STATE:
- trace_hvf_illegal_guest_state();
- /* fall through */
- default:
- g_assert_not_reached();
- }
+ flush_cpu_state(cpu);
+
+ bql_unlock();
+ r = hv_vcpu_run(cpu->accel->fd);
+ bql_lock();
+ switch (r) {
+ case HV_SUCCESS:
+ ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
+ break;
+ case HV_ILLEGAL_GUEST_STATE:
+ trace_hvf_illegal_guest_state();
+ /* fall through */
+ default:
+ g_assert_not_reached();
+ }
+ } while (ret == 0);
return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:39 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls Philippe Mathieu-Daudé
` (4 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
cpu-common.c | 3 +++
trace-events | 2 ++
2 files changed, 5 insertions(+)
diff --git a/cpu-common.c b/cpu-common.c
index 152661df8e9..614391fb9bc 100644
--- a/cpu-common.c
+++ b/cpu-common.c
@@ -249,6 +249,8 @@ void end_exclusive(void)
/* Wait for exclusive ops to finish, and begin cpu execution. */
void cpu_exec_start(CPUState *cpu)
{
+ trace_cpu_exec_start(cpu->cpu_index);
+
qatomic_set(&cpu->running, true);
/* Write cpu->running before reading pending_cpus. */
@@ -319,6 +321,7 @@ void cpu_exec_end(CPUState *cpu)
}
}
}
+ trace_cpu_exec_end(cpu->cpu_index);
}
void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func,
diff --git a/trace-events b/trace-events
index 3ec8a6c7202..faeba6242fa 100644
--- a/trace-events
+++ b/trace-events
@@ -29,6 +29,8 @@
breakpoint_insert(int cpu_index, uint64_t pc, int flags) "cpu=%d pc=0x%" PRIx64 " flags=0x%x"
breakpoint_remove(int cpu_index, uint64_t pc, int flags) "cpu=%d pc=0x%" PRIx64 " flags=0x%x"
breakpoint_singlestep(int cpu_index, int enabled) "cpu=%d enable=%d"
+cpu_exec_start(int cpu_index) "cpu=%d"
+cpu_exec_end(int cpu_index) "cpu=%d"
# job.c
job_state_transition(void *job, int ret, const char *legal, const char *s0, const char *s1) "job %p (ret: %d) attempting %s transition (%s-->%s)"
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 14:30 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn() Philippe Mathieu-Daudé
` (3 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 2 ++
target/i386/hvf/hvf.c | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index b60efdc1769..40ec930d244 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2154,7 +2154,9 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
flush_cpu_state(cpu);
bql_unlock();
+ cpu_exec_start(cpu);
r = hv_vcpu_run(cpu->accel->fd);
+ cpu_exec_end(cpu);
bql_lock();
switch (r) {
case HV_SUCCESS:
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 73c50175048..cb4af70e91d 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -749,9 +749,13 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
return EXCP_HLT;
}
+ cpu_exec_start(cpu);
+
hv_return_t r = hv_vcpu_run_until(cpu->accel->fd, HV_DEADLINE_FOREVER);
assert_hvf_ok(r);
+ cpu_exec_end(cpu);
+
/* handle VMEXIT */
uint64_t exit_reason = rvmcs(cpu->accel->fd, VMCS_EXIT_REASON);
uint64_t exit_qual = rvmcs(cpu->accel->fd, VMCS_EXIT_QUALIFICATION);
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn()
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:40 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState Philippe Mathieu-Daudé
` (2 subsequent siblings)
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/cpu64.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 26cf7e6dfa2..f81cfd0113c 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -762,20 +762,20 @@ static void aarch64_a53_initfn(Object *obj)
static void aarch64_host_initfn(Object *obj)
{
-#if defined(CONFIG_KVM)
ARMCPU *cpu = ARM_CPU(obj);
+#if defined(CONFIG_KVM)
kvm_arm_set_cpu_features_from_host(cpu);
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
aarch64_add_sve_properties(obj);
- aarch64_add_pauth_properties(obj);
}
#elif defined(CONFIG_HVF)
- ARMCPU *cpu = ARM_CPU(obj);
hvf_arm_set_cpu_features_from_host(cpu);
- aarch64_add_pauth_properties(obj);
#else
g_assert_not_reached();
#endif
+ if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+ aarch64_add_pauth_properties(obj);
+ }
}
static void aarch64_max_initfn(Object *obj)
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn() Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 12:41 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 23/24] target/arm: Rename init_cpreg_list() -> arm_init_cpreg_list() Philippe Mathieu-Daudé
2025-09-03 10:07 ` [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper Philippe Mathieu-Daudé
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Do not expose ARM specific fields to X86 implementation,
allowing to use the proper 'hv_vcpu_exit_t' type.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/hvf_int.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index 195d64dcf18..3d2be4092ef 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -59,10 +59,12 @@ extern HVFState *hvf_state;
struct AccelCPUState {
hvf_vcpuid fd;
- void *exit;
+#ifdef __aarch64__
+ hv_vcpu_exit_t *exit;
bool vtimer_masked;
sigset_t unblock_ipi_mask;
bool guest_debug_enabled;
+#endif
};
void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 23/24] target/arm: Rename init_cpreg_list() -> arm_init_cpreg_list()
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState Philippe Mathieu-Daudé
@ 2025-09-03 10:06 ` Philippe Mathieu-Daudé
2025-09-03 10:07 ` [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper Philippe Mathieu-Daudé
23 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:06 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
Prefix init_cpreg_list() with 'arm_'.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/internals.h | 2 +-
target/arm/cpu.c | 2 +-
target/arm/helper.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/arm/internals.h b/target/arm/internals.h
index f0aa26c5117..400b4d670f6 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -374,7 +374,7 @@ static inline int r14_bank_number(int mode)
void arm_cpu_register(const ARMCPUInfo *info);
void register_cp_regs_for_features(ARMCPU *cpu);
-void init_cpreg_list(ARMCPU *cpu);
+void arm_init_cpreg_list(ARMCPU *cpu);
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
void arm_translate_init(void);
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 633ec55a57c..1789890dea3 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2141,7 +2141,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
arm_cpu_register_gdb_regs_for_features(cpu);
arm_cpu_register_gdb_commands(cpu);
- init_cpreg_list(cpu);
+ arm_init_cpreg_list(cpu);
#ifndef CONFIG_USER_ONLY
MachineState *ms = MACHINE(qdev_get_machine());
diff --git a/target/arm/helper.c b/target/arm/helper.c
index fb62742d983..0db3e05571f 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -237,7 +237,7 @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b, gpointer d)
return 0;
}
-void init_cpreg_list(ARMCPU *cpu)
+void arm_init_cpreg_list(ARMCPU *cpu)
{
/*
* Initialise the cpreg_tuples[] array based on the cp_regs hash.
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2025-09-03 10:06 ` [PATCH 23/24] target/arm: Rename init_cpreg_list() -> arm_init_cpreg_list() Philippe Mathieu-Daudé
@ 2025-09-03 10:07 ` Philippe Mathieu-Daudé
2025-09-03 10:12 ` Philippe Mathieu-Daudé
23 siblings, 1 reply; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:07 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Alexander Graf, Richard Henderson,
qemu-arm, Mohamed Mediouni, Peter Maydell, Mads Ynddal,
Phil Dennis-Jordan, Stefan Hajnoczi, Cameron Esfahani,
Roman Bolshakov, Paolo Bonzini
arm_destroy_cpreg_list() releases ressources allocated by
arm_init_cpreg_list().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/internals.h | 2 ++
target/arm/helper.c | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/target/arm/internals.h b/target/arm/internals.h
index 400b4d670f6..5af9b1110e8 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -375,6 +375,8 @@ void arm_cpu_register(const ARMCPUInfo *info);
void register_cp_regs_for_features(ARMCPU *cpu);
void arm_init_cpreg_list(ARMCPU *cpu);
+/* Release ressources allocated by arm_init_cpreg_list() */
+void arm_destroy_cpreg_list(ARMCPU *cpu);
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
void arm_translate_init(void);
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 0db3e05571f..9b7a2b94bd3 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -268,6 +268,14 @@ void arm_init_cpreg_list(ARMCPU *cpu)
g_list_free(keys);
}
+void arm_destroy_cpreg_list(ARMCPU *cpu)
+{
+ g_free(cpu->cpreg_indexes);
+ g_free(cpu->cpreg_values);
+ g_free(cpu->cpreg_vmstate_indexes);
+ g_free(cpu->cpreg_vmstate_values);
+}
+
bool arm_pan_enabled(CPUARMState *env)
{
if (is_a64(env)) {
--
2.51.0
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Re: [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper
2025-09-03 10:07 ` [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper Philippe Mathieu-Daudé
@ 2025-09-03 10:12 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Alexander Graf, Richard Henderson, qemu-arm, Mohamed Mediouni,
Peter Maydell, Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 3/9/25 12:07, Philippe Mathieu-Daudé wrote:
> arm_destroy_cpreg_list() releases ressources allocated by
> arm_init_cpreg_list().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/internals.h | 2 ++
> target/arm/helper.c | 8 ++++++++
> 2 files changed, 10 insertions(+)
> +void arm_destroy_cpreg_list(ARMCPU *cpu)
> +{
> + g_free(cpu->cpreg_indexes);
> + g_free(cpu->cpreg_values);
> + g_free(cpu->cpreg_vmstate_indexes);
> + g_free(cpu->cpreg_vmstate_values);
> +}
Please ignore this patch, it is part of another series related
to arm DeviceUnrealize() implementation.
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU
2025-09-03 10:06 ` [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU Philippe Mathieu-Daudé
@ 2025-09-03 10:13 ` Philippe Mathieu-Daudé
2025-09-03 12:03 ` Richard Henderson
1 sibling, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:13 UTC (permalink / raw)
To: qemu-devel
Cc: Alexander Graf, Richard Henderson, qemu-arm, Mohamed Mediouni,
Peter Maydell, Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 3/9/25 12:06, Philippe Mathieu-Daudé wrote:
> From: Mohamed Mediouni <mohamed@unpredictable.fr>
>
> Creating a vCPU locks out APIs such as hv_gic_create().
>
> As a result, switch to using the hv_vcpu_config_get_feature_reg interface.
>
> Besides, all the following methods must be run on a vCPU thread:
>
> - hv_vcpu_create()
> - hv_vcpu_get_sys_reg()
> - hv_vcpu_destroy()
>
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Message-ID: <20250808070137.48716-3-mohamed@unpredictable.fr>
> [PMD: Release config calling os_release()]
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 36 +++++++++++++++---------------------
> 1 file changed, 15 insertions(+), 21 deletions(-)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 3039c0987dc..fd209d23c1e 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -869,24 +869,25 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
> {
> ARMISARegisters host_isar = {};
> const struct isar_regs {
> - int reg;
> + hv_feature_reg_t reg;
> uint64_t *val;
> } regs[] = {
> - { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64ISAR1_EL1, &host_isar.idregs[ID_AA64ISAR1_EL1_IDX] },
> /* Add ID_AA64ISAR2_EL1 here when HVF supports it */
> - { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.idregs[ID_AA64MMFR0_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.idregs[ID_AA64MMFR1_EL1_IDX] },
> - { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.idregs[ID_AA64MMFR2_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64MMFR0_EL1, &host_isar.idregs[ID_AA64MMFR0_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64MMFR1_EL1, &host_isar.idregs[ID_AA64MMFR1_EL1_IDX] },
> + { HV_FEATURE_REG_ID_AA64MMFR2_EL1, &host_isar.idregs[ID_AA64MMFR2_EL1_IDX] },
> /* Add ID_AA64MMFR3_EL1 here when HVF supports it */
> + { HV_FEATURE_REG_CTR_EL0, &host_isar.idregs[CTR_EL0_IDX] },
> + { HV_FEATURE_REG_CLIDR_EL1, &host_isar.idregs[CLIDR_EL1_IDX] },
I'd rather add the 2 last ones in a distinct patch, keeping
this one as a simple API conversion.
> };
> - hv_vcpu_t fd;
> hv_return_t r = HV_SUCCESS;
> - hv_vcpu_exit_t *exit;
> + hv_vcpu_config_t config = hv_vcpu_config_create();
> uint64_t t;
> int i;
>
> @@ -897,17 +898,10 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
> (1ULL << ARM_FEATURE_PMU) |
> (1ULL << ARM_FEATURE_GENERIC_TIMER);
>
> - /* We set up a small vcpu to extract host registers */
> -
> - if (hv_vcpu_create(&fd, &exit, NULL) != HV_SUCCESS) {
> - return false;
> - }
> -
> for (i = 0; i < ARRAY_SIZE(regs); i++) {
> - r |= hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val);
> + r |= hv_vcpu_config_get_feature_reg(config, regs[i].reg, regs[i].val);
> }
> - r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr);
> - r |= hv_vcpu_destroy(fd);
> + os_release(config);
>
> /*
> * Hardcode MIDR because Apple deliberately doesn't expose a divergent
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU
2025-09-03 10:06 ` [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU Philippe Mathieu-Daudé
2025-09-03 10:13 ` Philippe Mathieu-Daudé
@ 2025-09-03 12:03 ` Richard Henderson
2025-09-03 12:20 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 3039c0987dc..fd209d23c1e 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -869,24 +869,25 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
> {
> ARMISARegisters host_isar = {};
> const struct isar_regs {
> - int reg;
> + hv_feature_reg_t reg;
> uint64_t *val;
> } regs[] = {
> - { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
Versus the original, I suggested that this should be
{ HV_SYS_REG_ID_AA64PFR0_EL1, ID_AA64PFR0_EL1_IDX },
etc, so that the data structure could be static const.
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU
2025-09-03 12:03 ` Richard Henderson
@ 2025-09-03 12:20 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 12:20 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 3/9/25 14:03, Richard Henderson wrote:
> On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
>> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
>> index 3039c0987dc..fd209d23c1e 100644
>> --- a/target/arm/hvf/hvf.c
>> +++ b/target/arm/hvf/hvf.c
>> @@ -869,24 +869,25 @@ static bool
>> hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
>> {
>> ARMISARegisters host_isar = {};
>> const struct isar_regs {
>> - int reg;
>> + hv_feature_reg_t reg;
>> uint64_t *val;
>> } regs[] = {
>> - { HV_SYS_REG_ID_AA64PFR0_EL1,
>> &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
>
> Versus the original, I suggested that this should be
>
> { HV_SYS_REG_ID_AA64PFR0_EL1, ID_AA64PFR0_EL1_IDX },
>
> etc, so that the data structure could be static const.
Sorry I missed the comment. Good idea!
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create()
2025-09-03 10:06 ` [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create() Philippe Mathieu-Daudé
@ 2025-09-03 12:22 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hv_vcpu_config_create() is documented in <Hypervisor/hv_vcpu_config.h>
> as:
>
> /*!
> @abstract Creates a vcpu configuration object.
> @result A new vcpu configuration object. This should be released with os_release when no longer used.
> */
> OS_OBJECT_RETURNS_RETAINED OS_WARN_RESULT
> hv_vcpu_config_t hv_vcpu_config_create(void);
>
> Release the memory allocated by hv_vcpu_config_create() with
> os_release().
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 2 ++
> 1 file changed, 2 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value
2025-09-03 10:06 ` [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value Philippe Mathieu-Daudé
@ 2025-09-03 12:23 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini,
Alex Bennée
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hv_vcpus_exit() returns a hv_return_t enum type (defined
> in <Hypervisor/hv_error.h>). Assert we succeeded, as we
> are not ready to handle any error path.
>
> Suggested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 5 ++++-
> target/arm/hvf/trace-events | 1 +
> 2 files changed, 5 insertions(+), 1 deletion(-)
Tracing change not mentioned in commit message.
Split to a separate patch?
r~
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index d67372218de..65ac0bd71aa 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1086,8 +1086,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
>
> void hvf_kick_vcpu_thread(CPUState *cpu)
> {
> + hv_return_t ret;
> + trace_hvf_kick_vcpu_thread(cpu->cpu_index, cpu->stop);
> cpus_kick_thread(cpu);
> - hv_vcpus_exit(&cpu->accel->fd, 1);
> + ret = hv_vcpus_exit(&cpu->accel->fd, 1);
> + assert_hvf_ok(ret);
> }
>
> static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
> diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events
> index b29a995f3d3..538af6e0707 100644
> --- a/target/arm/hvf/trace-events
> +++ b/target/arm/hvf/trace-events
> @@ -12,3 +12,4 @@ hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid
> hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]"
> hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
> hvf_illegal_guest_state(void) "HV_ILLEGAL_GUEST_STATE"
> +hvf_kick_vcpu_thread(unsigned cpuidx, bool stop) "cpu:%u stop:%u"
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() returned value
2025-09-03 10:06 ` [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() " Philippe Mathieu-Daudé
@ 2025-09-03 12:30 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hv_vcpu_set_vtimer_mask() returns a hv_return_t enum type
> (defined in <Hypervisor/hv_error.h>). Assert we succeeded,
> as we are not ready to handle any error path.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 65ac0bd71aa..1b59cc0eb04 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1906,7 +1906,8 @@ static void hvf_sync_vtimer(CPUState *cpu)
>
> if (!irq_state) {
> /* Timer no longer asserting, we can unmask it */
> - hv_vcpu_set_vtimer_mask(cpu->accel->fd, false);
> + r = hv_vcpu_set_vtimer_mask(cpu->accel->fd, false);
> + assert_hvf_ok(r);
> cpu->accel->vtimer_masked = false;
> }
> }
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers
2025-09-03 10:06 ` [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers Philippe Mathieu-Daudé
@ 2025-09-03 12:31 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hvf_put_registers() and hvf_get_registers() are implemented per
> target, rename them using the 'hvf_arch_' prefix following the
> per target pattern.
>
> Since they call hv_vcpu_set_reg() / hv_vcpu_get_reg(), mention
> they must be called on the vCPU.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/system/hvf_int.h | 6 ++++--
> accel/hvf/hvf-accel-ops.c | 2 +-
> target/arm/hvf/hvf.c | 8 +++++---
> target/i386/hvf/hvf.c | 2 +-
> target/i386/hvf/x86hvf.c | 4 ++--
> 5 files changed, 13 insertions(+), 9 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread
2025-09-03 10:06 ` [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread Philippe Mathieu-Daudé
@ 2025-09-03 12:31 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Since flush_cpu_state() calls hvf_arch_put_registers(),
> which must run on a vCPU, it also must. Mention it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 21002f419f5..58934953c4a 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -814,6 +814,7 @@ int hvf_arch_put_registers(CPUState *cpu)
> return 0;
> }
>
> +/* Must be called by the owning thread */
> static void flush_cpu_state(CPUState *cpu)
> {
> if (cpu->vcpu_dirty) {
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() must run on vCPU thread
2025-09-03 10:06 ` [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() " Philippe Mathieu-Daudé
@ 2025-09-03 12:33 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hvf_arch_init_vcpu(), along with hvf_put_guest_debug_registers()
> and hvf_put_gdbstub_debug_registers(), calls hv_vcpu_set_sys_reg(),
> which must run on a vCPU. Mention they also must.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/hvf_int.h | 3 ++-
> target/arm/hvf/hvf.c | 2 ++
> 2 files changed, 4 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() must run on vCPU thread
2025-09-03 10:06 ` [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() " Philippe Mathieu-Daudé
@ 2025-09-03 12:34 ` Richard Henderson
2025-09-03 17:05 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Since hvf_wfi() calls hv_vcpu_get_sys_reg(), which
> must run on a vCPU, it also must. Mention it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index d87a41bcc53..05fc591b523 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1836,6 +1836,7 @@ static void hvf_wait_for_ipi(CPUState *cpu, struct timespec *ts)
> bql_lock();
> }
>
> +/* Must be called by the owning thread */
> static void hvf_wfi(CPUState *cpu)
> {
> ARMCPU *arm_cpu = ARM_CPU(cpu);
How can it not? Are all these separate patches and annotations helpful?
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy()
2025-09-03 10:06 ` [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy() Philippe Mathieu-Daudé
@ 2025-09-03 12:35 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Call hv_vcpu_destroy() to destroy our vCPU context.
>
> As hv_vcpu_destroy() must be called by the owning thread,
> document hvf_arch_vcpu_destroy() also does.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/hvf_int.h | 3 ++-
> target/arm/hvf/hvf.c | 4 ++++
> 2 files changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls
2025-09-03 10:06 ` [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls Philippe Mathieu-Daudé
@ 2025-09-03 12:39 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> cpu-common.c | 3 +++
> trace-events | 2 ++
> 2 files changed, 5 insertions(+)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn()
2025-09-03 10:06 ` [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn() Philippe Mathieu-Daudé
@ 2025-09-03 12:40 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/cpu64.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 26cf7e6dfa2..f81cfd0113c 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -762,20 +762,20 @@ static void aarch64_a53_initfn(Object *obj)
>
> static void aarch64_host_initfn(Object *obj)
> {
> -#if defined(CONFIG_KVM)
> ARMCPU *cpu = ARM_CPU(obj);
> +#if defined(CONFIG_KVM)
> kvm_arm_set_cpu_features_from_host(cpu);
> if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> aarch64_add_sve_properties(obj);
> - aarch64_add_pauth_properties(obj);
> }
> #elif defined(CONFIG_HVF)
> - ARMCPU *cpu = ARM_CPU(obj);
> hvf_arm_set_cpu_features_from_host(cpu);
> - aarch64_add_pauth_properties(obj);
> #else
> g_assert_not_reached();
> #endif
> + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> + aarch64_add_pauth_properties(obj);
> + }
> }
>
> static void aarch64_max_initfn(Object *obj)
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState
2025-09-03 10:06 ` [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState Philippe Mathieu-Daudé
@ 2025-09-03 12:41 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Do not expose ARM specific fields to X86 implementation,
> allowing to use the proper 'hv_vcpu_exit_t' type.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/hvf_int.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
> index 195d64dcf18..3d2be4092ef 100644
> --- a/include/system/hvf_int.h
> +++ b/include/system/hvf_int.h
> @@ -59,10 +59,12 @@ extern HVFState *hvf_state;
>
> struct AccelCPUState {
> hvf_vcpuid fd;
> - void *exit;
> +#ifdef __aarch64__
> + hv_vcpu_exit_t *exit;
> bool vtimer_masked;
> sigset_t unblock_ipi_mask;
> bool guest_debug_enabled;
> +#endif
> };
>
> void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out
2025-09-03 10:06 ` [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out Philippe Mathieu-Daudé
@ 2025-09-03 12:46 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> +/* Must be called by the owning thread */
How could it not?
> +static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)
> {
> ARMCPU *arm_cpu = ARM_CPU(cpu);
...
> +int hvf_arch_vcpu_exec(CPUState *cpu)
> +{
> + ARMCPU *arm_cpu = ARM_CPU(cpu);
Don't dynamic cast twice.
Pass down the ARMCPU, or use env_archcpu(cpu_env(cpu)).
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out
2025-09-03 10:06 ` [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out Philippe Mathieu-Daudé
@ 2025-09-03 12:47 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> +/* Must be called by the owning thread */
> +static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit)
> {
> ARMCPU *arm_cpu = ARM_CPU(cpu);
Likewise don't double-cast.
Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop
2025-09-03 10:06 ` [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop Philippe Mathieu-Daudé
@ 2025-09-03 12:47 ` Richard Henderson
0 siblings, 0 replies; 45+ messages in thread
From: Richard Henderson @ 2025-09-03 12:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 40 +++++++++++++++++++++-------------------
> 1 file changed, 21 insertions(+), 19 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 0cfe3066c23..b60efdc1769 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -2141,30 +2141,32 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
> int ret;
> hv_return_t r;
>
> - if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
> - hvf_inject_interrupts(cpu)) {
> - return EXCP_INTERRUPT;
> - }
> -
> if (cpu->halted) {
> return EXCP_HLT;
> }
>
> - flush_cpu_state(cpu);
> + do {
> + if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
> + hvf_inject_interrupts(cpu)) {
> + return EXCP_INTERRUPT;
> + }
>
> - bql_unlock();
> - r = hv_vcpu_run(cpu->accel->fd);
> - bql_lock();
> - switch (r) {
> - case HV_SUCCESS:
> - ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
> - break;
> - case HV_ILLEGAL_GUEST_STATE:
> - trace_hvf_illegal_guest_state();
> - /* fall through */
> - default:
> - g_assert_not_reached();
> - }
> + flush_cpu_state(cpu);
> +
> + bql_unlock();
> + r = hv_vcpu_run(cpu->accel->fd);
> + bql_lock();
> + switch (r) {
> + case HV_SUCCESS:
> + ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
> + break;
> + case HV_ILLEGAL_GUEST_STATE:
> + trace_hvf_illegal_guest_state();
> + /* fall through */
> + default:
> + g_assert_not_reached();
> + }
> + } while (ret == 0);
>
> return ret;
> }
r~
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls
2025-09-03 10:06 ` [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls Philippe Mathieu-Daudé
@ 2025-09-03 14:30 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 14:30 UTC (permalink / raw)
To: qemu-devel
Cc: Alexander Graf, Richard Henderson, qemu-arm, Mohamed Mediouni,
Peter Maydell, Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
Missing description:
Similarly to 1d78a3c3ab8 for KVM, wrap hv_vcpu_run() with
cpu_exec_start/end(), so that the accelerator can perform
pending operations while all vCPUs are quiescent. See also
explanation in commit c265e976f46 ("cpus-common: lock-free
fast path for cpu_exec_start/end").
On 3/9/25 12:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/hvf/hvf.c | 2 ++
> target/i386/hvf/hvf.c | 4 ++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index b60efdc1769..40ec930d244 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -2154,7 +2154,9 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
> flush_cpu_state(cpu);
>
> bql_unlock();
> + cpu_exec_start(cpu);
> r = hv_vcpu_run(cpu->accel->fd);
> + cpu_exec_end(cpu);
> bql_lock();
> switch (r) {
> case HV_SUCCESS:
> diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
> index 73c50175048..cb4af70e91d 100644
> --- a/target/i386/hvf/hvf.c
> +++ b/target/i386/hvf/hvf.c
> @@ -749,9 +749,13 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
> return EXCP_HLT;
> }
>
> + cpu_exec_start(cpu);
> +
> hv_return_t r = hv_vcpu_run_until(cpu->accel->fd, HV_DEADLINE_FOREVER);
> assert_hvf_ok(r);
>
> + cpu_exec_end(cpu);
> +
> /* handle VMEXIT */
> uint64_t exit_reason = rvmcs(cpu->accel->fd, VMCS_EXIT_REASON);
> uint64_t exit_qual = rvmcs(cpu->accel->fd, VMCS_EXIT_QUALIFICATION);
^ permalink raw reply [flat|nested] 45+ messages in thread
* Re: [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() must run on vCPU thread
2025-09-03 12:34 ` Richard Henderson
@ 2025-09-03 17:05 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 45+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 17:05 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Alexander Graf, qemu-arm, Mohamed Mediouni, Peter Maydell,
Mads Ynddal, Phil Dennis-Jordan, Stefan Hajnoczi,
Cameron Esfahani, Roman Bolshakov, Paolo Bonzini
On 3/9/25 14:34, Richard Henderson wrote:
> On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
>> Since hvf_wfi() calls hv_vcpu_get_sys_reg(), which
>> must run on a vCPU, it also must. Mention it.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> target/arm/hvf/hvf.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
>> index d87a41bcc53..05fc591b523 100644
>> --- a/target/arm/hvf/hvf.c
>> +++ b/target/arm/hvf/hvf.c
>> @@ -1836,6 +1836,7 @@ static void hvf_wait_for_ipi(CPUState *cpu,
>> struct timespec *ts)
>> bql_lock();
>> }
>> +/* Must be called by the owning thread */
>> static void hvf_wfi(CPUState *cpu)
>> {
>> ARMCPU *arm_cpu = ARM_CPU(cpu);
>
> How can it not? Are all these separate patches and annotations helpful?
Well they helped me understand the locking issue in patch 15 in
hvf_arm_get_host_cpu_features().
^ permalink raw reply [flat|nested] 45+ messages in thread
end of thread, other threads:[~2025-09-03 17:05 UTC | newest]
Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 10:06 [PATCH 00/24] target/arm/hvf: Consolidate Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 01/24] target/arm/hvf: Release memory allocated by hv_vcpu_config_create() Philippe Mathieu-Daudé
2025-09-03 12:22 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value Philippe Mathieu-Daudé
2025-09-03 12:23 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 03/24] target/arm/hvf: Check hv_vcpu_set_vtimer_mask() " Philippe Mathieu-Daudé
2025-09-03 12:30 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 04/24] accel/hvf: Rename hvf_vcpu_exec() -> hvf_arch_vcpu_exec() Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 05/24] accel/hvf: Rename hvf_put|get_registers -> hvf_arch_put|get_registers Philippe Mathieu-Daudé
2025-09-03 12:31 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 06/24] target/arm/hvf: Mention flush_cpu_state() must run on vCPU thread Philippe Mathieu-Daudé
2025-09-03 12:31 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 07/24] accel/hvf: Mention hvf_arch_init_vcpu() " Philippe Mathieu-Daudé
2025-09-03 12:33 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 08/24] target/arm/hvf: Mention hvf_wfi() " Philippe Mathieu-Daudé
2025-09-03 12:34 ` Richard Henderson
2025-09-03 17:05 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 09/24] target/arm/hvf: Mention hvf_sync_vtimer() " Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 10/24] target/arm/hvf: Mention hvf_arch_set_traps() " Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 11/24] accel/hvf: Mention hvf_arch_update_guest_debug() must run on vCPU Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 12/24] target/arm/hvf: Mention hvf_inject_interrupts() must run on vCPU thread Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 13/24] accel/hvf: Implement hvf_arch_vcpu_destroy() Philippe Mathieu-Daudé
2025-09-03 12:35 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 14/24] target/arm/hvf: Hardcode Apple MIDR Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 15/24] target/arm/hvf: switch hvf_arm_get_host_cpu_features to not create a vCPU Philippe Mathieu-Daudé
2025-09-03 10:13 ` Philippe Mathieu-Daudé
2025-09-03 12:03 ` Richard Henderson
2025-09-03 12:20 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 16/24] target/arm/hvf: Factor hvf_handle_exception() out Philippe Mathieu-Daudé
2025-09-03 12:46 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 17/24] target/arm/hvf: Factor hvf_handle_vmexit() out Philippe Mathieu-Daudé
2025-09-03 12:47 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop Philippe Mathieu-Daudé
2025-09-03 12:47 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 19/24] cpus: Trace cpu_exec_start() and cpu_exec_end() calls Philippe Mathieu-Daudé
2025-09-03 12:39 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 20/24] accel/hvf: Guard hv_vcpu_run() between cpu_exec_start/end() calls Philippe Mathieu-Daudé
2025-09-03 14:30 ` Philippe Mathieu-Daudé
2025-09-03 10:06 ` [PATCH 21/24] target/arm: Call aarch64_add_pauth_properties() once in host_initfn() Philippe Mathieu-Daudé
2025-09-03 12:40 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 22/24] accel/hvf: Restrict ARM specific fields of AccelCPUState Philippe Mathieu-Daudé
2025-09-03 12:41 ` Richard Henderson
2025-09-03 10:06 ` [PATCH 23/24] target/arm: Rename init_cpreg_list() -> arm_init_cpreg_list() Philippe Mathieu-Daudé
2025-09-03 10:07 ` [PATCH 24/24] target/arm: Add arm_destroy_cpreg_list() helper Philippe Mathieu-Daudé
2025-09-03 10:12 ` Philippe Mathieu-Daudé
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).