tools/libs/guest: fix save and restore of pv domains after 32-bit de-support
authorJuergen Gross <jgross@suse.com>
Mon, 7 Jun 2021 13:00:05 +0000 (15:00 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 7 Jun 2021 14:43:35 +0000 (15:43 +0100)
After 32-bit PV-guests have been security de-supported when not running
under PV-shim, the hypervisor will no longer be configured to support
those domains per default when not being built as PV-shim.

Unfortunately libxenguest will fail saving or restoring a PV domain
due to this restriction, as it is trying to get the compat MFN list
even for 64 bit guests.

Fix that by obtaining the compat MFN list only for 32-bit PV guests.

Fixes: 1a0f2fe2297d122a08fe ("SUPPORT.md: Un-shimmed 32-bit PV guests are no longer supported")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libs/guest/xg_sr_common.h
tools/libs/guest/xg_sr_common_x86_pv.c

index cc3ad1c3948030fa7301fe62feea3289704f5b30..e2994e18acf19f60462f5a14f19196f32866d4fe 100644 (file)
@@ -325,7 +325,7 @@ struct xc_sr_context
                 xen_pfn_t max_mfn;
                 /* Read-only machine to phys map */
                 xen_pfn_t *m2p;
-                /* first mfn of the compat m2p (Only needed for 32bit PV guests) */
+                /* first mfn of the compat m2p (Only set for 32bit PV guests) */
                 xen_pfn_t compat_m2p_mfn0;
                 /* Number of m2p frames mapped */
                 unsigned long nr_m2p_frames;
index cd33406aabd129665f1bf88bc8dde00e39f2af4d..c0acf00f9045af411f41e028a4fc0d24d873d7c0 100644 (file)
@@ -149,12 +149,13 @@ int x86_pv_map_m2p(struct xc_sr_context *ctx)
 
     ctx->x86.pv.nr_m2p_frames = (M2P_CHUNK_SIZE >> PAGE_SHIFT) * m2p_chunks;
 
+    if ( ctx->x86.pv.levels == 3 )
+    {
 #ifdef __i386__
-    /* 32 bit toolstacks automatically get the compat m2p */
-    ctx->x86.pv.compat_m2p_mfn0 = entries[0].mfn;
+        /* 32 bit toolstacks automatically get the compat m2p */
+        ctx->x86.pv.compat_m2p_mfn0 = entries[0].mfn;
 #else
-    /* 64 bit toolstacks need to ask Xen specially for it */
-    {
+        /* 64 bit toolstacks need to ask Xen specially for it */
         struct xen_machphys_mfn_list xmml = {
             .max_extents = 1,
             .extent_start = { &ctx->x86.pv.compat_m2p_mfn0 },
@@ -168,8 +169,10 @@ int x86_pv_map_m2p(struct xc_sr_context *ctx)
             rc = -1;
             goto err;
         }
-    }
 #endif
+    }
+    else
+        ctx->x86.pv.compat_m2p_mfn0 = INVALID_MFN;
 
     /* All Done */
     rc = 0;