linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: zhichao.huang@linaro.org (Zhichao Huang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 13/15] KVM: arm: keep track of guest use of the debug registers
Date: Tue, 29 Sep 2015 13:36:15 +0800	[thread overview]
Message-ID: <560A234F.9050702@linaro.org> (raw)
In-Reply-To: <20150902160103.GP10991@cbox>



On 2015/9/3 0:01, Christoffer Dall wrote:
> On Mon, Aug 10, 2015 at 09:26:05PM +0800, Zhichao Huang wrote:
>>  
>> -static bool trap_debug32(struct kvm_vcpu *vcpu,
>> +/* Indicate whether the guest has enabled any break/watch points or not. */
>> +static bool guest_debug_in_use(struct kvm_vcpu *vcpu)
>> +{
>> +	unsigned int i;
>> +
>> +	for (i = 0; i < ARM_MAX_BRP; i++)
>> +		if (vcpu->arch.cp14[cp14_DBGBCR0 + i] & 0x1)
>> +			return true;
>> +	for (i = 0; i < ARM_MAX_WRP; i++)
>> +		if (vcpu->arch.cp14[cp14_DBGWCR0 + i] & 0x1)
>> +			return true;
>> +
>> +	return false;
>> +}
>> +
>> +static bool __trap_debug32(struct kvm_vcpu *vcpu,
>>  			const struct coproc_params *p,
>>  			const struct coproc_reg *r)
>>  {
>> @@ -232,6 +247,56 @@ static bool trap_debug32(struct kvm_vcpu *vcpu,
>>  	return true;
>>  }
>>  

>> +static bool trap_debug32(struct kvm_vcpu *vcpu,
>> +			const struct coproc_params *p,
>> +			const struct coproc_reg *r)
>> +{
>> +	__trap_debug32(vcpu, p, r);
>> +
>> +	if (p->is_write) {
>> +		if ((vcpu->arch.cp14[r->reg] & 0x1) ||
>> +		    guest_debug_in_use(vcpu))
>> +			vcpu->arch.debug_flags |= KVM_ARM_DEBUG_GUEST_INUSE;
>> +		else
>> +			vcpu->arch.debug_flags &= ~KVM_ARM_DEBUG_GUEST_INUSE;
> 
> I don't understand this logic, if we are enabling one of the w/b points
> or if there was already an enabled w/b point, then we set the flag, but
> if you disable a single one then you clear the flag?
> 
> It looks to me like you're mixing two approaches here;  either read
> through all the registers whenever you need to know to set the flag or
> not, or you keep track of this on every read/write of the registers.
> 

I did it in the function guest_debug_in_use(), which will read through all the
registers.


> 
> So __trap_debug32 is for the non-control registers and trap-debug32 is
> for the control registers?
> 
> I think specifically naming the control register function
> trap_debug_cr would be cleaner in that case.
> 

OK.

> Thanks,
> -Christoffer
> 

  reply	other threads:[~2015-09-29  5:36 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 [this message]
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
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=560A234F.9050702@linaro.org \
    --to=zhichao.huang@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).