[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/21] target/arm: Initialize debug capabilities only once
From: |
Peter Maydell |
Subject: |
[PULL 11/21] target/arm: Initialize debug capabilities only once |
Date: |
Thu, 20 Apr 2023 11:04:46 +0100 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
kvm_arm_init_debug() used to be called several times on a SMP system as
kvm_arch_init_vcpu() calls it. Move the call to kvm_arch_init() to make
sure it will be called only once; otherwise it will overwrite pointers
to memory allocated with the previous call and leak it.
Fixes: e4482ab7e3 ("target-arm: kvm - add support for HW assisted debug")
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-id: 20230405153644.25300-1-akihiko.odaki@daynix.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/kvm_arm.h | 8 ++++++++
target/arm/kvm.c | 2 ++
target/arm/kvm64.c | 18 ++++--------------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index 99017b635ce..330fbe5c722 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -18,6 +18,14 @@
#define KVM_ARM_VGIC_V2 (1 << 0)
#define KVM_ARM_VGIC_V3 (1 << 1)
+/**
+ * kvm_arm_init_debug() - initialize guest debug capabilities
+ * @s: KVMState
+ *
+ * Should be called only once before using guest debug capabilities.
+ */
+void kvm_arm_init_debug(KVMState *s);
+
/**
* kvm_arm_vcpu_init:
* @cs: CPUState
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index f022c644d2f..84da49332c4 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -280,6 +280,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
}
}
+ kvm_arm_init_debug(s);
+
return ret;
}
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 1197253d12f..810db33ccbd 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -74,24 +74,16 @@ GArray *hw_breakpoints, *hw_watchpoints;
#define get_hw_bp(i) (&g_array_index(hw_breakpoints, HWBreakpoint, i))
#define get_hw_wp(i) (&g_array_index(hw_watchpoints, HWWatchpoint, i))
-/**
- * kvm_arm_init_debug() - check for guest debug capabilities
- * @cs: CPUState
- *
- * kvm_check_extension returns the number of debug registers we have
- * or 0 if we have none.
- *
- */
-static void kvm_arm_init_debug(CPUState *cs)
+void kvm_arm_init_debug(KVMState *s)
{
- have_guest_debug = kvm_check_extension(cs->kvm_state,
+ have_guest_debug = kvm_check_extension(s,
KVM_CAP_SET_GUEST_DEBUG);
- max_hw_wps = kvm_check_extension(cs->kvm_state,
KVM_CAP_GUEST_DEBUG_HW_WPS);
+ max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
hw_watchpoints = g_array_sized_new(true, true,
sizeof(HWWatchpoint), max_hw_wps);
- max_hw_bps = kvm_check_extension(cs->kvm_state,
KVM_CAP_GUEST_DEBUG_HW_BPS);
+ max_hw_bps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_BPS);
hw_breakpoints = g_array_sized_new(true, true,
sizeof(HWBreakpoint), max_hw_bps);
return;
@@ -920,8 +912,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
}
cpu->mp_affinity = mpidr & ARM64_AFFINITY_MASK;
- kvm_arm_init_debug(cs);
-
/* Check whether user space can specify guest syndrome value */
kvm_arm_init_serror_injection(cs);
--
2.34.1
- [PULL 04/21] hw/arm: Add WDT to Allwinner-A10 and Cubieboard, (continued)
- [PULL 04/21] hw/arm: Add WDT to Allwinner-A10 and Cubieboard, Peter Maydell, 2023/04/20
- [PULL 06/21] tests/avocado: Add reboot tests to Cubieboard, Peter Maydell, 2023/04/20
- [PULL 09/21] target/arm: Remove KVM AArch32 CPU definitions, Peter Maydell, 2023/04/20
- [PULL 18/21] fsl-imx6ul: Add fec[12]-phy-connected properties, Peter Maydell, 2023/04/20
- [PULL 17/21] hw/net/imx_fec: Support two Ethernet interfaces connected to single MDIO bus, Peter Maydell, 2023/04/20
- [PULL 14/21] target/arm: Implement FEAT_PAN3, Peter Maydell, 2023/04/20
- [PULL 02/21] exynos: Fix out-of-bounds access in exynos4210_gcomp_find debug printf, Peter Maydell, 2023/04/20
- [PULL 07/21] hw/timer/imx_epit: don't shadow variable, Peter Maydell, 2023/04/20
- [PULL 03/21] hw/watchdog: Allwinner WDT emulation for system reset, Peter Maydell, 2023/04/20
- [PULL 08/21] hw/timer/imx_epit: fix limit check, Peter Maydell, 2023/04/20
- [PULL 11/21] target/arm: Initialize debug capabilities only once,
Peter Maydell <=
- [PULL 21/21] arm/mcimx7d-sabre: Set fec2-phy-connected property to false, Peter Maydell, 2023/04/20
- [PULL 10/21] hw/arm/virt: Restrict Cortex-A7 check to TCG, Peter Maydell, 2023/04/20
- [PULL 12/21] target/arm: Pass ARMMMUFaultInfo to merge_syn_data_abort(), Peter Maydell, 2023/04/20
- [PULL 13/21] target/arm: Don't set ISV when reporting stage 1 faults in ESR_EL2, Peter Maydell, 2023/04/20
- [PULL 15/21] docs/devel/kconfig.rst: Fix incorrect markup, Peter Maydell, 2023/04/20
- [PULL 16/21] target/arm: Report pauth information to gdb as 'pauth_v2', Peter Maydell, 2023/04/20
- [PULL 19/21] arm/mcimx6ul-evk: Set fec1-phy-connected property to false, Peter Maydell, 2023/04/20
- [PULL 20/21] fsl-imx7: Add fec[12]-phy-connected properties, Peter Maydell, 2023/04/20
- Re: [PULL 00/21] target-arm queue, Richard Henderson, 2023/04/21