All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Francesco Cagnin <francesco.cagnin@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, mads@ynddal.dk, dirty@apple.com,
	qemu-arm@nongnu.org, agraf@csgraf.de, pbonzini@redhat.com,
	Francesco Cagnin <fcagnin@quarkslab.com>
Subject: Re: [PATCH v2 2/3] hvf: implement guest debugging on Apple Silicon hosts
Date: Tue, 20 Dec 2022 08:31:25 +0000	[thread overview]
Message-ID: <871qouihzl.fsf@linaro.org> (raw)
In-Reply-To: <CAF8_6KkPDwe8-twtJEM3_HDuRVmxn25gJGDQVhRJF=DuA+fm3w@mail.gmail.com>


Francesco Cagnin <francesco.cagnin@gmail.com> writes:

> Hi,
> indeed, the patch doesn't keep separate copies of debug registers and
> just directly sets cp15.* values, as I was not aware of the issue—thanks
> for the detailed explanation.
>
> I remain available to implement the required fixes, but I'd need
> some guidance on how to proceed. Thanks,

In the KVM world we put of the final setting of the registers until
right before the context switch. I guess the equivalent in HVF would be
to modify hvf_put_registers() and make the decision about if to use the
QEMU supplied debug registers or the env values there.

Something like:

    for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) {
        if (hvf_sreg_match[i].cp_idx == -1) {
            continue;
        }
        if (hvf_sref_match[i].can_override && should_override) {
            val = get_from_debug(...)        
        } else {
            val = arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx];
        }
        ret = hv_vcpu_set_sys_reg(cpu->hvf->fd, hvf_sreg_match[i].reg, val);
        assert_hvf_ok(ret);
    }

You will of course have to ensure the get_registers doesn't
inadvertently splat the env values with what we have just written here.

I'm not super familiar with the HVF architecture but maybe its possible
to do directly call hv_vcpu_set_sys_reg steps in your current
update_guest_debug function instead of copying to env and then and just
skip setting/getting them again in the final put registers just before
you exec.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2022-12-20  8:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 17:47 [PATCH v2 0/3] Add gdbstub support to HVF francesco.cagnin
2022-11-16 17:47 ` [PATCH v2 1/3] arm: move KVM breakpoints helpers francesco.cagnin
2022-11-22 10:06   ` Alex Bennée
2022-11-16 17:47 ` [PATCH v2 2/3] hvf: implement guest debugging on Apple Silicon hosts francesco.cagnin
2022-11-17 14:01   ` Mads Ynddal
2022-12-12 16:16   ` Peter Maydell
2022-12-20  7:22     ` Francesco Cagnin
2022-12-20  8:31       ` Alex Bennée [this message]
2022-11-16 17:47 ` [PATCH v2 3/3] hvf: handle writes of MDSCR_EL1 and DBG*_EL1 francesco.cagnin
2022-11-17 14:01   ` 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=871qouihzl.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=dirty@apple.com \
    --cc=fcagnin@quarkslab.com \
    --cc=francesco.cagnin@gmail.com \
    --cc=mads@ynddal.dk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.