aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Ynddal <m.ynddal@samsung.com>2025-04-02 15:52:28 +0200
committerPeter Maydell <peter.maydell@linaro.org>2025-05-06 15:01:22 +0100
commit90f0078d023fc364c870188075f530f84f652758 (patch)
treed6ffbfce826df8c495c8aff20988a18a15b7f2cb
parent97cdd1b0a7a010702a1d118b74c3af3bb2edb35c (diff)
downloadqemu-90f0078d023fc364c870188075f530f84f652758.zip
qemu-90f0078d023fc364c870188075f530f84f652758.tar.gz
qemu-90f0078d023fc364c870188075f530f84f652758.tar.bz2
hvf: avoid repeatedly setting trap debug for each cpu
hvf_arch_set_traps is already called from a context of a specific CPUState, so we don't need to do a nested CPU_FOREACH. It also results in an error from hv_vcpu_set_sys_reg, as it may only be called from the thread owning the vCPU. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2895 Tested-by: Daniel Gomez <da.gomez@samsung.com> Signed-off-by: Mads Ynddal <m.ynddal@samsung.com> Reported-by: Daniel Gomez <da.gomez@samsung.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20250402135229.28143-2-mads@ynddal.dk Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--target/arm/hvf/hvf.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 34ca36f..42258cc 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2278,28 +2278,23 @@ static inline bool hvf_arm_hw_debug_active(CPUState *cpu)
return ((cur_hw_wps > 0) || (cur_hw_bps > 0));
}
-static void hvf_arch_set_traps(void)
+static void hvf_arch_set_traps(CPUState *cpu)
{
- CPUState *cpu;
bool should_enable_traps = false;
hv_return_t r = HV_SUCCESS;
/* Check whether guest debugging is enabled for at least one vCPU; if it
* is, enable exiting the guest on all vCPUs */
- CPU_FOREACH(cpu) {
- should_enable_traps |= cpu->accel->guest_debug_enabled;
- }
- CPU_FOREACH(cpu) {
- /* Set whether debug exceptions exit the guest */
- r = hv_vcpu_set_trap_debug_exceptions(cpu->accel->fd,
- should_enable_traps);
- assert_hvf_ok(r);
+ should_enable_traps |= cpu->accel->guest_debug_enabled;
+ /* Set whether debug exceptions exit the guest */
+ r = hv_vcpu_set_trap_debug_exceptions(cpu->accel->fd,
+ should_enable_traps);
+ assert_hvf_ok(r);
- /* Set whether accesses to debug registers exit the guest */
- r = hv_vcpu_set_trap_debug_reg_accesses(cpu->accel->fd,
- should_enable_traps);
- assert_hvf_ok(r);
- }
+ /* Set whether accesses to debug registers exit the guest */
+ r = hv_vcpu_set_trap_debug_reg_accesses(cpu->accel->fd,
+ should_enable_traps);
+ assert_hvf_ok(r);
}
void hvf_arch_update_guest_debug(CPUState *cpu)
@@ -2340,7 +2335,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
deposit64(env->cp15.mdscr_el1, MDSCR_EL1_MDE_SHIFT, 1, 0);
}
- hvf_arch_set_traps();
+ hvf_arch_set_traps(cpu);
}
bool hvf_arch_supports_guest_debug(void)