All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhichao Huang <zhichao.huang@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,
	alex.bennee@linaro.org, will.deacon@arm.com,
	huangzhichao@huawei.com, stable@vger.kernel.org
Subject: Re: [PATCH v4 01/15] KVM: arm: plug guest debug exploit
Date: Tue, 29 Sep 2015 13:13:01 +0800	[thread overview]
Message-ID: <560A1DDD.1060100@linaro.org> (raw)
In-Reply-To: <20150902113804.GJ10991@cbox>



On 2015/9/2 19:38, Christoffer Dall wrote:
> 
> I really think that we should read the register, clear the bits you care
> about (MDBGen and HDBGen) and then write back the register.
> 
> So, if I recall correctly, this is to avoid having to set HDCR_TDE
> below?
> 
> Given Will's concerns about touching this register, I'm thinking if we
> shouldn't start with the HDCR_TDE enabled (and a handler in KVM) and
> then see if we want to add this optimization later?
> 
> At the very least, you should do as Will pointed out and predicate
> writes to this register based on whether the reset code in
> hw_breakpoint.c successfully reset the debug regs.  I think checking the
> debug_err_mask variable from the C code and pass this on to the Hyp code
> would be the right way to go.
> 
> But as I said, I think we should just trap debug exceptions to begin
> with (to plug the hole) and then add the more intelligent stuff later.
> 

OK, I will set HDCR_TDE, and ignore all the debug exceptions in
KVM handlers to prevent the guest to mess with the host states.

>> +	.endif
>> +
>> +	mcr	p14, 0, r2, c0, c2, 2	@ DBGDSCR
>>  .endm
>>  
>>  /*
>> @@ -620,7 +633,7 @@ ARM_BE8(rev	r6, r6  )
>>   * (hardware reset value is 0) */
>>  .macro set_hdcr operation
>>  	mrc	p15, 4, r2, c1, c1, 1
>> -	ldr	r3, =(HDCR_TPM|HDCR_TPMCR)
>> +	ldr	r3, =(HDCR_TPM|HDCR_TPMCR|HDCR_TDRA|HDCR_TDOSA|HDCR_TDA)
> 
> 
> 
>>  	.if \operation == vmentry
>>  	orr	r2, r2, r3		@ Trap some perfmon accesses
>>  	.else
>> -- 
>> 1.7.12.4
>>
> 
> Thanks,
> -Christoffer
> 

WARNING: multiple messages have this Message-ID (diff)
From: zhichao.huang@linaro.org (Zhichao Huang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 01/15] KVM: arm: plug guest debug exploit
Date: Tue, 29 Sep 2015 13:13:01 +0800	[thread overview]
Message-ID: <560A1DDD.1060100@linaro.org> (raw)
In-Reply-To: <20150902113804.GJ10991@cbox>



On 2015/9/2 19:38, Christoffer Dall wrote:
> 
> I really think that we should read the register, clear the bits you care
> about (MDBGen and HDBGen) and then write back the register.
> 
> So, if I recall correctly, this is to avoid having to set HDCR_TDE
> below?
> 
> Given Will's concerns about touching this register, I'm thinking if we
> shouldn't start with the HDCR_TDE enabled (and a handler in KVM) and
> then see if we want to add this optimization later?
> 
> At the very least, you should do as Will pointed out and predicate
> writes to this register based on whether the reset code in
> hw_breakpoint.c successfully reset the debug regs.  I think checking the
> debug_err_mask variable from the C code and pass this on to the Hyp code
> would be the right way to go.
> 
> But as I said, I think we should just trap debug exceptions to begin
> with (to plug the hole) and then add the more intelligent stuff later.
> 

OK, I will set HDCR_TDE, and ignore all the debug exceptions in
KVM handlers to prevent the guest to mess with the host states.

>> +	.endif
>> +
>> +	mcr	p14, 0, r2, c0, c2, 2	@ DBGDSCR
>>  .endm
>>  
>>  /*
>> @@ -620,7 +633,7 @@ ARM_BE8(rev	r6, r6  )
>>   * (hardware reset value is 0) */
>>  .macro set_hdcr operation
>>  	mrc	p15, 4, r2, c1, c1, 1
>> -	ldr	r3, =(HDCR_TPM|HDCR_TPMCR)
>> +	ldr	r3, =(HDCR_TPM|HDCR_TPMCR|HDCR_TDRA|HDCR_TDOSA|HDCR_TDA)
> 
> 
> 
>>  	.if \operation == vmentry
>>  	orr	r2, r2, r3		@ Trap some perfmon accesses
>>  	.else
>> -- 
>> 1.7.12.4
>>
> 
> Thanks,
> -Christoffer
> 

  reply	other threads:[~2015-09-29  5:13 UTC|newest]

Thread overview: 65+ 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 ` Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 01/15] KVM: arm: plug guest debug exploit Zhichao Huang
2015-08-10 13:25   ` Zhichao Huang
2015-08-10 13:25   ` Zhichao Huang
2015-09-02 11:38   ` Christoffer Dall
2015-09-02 11:38     ` Christoffer Dall
2015-09-29  5:13     ` Zhichao Huang [this message]
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   ` 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   ` Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 04/15] KVM: arm: common infrastructure for handling AArch32 CP14/CP15 Zhichao Huang
2015-08-10 13:25   ` Zhichao Huang
2015-09-02 13:09   ` Christoffer Dall
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   ` Zhichao Huang
2015-08-10 13:25 ` [PATCH v4 06/15] KVM: arm: add trap handlers for 32-bit debug registers Zhichao Huang
2015-08-10 13:25   ` Zhichao Huang
2015-09-02 16:03   ` Christoffer Dall
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:25   ` 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   ` 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-08-10 13:26   ` Zhichao Huang
2015-09-02 14:54   ` Christoffer Dall
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-08-10 13:26   ` Zhichao Huang
2015-09-02 14:53   ` Christoffer Dall
2015-09-02 14:53     ` Christoffer Dall
2015-09-29  5:32     ` Zhichao Huang
2015-09-29  5:32       ` Zhichao Huang
2015-09-29  7:34       ` Christoffer Dall
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-08-10 13:26   ` Zhichao Huang
2015-09-02 15:40   ` Christoffer Dall
2015-09-02 15:40     ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 12/15] KVM: arm: " Zhichao Huang
2015-08-10 13:26   ` Zhichao Huang
2015-09-02 15:44   ` Christoffer Dall
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-08-10 13:26   ` Zhichao Huang
2015-09-02 16:01   ` Christoffer Dall
2015-09-02 16:01     ` Christoffer Dall
2015-09-29  5:36     ` Zhichao Huang
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-08-10 13:26   ` Zhichao Huang
2015-09-02 16:06   ` Christoffer Dall
2015-09-02 16:06     ` Christoffer Dall
2015-08-10 13:26 ` [PATCH v4 15/15] KVM: arm: enable trapping of all " Zhichao Huang
2015-08-10 13:26   ` Zhichao Huang
2015-09-02 16:08   ` Christoffer Dall
2015-09-02 16:08     ` Christoffer Dall
2015-09-29  5:41     ` Zhichao Huang
2015-09-29  5:41       ` Zhichao Huang
2015-09-29  7:38       ` Christoffer Dall
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=560A1DDD.1060100@linaro.org \
    --to=zhichao.huang@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=christoffer.dall@linaro.org \
    --cc=huangzhichao@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=stable@vger.kernel.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.