From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, kvm@vger.kernel.org,
"Peter Maydell" <peter.maydell@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH] target/arm: Check if debug is already initialized
Date: Wed, 5 Apr 2023 12:03:33 +0200 [thread overview]
Message-ID: <51212bc5-cbb7-4d24-f97f-8ad00dda42f2@linaro.org> (raw)
In-Reply-To: <20230405070244.23464-1-akihiko.odaki@daynix.com>
On 5/4/23 09:02, Akihiko Odaki wrote:
> When virtualizing SMP system, kvm_arm_init_debug() will be called
> multiple times. Check if the debug feature is already initialized when the
> function is called; 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")
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> target/arm/kvm64.c | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
> index 1197253d12..d2fce5e582 100644
> --- a/target/arm/kvm64.c
> +++ b/target/arm/kvm64.c
> @@ -32,7 +32,11 @@
> #include "hw/acpi/ghes.h"
> #include "hw/arm/virt.h"
>
> -static bool have_guest_debug;
> +static enum {
> + GUEST_DEBUG_UNINITED,
> + GUEST_DEBUG_INITED,
> + GUEST_DEBUG_UNAVAILABLE,
> +} guest_debug;
>
> /*
> * Although the ARM implementation of hardware assisted debugging
> @@ -84,8 +88,14 @@ GArray *hw_breakpoints, *hw_watchpoints;
> */
> static void kvm_arm_init_debug(CPUState *cs)
> {
> - have_guest_debug = kvm_check_extension(cs->kvm_state,
> - KVM_CAP_SET_GUEST_DEBUG);
- Maybe we can merge kvm{,64}.c (see commit 82bf7ae84c
"target/arm: Remove KVM support for 32-bit Arm hosts")
- Could kvm_arm_init_debug() belong to kvm_arch_init()?
Then this patch / enum is not required.
- Why we keep a reference to the global kvm_state in CPUState is not
clear to me.
next prev parent reply other threads:[~2023-04-05 10:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 7:02 [PATCH] target/arm: Check if debug is already initialized Akihiko Odaki
2023-04-05 10:03 ` Philippe Mathieu-Daudé [this message]
2023-04-11 14:42 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51212bc5-cbb7-4d24-f97f-8ad00dda42f2@linaro.org \
--to=philmd@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=alex.bennee@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).