From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 3/9] arm64: KVM: add trap handlers for AArch64 debug registers
Date: Wed, 09 Jul 2014 17:20:22 +0100 [thread overview]
Message-ID: <871ttu7bcp.fsf@why.wild-wind.fr.eu.org> (raw)
In-Reply-To: <20140709145232.GA20459@cbox> (Christoffer Dall's message of "Wed, 9 Jul 2014 15:52:32 +0100")
On Wed, Jul 09 2014 at 3:52:32 pm BST, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> On Wed, Jul 09, 2014 at 12:09:29PM +0100, Marc Zyngier wrote:
>> On Wed, Jul 09 2014 at 10:38:13 am BST, Christoffer Dall
>> <christoffer.dall@linaro.org> wrote:
>> > On Fri, Jun 20, 2014 at 02:00:01PM +0100, Marc Zyngier wrote:
>> >> Add handlers for all the AArch64 debug registers that are accessible
>> >> from EL0 or EL1. The trapping code keeps track of the state of the
>> >> debug registers, allowing for the switch code to implement a lazy
>> >> switching strategy.
>> >>
>> >> Reviewed-by: Anup Patel <anup.patel@linaro.org>
>> >> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> >> ---
>> >> arch/arm64/include/asm/kvm_asm.h | 28 ++++++--
>> >> arch/arm64/include/asm/kvm_host.h | 3 +
>> >> arch/arm64/kvm/sys_regs.c | 137 +++++++++++++++++++++++++++++++++++++-
>> >> 3 files changed, 159 insertions(+), 9 deletions(-)
[...]
>> >> +/*
>> >> + * We want to avoid world-switching all the DBG registers all the
>> >> + * time. For this, we use a DIRTY but, indicating the guest has
>> >
>> > a DIRTY but? (at least there's only one t in there).
>>
>> The whole debug architecture makes me feel very dirty.
>>
>> >> + * modified the debug registers, and only restore the registers once,
>> >> + * disabling traps.
>> >
>> > I don't think I understand the "only restore the registers once" bit
>> > here. I know I'm being incredibly stupid, but I forgot since the last
>> > review round how this actually works; when we return from the guest and
>> > the guest has somehow enabled certain DBG functionality, then we
>> > set the dirty
>> > flag, which means we should stop trapping and context switch all the
>> > registers on world-switches, but if we see when returning from the guest
>> > that the guest doesn't appear to be using the registers we enable
>> > trapping and stop world-switching, right?
>>
>> Almost. We always decide on the trapping when entering the guest:
>> - If the dirty bit is set (because we're coming back from trapping),
>> disable the traps, restore the registers
>> - If debug is actively in use (DBG_MDSCR_KDE or DBG_MDSCR_MDE set),
>> disable the traps, restore the registers
>
> this also sets the dirty bit then?
Indeed. I'll mention it.
>
>> - Otherwise, enable the traps
>>
>> When exiting the guest: If the dirty bit is set, save the registers and
>> clear the dirty bit.
>
> because the host should always be able to freely use the debug registers
> so we always have to restore the host registers on coming out of the VM,
> right?
Yes. The host may have its own debug state active, and we want to
preserve that.
>>
>> > Do we clearly define which state triggers the world-switching and why
>> > that's a good rationale? (sorry, the debug architecture is not my
>> > favorite part of the ARM ARM).
>>
>> I thing the above comment describes the state precisely. My rational is:
>> - If we've touched any debug register, it is likely that we're going to
>> touch more of them. It then makes sense to disable the traps and start
>> doing the save/restore dance
>> - If debug is active (DBG_MDSCR_KDE or DBG_MDSCR_MDE set), it is then
>> mandatory to save/restore the registers, as the guest depends on them.
>>
>> Does this make the process clearer? If so, I can add it to the comment.
>>
>
> yes, the above comments help a lot. thanks!!
>
> [if I don't see your response because you already left for vacation, I'm
> going to incorporate your comments in the patches to apply to
> kvmarm/next].
I'm not quite gone yet! ;-) Just enough time left to respin the branch
on top of what's already queued, push it out and post the series.
M.
--
Without deviation from the norm, progress is not possible.
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: "linux-arm-kernel\@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"kvmarm\@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
Anup Patel <anup.patel@linaro.org>
Subject: Re: [PATCH v3 3/9] arm64: KVM: add trap handlers for AArch64 debug registers
Date: Wed, 09 Jul 2014 17:20:22 +0100 [thread overview]
Message-ID: <871ttu7bcp.fsf@why.wild-wind.fr.eu.org> (raw)
In-Reply-To: <20140709145232.GA20459@cbox> (Christoffer Dall's message of "Wed, 9 Jul 2014 15:52:32 +0100")
On Wed, Jul 09 2014 at 3:52:32 pm BST, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> On Wed, Jul 09, 2014 at 12:09:29PM +0100, Marc Zyngier wrote:
>> On Wed, Jul 09 2014 at 10:38:13 am BST, Christoffer Dall
>> <christoffer.dall@linaro.org> wrote:
>> > On Fri, Jun 20, 2014 at 02:00:01PM +0100, Marc Zyngier wrote:
>> >> Add handlers for all the AArch64 debug registers that are accessible
>> >> from EL0 or EL1. The trapping code keeps track of the state of the
>> >> debug registers, allowing for the switch code to implement a lazy
>> >> switching strategy.
>> >>
>> >> Reviewed-by: Anup Patel <anup.patel@linaro.org>
>> >> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> >> ---
>> >> arch/arm64/include/asm/kvm_asm.h | 28 ++++++--
>> >> arch/arm64/include/asm/kvm_host.h | 3 +
>> >> arch/arm64/kvm/sys_regs.c | 137 +++++++++++++++++++++++++++++++++++++-
>> >> 3 files changed, 159 insertions(+), 9 deletions(-)
[...]
>> >> +/*
>> >> + * We want to avoid world-switching all the DBG registers all the
>> >> + * time. For this, we use a DIRTY but, indicating the guest has
>> >
>> > a DIRTY but? (at least there's only one t in there).
>>
>> The whole debug architecture makes me feel very dirty.
>>
>> >> + * modified the debug registers, and only restore the registers once,
>> >> + * disabling traps.
>> >
>> > I don't think I understand the "only restore the registers once" bit
>> > here. I know I'm being incredibly stupid, but I forgot since the last
>> > review round how this actually works; when we return from the guest and
>> > the guest has somehow enabled certain DBG functionality, then we
>> > set the dirty
>> > flag, which means we should stop trapping and context switch all the
>> > registers on world-switches, but if we see when returning from the guest
>> > that the guest doesn't appear to be using the registers we enable
>> > trapping and stop world-switching, right?
>>
>> Almost. We always decide on the trapping when entering the guest:
>> - If the dirty bit is set (because we're coming back from trapping),
>> disable the traps, restore the registers
>> - If debug is actively in use (DBG_MDSCR_KDE or DBG_MDSCR_MDE set),
>> disable the traps, restore the registers
>
> this also sets the dirty bit then?
Indeed. I'll mention it.
>
>> - Otherwise, enable the traps
>>
>> When exiting the guest: If the dirty bit is set, save the registers and
>> clear the dirty bit.
>
> because the host should always be able to freely use the debug registers
> so we always have to restore the host registers on coming out of the VM,
> right?
Yes. The host may have its own debug state active, and we want to
preserve that.
>>
>> > Do we clearly define which state triggers the world-switching and why
>> > that's a good rationale? (sorry, the debug architecture is not my
>> > favorite part of the ARM ARM).
>>
>> I thing the above comment describes the state precisely. My rational is:
>> - If we've touched any debug register, it is likely that we're going to
>> touch more of them. It then makes sense to disable the traps and start
>> doing the save/restore dance
>> - If debug is active (DBG_MDSCR_KDE or DBG_MDSCR_MDE set), it is then
>> mandatory to save/restore the registers, as the guest depends on them.
>>
>> Does this make the process clearer? If so, I can add it to the comment.
>>
>
> yes, the above comments help a lot. thanks!!
>
> [if I don't see your response because you already left for vacation, I'm
> going to incorporate your comments in the patches to apply to
> kvmarm/next].
I'm not quite gone yet! ;-) Just enough time left to respin the branch
on top of what's already queued, push it out and post the series.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2014-07-09 16:20 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 12:59 [PATCH v3 0/9] arm64: KVM: debug infrastructure support Marc Zyngier
2014-06-20 12:59 ` Marc Zyngier
2014-06-20 12:59 ` [PATCH v3 1/9] arm64: KVM: rename pm_fake handler to trap_raz_wi Marc Zyngier
2014-06-20 12:59 ` Marc Zyngier
2014-07-09 9:27 ` Christoffer Dall
2014-07-09 9:27 ` Christoffer Dall
2014-07-09 9:36 ` Marc Zyngier
2014-07-09 9:36 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 2/9] arm64: move DBG_MDSCR_* to asm/debug-monitors.h Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 3/9] arm64: KVM: add trap handlers for AArch64 debug registers Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-07-09 9:38 ` Christoffer Dall
2014-07-09 9:38 ` Christoffer Dall
2014-07-09 11:09 ` Marc Zyngier
2014-07-09 11:09 ` Marc Zyngier
2014-07-09 14:52 ` Christoffer Dall
2014-07-09 14:52 ` Christoffer Dall
2014-07-09 16:20 ` Marc Zyngier [this message]
2014-07-09 16:20 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 4/9] arm64: KVM: common infrastructure for handling AArch32 CP14/CP15 Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 5/9] arm64: KVM: use separate tables for AArch32 32 and 64bit traps Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 6/9] arm64: KVM: check ordering of all system register tables Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 7/9] arm64: KVM: add trap handlers for AArch32 debug registers Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-07-09 9:43 ` Christoffer Dall
2014-07-09 9:43 ` Christoffer Dall
2014-06-20 13:00 ` [PATCH v3 8/9] arm64: KVM: implement lazy world switch for " Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
2014-07-09 9:45 ` Christoffer Dall
2014-07-09 9:45 ` Christoffer Dall
2014-07-09 11:18 ` Marc Zyngier
2014-07-09 11:18 ` Marc Zyngier
2014-06-20 13:00 ` [PATCH v3 9/9] arm64: KVM: enable trapping of all " Marc Zyngier
2014-06-20 13:00 ` Marc Zyngier
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=871ttu7bcp.fsf@why.wild-wind.fr.eu.org \
--to=marc.zyngier@arm.com \
--cc=linux-arm-kernel@lists.infradead.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.