提交 c53b7ddc 编写于 作者: D Dr. David Alan Gilbert 提交者: Juan Quintela

postcopy: Check order of received target pages

Ensure that target pages received within a host page are in order.
This shouldn't trigger, but in the cases where the sender goes
wrong and sends stuff out of order it produces a corruption that's
really nasty to debug.
Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: NJuan Quintela <quintela@redhat.com>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
上级 a7180877
...@@ -2097,6 +2097,7 @@ static int ram_load_postcopy(QEMUFile *f) ...@@ -2097,6 +2097,7 @@ static int ram_load_postcopy(QEMUFile *f)
MigrationIncomingState *mis = migration_incoming_get_current(); MigrationIncomingState *mis = migration_incoming_get_current();
/* Temporary page that is later 'placed' */ /* Temporary page that is later 'placed' */
void *postcopy_host_page = postcopy_get_tmp_page(mis); void *postcopy_host_page = postcopy_get_tmp_page(mis);
void *last_host = NULL;
while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
ram_addr_t addr; ram_addr_t addr;
...@@ -2133,8 +2134,17 @@ static int ram_load_postcopy(QEMUFile *f) ...@@ -2133,8 +2134,17 @@ static int ram_load_postcopy(QEMUFile *f)
/* If all TP are zero then we can optimise the place */ /* If all TP are zero then we can optimise the place */
if (!((uintptr_t)host & ~qemu_host_page_mask)) { if (!((uintptr_t)host & ~qemu_host_page_mask)) {
all_zero = true; all_zero = true;
} else {
/* not the 1st TP within the HP */
if (host != (last_host + TARGET_PAGE_SIZE)) {
error_report("Non-sequential target page %p/%p\n",
host, last_host);
ret = -EINVAL;
break;
}
} }
/* /*
* If it's the last part of a host page then we place the host * If it's the last part of a host page then we place the host
* page * page
...@@ -2143,6 +2153,7 @@ static int ram_load_postcopy(QEMUFile *f) ...@@ -2143,6 +2153,7 @@ static int ram_load_postcopy(QEMUFile *f)
~qemu_host_page_mask) == 0; ~qemu_host_page_mask) == 0;
place_source = postcopy_host_page; place_source = postcopy_host_page;
} }
last_host = host;
switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
case RAM_SAVE_FLAG_COMPRESS: case RAM_SAVE_FLAG_COMPRESS:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册