linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 14/15] KVM: arm: implement lazy world switch for debug registers
Date: Wed, 2 Sep 2015 18:06:20 +0200	[thread overview]
Message-ID: <20150902160620.GR10991@cbox> (raw)
In-Reply-To: <1439213167-8988-15-git-send-email-zhichao.huang@linaro.org>

On Mon, Aug 10, 2015 at 09:26:06PM +0800, Zhichao Huang wrote:
> Avoid world-switching all the debug registers when neither the host
> nor the guest has configured any [WB]points.
> 
> Signed-off-by: Zhichao Huang <zhichao.huang@linaro.org>
> ---
>  arch/arm/kvm/interrupts_head.S | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/kvm/interrupts_head.S b/arch/arm/kvm/interrupts_head.S
> index b9e7410..7ad0adf 100644
> --- a/arch/arm/kvm/interrupts_head.S
> +++ b/arch/arm/kvm/interrupts_head.S
> @@ -332,6 +332,21 @@ vcpu	.req	r0		@ vcpu pointer always in r0
>  	sub	r12, r2, r12		@ How many WPs to skip
>  .endm
>  

> +/* If VCPU_DEBUG_FLAGS is not set, it means that neither the host

For multi-line comments, can you please have the opening '/*' on a
separate line in keeping with the rest of these files?  Please change
this throughout the patch series (I think I've asked this before).

> + * nor the guest has configured any [WB]points.
> + *
> + * We avoid world-switching all the debug registers in that case.
> + *
> + * Assume vcpu pointer in vcpu reg
> + *
> + * clobbers r2
> + */
> +.macro skip_debug_state target
> +	ldr	r2, [vcpu, #VCPU_DEBUG_FLAGS]
> +	cmp	r2, #0
> +	beq	\target
> +.endm

But if the guest started using the registers and we're not trapping
accesses, then surely you need to store the values of the registers when
you come back from the guest, right?

Something about this feels weird.

> +
>  /* Reads cp14 registers from hardware.
>   * Writes cp14 registers in-order to the CP14 struct pointed to by r10
>   *
> @@ -340,12 +355,14 @@ vcpu	.req	r0		@ vcpu pointer always in r0
>   * Clobbers r2-r12
>   */
>  .macro save_debug_state
> +	skip_debug_state 9999f
> +
>  	read_hw_dbg_num
>  	cp14_read_and_str r10, 4, cp14_DBGBVR0, r11
>  	cp14_read_and_str r10, 5, cp14_DBGBCR0, r11
>  	cp14_read_and_str r10, 6, cp14_DBGWVR0, r12
>  	cp14_read_and_str r10, 7, cp14_DBGWCR0, r12
> -
> +9999:
>  	/* DBGDSCR reg */
>  	mrc	p14, 0, r2, c0, c1, 0
>  	str	r2, [r10, #CP14_OFFSET(cp14_DBGDSCRext)]
> @@ -359,12 +376,14 @@ vcpu	.req	r0		@ vcpu pointer always in r0
>   * Clobbers r2-r12
>   */
>  .macro restore_debug_state
> +	skip_debug_state 9999f
> +
>  	read_hw_dbg_num
>  	cp14_ldr_and_write r10, 4, cp14_DBGBVR0, r11
>  	cp14_ldr_and_write r10, 5, cp14_DBGBCR0, r11
>  	cp14_ldr_and_write r10, 6, cp14_DBGWVR0, r12
>  	cp14_ldr_and_write r10, 7, cp14_DBGWCR0, r12
> -
> +9999:
>  	/* DBGDSCR reg */
>  	ldr	r2, [r10, #CP14_OFFSET(cp14_DBGDSCRext)]
>  	mcr	p14, 0, r2, c0, c2, 2
> -- 
> 1.7.12.4
> 

  reply	other threads:[~2015-09-02 16:06 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10 13:25 [PATCH v4 00/15] KVM: arm: debug infrastructure support Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 01/15] KVM: arm: plug guest debug exploit Zhichao Huang
2015-09-02 11:38   ` Christoffer Dall
2015-09-29  5:13     ` Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 02/15] KVM: arm: rename pm_fake handler to trap_raz_wi Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 03/15] KVM: arm: enable to use the ARM_DSCR_MDBGEN macro from KVM assembly code Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 04/15] KVM: arm: common infrastructure for handling AArch32 CP14/CP15 Zhichao Huang
2015-09-02 13:09   ` Christoffer Dall
2015-08-10 13:25 ` [PATCH v4 05/15] KVM: arm: check ordering of all system register tables Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 06/15] KVM: arm: add trap handlers for 32-bit debug registers Zhichao Huang
2015-09-02 16:03   ` Christoffer Dall
2015-08-10 13:25 ` [PATCH v4 07/15] KVM: arm: add trap handlers for 64-bit " Zhichao Huang
2015-08-10 13:26 ` [PATCH v4 08/15] KVM: arm: add a trace event for cp14 traps Zhichao Huang
2015-08-10 13:26 ` [PATCH v4 09/15] KVM: arm: redefine kvm_cpu_context_t to save the host cp14 states Zhichao Huang
2015-09-02 14:54   ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 10/15] KVM: arm: implement world switch for debug registers Zhichao Huang
2015-09-02 14:53   ` Christoffer Dall
2015-09-29  5:32     ` Zhichao Huang
2015-09-29  7:34       ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 11/15] KVM: arm: add a function to keep track of host use of the " Zhichao Huang
2015-09-02 15:40   ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 12/15] KVM: arm: " Zhichao Huang
2015-09-02 15:44   ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 13/15] KVM: arm: keep track of guest " Zhichao Huang
2015-09-02 16:01   ` Christoffer Dall
2015-09-29  5:36     ` Zhichao Huang
2015-08-10 13:26 ` [PATCH v4 14/15] KVM: arm: implement lazy world switch for " Zhichao Huang
2015-09-02 16:06   ` Christoffer Dall [this message]
2015-08-10 13:26 ` [PATCH v4 15/15] KVM: arm: enable trapping of all " Zhichao Huang
2015-09-02 16:08   ` Christoffer Dall
2015-09-29  5:41     ` Zhichao Huang
2015-09-29  7:38       ` Christoffer Dall

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=20150902160620.GR10991@cbox \
    --to=christoffer.dall@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).