提交 e094c4c1 编写于 作者: C Cédric Le Goater 提交者: Alexander Graf

target-ppc: explicitly save page table headers in big endian

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: NCédric Le Goater <clg@fr.ibm.com>
Signed-off-by: NAlexander Graf <agraf@suse.de>
上级 58dd0a47
...@@ -2246,8 +2246,23 @@ int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns) ...@@ -2246,8 +2246,23 @@ int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns)
strerror(errno)); strerror(errno));
return rc; return rc;
} else if (rc) { } else if (rc) {
/* Kernel already retuns data in BE format for the file */ uint8_t *buffer = buf;
qemu_put_buffer(f, buf, rc); 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) } while ((rc != 0)
&& ((max_ns < 0) && ((max_ns < 0)
...@@ -2264,7 +2279,6 @@ int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, ...@@ -2264,7 +2279,6 @@ int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
ssize_t rc; ssize_t rc;
buf = alloca(chunksize); buf = alloca(chunksize);
/* This is KVM on ppc, so this is all big-endian */
buf->index = index; buf->index = index;
buf->n_valid = n_valid; buf->n_valid = n_valid;
buf->n_invalid = n_invalid; buf->n_invalid = n_invalid;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册