[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/30] migration: Fix migration crash when target psize larger tha
From: |
Juan Quintela |
Subject: |
[PULL 01/30] migration: Fix migration crash when target psize larger than host |
Date: |
Tue, 7 Feb 2023 01:56:21 +0100 |
From: Peter Xu <peterx@redhat.com>
Commit d9e474ea56 overlooked the case where the target psize is even larger
than the host psize. One example is Alpha has 8K page size and migration
will start to crash the source QEMU when running Alpha migration on x86.
Fix it by detecting that case and set host start/end just to cover the
single page to be migrated.
This will slightly optimize the common case where host psize equals to
guest psize so we don't even need to do the roundups, but that's trivial.
Cc: qemu-stable@nongnu.org
Reported-by: Thomas Huth <thuth@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1456
Fixes: d9e474ea56 ("migration: Teach PSS about host page")
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/ram.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 334309f1c6..68a45338e3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2319,8 +2319,25 @@ static void pss_host_page_prepare(PageSearchStatus *pss)
size_t guest_pfns = qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS;
pss->host_page_sending = true;
- pss->host_page_start = ROUND_DOWN(pss->page, guest_pfns);
- pss->host_page_end = ROUND_UP(pss->page + 1, guest_pfns);
+ if (guest_pfns <= 1) {
+ /*
+ * This covers both when guest psize == host psize, or when guest
+ * has larger psize than the host (guest_pfns==0).
+ *
+ * For the latter, we always send one whole guest page per
+ * iteration of the host page (example: an Alpha VM on x86 host
+ * will have guest psize 8K while host psize 4K).
+ */
+ pss->host_page_start = pss->page;
+ pss->host_page_end = pss->page + 1;
+ } else {
+ /*
+ * The host page spans over multiple guest pages, we send them
+ * within the same host page iteration.
+ */
+ pss->host_page_start = ROUND_DOWN(pss->page, guest_pfns);
+ pss->host_page_end = ROUND_UP(pss->page + 1, guest_pfns);
+ }
}
/*
--
2.39.1
- [PULL 00/30] Migration 20230206 patches, Juan Quintela, 2023/02/06
- [PULL 01/30] migration: Fix migration crash when target psize larger than host,
Juan Quintela <=
- [PULL 03/30] migration: Split save_live_pending() into state_pending_*, Juan Quintela, 2023/02/06
- [PULL 02/30] migration: No save_live_pending() method uses the QEMUFile parameter, Juan Quintela, 2023/02/06
- [PULL 05/30] migration: simplify migration_iteration_run(), Juan Quintela, 2023/02/06
- [PULL 04/30] migration: Remove unused threshold_size parameter, Juan Quintela, 2023/02/06
- [PULL 06/30] util/userfaultfd: Add uffd_open(), Juan Quintela, 2023/02/06
- [PULL 07/30] migration/ram: Fix populate_read_range(), Juan Quintela, 2023/02/06
- [PULL 08/30] migration/ram: Fix error handling in ram_write_tracking_start(), Juan Quintela, 2023/02/06
- [PULL 09/30] migration/ram: Don't explicitly unprotect when unregistering uffd-wp, Juan Quintela, 2023/02/06