kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: Book3S HV: ptes are big endian 
@ 2014-11-03 15:35 Cédric Le Goater
  2014-11-20 17:28 ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Cédric Le Goater @ 2014-11-03 15:35 UTC (permalink / raw)
  To: agraf
  Cc: kvm-ppc, kvm, Cédric Le Goater, Paul Mackerras,
	Alexey Kardashevskiy, Gregory Kurz

When being restored from qemu, the kvm_get_htab_header are in native
endian, but the ptes are big endian. 

This patch fixes restore on a KVM LE host. Qemu also needs a fix for
this :

     http://lists.nongnu.org/archive/html/qemu-ppc/2014-11/msg00008.html

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Gregory Kurz <gkurz@linux.vnet.ibm.com>

---

 Tested on 3.17-rc7 with LE and BE host.

 

 arch/powerpc/kvm/book3s_64_mmu_hv.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
===================================================================
--- linux-3.18-hv.git.orig/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -1542,6 +1542,8 @@ static ssize_t kvm_htab_write(struct fil
 			err = -EFAULT;
 			if (__get_user(v, lbuf) || __get_user(r, lbuf + 1))
 				goto out;
+			v = be64_to_cpu(v);
+			r = be64_to_cpu(r);
 			err = -EINVAL;
 			if (!(v & HPTE_V_VALID))
 				goto out;

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

* Re: [PATCH] KVM: PPC: Book3S HV: ptes are big endian
  2014-11-03 15:35 [PATCH] KVM: PPC: Book3S HV: ptes are big endian Cédric Le Goater
@ 2014-11-20 17:28 ` Alexander Graf
  2014-11-20 23:45   ` [PATCH v2] " Cédric Le Goater
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2014-11-20 17:28 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: kvm-ppc, kvm, Paul Mackerras, Alexey Kardashevskiy, Gregory Kurz



On 03.11.14 16:35, Cédric Le Goater wrote:
> When being restored from qemu, the kvm_get_htab_header are in native
> endian, but the ptes are big endian. 
> 
> This patch fixes restore on a KVM LE host. Qemu also needs a fix for
> this :
> 
>      http://lists.nongnu.org/archive/html/qemu-ppc/2014-11/msg00008.html
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: Gregory Kurz <gkurz@linux.vnet.ibm.com>
> 
> ---
> 
>  Tested on 3.17-rc7 with LE and BE host.
> 
>  
> 
>  arch/powerpc/kvm/book3s_64_mmu_hv.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> Index: linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
> ===================================================================
> --- linux-3.18-hv.git.orig/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -1542,6 +1542,8 @@ static ssize_t kvm_htab_write(struct fil
>  			err = -EFAULT;
>  			if (__get_user(v, lbuf) || __get_user(r, lbuf + 1))
>  				goto out;
> +			v = be64_to_cpu(v);
> +			r = be64_to_cpu(r);

This will trigger warnings with sparse. Please introduce new be64
variables that you do get_user on and that you then use as source for v
and r.


Alex

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

* [PATCH v2] KVM: PPC: Book3S HV: ptes are big endian 
  2014-11-20 17:28 ` Alexander Graf
@ 2014-11-20 23:45   ` Cédric Le Goater
  2014-11-23  0:39     ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Cédric Le Goater @ 2014-11-20 23:45 UTC (permalink / raw)
  To: agraf
  Cc: kvm-ppc, kvm, Cédric Le Goater, Paul Mackerras,
	Alexey Kardashevskiy, Gregory Kurz

When being restored from qemu, the kvm_get_htab_header are in native
endian, but the ptes are big endian. 

This patch fixes restore on a KVM LE host. Qemu also needs a fix for
this :

     http://lists.nongnu.org/archive/html/qemu-ppc/2014-11/msg00008.html

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Gregory Kurz <gkurz@linux.vnet.ibm.com>

---

Tested on 3.18-rc5 with LE and BE host.

v2: add be64 local variables to be friendly with sparse
 

 arch/powerpc/kvm/book3s_64_mmu_hv.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
===================================================================
--- linux-3.18-hv.git.orig/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ linux-3.18-hv.git/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -1539,9 +1539,15 @@ static ssize_t kvm_htab_write(struct fil
 		hptp = (__be64 *)(kvm->arch.hpt_virt + (i * HPTE_SIZE));
 		lbuf = (unsigned long __user *)buf;
 		for (j = 0; j < hdr.n_valid; ++j) {
+			__be64 hpte_v;
+			__be64 hpte_r;
+
 			err = -EFAULT;
-			if (__get_user(v, lbuf) || __get_user(r, lbuf + 1))
+			if (__get_user(hpte_v, lbuf) ||
+			    __get_user(hpte_r, lbuf + 1))
 				goto out;
+			v = be64_to_cpu(hpte_v);
+			r = be64_to_cpu(hpte_r);
 			err = -EINVAL;
 			if (!(v & HPTE_V_VALID))
 				goto out;


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

* Re: [PATCH v2] KVM: PPC: Book3S HV: ptes are big endian
  2014-11-20 23:45   ` [PATCH v2] " Cédric Le Goater
@ 2014-11-23  0:39     ` Alexander Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2014-11-23  0:39 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: kvm-ppc, kvm, Paul Mackerras, Alexey Kardashevskiy, Gregory Kurz



On 21.11.14 00:45, Cédric Le Goater wrote:
> When being restored from qemu, the kvm_get_htab_header are in native
> endian, but the ptes are big endian. 
> 
> This patch fixes restore on a KVM LE host. Qemu also needs a fix for
> this :
> 
>      http://lists.nongnu.org/archive/html/qemu-ppc/2014-11/msg00008.html
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: Gregory Kurz <gkurz@linux.vnet.ibm.com>

Thanks, applied to kvm-ppc-queue.


Alex

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

end of thread, other threads:[~2014-11-23  0:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03 15:35 [PATCH] KVM: PPC: Book3S HV: ptes are big endian Cédric Le Goater
2014-11-20 17:28 ` Alexander Graf
2014-11-20 23:45   ` [PATCH v2] " Cédric Le Goater
2014-11-23  0:39     ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).