diff mbox

[8/8] KVM:PPC:booke: Allow debug interrupt injection to guest

Message ID 1358324685-30225-7-git-send-email-bharat.bhushan@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bharat Bhushan Jan. 16, 2013, 8:24 a.m. UTC
Allow userspace to inject debug interrupt to guest. QEMU can
inject the debug interrupt to guest if it is not able to handle
the debug interrupt.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
 arch/powerpc/kvm/booke.c  |   32 +++++++++++++++++++++++++++++++-
 arch/powerpc/kvm/e500mc.c |   10 +++++++++-
 2 files changed, 40 insertions(+), 2 deletions(-)

Comments

Alexander Graf Jan. 25, 2013, 12:13 p.m. UTC | #1
On 16.01.2013, at 09:24, Bharat Bhushan wrote:

> Allow userspace to inject debug interrupt to guest. QEMU can

s/QEMU/user space.

> inject the debug interrupt to guest if it is not able to handle
> the debug interrupt.
> 
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> arch/powerpc/kvm/booke.c  |   32 +++++++++++++++++++++++++++++++-
> arch/powerpc/kvm/e500mc.c |   10 +++++++++-
> 2 files changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index faa0a0b..547797f 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -133,6 +133,13 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu)
> #endif
> }
> 
> +#ifdef CONFIG_KVM_BOOKE_HV
> +static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu)
> +{
> +	return test_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions);
> +}
> +#endif
> +
> /*
>  * Helper function for "full" MSR writes.  No need to call this if only
>  * EE/CE/ME/DE/RI are changing.
> @@ -144,7 +151,11 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
> #ifdef CONFIG_KVM_BOOKE_HV
> 	new_msr |= MSR_GS;
> 
> -	if (vcpu->guest_debug)
> +	/*
> +	 * Set MSR_DE if the hardware debug resources are owned by user-space
> +	 * and there is no debug interrupt pending for guest to handle.

Why? And why is this whole thing only executed on HV?


Alex

> +	 */
> +	if (vcpu->guest_debug && !kvmppc_core_pending_debug(vcpu))
> 		new_msr |= MSR_DE;
> #endif
> 
> @@ -234,6 +245,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);
> +}
> +
> static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1)
> {
> #ifdef CONFIG_KVM_BOOKE_HV
> @@ -1278,6 +1299,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,
> @@ -1310,6 +1332,14 @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
> 		update_timer_ints(vcpu);
> 	}
> 
> +	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;
> }
> 
> diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> index 81abe92..7d90622 100644
> --- a/arch/powerpc/kvm/e500mc.c
> +++ b/arch/powerpc/kvm/e500mc.c
> @@ -208,7 +208,7 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
> 	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;
> @@ -216,6 +216,9 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
> 	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] =
> @@ -256,6 +259,11 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
> 			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;
> +	}
> +
> 	return kvmppc_set_sregs_ivor(vcpu, sregs);
> }
> 
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bharat Bhushan Jan. 30, 2013, 11:12 a.m. UTC | #2
> -----Original Message-----
> From: kvm-ppc-owner@vger.kernel.org [mailto:kvm-ppc-owner@vger.kernel.org] On
> Behalf Of Alexander Graf
> Sent: Friday, January 25, 2013 5:44 PM
> To: Bhushan Bharat-R65777
> Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Bhushan Bharat-R65777
> Subject: Re: [PATCH 8/8] KVM:PPC:booke: Allow debug interrupt injection to guest
> 
> 
> On 16.01.2013, at 09:24, Bharat Bhushan wrote:
> 
> > Allow userspace to inject debug interrupt to guest. QEMU can
> 
> s/QEMU/user space.
> 
> > inject the debug interrupt to guest if it is not able to handle the
> > debug interrupt.
> >
> > Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> > ---
> > arch/powerpc/kvm/booke.c  |   32 +++++++++++++++++++++++++++++++-
> > arch/powerpc/kvm/e500mc.c |   10 +++++++++-
> > 2 files changed, 40 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
> > faa0a0b..547797f 100644
> > --- a/arch/powerpc/kvm/booke.c
> > +++ b/arch/powerpc/kvm/booke.c
> > @@ -133,6 +133,13 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu
> > *vcpu) #endif }
> >
> > +#ifdef CONFIG_KVM_BOOKE_HV
> > +static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu) {
> > +	return test_bit(BOOKE_IRQPRIO_DEBUG,
> > +&vcpu->arch.pending_exceptions); } #endif
> > +
> > /*
> >  * Helper function for "full" MSR writes.  No need to call this if only
> >  * EE/CE/ME/DE/RI are changing.
> > @@ -144,7 +151,11 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
> > #ifdef CONFIG_KVM_BOOKE_HV
> > 	new_msr |= MSR_GS;
> >
> > -	if (vcpu->guest_debug)
> > +	/*
> > +	 * Set MSR_DE if the hardware debug resources are owned by user-space
> > +	 * and there is no debug interrupt pending for guest to handle.
> 
> Why?

QEMU is using the IAC/DAC registers to set hardware breakpoint/watchpoints via debug ioctls. As debug events are enabled/gated by MSR_DE so somehow we need to set MSR_DE on hardware MSR when guest is running in this case.

On bookehv this is how I am controlling the MSR_DE in hardware MSR.  

> And why is this whole thing only executed on HV?

On e500v2 we always enable MSR_DE using vcpu->arch.shadow_msr in e500.c
#ifndef CONFIG_KVM_BOOKE_HV
-       vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS;
+       vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS;
        vcpu->arch.shadow_pid = 1;
        vcpu->arch.shared->msr = 0;
#endif

Thanks
-Bharat

> 
> 
> Alex
> 
> > +	 */
> > +	if (vcpu->guest_debug && !kvmppc_core_pending_debug(vcpu))
> > 		new_msr |= MSR_DE;
> > #endif
> >
> > @@ -234,6 +245,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);
> > +}
> > +
> > static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1)
> > {
> > #ifdef CONFIG_KVM_BOOKE_HV
> > @@ -1278,6 +1299,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,
> > @@ -1310,6 +1332,14 @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
> > 		update_timer_ints(vcpu);
> > 	}
> >
> > +	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;
> > }
> >
> > diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> > index 81abe92..7d90622 100644
> > --- a/arch/powerpc/kvm/e500mc.c
> > +++ b/arch/powerpc/kvm/e500mc.c
> > @@ -208,7 +208,7 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct
> kvm_sregs *sregs)
> > 	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;
> > @@ -216,6 +216,9 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct
> kvm_sregs *sregs)
> > 	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] =
> > @@ -256,6 +259,11 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct
> kvm_sregs *sregs)
> > 			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;
> > +	}
> > +
> > 	return kvmppc_set_sregs_ivor(vcpu, sregs);
> > }
> >
> > --
> > 1.7.0.4
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf Jan. 31, 2013, 12:04 p.m. UTC | #3
On 30.01.2013, at 12:12, Bhushan Bharat-R65777 wrote:

> 
> 
>> -----Original Message-----
>> From: kvm-ppc-owner@vger.kernel.org [mailto:kvm-ppc-owner@vger.kernel.org] On
>> Behalf Of Alexander Graf
>> Sent: Friday, January 25, 2013 5:44 PM
>> To: Bhushan Bharat-R65777
>> Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Bhushan Bharat-R65777
>> Subject: Re: [PATCH 8/8] KVM:PPC:booke: Allow debug interrupt injection to guest
>> 
>> 
>> On 16.01.2013, at 09:24, Bharat Bhushan wrote:
>> 
>>> Allow userspace to inject debug interrupt to guest. QEMU can
>> 
>> s/QEMU/user space.
>> 
>>> inject the debug interrupt to guest if it is not able to handle the
>>> debug interrupt.
>>> 
>>> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
>>> ---
>>> arch/powerpc/kvm/booke.c  |   32 +++++++++++++++++++++++++++++++-
>>> arch/powerpc/kvm/e500mc.c |   10 +++++++++-
>>> 2 files changed, 40 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index
>>> faa0a0b..547797f 100644
>>> --- a/arch/powerpc/kvm/booke.c
>>> +++ b/arch/powerpc/kvm/booke.c
>>> @@ -133,6 +133,13 @@ static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu
>>> *vcpu) #endif }
>>> 
>>> +#ifdef CONFIG_KVM_BOOKE_HV
>>> +static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu) {
>>> +	return test_bit(BOOKE_IRQPRIO_DEBUG,
>>> +&vcpu->arch.pending_exceptions); } #endif
>>> +
>>> /*
>>> * Helper function for "full" MSR writes.  No need to call this if only
>>> * EE/CE/ME/DE/RI are changing.
>>> @@ -144,7 +151,11 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
>>> #ifdef CONFIG_KVM_BOOKE_HV
>>> 	new_msr |= MSR_GS;
>>> 
>>> -	if (vcpu->guest_debug)
>>> +	/*
>>> +	 * Set MSR_DE if the hardware debug resources are owned by user-space
>>> +	 * and there is no debug interrupt pending for guest to handle.
>> 
>> Why?
> 
> QEMU is using the IAC/DAC registers to set hardware breakpoint/watchpoints via debug ioctls. As debug events are enabled/gated by MSR_DE so somehow we need to set MSR_DE on hardware MSR when guest is running in this case.

Reading this 5 times I still have no idea what you're really checking for here. Maybe the naming for kvmppc_core_pending_debug is just unnatural? What does that function do really?

> 
> On bookehv this is how I am controlling the MSR_DE in hardware MSR.  
> 
>> And why is this whole thing only executed on HV?
> 
> On e500v2 we always enable MSR_DE using vcpu->arch.shadow_msr in e500.c
> #ifndef CONFIG_KVM_BOOKE_HV
> -       vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS;
> +       vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS;

Why? How is e500v2 any different wrt debug? And why wouldn't that work for e500mc?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Scott Wood Jan. 31, 2013, 6:03 p.m. UTC | #4
On 01/31/2013 06:04:29 AM, Alexander Graf wrote:
> 
> On 30.01.2013, at 12:12, Bhushan Bharat-R65777 wrote:
> 
> > On bookehv this is how I am controlling the MSR_DE in hardware MSR.
> >
> >> And why is this whole thing only executed on HV?
> >
> > On e500v2 we always enable MSR_DE using vcpu->arch.shadow_msr in  
> e500.c
> > #ifndef CONFIG_KVM_BOOKE_HV
> > -       vcpu->arch.shadow_msr = MSR_USER | MSR_IS | MSR_DS;
> > +       vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS;
> 
> Why? How is e500v2 any different wrt debug? And why wouldn't that  
> work for e500mc?

shadow_msr isn't used at all on bookehv.

-Scott
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index faa0a0b..547797f 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -133,6 +133,13 @@  static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu)
 #endif
 }
 
+#ifdef CONFIG_KVM_BOOKE_HV
+static int kvmppc_core_pending_debug(struct kvm_vcpu *vcpu)
+{
+	return test_bit(BOOKE_IRQPRIO_DEBUG, &vcpu->arch.pending_exceptions);
+}
+#endif
+
 /*
  * Helper function for "full" MSR writes.  No need to call this if only
  * EE/CE/ME/DE/RI are changing.
@@ -144,7 +151,11 @@  void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
 #ifdef CONFIG_KVM_BOOKE_HV
 	new_msr |= MSR_GS;
 
-	if (vcpu->guest_debug)
+	/*
+	 * Set MSR_DE if the hardware debug resources are owned by user-space
+	 * and there is no debug interrupt pending for guest to handle.
+	 */
+	if (vcpu->guest_debug && !kvmppc_core_pending_debug(vcpu))
 		new_msr |= MSR_DE;
 #endif
 
@@ -234,6 +245,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);
+}
+
 static void set_guest_srr(struct kvm_vcpu *vcpu, unsigned long srr0, u32 srr1)
 {
 #ifdef CONFIG_KVM_BOOKE_HV
@@ -1278,6 +1299,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,
@@ -1310,6 +1332,14 @@  static int set_sregs_base(struct kvm_vcpu *vcpu,
 		update_timer_ints(vcpu);
 	}
 
+	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;
 }
 
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index 81abe92..7d90622 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -208,7 +208,7 @@  void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
 	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;
@@ -216,6 +216,9 @@  void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
 	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] =
@@ -256,6 +259,11 @@  int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
 			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;
+	}
+
 	return kvmppc_set_sregs_ivor(vcpu, sregs);
 }