[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/2] tools/libs/guest: re-read dominfo after changing a PV guest's width on restore



The x86 PV restore code reads the domain's information once, when the
stream starts, and keeps it in ctx->dominfo.  When the X86_PV_INFO
record gives a width other than the domain's, handle_x86_pv_info()
changes it with XEN_DOMCTL_set_address_size, and then refreshes only
the guest's width and page-table levels.

Since 8a9255405ca6 ("x86/domain: adjust limitation on shared_info
allocation below 4G"), making a domain 32-bit may replace a
shared_info page (if the originally allocated page was above 4GiB).
The shared_info_frame read when the stream started will refer to a
freed page.  handle_shared_info() maps that frame to write the
SHARED_INFO record, and process_start_info() puts it in the guest's
start_info.  Xen holds no reference to the replaced page by then, so
the mapping fails, and with it the restore of any 32-bit PV guest
whose shared_info page was moved.

Re-read the domain's information after changing its width.

Fixes: 8a9255405ca6 ("x86/domain: adjust limitation on shared_info allocation 
below 4G")
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Not tested end to end: no 32-bit PV guest here can suspend.  Restore's
steps replayed from dom0 on staging, on an Intel box (create a PV
domain, read its info, make it 32-bit, populate 1GiB, then map the
frame read first): that map fails with -EBUSY every time, while the
frame read after the switch maps.  Build-tested.
---
 tools/libs/guest/xg_sr_restore_x86_pv.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/libs/guest/xg_sr_restore_x86_pv.c 
b/tools/libs/guest/xg_sr_restore_x86_pv.c
index 876748c11e..b72cacd000 100644
--- a/tools/libs/guest/xg_sr_restore_x86_pv.c
+++ b/tools/libs/guest/xg_sr_restore_x86_pv.c
@@ -646,6 +646,12 @@ static int handle_x86_pv_info(struct xc_sr_context *ctx,
         }
 
         /* Domain's information changed, better to refresh. */
+        if ( xc_domain_getinfo_single(xch, ctx->domid, &ctx->dominfo) < 0 )
+        {
+            PERROR("Failed to refresh dominfo for d%d", ctx->domid);
+            return -1;
+        }
+
         rc = x86_pv_domain_info(ctx);
         if ( rc != 0 )
         {
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.