From patchwork Mon Nov 3 15:14:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 406231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 19D9A140081 for ; Tue, 4 Nov 2014 02:16:47 +1100 (AEDT) Received: from localhost ([::1]:35424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlJN7-0002Ur-67 for incoming@patchwork.ozlabs.org; Mon, 03 Nov 2014 10:16:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlJMf-00021L-IY for qemu-devel@nongnu.org; Mon, 03 Nov 2014 10:16:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlJMY-0005VK-1C for qemu-devel@nongnu.org; Mon, 03 Nov 2014 10:16:17 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:37619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlJMX-0005Up-PD for qemu-devel@nongnu.org; Mon, 03 Nov 2014 10:16:09 -0500 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Nov 2014 15:16:08 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 3 Nov 2014 15:16:06 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1DCE21B08023; Mon, 3 Nov 2014 15:16:11 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA3FG5Qd15860108; Mon, 3 Nov 2014 15:16:05 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sA3FG4rE016007; Mon, 3 Nov 2014 08:16:05 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sA3FG3tT015925; Mon, 3 Nov 2014 08:16:03 -0700 Received: from hermes.kaod.org (sig-9-146-194-121.uk.ibm.com [9.146.194.121]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 0F98F210FFE; Mon, 3 Nov 2014 16:16:00 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Alexander Graf Date: Mon, 3 Nov 2014 16:14:50 +0100 Message-Id: <1415027690-9123-1-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14110315-0021-0000-0000-000001A3B1DC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paul Mackerras , qemu-ppc@nongnu.org Subject: [Qemu-devel] =?utf-8?q?=5BPATCH=5D_target-ppc=3A_explicitly_save_?= =?utf-8?q?page_table_headers_in_big_endian?= X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, when the page tables are saved, the kvm_get_htab_header structs 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édric Le Goater Cc: Paul Mackerras Cc: Alexey Kardashevskiy Cc: Gregory Kurz --- This patch needs to be completed by a relatively simple modification of kvm_htab_write() in the kvm_hv kernel mmodule. Tested on 3.17-rc7 with LE and BE host, and with a cross endian gdb. target-ppc/kvm.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) Index: qemu.git/target-ppc/kvm.c =================================================================== --- qemu.git.orig/target-ppc/kvm.c +++ qemu.git/target-ppc/kvm.c @@ -2246,8 +2246,23 @@ int kvmppc_save_htab(QEMUFile *f, int fd 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 = buf; + ssize_t n = rc; + while (n) { + struct kvm_get_htab_header *head = + (struct kvm_get_htab_header *) buffer; + size_t chunksize = 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 += chunksize; + n -= chunksize; + } } } while ((rc != 0) && ((max_ns < 0) @@ -2264,7 +2279,6 @@ int kvmppc_load_htab_chunk(QEMUFile *f, ssize_t rc; buf = alloca(chunksize); - /* This is KVM on ppc, so this is all big-endian */ buf->index = index; buf->n_valid = n_valid; buf->n_invalid = n_invalid;