diff mbox

[2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under debug

Message ID 1405067941-27134-3-git-send-email-Bharat.Bhushan@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bharat Bhushan July 11, 2014, 8:38 a.m. UTC
When userspace (QEMU) is using the debug resource to debug guest
then we want MSR_DE to be always set. This patch adds missing
MSR_DE setting in "rfci" instruction.

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
---
 arch/powerpc/kvm/booke_emulate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Alexander Graf July 28, 2014, 1:54 p.m. UTC | #1
On 11.07.14 10:38, Bharat Bhushan wrote:
> When userspace (QEMU) is using the debug resource to debug guest
> then we want MSR_DE to be always set. This patch adds missing
> MSR_DE setting in "rfci" instruction.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>

Shouldn't this be in kvmppc_set_msr() instead then to catch all users?


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 July 28, 2014, 9:54 p.m. UTC | #2
On Fri, 2014-07-11 at 14:08 +0530, Bharat Bhushan wrote:
> When userspace (QEMU) is using the debug resource to debug guest
> then we want MSR_DE to be always set. This patch adds missing
> MSR_DE setting in "rfci" instruction.
> 
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
> ---
>  arch/powerpc/kvm/booke_emulate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
> index 27a4b28..80c51a2 100644
> --- a/arch/powerpc/kvm/booke_emulate.c
> +++ b/arch/powerpc/kvm/booke_emulate.c
> @@ -40,7 +40,11 @@ static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
>  static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
>  {
>  	vcpu->arch.pc = vcpu->arch.csrr0;
> -	kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
> +	/* Force MSR_DE when guest does not own debug facilities */
> +	if (vcpu->guest_debug)
> +		kvmppc_set_msr(vcpu, vcpu->arch.csrr1 | MSR_DE);
> +	else
> +		kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
>  }
>  
>  int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,

It looks like this is already handled by kvmppc_vcpu_sync_debug(), which
is called by kvmppc_set_msr().

Plus, it should only be done for HV mode.

-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
Bharat Bhushan July 30, 2014, 5:30 a.m. UTC | #3
> -----Original Message-----

> From: Wood Scott-B07421

> Sent: Tuesday, July 29, 2014 3:25 AM

> To: Bhushan Bharat-R65777

> Cc: agraf@suse.de; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder Stuart-

> B08248

> Subject: Re: [PATCH 2/6] KVM: PPC: BOOKE: Force MSR_DE in rfci if guest is under

> debug

> 

> On Fri, 2014-07-11 at 14:08 +0530, Bharat Bhushan wrote:

> > When userspace (QEMU) is using the debug resource to debug guest then

> > we want MSR_DE to be always set. This patch adds missing MSR_DE

> > setting in "rfci" instruction.

> >

> > Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>

> > ---

> >  arch/powerpc/kvm/booke_emulate.c | 6 +++++-

> >  1 file changed, 5 insertions(+), 1 deletion(-)

> >

> > diff --git a/arch/powerpc/kvm/booke_emulate.c

> > b/arch/powerpc/kvm/booke_emulate.c

> > index 27a4b28..80c51a2 100644

> > --- a/arch/powerpc/kvm/booke_emulate.c

> > +++ b/arch/powerpc/kvm/booke_emulate.c

> > @@ -40,7 +40,11 @@ static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)

> > static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)  {

> >  	vcpu->arch.pc = vcpu->arch.csrr0;

> > -	kvmppc_set_msr(vcpu, vcpu->arch.csrr1);

> > +	/* Force MSR_DE when guest does not own debug facilities */

> > +	if (vcpu->guest_debug)

> > +		kvmppc_set_msr(vcpu, vcpu->arch.csrr1 | MSR_DE);

> > +	else

> > +		kvmppc_set_msr(vcpu, vcpu->arch.csrr1);

> >  }

> >

> >  int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu

> > *vcpu,

> 

> It looks like this is already handled by kvmppc_vcpu_sync_debug(), which is

> called by kvmppc_set_msr().


Yes, you are right. This patch is not needed.

Thanks
-Bharat

> 

> Plus, it should only be done for HV mode.

> 

> -Scott

>
diff mbox

Patch

diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 27a4b28..80c51a2 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -40,7 +40,11 @@  static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
 static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
 {
 	vcpu->arch.pc = vcpu->arch.csrr0;
-	kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
+	/* Force MSR_DE when guest does not own debug facilities */
+	if (vcpu->guest_debug)
+		kvmppc_set_msr(vcpu, vcpu->arch.csrr1 | MSR_DE);
+	else
+		kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
 }
 
 int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,