All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/9] arm64: KVM: debug infrastructure support
Date: Mon, 19 May 2014 13:59:54 +0100	[thread overview]
Message-ID: <87iop153g5.fsf@approximate.cambridge.arm.com> (raw)
In-Reply-To: <CAFEAcA9K0fu+B-j0sN7OaWPzkT+0hYCxu3JLwDKT3qYob4h1PA@mail.gmail.com> (Peter Maydell's message of "Mon, 19 May 2014 13:32:28 +0100")

On Mon, May 19 2014 at  1:32:28 pm BST, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 19 May 2014 10:28, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> If you look carefully at patch #8 (last hunk of the patch), you'll see
>> that I always reset the debug state to "clean" at the end of a guest
>> run:
>>
>> @@ -609,6 +1040,12 @@ __kvm_vcpu_return:
>>
>>         bl __restore_sysregs
>>         bl __restore_fpsimd
>> +
>> +       skip_clean_debug_state x3, 1f
>> +       // Clear the dirty flag for the next run
>> +       str     xzr, [x0, #VCPU_DEBUG_FLAGS]
>> +       bl      __restore_debug
>> +1:
>>         restore_host_regs
>>
>>         mov     x0, x1
>>
>> This ensures that the guest's debug state will only be reloaded if:
>>
>> - MDSCR_EL1 has either MDE or KDE set (which means the guest is actively
>> using the debug infrastructure)
>> - or the guest has written to a trapped register (which marks the state
>> as dirty).
>
> Do we also handle the case where the guest didn't write to the trapped
> register but userspace did (via the SET_ONE_REG API)? Maybe this just
> falls out in the wash or is handled already...

This is pretty much handled by the same code:

- Userspace wrote to any register but MDSCR_EL1, and MDSCR_EL1 doesn't
have MDE/KDE set. In this case, we don't need to do anything, as the new
state is not in use yet.
- Userspace has written to MDSCR_EL1.{MDE,KDE}, and this indicates we
must restore the state.

Compared to what the guest does, we don't flag the state as dirty when
we write to any of the debug registers (only MDSCR_EL1 can be used to
enter the "dirty" state). It is not really a problem, as this is only a
perfermance optimisation (as soon as the guest starts using debug
registers, we want to disable trapping).

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Anup Patel <anup.patel@linaro.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	Will Deacon <Will.Deacon@arm.com>,
	"kvmarm\@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 0/9] arm64: KVM: debug infrastructure support
Date: Mon, 19 May 2014 13:59:54 +0100	[thread overview]
Message-ID: <87iop153g5.fsf@approximate.cambridge.arm.com> (raw)
In-Reply-To: <CAFEAcA9K0fu+B-j0sN7OaWPzkT+0hYCxu3JLwDKT3qYob4h1PA@mail.gmail.com> (Peter Maydell's message of "Mon, 19 May 2014 13:32:28 +0100")

On Mon, May 19 2014 at  1:32:28 pm BST, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 19 May 2014 10:28, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> If you look carefully at patch #8 (last hunk of the patch), you'll see
>> that I always reset the debug state to "clean" at the end of a guest
>> run:
>>
>> @@ -609,6 +1040,12 @@ __kvm_vcpu_return:
>>
>>         bl __restore_sysregs
>>         bl __restore_fpsimd
>> +
>> +       skip_clean_debug_state x3, 1f
>> +       // Clear the dirty flag for the next run
>> +       str     xzr, [x0, #VCPU_DEBUG_FLAGS]
>> +       bl      __restore_debug
>> +1:
>>         restore_host_regs
>>
>>         mov     x0, x1
>>
>> This ensures that the guest's debug state will only be reloaded if:
>>
>> - MDSCR_EL1 has either MDE or KDE set (which means the guest is actively
>> using the debug infrastructure)
>> - or the guest has written to a trapped register (which marks the state
>> as dirty).
>
> Do we also handle the case where the guest didn't write to the trapped
> register but userspace did (via the SET_ONE_REG API)? Maybe this just
> falls out in the wash or is handled already...

This is pretty much handled by the same code:

- Userspace wrote to any register but MDSCR_EL1, and MDSCR_EL1 doesn't
have MDE/KDE set. In this case, we don't need to do anything, as the new
state is not in use yet.
- Userspace has written to MDSCR_EL1.{MDE,KDE}, and this indicates we
must restore the state.

Compared to what the guest does, we don't flag the state as dirty when
we write to any of the debug registers (only MDSCR_EL1 can be used to
enter the "dirty" state). It is not really a problem, as this is only a
perfermance optimisation (as soon as the guest starts using debug
registers, we want to disable trapping).

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

  reply	other threads:[~2014-05-19 12:59 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 15:20 [PATCH 0/9] arm64: KVM: debug infrastructure support Marc Zyngier
2014-05-07 15:20 ` Marc Zyngier
2014-05-07 15:20 ` [PATCH 1/9] arm64: KVM: rename pm_fake handler to trap_wi_raz Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-07 15:34   ` Peter Maydell
2014-05-07 15:34     ` Peter Maydell
2014-05-07 15:42     ` Marc Zyngier
2014-05-07 15:42       ` Marc Zyngier
2014-05-19  8:43   ` Anup Patel
2014-05-19  8:43     ` Anup Patel
2014-05-07 15:20 ` [PATCH 2/9] arm64: move DBG_MDSCR_* to asm/debug-monitors.h Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-07 17:14   ` Will Deacon
2014-05-07 17:14     ` Will Deacon
2014-05-07 15:20 ` [PATCH 3/9] arm64: KVM: add trap handlers for AArch64 debug registers Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:27   ` Anup Patel
2014-05-19  8:27     ` Anup Patel
2014-05-07 15:20 ` [PATCH 4/9] arm64: KVM: common infrastructure for handling AArch32 CP14/CP15 Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:29   ` Anup Patel
2014-05-19  8:29     ` Anup Patel
2014-05-07 15:20 ` [PATCH 5/9] arm64: KVM: use separate tables for AArch32 32 and 64bit traps Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:29   ` Anup Patel
2014-05-19  8:29     ` Anup Patel
2014-05-07 15:20 ` [PATCH 6/9] arm64: KVM: check ordering of all system register tables Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:31   ` Anup Patel
2014-05-19  8:31     ` Anup Patel
2014-05-07 15:20 ` [PATCH 7/9] arm64: KVM: add trap handlers for AArch32 debug registers Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:33   ` Anup Patel
2014-05-19  8:33     ` Anup Patel
2014-05-07 15:20 ` [PATCH 8/9] arm64: KVM: implement lazy world switch for " Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:38   ` Anup Patel
2014-05-19  8:38     ` Anup Patel
2014-05-19 16:01     ` Marc Zyngier
2014-05-19 16:01       ` Marc Zyngier
2014-05-07 15:20 ` [PATCH 9/9] arm64: KVM: enable trapping of all " Marc Zyngier
2014-05-07 15:20   ` Marc Zyngier
2014-05-19  8:40   ` Anup Patel
2014-05-19  8:40     ` Anup Patel
2014-05-07 15:42 ` [PATCH 0/9] arm64: KVM: debug infrastructure support Peter Maydell
2014-05-07 15:42   ` Peter Maydell
2014-05-07 15:57   ` Marc Zyngier
2014-05-07 15:57     ` Marc Zyngier
2014-05-19  9:05 ` Anup Patel
2014-05-19  9:05   ` Anup Patel
2014-05-19  9:28   ` Marc Zyngier
2014-05-19  9:28     ` Marc Zyngier
2014-05-19  9:35     ` Anup Patel
2014-05-19  9:35       ` Anup Patel
2014-05-19 12:22       ` Marc Zyngier
2014-05-19 12:22         ` Marc Zyngier
2014-05-19 12:32     ` Peter Maydell
2014-05-19 12:32       ` Peter Maydell
2014-05-19 12:59       ` Marc Zyngier [this message]
2014-05-19 12:59         ` 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=87iop153g5.fsf@approximate.cambridge.arm.com \
    --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.