public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: fix ONE_REG AltiVec support
@ 2015-12-16 17:24 Greg Kurz
  2016-01-04  9:14 ` Greg Kurz
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2015-12-16 17:24 UTC (permalink / raw)
  To: Alexander Graf; +Cc: mihai.caraman, Paul Mackerras, kvm, kvm-ppc, Paolo Bonzini

The get and set operations got exchanged by mistake when moving the
code from book3s.c to powerpc.c.

Fixes: 3840edc8033ad5b86deee309c1c321ca54257452
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---

It's been there for over a year but I guess we want that in 4.4, even
if doesn't break the host kernel.

 arch/powerpc/kvm/powerpc.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6fd2405c7f4a..a3b182dcb823 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -919,21 +919,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 				r = -ENXIO;
 				break;
 			}
-			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
+			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
 			break;
 		case KVM_REG_PPC_VSCR:
 			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
 				r = -ENXIO;
 				break;
 			}
-			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
+			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
 			break;
 		case KVM_REG_PPC_VRSAVE:
-			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
-				r = -ENXIO;
-				break;
-			}
-			vcpu->arch.vrsave = set_reg_val(reg->id, val);
+			val = get_reg_val(reg->id, vcpu->arch.vrsave);
 			break;
 #endif /* CONFIG_ALTIVEC */
 		default:
@@ -974,17 +970,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 				r = -ENXIO;
 				break;
 			}
-			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
+			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
 			break;
 		case KVM_REG_PPC_VSCR:
 			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
 				r = -ENXIO;
 				break;
 			}
-			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
+			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
 			break;
 		case KVM_REG_PPC_VRSAVE:
-			val = get_reg_val(reg->id, vcpu->arch.vrsave);
+			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
+				r = -ENXIO;
+				break;
+			}
+			vcpu->arch.vrsave = set_reg_val(reg->id, val);
 			break;
 #endif /* CONFIG_ALTIVEC */
 		default:


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: PPC: fix ONE_REG AltiVec support
  2015-12-16 17:24 [PATCH] KVM: PPC: fix ONE_REG AltiVec support Greg Kurz
@ 2016-01-04  9:14 ` Greg Kurz
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2016-01-04  9:14 UTC (permalink / raw)
  To: Alexander Graf; +Cc: mihai.caraman, Paul Mackerras, kvm, kvm-ppc, Paolo Bonzini

Happy new year !

On Wed, 16 Dec 2015 18:24:03 +0100
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:

> The get and set operations got exchanged by mistake when moving the
> code from book3s.c to powerpc.c.
> 
> Fixes: 3840edc8033ad5b86deee309c1c321ca54257452
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
> 

Ping ?

> It's been there for over a year but I guess we want that in 4.4, even
> if doesn't break the host kernel.
> 
>  arch/powerpc/kvm/powerpc.c |   20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 6fd2405c7f4a..a3b182dcb823 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -919,21 +919,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
>  				r = -ENXIO;
>  				break;
>  			}
> -			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
> +			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
>  			break;
>  		case KVM_REG_PPC_VSCR:
>  			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
>  				r = -ENXIO;
>  				break;
>  			}
> -			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
> +			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
>  			break;
>  		case KVM_REG_PPC_VRSAVE:
> -			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
> -				r = -ENXIO;
> -				break;
> -			}
> -			vcpu->arch.vrsave = set_reg_val(reg->id, val);
> +			val = get_reg_val(reg->id, vcpu->arch.vrsave);
>  			break;
>  #endif /* CONFIG_ALTIVEC */
>  		default:
> @@ -974,17 +970,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
>  				r = -ENXIO;
>  				break;
>  			}
> -			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
> +			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
>  			break;
>  		case KVM_REG_PPC_VSCR:
>  			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
>  				r = -ENXIO;
>  				break;
>  			}
> -			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
> +			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
>  			break;
>  		case KVM_REG_PPC_VRSAVE:
> -			val = get_reg_val(reg->id, vcpu->arch.vrsave);
> +			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
> +				r = -ENXIO;
> +				break;
> +			}
> +			vcpu->arch.vrsave = set_reg_val(reg->id, val);
>  			break;
>  #endif /* CONFIG_ALTIVEC */
>  		default:
> 
> --
> 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
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] KVM: PPC: fix ONE_REG AltiVec support
@ 2016-01-13 17:28 Greg Kurz
  2016-01-14  3:38 ` Paul Mackerras
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2016-01-13 17:28 UTC (permalink / raw)
  To: Paul Mackerras, Alexander Graf; +Cc: mihai.caraman, kvm, kvm-ppc, Paolo Bonzini

The get and set operations got exchanged by mistake when moving the
code from book3s.c to powerpc.c.

Fixes: 3840edc8033ad5b86deee309c1c321ca54257452
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---

I posted the very same patch before the holidays but it did not gain
attention. It is very surprising that the error did not cause trouble
for such a long time... I discovered it by accident while implementing
gdbstubs for VSX registers in QEMU. But I guess it is also likely to
break migration of guests that do AltiVec.

I am not sure if Alex is available to handle this patch... since the
error is obvious and the fix straightforward, can this patch be applied
by someone else ? Paulus ? Paolo ?

Thanks.

 arch/powerpc/kvm/powerpc.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6fd2405c7f4a..a3b182dcb823 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -919,21 +919,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 				r = -ENXIO;
 				break;
 			}
-			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
+			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
 			break;
 		case KVM_REG_PPC_VSCR:
 			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
 				r = -ENXIO;
 				break;
 			}
-			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
+			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
 			break;
 		case KVM_REG_PPC_VRSAVE:
-			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
-				r = -ENXIO;
-				break;
-			}
-			vcpu->arch.vrsave = set_reg_val(reg->id, val);
+			val = get_reg_val(reg->id, vcpu->arch.vrsave);
 			break;
 #endif /* CONFIG_ALTIVEC */
 		default:
@@ -974,17 +970,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 				r = -ENXIO;
 				break;
 			}
-			val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
+			vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
 			break;
 		case KVM_REG_PPC_VSCR:
 			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
 				r = -ENXIO;
 				break;
 			}
-			val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
+			vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
 			break;
 		case KVM_REG_PPC_VRSAVE:
-			val = get_reg_val(reg->id, vcpu->arch.vrsave);
+			if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
+				r = -ENXIO;
+				break;
+			}
+			vcpu->arch.vrsave = set_reg_val(reg->id, val);
 			break;
 #endif /* CONFIG_ALTIVEC */
 		default:


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: PPC: fix ONE_REG AltiVec support
  2016-01-13 17:28 Greg Kurz
@ 2016-01-14  3:38 ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2016-01-14  3:38 UTC (permalink / raw)
  To: Greg Kurz; +Cc: Alexander Graf, mihai.caraman, kvm, kvm-ppc, Paolo Bonzini

On Wed, Jan 13, 2016 at 06:28:17PM +0100, Greg Kurz wrote:
> The get and set operations got exchanged by mistake when moving the
> code from book3s.c to powerpc.c.
> 
> Fixes: 3840edc8033ad5b86deee309c1c321ca54257452
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
> 
> I posted the very same patch before the holidays but it did not gain
> attention. It is very surprising that the error did not cause trouble
> for such a long time... I discovered it by accident while implementing
> gdbstubs for VSX registers in QEMU. But I guess it is also likely to
> break migration of guests that do AltiVec.
> 
> I am not sure if Alex is available to handle this patch... since the
> error is obvious and the fix straightforward, can this patch be applied
> by someone else ? Paulus ? Paolo ?

I'll take it and add it to my upcoming pull request to Paolo.

Paul.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-14  3:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16 17:24 [PATCH] KVM: PPC: fix ONE_REG AltiVec support Greg Kurz
2016-01-04  9:14 ` Greg Kurz
  -- strict thread matches above, loose matches on Subject: below --
2016-01-13 17:28 Greg Kurz
2016-01-14  3:38 ` Paul Mackerras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox