All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Alexander Graf <agraf@suse.de>, Will Deacon <will.deacon@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	kvmarm@lists.cs.columbia.edu,
	KVM devel mailing list <kvm@vger.kernel.org>
Subject: Re: Exposing host debug capabilities to userspace
Date: Wed, 26 Nov 2014 12:11:01 +0000	[thread overview]
Message-ID: <87wq6ikvqi.fsf@linaro.org> (raw)
In-Reply-To: <5474B365.10009@redhat.com>


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 25/11/2014 17:35, Alexander Graf wrote:
>> Unfortunately on ARM you also have a few other constraints - the debug
>> register space is partitioned into magic super debug registers at the
>> top (with an implementation specific amount) and normal debug registers
>> in the lower end of the space.
>
> Does the gdbstub ever need to use the magic super debug registers?  Even
> if it does, the logic is the same as x86.  On x86 you might run out of
> breakpoints, on ARM you might run out of breakpoints in general or magic
> super breakpoints in particular.

By default gdbstub uses normal software breakpoints unless a) the user
asks for a HW one or b) the memory is RO (i.e a ROM). For watchpoints
the situation is reversed and they are used by default if available.

>> I would just treat gdbstub debugging as the ugly step child that it is
>> and not introduce anything special for it (except for debug event
>> deflection to user space). Then only ever work on guest debug registers
>> and call it a day. Chances are just too high that we get the interfaces
>> wrong and shoot ourselves in the foot.
>
> I agree.  But we do need a way to retrieve the number of valid fields in
> struct kvm_guest_debug_arch, if that is not architecturally defined
> (e.g. on x86 it's just always 4).

It's IMPDEF (implementation defined) up to a maximum of 16.

> A "hidden" ONE_REG, whose existence
> is determined by (ARM || ARM64) &&
> kvm_check_extension(KVM_CAP_SET_GUEST_DEBUG), is certainly fine and I
> like it because it doesn't pollute the global KVM_CAP_* namespace.

My original implementation more or less did that but my main worry is
migration code tends to iterate over the whole ONE_REG list and
introducing a value that doesn't happen to be strictly the guests is
semantically impure. Of course if you mean by "hidden" don't export it
via GET_REG_LIST then I guess that would work. Does seem a little ugly
as the internal KVM code now needs to learn about hidden and non-hidden
registers.

> The alternative is a capability; however, if you start with two
> capabilities you'll end up needing four, and then realize that returning
> a struct via ONE_REG would have been a better idea.  :)  We already have
> how many breakpoints, how many watchpoints, how many magic super debug
> registers,...

Only two, not sure what the super debug registers are?

Certainly on the QEMU side the capability based approach is beautifully
simple:

    max_hw_wp = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_WPS);
    max_hw_bp = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_BPS);

thanks to kvm_check_extension zeroing failure modes.

And in it's defence it's a generic enough capability to be used across
any other architectures that need to expose this information compared to
the many PPC specific capabilities. Perhaps a KVM_ARCH_EXTENSION ioctl
would be more useful in reducing the growth of the space?

>
> Paolo

-- 
Alex Bennée

  reply	other threads:[~2014-11-26 12:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 16:55 Exposing host debug capabilities to userspace Alex Bennée
2014-11-21 10:08 ` Christoffer Dall
2014-11-21 10:29   ` Alex Bennée
2014-11-21 11:23   ` Alex Bennée
     [not found] ` <87egssn91o.fsf@zen.linaro.local.i-did-not-set--mail-host-address--so-tickle-me>
2014-11-24 11:21   ` Peter Maydell
2014-11-24 12:20     ` Christoffer Dall
2014-11-24 11:35   ` Alex Bennée
2014-11-24 12:26     ` Alexander Graf
2014-11-24 12:32       ` Peter Maydell
2014-11-24 12:41         ` Alexander Graf
2014-11-24 12:44           ` Peter Maydell
2014-11-24 12:51             ` Alexander Graf
2014-11-24 12:53               ` Christoffer Dall
2014-11-24 12:56                 ` Alexander Graf
2014-11-24 13:10                   ` Christoffer Dall
2014-11-24 14:07                     ` Alexander Graf
2014-11-24 14:52                       ` Christoffer Dall
2014-11-25 16:44                         ` Paolo Bonzini
2014-11-24 12:53           ` Alex Bennée
2014-11-24 12:54             ` Christoffer Dall
2014-11-24 13:59     ` Alex Bennée
2014-11-25 16:21       ` Paolo Bonzini
2014-11-25 16:35         ` Alexander Graf
2014-11-25 16:50           ` Paolo Bonzini
2014-11-26 12:11             ` Alex Bennée [this message]
2014-11-26 12:23             ` 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=87wq6ikvqi.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=agraf@suse.de \
    --cc=christoffer.dall@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=will.deacon@arm.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 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.