qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian
@ 2014-10-27 10:23 Cédric Le Goater
  2014-11-03 14:53 ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2014-10-27 10:23 UTC (permalink / raw)
  To: Alexander Graf; +Cc: aik, qemu-devel, Cédric Le Goater, paulus, qemu-ppc

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 <clg@fr.ibm.com>
Cc: paulus@samba.org
Cc: aik@ozlabs.ru
Cc: gkurz@linux.vnet.ibm.com

---

 This patch needs to be completed by a relatively simple modification of
 kvm_htab_write() in the kvm_hv kernel mmodule. To be sent later.

 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;

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

* Re: [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian
  2014-10-27 10:23 [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian Cédric Le Goater
@ 2014-11-03 14:53 ` Alexander Graf
  2014-11-03 14:56   ` Cedric Le Goater
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2014-11-03 14:53 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: aik, paulus, qemu-ppc, qemu-devel



On 27.10.14 11:23, Cédric Le Goater wrote:
> 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 <clg@fr.ibm.com>
> Cc: paulus@samba.org
> Cc: aik@ozlabs.ru
> Cc: gkurz@linux.vnet.ibm.com

LGTM :)


Alex

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

* Re: [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian
  2014-11-03 14:53 ` Alexander Graf
@ 2014-11-03 14:56   ` Cedric Le Goater
  2014-11-03 15:10     ` Alexander Graf
  0 siblings, 1 reply; 5+ messages in thread
From: Cedric Le Goater @ 2014-11-03 14:56 UTC (permalink / raw)
  To: Alexander Graf; +Cc: aik, paulus, qemu-ppc, qemu-devel

On 11/03/2014 03:53 PM, Alexander Graf wrote:
> 
> 
> On 27.10.14 11:23, Cédric Le Goater wrote:
>> 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 <clg@fr.ibm.com>
>> Cc: paulus@samba.org
>> Cc: aik@ozlabs.ru
>> Cc: gkurz@linux.vnet.ibm.com
> 
> LGTM :)

OK then. I will resend as a PATCH, along with the kvm kernel patch which is 
just a couple of lines. Then, we can start testing cross-endian migration !

Thanks,

C. 

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

* Re: [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian
  2014-11-03 14:56   ` Cedric Le Goater
@ 2014-11-03 15:10     ` Alexander Graf
  2014-11-13  6:43       ` Alexey Kardashevskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2014-11-03 15:10 UTC (permalink / raw)
  To: Cedric Le Goater; +Cc: aik, paulus, qemu-ppc, qemu-devel



On 03.11.14 15:56, Cedric Le Goater wrote:
> On 11/03/2014 03:53 PM, Alexander Graf wrote:
>>
>>
>> On 27.10.14 11:23, Cédric Le Goater wrote:
>>> 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 <clg@fr.ibm.com>
>>> Cc: paulus@samba.org
>>> Cc: aik@ozlabs.ru
>>> Cc: gkurz@linux.vnet.ibm.com
>>
>> LGTM :)
> 
> OK then. I will resend as a PATCH, along with the kvm kernel patch which is 
> just a couple of lines. Then, we can start testing cross-endian migration !

Awesome! Looking forward to it :).


Alex

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

* Re: [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian
  2014-11-03 15:10     ` Alexander Graf
@ 2014-11-13  6:43       ` Alexey Kardashevskiy
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2014-11-13  6:43 UTC (permalink / raw)
  To: Alexander Graf, Cedric Le Goater; +Cc: paulus, qemu-ppc, qemu-devel

On 11/04/2014 02:10 AM, Alexander Graf wrote:
> 
> 
> On 03.11.14 15:56, Cedric Le Goater wrote:
>> On 11/03/2014 03:53 PM, Alexander Graf wrote:
>>>
>>>
>>> On 27.10.14 11:23, Cédric Le Goater wrote:
>>>> 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 <clg@fr.ibm.com>
>>>> Cc: paulus@samba.org
>>>> Cc: aik@ozlabs.ru
>>>> Cc: gkurz@linux.vnet.ibm.com
>>>
>>> LGTM :)
>>
>> OK then. I will resend as a PATCH, along with the kvm kernel patch which is 
>> just a couple of lines. Then, we can start testing cross-endian migration !
> 
> Awesome! Looking forward to it :).

I feel uncomfortable when I see native endian interface. I'd do the whole
kvm_get_htab_header/etc thing BE rather than native but may be it is just me :)



-- 
Alexey

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

end of thread, other threads:[~2014-11-13  6:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-27 10:23 [Qemu-devel] [RFC PATCH] target-ppc: explicitly save page table headers in big endian Cédric Le Goater
2014-11-03 14:53 ` Alexander Graf
2014-11-03 14:56   ` Cedric Le Goater
2014-11-03 15:10     ` Alexander Graf
2014-11-13  6:43       ` Alexey Kardashevskiy

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