From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Thu, 20 Nov 2014 23:45:59 +0000 Subject: =?UTF-8?q?=5BPATCH=20v2=5D=20KVM=3A=20PPC=3A=20Book3S=20HV=3A=20ptes=20are=20big=20endian=20?= Message-Id: <1416527159-26979-1-git-send-email-clg@fr.ibm.com> List-Id: References: <546E24C2.1090908@suse.de> In-Reply-To: <546E24C2.1090908@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: agraf@suse.de Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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.=20 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=C3=A9dric Le Goater Cc: Paul Mackerras Cc: Alexey Kardashevskiy Cc: Gregory Kurz --- Tested on 3.18-rc5 with LE and BE host. v2: add be64 local variables to be friendly with sparse =20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D--- 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 =3D (__be64 *)(kvm->arch.hpt_virt + (i * HPTE_SIZE)); lbuf =3D (unsigned long __user *)buf; for (j =3D 0; j < hdr.n_valid; ++j) { + __be64 hpte_v; + __be64 hpte_r; + err =3D -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 =3D be64_to_cpu(hpte_v); + r =3D be64_to_cpu(hpte_r); err =3D -EINVAL; if (!(v & HPTE_V_VALID)) goto out;