qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Mads Ynddal <mads@ynddal.dk>
Cc: "Francesco Cagnin" <francesco.cagnin@gmail.com>,
	qemu-devel@nongnu.org, dirty@apple.com, r.bolshakov@yadro.com,
	"open list:ARM cores" <qemu-arm@nongnu.org>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Francesco Cagnin" <fcagnin@quarkslab.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH 2/3] hvf: implement guest debugging on Apple Silicon hosts
Date: Wed, 9 Nov 2022 10:58:01 +0000	[thread overview]
Message-ID: <CAFEAcA9jVVQhouS7uhmh+gMs328M_0r9Nz3npzrbmBoVhS+=TA@mail.gmail.com> (raw)
In-Reply-To: <D86C8F4E-517E-4ECC-A66D-E57F551FFECF@ynddal.dk>

On Tue, 8 Nov 2022 at 11:51, Mads Ynddal <mads@ynddal.dk> wrote:
> I also noticed you are adding 1 to the WRPs and BRPs. As I interpret the
> documentation, you should subtract 1 instead, given the value 0 is reserved:
>
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index dbc3605f6d..80a583cbd1 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -39,11 +39,11 @@ static void hvf_arm_init_debug(CPUState *cpu)
>  {
>      ARMCPU *arm_cpu = ARM_CPU(cpu);
>
> -    max_hw_bps = 1 + extract64(arm_cpu->isar.id_aa64dfr0, 12, 4);
> +    max_hw_bps = extract64(arm_cpu->isar.id_aa64dfr0, 12, 4) - 1;
>      hw_breakpoints =
>          g_array_sized_new(true, true, sizeof(HWBreakpoint), max_hw_bps);
>
> -    max_hw_wps = 1 + extract64(arm_cpu->isar.id_aa64dfr0, 20, 4);
> +    max_hw_wps = extract64(arm_cpu->isar.id_aa64dfr0, 20, 4) - 1;
>      hw_watchpoints =
>          g_array_sized_new(true, true, sizeof(HWWatchpoint), max_hw_wps);
>      return;
>
> But the documentation is a bit ambiguous on that. Maybe we can test it?

Adding 1 is correct -- the field definition is "number of breakpoints - 1",
so the number of bps is "field value + 1". You don't need to open-code this,
though -- there are functions arm_num_brps() and arm_num_wrps()
in target/arm/internals.h that extract the fields from the ID registers
and adjust them to give the actual number.

thanks
-- PMM


  parent reply	other threads:[~2022-11-09 10:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 18:40 [PATCH 0/3] Add gdbstub support to HVF francesco.cagnin
2022-11-04 18:40 ` [PATCH 1/3] arm: move KVM breakpoints helpers francesco.cagnin
2022-11-07 13:00   ` Mads Ynddal
2022-11-07 14:15   ` Alex Bennée
2022-11-07 14:39     ` Philippe Mathieu-Daudé
2022-11-09 12:55       ` Francesco Cagnin
2022-11-04 18:41 ` [PATCH 2/3] hvf: implement guest debugging on Apple Silicon hosts francesco.cagnin
2022-11-07 12:38   ` Mads Ynddal
2022-11-07 13:28   ` Mads Ynddal
2022-11-08 10:09     ` Francesco Cagnin
2022-11-08 11:51       ` Mads Ynddal
2022-11-09 10:12         ` Mads Ynddal
2022-11-09 10:58         ` Peter Maydell [this message]
2022-11-09 11:34           ` Francesco Cagnin
2022-11-04 18:41 ` [PATCH 3/3] hvf: handle writes of MDSCR_EL1 and DBG*_EL1 francesco.cagnin
2022-11-07 13:00   ` Mads Ynddal

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='CAFEAcA9jVVQhouS7uhmh+gMs328M_0r9Nz3npzrbmBoVhS+=TA@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=alex.bennee@linaro.org \
    --cc=dirty@apple.com \
    --cc=fcagnin@quarkslab.com \
    --cc=francesco.cagnin@gmail.com \
    --cc=mads@ynddal.dk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    /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).