The UFFD_PAGEFAULT_FLAG_WP should be set every time the page fault is due to a write to a write-protected page. Flag should be checked at every time to be sure the page fault is due to a write into WP area.
Signed-off-by: Christian Pinto <c.pi...@virtualopensystems.com> Signed-off-by: Baptiste Reynal <b.rey...@virtualopensystems.com> --- migration/postcopy-ram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index ea70bd5d16..9c45f1059f 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -534,7 +534,12 @@ static void *postcopy_ram_fault_thread(void *opaque) migrate_send_rp_req_pages(mis, NULL, rb_offset, hostpagesize); } - } else { /* UFFDIO_REGISTER_MODE_WP */ + } else if (msg.arg.pagefault.flags & + UFFD_PAGEFAULT_FLAG_WP) { /* UFFDIO_REGISTER_MODE_WP */ + /* + * msg.arg.pagefault.flags &UFFD_PAGEFAULT_FLAG_WP expected to + * be set in case of pagefault due to write protected page + * */ MigrationState *ms = container_of(us, MigrationState, userfault_state); ret = ram_save_queue_pages(ms, qemu_ram_get_idstr(rb), rb_offset, -- 2.11.0