RE: [PATCH 2/2] KVM : powerpc/booke: Allow debug interrupt injection to guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Friday, June 27, 2014 11:53 PM
> To: Bhushan Bharat-R65777
> Cc: agraf@xxxxxxx; kvm-ppc@xxxxxxxxxxxxxxx; kvm@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH 2/2] KVM : powerpc/booke: Allow debug interrupt injection to
> guest
> 
> On Fri, 2014-06-27 at 11:55 +0530, Bharat Bhushan wrote:
> > This patch allow userspace to inject debug interrupt to guest.
> >
> > Signed-off-by: Bharat Bhushan <Bharat.Bhushan@xxxxxxxxxxxxx>
> 
> Could you describe how userspace plans to make use of this, and go into more
> detail about the changes you're making?

When a debug interrupt happens in guest then we switch to host userspace (QEMU) and if QEMU is not able to handle a debug interrupt then it injects the debug interrupt to guest. QEMU uses SET_SREGS (not a one_reg interface), with DBSR have proper values, for injecting the debug interrupt. In SET_SREGS handling for DBSR register, KVM injects debug interrupt to guest.

> 
> > ---
> >  arch/powerpc/kvm/booke.c  | 31 +++++++++++++++++++++++++++++--
> > arch/powerpc/kvm/e500mc.c | 10 +++++++++-
> >  2 files changed, 38 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
> > bb25937..63ac38c 100644
> > --- a/arch/powerpc/kvm/booke.c
> > +++ b/arch/powerpc/kvm/booke.c
> > @@ -135,6 +135,11 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu
> > *vcpu)  #endif  }
> >
> > +static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu) {
> > +	return test_bit(BOOKE_IRQPRIO_DEBUG,
> > +&vcpu->arch.pending_exceptions); }
> > +
> >  static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu)  {
> >  	/* Synchronize guest's desire to get debug interrupts into shadow
> > MSR */ @@ -143,8 +148,11 @@ static void kvmppc_vcpu_sync_debug(struct kvm_vcpu
> *vcpu)
> >  	vcpu->arch.shadow_msr |= vcpu->arch.shared->msr & MSR_DE;  #endif
> >
> > -	/* Force enable debug interrupts when user space wants to debug */
> > -	if (vcpu->guest_debug) {
> > +	/*
> > +	 * Force enable debug interrupts when user space wants to debug
> > +	 * and there is no debug interrupt pending for guest to handle.
> > +	 */
> > +	if (vcpu->guest_debug && !kvmppc_core_pending_debug(vcpu)) {
> 
> Are you trying to allow the guest to be simultaneously debugged by itself and by
> host userspace?  How does this work?

Not actually, Currently we are not partitioning debug resources between host userspace and guest. In fact we do not emulate debug registers for guest. But we want host userspace to pass the interrupt to guest if it is not able to handle. 

> 
> >  #ifdef CONFIG_KVM_BOOKE_HV
> >  		/*
> >  		 * Since there is no shadow MSR, sync MSR_DE into the guest @@
> > -264,6 +272,16 @@ static void kvmppc_core_dequeue_watchdog(struct kvm_vcpu
> *vcpu)
> >  	clear_bit(BOOKE_IRQPRIO_WATCHDOG, &vcpu->arch.pending_exceptions);
> > }
> >
> > +static void kvmppc_core_queue_debug(struct kvm_vcpu *vcpu) {
> > +	kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_DEBUG); }
> > +
> > +static void kvmppc_core_dequeue_debug(struct kvm_vcpu *vcpu) {
> > +	clear_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions); }
> 
> Is there currently no support for a guest debugging itself (i.e.
> guest_debug unset) on e500v2?

Yes, It is not yet supported (IACx/DACx/DBCR/DBSR/DSRRx are not yet emulated). 

> 
> >  static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0,
> > u32 srr1)  {  #ifdef CONFIG_KVM_BOOKE_HV @@ -1332,6 +1350,7 @@ static
> > void get_sregs_base(struct kvm_vcpu *vcpu,
> >  	sregs->u.e.dec = kvmppc_get_dec(vcpu, tb);
> >  	sregs->u.e.tb = tb;
> >  	sregs->u.e.vrsave = vcpu->arch.vrsave;
> > +	sregs->u.e.dbsr = vcpu->arch.dbsr;
> >  }
> >
> >  static int set_sregs_base(struct kvm_vcpu *vcpu, @@ -1356,6 +1375,14
> > @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
> >  	if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_TSR)
> >  		kvmppc_set_tsr(vcpu, sregs->u.e.tsr);
> >
> > +	if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DBSR) {
> > +		vcpu->arch.dbsr = sregs->u.e.dbsr;
> > +		if (vcpu->arch.dbsr)
> > +			kvmppc_core_queue_debug(vcpu);
> > +		else
> > +			kvmppc_core_dequeue_debug(vcpu);
> > +	}
> > +
> >  	return 0;
> >  }
> 
> one reg?

We are using SREGS but if required we can use one_reg.

> 
> > diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> > index 17e4562..ea724f2 100644
> > --- a/arch/powerpc/kvm/e500mc.c
> > +++ b/arch/powerpc/kvm/e500mc.c
> > @@ -212,7 +212,7 @@ static int kvmppc_core_get_sregs_e500mc(struct kvm_vcpu
> *vcpu,
> >  	struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
> >
> >  	sregs->u.e.features |= KVM_SREGS_E_ARCH206_MMU | KVM_SREGS_E_PM |
> > -			       KVM_SREGS_E_PC;
> > +			       KVM_SREGS_E_PC | KVM_SREGS_E_ED;
> >
> >  	sregs->u.e.impl_id = KVM_SREGS_E_IMPL_FSL;
> >
> >  	sregs->u.e.impl.fsl.features = 0;
> > @@ -220,6 +220,9 @@ static int kvmppc_core_get_sregs_e500mc(struct kvm_vcpu
> *vcpu,
> >  	sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0;
> >  	sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar;
> >
> > +	sregs->u.e.dsrr0 = vcpu->arch.dsrr0;
> > +	sregs->u.e.dsrr1 = vcpu->arch.dsrr1;
> > +
> >  	kvmppc_get_sregs_e500_tlb(vcpu, sregs);
> >
> >  	sregs->u.e.ivor_high[3] =
> > @@ -261,6 +264,11 @@ static int kvmppc_core_set_sregs_e500mc(struct kvm_vcpu
> *vcpu,
> >  			sregs->u.e.ivor_high[5];
> >  	}
> >
> > +	if (sregs->u.e.features & KVM_SREGS_E_ED) {
> > +		vcpu->arch.dsrr0 = sregs->u.e.dsrr0;
> > +		vcpu->arch.dsrr1 = sregs->u.e.dsrr1;
> > +	}
> 
> SPRG9?

Yes we need to emulate this register as well, and other DEBUG registers.
So the question is, should this patch be sent with the patchset when we emulates other debug registers for guest?

> 
> -Scott
> 

��.n��������+%������w��{.n�����o�^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux