public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Bhushan Bharat-R65777 <Bharat.Bhushan@freescale.com>
Cc: "agraf@suse.de" <agraf@suse.de>,
	"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Yoder Stuart-B08248" <stuart.yoder@freescale.com>
Subject: Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception
Date: Wed, 30 Jul 2014 21:47:54 -0500	[thread overview]
Message-ID: <1406774874.29414.312.camel@snotra.buserror.net> (raw)
In-Reply-To: <fda708f6c0464f5f8261de034af5cb08@BLUPR03MB566.namprd03.prod.outlook.com>

On Wed, 2014-07-30 at 01:43 -0500, Bhushan Bharat-R65777 wrote:
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Tuesday, July 29, 2014 3:58 AM
> > To: Bhushan Bharat-R65777
> > Cc: agraf@suse.de; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder Stuart-
> > B08248
> > Subject: Re: [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception
> > 
> >  Userspace might be interested in
> > the raw value,
> 
> With the current design, If userspace is interested then it will not
> get the DBSR.

Oh, because DBSR isn't currently implemented in sregs or one reg?

>  But why userspace will be interested?

Do you expose all of the hardware's debugging features in your
high-level interface?

> > plus it's a change from the current API semantics.
> 
> Can you please let us know how ?

It looked like it was removing dbsr visibility and the requirement for
userspace to clear dbsr.  I guess the old way was that the value in
vcpu->arch.dbsr didn't matter until the next debug exception, when it
would be overwritten by the new SPRN_DBSR?

> > > +	case SPRN_DBCR2:
> > > +		/*
> > > +		 * If userspace is debugging guest then guest
> > > +		 * can not access debug registers.
> > > +		 */
> > > +		if (vcpu->guest_debug)
> > > +			break;
> > > +
> > > +		debug_inst = true;
> > > +		vcpu->arch.dbg_reg.dbcr2 = spr_val;
> > > +		vcpu->arch.shadow_dbg_reg.dbcr2 = spr_val;
> > >  		break;
> > 
> > In what circumstances can the architected and shadow registers differ?
> 
> As of now they are same. But I think that if we want to implement other features like "Freeze Timer (FT)" then they can be different.

I don't think we can possibly implement Freeze Timer.
 
> > >  	case SPRN_DBSR:
> > > +		/*
> > > +		 * If userspace is debugging guest then guest
> > > +		 * can not access debug registers.
> > > +		 */
> > > +		if (vcpu->guest_debug)
> > > +			break;
> > > +
> > >  		vcpu->arch.dbsr &= ~spr_val;
> > > +		if (vcpu->arch.dbsr == 0)
> > > +			kvmppc_core_dequeue_debug(vcpu);
> > >  		break;
> > 
> > Not all DBSR bits cause an exception, e.g. IDE and MRR.
> 
> I am not sure what we should in that case ?
>
> As we are currently emulating a subset of debug events (IAC, DAC, IC,
> BT and TIE --- DBCR0 emulation) then we should expose status of those
> events in guest dbsr and rest should be cleared ?

I'm not saying they need to be exposed to the guest, but I don't see
where you filter out bits like these.

> > > @@ -273,6 +397,10 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int
> > sprn, ulong spr_val)
> > >  		emulated = EMULATE_FAIL;
> > >  	}
> > >
> > > +	if (debug_inst) {
> > > +		switch_booke_debug_regs(&vcpu->arch.shadow_dbg_reg);
> > > +		current->thread.debug = vcpu->arch.shadow_dbg_reg;
> > > +	}
> > 
> > Could you explain what's going on with regard to copying the registers
> > into current->thread.debug?  Why is it done after loading the registers
> > into the hardware (is there a race if we get preempted in the middle)?
> 
> Yes, and this was something I was not clear when writing this code.
> Should we have preempt disable-enable around this.

Can they be reordered instead?

-Scott

  reply	other threads:[~2014-07-31  2:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  8:38 [PATCH 0/6] Guest debug emulation Bharat Bhushan
2014-07-11  8:38 ` [PATCH 1/6] KVM: PPC: BOOKE: No need to set DBCR0_EDM in guest visible register Bharat Bhushan
2014-07-28 21:52   ` Scott Wood
2014-07-30  5:21     ` Bharat.Bhushan
2014-07-30 17:47       ` Scott Wood
2014-07-30 17:57         ` Bharat.Bhushan
2014-07-30 18:15           ` Scott Wood
2014-07-11  8:38 ` [PATCH 2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under debug Bharat Bhushan
2014-07-28 13:54   ` Alexander Graf
2014-07-28 21:54   ` Scott Wood
2014-07-30  5:30     ` Bharat.Bhushan
2014-07-11  8:38 ` [PATCH 3/6] KVM: PPC: BOOKE: allow debug interrupt at "debug level" Bharat Bhushan
2014-07-11  8:38 ` [PATCH 4/6] KVM: PPC: BOOKE : Emulate rfdi instruction Bharat Bhushan
2014-07-11  8:39 ` [PATCH 5/6] KVM: PPC: BOOKE: Allow guest to change MSR_DE Bharat Bhushan
2014-07-28 22:01   ` Scott Wood
2014-07-29 14:05     ` Alexander Graf
2014-07-30  5:37       ` Bharat.Bhushan
2014-07-11  8:39 ` [PATCH 6/6] KVM: PPC: BOOKE: Emulate debug registers and exception Bharat Bhushan
2014-07-28 14:04   ` Alexander Graf
2014-07-28 22:33     ` Scott Wood
2014-07-29 14:06       ` Alexander Graf
2014-07-29 17:50         ` Scott Wood
2014-07-29 18:23           ` Alexander Graf
2014-07-30  5:43           ` Bharat.Bhushan
2014-07-30  6:33             ` Alexander Graf
2014-07-30  6:49     ` Bharat.Bhushan
2014-07-28 22:28   ` Scott Wood
2014-07-30  6:43     ` Bharat.Bhushan
2014-07-31  2:47       ` Scott Wood [this message]
2014-07-31  6:15         ` Bharat.Bhushan
2014-07-31 20:45           ` Scott Wood
2014-08-01  9:34             ` Bharat.Bhushan
2014-08-02  3:35               ` Scott Wood

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=1406774874.29414.312.camel@snotra.buserror.net \
    --to=scottwood@freescale.com \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=stuart.yoder@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox