diff mbox

KVM: PPC: Book3S HV: ptes are big endian

Message ID 1415028950-9654-1-git-send-email-clg@fr.ibm.com
State New, archived
Headers show

Commit Message

Cédric Le Goater Nov. 3, 2014, 3:35 p.m. UTC
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(+)


--
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

Comments

Alexander Graf Nov. 20, 2014, 5:28 p.m. UTC | #1
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
--
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
diff mbox

Patch

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;