From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> 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: Dr. David Alan Gilbert <dgilb...@redhat.com> --- migration/ram.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index d6437be..8b1570d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2212,6 +2212,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) void *postcopy_host_page = NULL; bool postcopy_place_needed = false; bool matching_page_sizes = qemu_host_page_size == TARGET_PAGE_SIZE; + void *last_host = NULL; seq_iter++; @@ -2264,6 +2265,14 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) /* If all TP are zero then we can optimise the place */ if (!((uintptr_t)host & ~qemu_host_page_mask)) { 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; + } } /* @@ -2274,6 +2283,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ~qemu_host_page_mask) == 0; postcopy_place_source = postcopy_host_page; } + last_host = host; } switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { -- 2.5.0