From: "Alex Bennée" <alex.bennee@linaro.org>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com,
peter.maydell@linaro.org, agraf@suse.de, drjones@redhat.com,
pbonzini@redhat.com, zhichao.huang@linaro.org,
jan.kiszka@siemens.com, dahi@linux.vnet.ibm.com,
r65777@freescale.com, bp@suse.de, Gleb Natapov <gleb@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Russell King <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Ingo Molnar <mingo@kernel.org>,
"open list\:DOCUMENTATION" <linux-doc@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list\:ABI\/API" <linux-api@vger.kernel.org>
Subject: Re: [PATCH v6 10/12] KVM: arm64: guest debug, HW assisted debug support
Date: Thu, 25 Jun 2015 11:42:25 +0100 [thread overview]
Message-ID: <87k2usxe5q.fsf@linaro.org> (raw)
In-Reply-To: <20150625074934.GB28244@cbox>
Christoffer Dall <christoffer.dall@linaro.org> writes:
> On Thu, Jun 25, 2015 at 07:38:33AM +0100, Alex Bennée wrote:
>>
>> Christoffer Dall <christoffer.dall@linaro.org> writes:
>>
>> > On Fri, Jun 19, 2015 at 01:23:48PM +0100, Alex Bennée wrote:
>> >> This adds support for userspace to control the HW debug registers for
>> >> guest debug. In the debug ioctl we copy the IMPDEF defined number of
<snip>
>> >> void kvm_arm_clear_debug(struct kvm_vcpu *vcpu)
>> >> {
>> >> - if (vcpu->guest_debug)
>> >> + if (vcpu->guest_debug) {
>> >> restore_guest_debug_regs(vcpu);
>> >> +
>> >> + /*
>> >> + * If we were using HW debug we need to restore the
>> >> + * debug_ptr to the guest debug state.
>> >> + */
>> >> + if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW)
>> >> + vcpu->arch.debug_ptr = &vcpu->arch.vcpu_debug_state;
>> >
>> > I still think this would be more cleanly done in the setup_debug
>> > function, but ok:
>>
>> I don't follow, setup_debug is called before we enter KVM. It's pretty
>> light when no debugging is being done so this ensure we leave state how
>> we would like it when we stop debugging.
>>
>> I can move it to an else leg in setup if you really want.
>>
> I just feel like whenever you enter the guest you setup the state you
> want for your guest and then when reading the code you never have to
> worry about "did I set the pointer back correctly last time it exited",
> but thinking about your response, I guess that's an extra store on each
> world-switch, so theoretically that may be a bit more overhead (on top
> of the hundreds other stores and spinlocks we take and stuff).
The setup/clear() calls are tightly paired around the KVM_RUN ioctl code
without any obvious exit points.
Are there any cases you can escape the ioctl code flow? I notice irq's
are re-enabled so I guess a suitably determined irq function could
change the return address or mess around with guest_debug.
> If you prefer, leave it like this, but consider adding a
> BUG_ON(!guest_debugging && debug_ptr != &vcpu->arch.vcpu_debug_state) in
> the setup function...
The clear_debug() code would end up being a fairly sparse piece of code
without it ;-)
> I'm probably being paranoid.
A little paranoia goes a long way in kernel mode ;-)
>
> -Christoffer
--
Alex Bennée
next prev parent reply other threads:[~2015-06-25 10:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1434716630-18260-1-git-send-email-alex.bennee@linaro.org>
2015-06-19 12:23 ` [PATCH v6 01/12] KVM: add comments for kvm_debug_exit_arch struct Alex Bennée
2015-06-19 12:23 ` [PATCH v6 02/12] KVM: arm64: fix misleading comments in save/restore Alex Bennée
2015-06-19 12:23 ` [PATCH v6 03/12] KVM: arm64: guest debug, define API headers Alex Bennée
2015-06-19 12:23 ` [PATCH v6 04/12] KVM: arm: guest debug, add stub KVM_SET_GUEST_DEBUG ioctl Alex Bennée
2015-06-19 12:23 ` [PATCH v6 05/12] KVM: arm: introduce kvm_arm_init/setup/clear_debug Alex Bennée
2015-06-19 12:23 ` [PATCH v6 06/12] KVM: arm64: guest debug, add SW break point support Alex Bennée
2015-06-19 12:23 ` [PATCH v6 07/12] KVM: arm64: guest debug, add support for single-step Alex Bennée
2015-06-19 12:23 ` [PATCH v6 08/12] KVM: arm64: re-factor hyp.S debug register code Alex Bennée
2015-06-24 20:19 ` Christoffer Dall
2015-06-25 6:34 ` Alex Bennée
2015-06-19 12:23 ` [PATCH v6 09/12] KVM: arm64: introduce vcpu->arch.debug_ptr Alex Bennée
2015-06-24 11:42 ` Christoffer Dall
2015-06-25 6:32 ` Alex Bennée
2015-06-25 7:46 ` Christoffer Dall
2015-06-19 12:23 ` [PATCH v6 10/12] KVM: arm64: guest debug, HW assisted debug support Alex Bennée
2015-06-24 20:22 ` Christoffer Dall
2015-06-25 6:38 ` Alex Bennée
2015-06-25 7:49 ` Christoffer Dall
2015-06-25 10:42 ` Alex Bennée [this message]
2015-06-19 12:23 ` [PATCH v6 11/12] KVM: arm64: enable KVM_CAP_SET_GUEST_DEBUG Alex Bennée
2015-06-19 12:23 ` [PATCH v6 12/12] KVM: arm64: add trace points for guest_debug debug Alex Bennée
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=87k2usxe5q.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=agraf@suse.de \
--cc=bp@suse.de \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=corbet@lwn.net \
--cc=dahi@linux.vnet.ibm.com \
--cc=drjones@redhat.com \
--cc=gleb@kernel.org \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-api@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=lorenzo.pieralisi@arm.com \
--cc=marc.zyngier@arm.com \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterz@infradead.org \
--cc=r65777@freescale.com \
--cc=will.deacon@arm.com \
--cc=zhichao.huang@linaro.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