From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8sPo-0005tt-1D for qemu-devel@nongnu.org; Wed, 07 Jan 2015 10:21:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8sPj-0003Bh-6F for qemu-devel@nongnu.org; Wed, 07 Jan 2015 10:20:55 -0500 From: Alexander Graf Date: Wed, 7 Jan 2015 16:20:23 +0100 Message-Id: <1420644048-16919-13-git-send-email-agraf@suse.de> In-Reply-To: <1420644048-16919-1-git-send-email-agraf@suse.de> References: <1420644048-16919-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 12/37] target-ppc: explicitly save page table headers in big endian List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-devel@nongnu.org From: C=C3=A9dric Le Goater Currently, when the page tables are saved, the kvm_get_htab_header struct= s and the ptes are assumed being big endian and dumped as a indistinct blob in the statefile. This is no longer true when the host is little endian and this breaks restoration. This patch unfolds the kvmppc_save_htab routine to write explicitly the kvm_get_htab_header structs in big endian. The ptes are left untouched. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Alexander Graf --- target-ppc/kvm.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 6843fa0..911f912 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -2246,8 +2246,23 @@ int kvmppc_save_htab(QEMUFile *f, int fd, size_t b= ufsize, int64_t max_ns) strerror(errno)); return rc; } else if (rc) { - /* Kernel already retuns data in BE format for the file */ - qemu_put_buffer(f, buf, rc); + uint8_t *buffer =3D buf; + ssize_t n =3D rc; + while (n) { + struct kvm_get_htab_header *head =3D + (struct kvm_get_htab_header *) buffer; + size_t chunksize =3D sizeof(*head) + + HASH_PTE_SIZE_64 * head->n_valid; + + qemu_put_be32(f, head->index); + qemu_put_be16(f, head->n_valid); + qemu_put_be16(f, head->n_invalid); + qemu_put_buffer(f, (void *)(head + 1), + HASH_PTE_SIZE_64 * head->n_valid); + + buffer +=3D chunksize; + n -=3D chunksize; + } } } while ((rc !=3D 0) && ((max_ns < 0) @@ -2264,7 +2279,6 @@ int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uin= t32_t index, ssize_t rc; =20 buf =3D alloca(chunksize); - /* This is KVM on ppc, so this is all big-endian */ buf->index =3D index; buf->n_valid =3D n_valid; buf->n_invalid =3D n_invalid; --=20 1.8.1.4