Skip to contentSkip to conversation

x86: nuke PV superpage support

PATCH Superseded Wei Liu 3 participants 14 messages Jul 24, 2017 – Jul 25, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
author
#4 lore raw

PATCH 2/3 tools: nuke superpage parameters in code

In reply to Wei Liu

Also fix manpage because there is no superpages options in xl.cfg.

---
 docs/man/xl.conf.pod.5           | 3 ---
 tools/libxc/include/xenguest.h   | 3 +--
 tools/libxc/xc_nomigrate.c       | 2 +-
 tools/libxc/xc_sr_restore.c      | 7 +++----
 tools/libxl/libxl_internal.h     | 2 +-
 tools/libxl/libxl_save_callout.c | 4 ++--
 tools/libxl/libxl_save_helper.c  | 3 +--
 tools/libxl/libxl_stream_read.c  | 2 +-
 8 files changed, 10 insertions(+), 16 deletions(-)
docs/man/xl.conf.pod.5 +0 -3
index 8f7fd28882..88ab506609 100644
@@ -154,9 +154,6 @@ while the guest is populated.
 Note that to enable tmem type guests, one needs to provide C<tmem> on the
 Xen hypervisor argument and as well on the Linux kernel command line.
 
-Note that the claim call is not attempted if C<superpages> option is
-used in the guest config (see xl.cfg(5)).
-
 Default: C<1>
 
 =over 4
tools/libxc/include/xenguest.h +1 -2
index 40902ee4c9..5cd8111447 100644
@@ -157,7 +157,6 @@ struct restore_callbacks {
  * @parm store_mfn returned with the mfn of the store page
  * @parm hvm non-zero if this is a HVM restore
  * @parm pae non-zero if this HVM domain has PAE support enabled
- * @parm superpages non-zero to allocate guest memory with superpages
  * @parm stream_type non-zero if the far end of the stream is using checkpointing
  * @parm callbacks non-NULL to receive a callback to restore toolstack
  *       specific data
@@ -167,7 +166,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned int store_evtchn, unsigned long *store_mfn,
                       domid_t store_domid, unsigned int console_evtchn,
                       unsigned long *console_mfn, domid_t console_domid,
-                      unsigned int hvm, unsigned int pae, int superpages,
+                      unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
                       struct restore_callbacks *callbacks, int send_back_fd);
 
tools/libxc/xc_nomigrate.c +1 -1
index 15c838f476..317c8cece6 100644
@@ -33,7 +33,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned int store_evtchn, unsigned long *store_mfn,
                       domid_t store_domid, unsigned int console_evtchn,
                       unsigned long *console_mfn, domid_t console_domid,
-                      unsigned int hvm, unsigned int pae, int superpages,
+                      unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
                       struct restore_callbacks *callbacks, int send_back_fd)
 {
tools/libxc/xc_sr_restore.c +3 -4
index 3549f0a1ae..a016678332 100644
@@ -827,7 +827,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                       unsigned int store_evtchn, unsigned long *store_mfn,
                       domid_t store_domid, unsigned int console_evtchn,
                       unsigned long *console_gfn, domid_t console_domid,
-                      unsigned int hvm, unsigned int pae, int superpages,
+                      unsigned int hvm, unsigned int pae,
                       xc_migration_stream_t stream_type,
                       struct restore_callbacks *callbacks, int send_back_fd)
 {
@@ -860,9 +860,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
                callbacks->restore_results);
     }
 
-    DPRINTF("fd %d, dom %u, hvm %u, pae %u, superpages %d"
-            ", stream_type %d", io_fd, dom, hvm, pae,
-            superpages, stream_type);
+    DPRINTF("fd %d, dom %u, hvm %u, pae %u, stream_type %d",
+            io_fd, dom, hvm, pae, stream_type);
 
     if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 )
     {
tools/libxl/libxl_internal.h +1 -1
index afe6652847..724750967c 100644
@@ -3760,7 +3760,7 @@ _hidden int libxl__restore_emulator_xenstore_data
 _hidden void libxl__xc_domain_restore(libxl__egc *egc,
                                       libxl__domain_create_state *dcs,
                                       libxl__save_helper_state *shs,
-                                      int hvm, int pae, int superpages);
+                                      int hvm, int pae);
 /* If rc==0 then retval is the return value from xc_domain_save
  * and errnoval is the errno value it provided.
  * If rc!=0, retval and errnoval are undefined. */
tools/libxl/libxl_save_callout.c +2 -2
index 46b892c626..891c669d15 100644
@@ -43,7 +43,7 @@ static void helper_done(libxl__egc *egc, libxl__save_helper_state *shs);
 
 void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
                               libxl__save_helper_state *shs,
-                              int hvm, int pae, int superpages)
+                              int hvm, int pae)
 {
     STATE_AO_GC(dcs->ao);
 
@@ -61,7 +61,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
         state->store_port,
         state->store_domid, state->console_port,
         state->console_domid,
-        hvm, pae, superpages,
+        hvm, pae,
         cbflags, dcs->restore_params.checkpointed_stream,
     };
 
tools/libxl/libxl_save_helper.c +1 -2
index d3def6b6fd..1dece2351c 100644
@@ -280,7 +280,6 @@ int main(int argc, char **argv)
         domid_t console_domid =             strtoul(NEXTARG,0,10);
         unsigned int hvm =                  strtoul(NEXTARG,0,10);
         unsigned int pae =                  strtoul(NEXTARG,0,10);
-        int superpages =                    strtoul(NEXTARG,0,10);
         unsigned cbflags =                  strtoul(NEXTARG,0,10);
         xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
         assert(!*++argv);
@@ -295,7 +294,7 @@ int main(int argc, char **argv)
 
         r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn,
                               store_domid, console_evtchn, &console_mfn,
-                              console_domid, hvm, pae, superpages,
+                              console_domid, hvm, pae,
                               stream_type,
                               &helper_restore_callbacks, send_back_fd);
         helper_stub_restore_results(store_mfn,console_mfn,0);
tools/libxl/libxl_stream_read.c +1 -1
index 89c2f216e9..483875038c 100644
@@ -580,7 +580,7 @@ static bool process_record(libxl__egc *egc,
         break;
 
     case REC_TYPE_LIBXC_CONTEXT:
-        libxl__xc_domain_restore(egc, dcs, &stream->shs, 0, 0, 0);
+        libxl__xc_domain_restore(egc, dcs, &stream->shs, 0, 0);
         break;
 
     case REC_TYPE_EMULATOR_XENSTORE_DATA:
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Wei Liu

author
#0 lore raw

cover x86: nuke PV superpage support

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

 docs/man/xl.conf.pod.5              |   3 -
 docs/misc/xen-command-line.markdown |   7 -
 tools/libxc/include/xenguest.h      |   3 +-
 tools/libxc/xc_nomigrate.c          |   2 +-
 tools/libxc/xc_sr_restore.c         |   7 +-
 tools/libxl/libxl_internal.h        |   2 +-
 tools/libxl/libxl_save_callout.c    |   4 +-
 tools/libxl/libxl_save_helper.c     |   3 +-
 tools/libxl/libxl_stream_read.c     |   2 +-
 xen/arch/x86/domain.c               |   2 -
 xen/arch/x86/mm.c                   | 257 ++----------------------------------
 xen/arch/x86/pv/dom0_build.c        |   2 -
 xen/include/asm-x86/config.h        |  16 +--
 xen/include/asm-x86/guest_pt.h      |   2 +-
 xen/include/asm-x86/mm.h            |  20 ---
 xen/include/asm-x86/page.h          |   9 --
 xen/include/asm-x86/paging.h        |   2 +-
 xen/include/asm-x86/x86_64/page.h   |   2 -
 18 files changed, 24 insertions(+), 321 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw

PATCH 1/3 x86: nuke PV superpage option and code

Delete the user visible option and code for PV superpage support. The mm code is modified as if the option is set to false (the default value).

Return the address space occupied by spage_info back to the reserved address space.

---
Done some basic testing with xtf, also tested with basic PV guest life cycle.

Will try to run more tests in either osstest or XenServer's test suite

---
 xen/arch/x86/domain.c             |   2 -
 xen/arch/x86/mm.c                 | 257 ++------------------------------------
 xen/arch/x86/pv/dom0_build.c      |   2 -
 xen/include/asm-x86/config.h      |  16 +--
 xen/include/asm-x86/guest_pt.h    |   2 +-
 xen/include/asm-x86/mm.h          |  20 ---
 xen/include/asm-x86/page.h        |   9 --
 xen/include/asm-x86/paging.h      |   2 +-
 xen/include/asm-x86/x86_64/page.h |   2 -
 9 files changed, 14 insertions(+), 298 deletions(-)
xen/arch/x86/domain.c +0 -2
index dd8bf1302f..1ce804b05f 100644
@@ -1782,8 +1782,6 @@ static int relinquish_memory(
             BUG();
         }
 
-        clear_superpage_mark(page);
-
         if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
             put_page(page);
 
xen/arch/x86/mm.c +10 -247

304 lines not on this page · raw message

xen/arch/x86/pv/dom0_build.c +0 -2
index 18c19a256f..e67ffdd7b8 100644
@@ -181,8 +181,6 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn,
                                              0)) != NULL )
             {
                 *pl2e = l2e_from_page(page, L1_PROT|_PAGE_DIRTY|_PAGE_PSE);
-                if ( opt_allow_superpage )
-                    get_superpage(page_to_mfn(page), d);
                 vphysmap_start += 1UL << L2_PAGETABLE_SHIFT;
                 continue;
             }
xen/include/asm-x86/config.h +2 -14
index dc424f99e4..bc0730fd9d 100644
@@ -143,19 +143,15 @@ extern unsigned char boot_edid_info[128];
  *  0xffff82d080000000 - 0xffff82d0bfffffff [1GB,   2^30 bytes, PML4:261]
  *    Xen text, static data, bss.
 #ifndef CONFIG_BIGMEM
- *  0xffff82d0c0000000 - 0xffff82dffbffffff [61GB - 64MB,       PML4:261]
+ *  0xffff82d0c0000000 - 0xffff82dfffffffff [61GB,              PML4:261]
  *    Reserved for future use.
- *  0xffff82dffc000000 - 0xffff82dfffffffff [64MB,  2^26 bytes, PML4:261]
- *    Super-page information array.
  *  0xffff82e000000000 - 0xffff82ffffffffff [128GB, 2^37 bytes, PML4:261]
  *    Page-frame information array.
  *  0xffff830000000000 - 0xffff87ffffffffff [5TB, 5*2^40 bytes, PML4:262-271]
  *    1:1 direct mapping of all physical memory.
 #else
- *  0xffff82d0c0000000 - 0xffff82ffdfffffff [188.5GB,           PML4:261]
+ *  0xffff82d0c0000000 - 0xffff82ffffffffff [189GB,             PML4:261]
  *    Reserved for future use.
- *  0xffff82ffe0000000 - 0xffff82ffffffffff [512MB, 2^29 bytes, PML4:261]
- *    Super-page information array.
  *  0xffff830000000000 - 0xffff847fffffffff [1.5TB, 3*2^39 bytes, PML4:262-264]
  *    Page-frame information array.
  *  0xffff848000000000 - 0xffff87ffffffffff [3.5TB, 7*2^39 bytes, PML4:265-271]
@@ -230,14 +226,6 @@ extern unsigned char boot_edid_info[128];
 #define XEN_VIRT_START          (HIRO_COMPAT_MPT_VIRT_END)
 #define XEN_VIRT_END            (XEN_VIRT_START + GB(1))
 
-/* Slot 261: superpage information array (64MB or 512MB). */
-#define SPAGETABLE_VIRT_END     FRAMETABLE_VIRT_START
-#define SPAGETABLE_NR           (((FRAMETABLE_NR - 1) >> (SUPERPAGE_SHIFT - \
-                                                          PAGE_SHIFT)) + 1)
-#define SPAGETABLE_SIZE         (SPAGETABLE_NR * sizeof(struct spage_info))
-#define SPAGETABLE_VIRT_START   ((SPAGETABLE_VIRT_END - SPAGETABLE_SIZE) & \
-                                 (_AC(-1,UL) << SUPERPAGE_SHIFT))
-
 #ifndef CONFIG_BIGMEM
 /* Slot 261: page-frame information array (128GB). */
 #define FRAMETABLE_SIZE         GB(128)
xen/include/asm-x86/guest_pt.h +1 -1
index 72126d58d5..af18c90efa 100644
@@ -210,7 +210,7 @@ static inline bool guest_can_use_l2_superpages(const struct vcpu *v)
      * It's also used in the dummy PT for vcpus with CR0.PG cleared.
      */
     return (is_pv_vcpu(v)
-            ? opt_allow_superpage
+            ? false
             : (GUEST_PAGING_LEVELS != 2
                || !hvm_paging_enabled(v)
                || (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PSE)));
xen/include/asm-x86/mm.h +0 -20
index 2550e35f85..2bf3f335ad 100644
@@ -233,21 +233,6 @@ struct page_info
 #define PGC_count_width   PG_shift(9)
 #define PGC_count_mask    ((1UL<<PGC_count_width)-1)
 
-struct spage_info
-{
-       unsigned long type_info;
-};
-
- /* The following page types are MUTUALLY EXCLUSIVE. */
-#define SGT_none          PG_mask(0, 2)  /* superpage not in use */
-#define SGT_mark          PG_mask(1, 2)  /* Marked as a superpage */
-#define SGT_dynamic       PG_mask(2, 2)  /* has been dynamically mapped as a superpage */
-#define SGT_type_mask     PG_mask(3, 2)  /* Bits 30-31 or 62-63. */
-
- /* Count of uses of this superpage as its current type. */
-#define SGT_count_width   PG_shift(3)
-#define SGT_count_mask    ((1UL<<SGT_count_width)-1)
-
 #define is_xen_heap_page(page) ((page)->count_info & PGC_xen_heap)
 #define is_xen_heap_mfn(mfn) \
     (__mfn_valid(mfn) && is_xen_heap_page(__mfn_to_page(mfn)))
@@ -282,8 +267,6 @@ extern void share_xen_page_with_privileged_guests(
 extern void free_shared_domheap_page(struct page_info *page);
 
 #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
-#define spage_table ((struct spage_info *)SPAGETABLE_VIRT_START)
-int get_superpage(unsigned long mfn, struct domain *d);
 extern unsigned long max_page;
 extern unsigned long total_pages;
 void init_frametable(void);
@@ -329,8 +312,6 @@ void zap_ro_mpt(unsigned long mfn);
 
 bool is_iomem_page(mfn_t mfn);
 
-void clear_superpage_mark(struct page_info *page);
-
 const unsigned long *get_platform_badpages(unsigned int *array_size);
 /* Per page locks:
  * page_lock() is used for two purposes: pte serialization, and memory sharing.
@@ -403,7 +384,6 @@ static inline int get_page_and_type(struct page_info *page,
 
 int check_descriptor(const struct domain *, struct desc_struct *d);
 
-extern bool opt_allow_superpage;
 extern paddr_t mem_hotplug;
 
 /******************************************************************************
xen/include/asm-x86/page.h +0 -9
index 474b9bde78..5e1b7f3256 100644
@@ -239,15 +239,6 @@ void copy_page_sse2(void *, const void *);
 #define __pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT)
 #define __paddr_to_pfn(pa)  ((unsigned long)((pa) >> PAGE_SHIFT))
 
-
-/* Convert between machine frame numbers and spage-info structures. */
-#define __mfn_to_spage(mfn)  (spage_table + pfn_to_sdx(mfn))
-#define __spage_to_mfn(pg)   sdx_to_pfn((unsigned long)((pg) - spage_table))
-
-/* Convert between page-info structures and spage-info structures. */
-#define page_to_spage(page)  (spage_table+(((page)-frame_table)>>(SUPERPAGE_SHIFT-PAGE_SHIFT)))
-#define spage_to_page(spage)  (frame_table+(((spage)-spage_table)<<(SUPERPAGE_SHIFT-PAGE_SHIFT)))
-
 /*
  * We define non-underscored wrappers for above conversion functions. These are
  * overridden in various source files while underscored versions remain intact.
xen/include/asm-x86/paging.h +1 -1
index 44e86d6a1f..6dcf5e9ca8 100644
@@ -372,7 +372,7 @@ static inline unsigned int paging_max_paddr_bits(const struct domain *d)
     unsigned int bits = paging_mode_hap(d) ? hap_paddr_bits : paddr_bits;
 
     if ( !IS_ENABLED(BIGMEM) && paging_mode_shadow(d) &&
-         (!is_pv_domain(d) || opt_allow_superpage) )
+         !is_pv_domain(d) )
     {
         /* Shadowed superpages store GFNs in 32-bit page_info fields. */
         bits = min(bits, 32U + PAGE_SHIFT);
xen/include/asm-x86/x86_64/page.h +0 -2
index 31ba975e3d..1b48309363 100644
@@ -41,8 +41,6 @@
 
 extern unsigned long xen_virt_end;
 
-#define spage_to_pdx(spg) (((spg) - spage_table)<<(SUPERPAGE_SHIFT-PAGE_SHIFT))
-#define pdx_to_spage(pdx) (spage_table + ((pdx)>>(SUPERPAGE_SHIFT-PAGE_SHIFT)))
 /*
  * Note: These are solely for the use by page_{get,set}_owner(), and
  *       therefore don't need to handle the XEN_VIRT_{START,END} range.
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#6 lore raw

PATCH 3/3 docs: delete PV superpage option

In reply to Wei Liu
---
 docs/misc/xen-command-line.markdown | 7 -------
 1 file changed, 7 deletions(-)
docs/misc/xen-command-line.markdown +0 -7
index a130452462..4002eab08b 100644
@@ -133,13 +133,6 @@ resume.
 `s3_mode` instructs Xen to set up the boot time (option `vga=`) video
 mode during S3 resume.
 
-### allowsuperpage
-> `= <boolean>`
-
-> Default: `true`
-
-Permit Xen to use superpages when performing memory management.
-
 ### altp2m (Intel)
 > `= <boolean>`
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#8 lore raw
In reply to Wei Liu
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#9 lore raw
Quoted 11 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

Why was it done like that in the first place?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
Quoted 6 lines · Wei Liu
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

Quoted 6 lines
Quoted 5 lines

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

Why was it done like that in the first place?

Because if a PV guest shatters all of its superpages during the live phase, it can be successfully moved.

This work was mixed up in the question of the time as to whether PV migraiton worked with superpages at all, seeing as the legacy code took a (non-working) stab at attempting the migration.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#11 lore raw
Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Wei Liu
Quoted 10 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

Quoted 9 lines
Quoted 1 line

Why was it done like that in the first place?

Because if a PV guest shatters all of its superpages during the live phase, it can be successfully moved.

This work was mixed up in the question of the time as to whether PV migraiton worked with superpages at all, seeing as the legacy code took a (non-working) stab at attempting the migration.

OK. This makes sense. I will submit a separate patch for the thing you asked for, since it is more like an improvement to the code.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#12 lore raw
Quoted 18 lines · Wei Liu
Quoted 17 lines · Andrew Cooper
Quoted 6 lines · Wei Liu
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

Quoted 6 lines
Quoted 5 lines

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

Why was it done like that in the first place?

Because if a PV guest shatters all of its superpages during the live phase, it can be successfully moved.

Quoted 7 lines
Quoted 4 lines

This work was mixed up in the question of the time as to whether PV migraiton worked with superpages at all, seeing as the legacy code took a (non-working) stab at attempting the migration.

OK. This makes sense. I will submit a separate patch for the thing you asked for, since it is more like an improvement to the code.

---8<---
From fd4934b754eb3a1b8a98167aa4432a105caac185 Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Mon, 24 Jul 2017 16:35:09 +0100
Subject: [PATCH] libxc: bail immediately when PV superpage is discovered

The original code was added with the hope that PV superpage migration might work. But it was never proven that the code actually worked.

Now that PV superpage is gone, simplify the code by returning error immediately.

---
 tools/libxc/xc_sr_save_x86_pv.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
tools/libxc/xc_sr_save_x86_pv.c +3 -8
index 36b10583d6..ff5efe954b 100644
@@ -975,14 +975,9 @@ static int normalise_pagetable(struct xc_sr_context *ctx, const uint64_t *src,
 
             if ( (type > XEN_DOMCTL_PFINFO_L1TAB) && (pte & _PAGE_PSE) )
             {
-                if ( !ctx->dominfo.paused )
-                    errno = EAGAIN;
-                else
-                {
-                    ERROR("Cannot migrate superpage (L%lu[%u]: 0x%016"PRIx64")",
-                          type >> XEN_DOMCTL_PFINFO_LTAB_SHIFT, i, pte);
-                    errno = E2BIG;
-                }
+                ERROR("Cannot migrate superpage (L%lu[%u]: 0x%016"PRIx64")",
+                      type >> XEN_DOMCTL_PFINFO_LTAB_SHIFT, i, pte);
+                errno = E2BIG;
                 return -1;
             }
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 1/3] x86: nuke PV superpage option and code

In reply to Wei Liu

xen/arch/x86/mm.c static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) · line 1293

Quoted 12 lines · Wei Liu
xen/arch/x86/mm.c +6 -2
@@ -1317,8 +1285,13 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
         return 1;
 
     if ( l2e_get_flags(l2e) & _PAGE_PSE )
-        put_superpage(l2e_get_pfn(l2e));
-    else
+    {
+        struct page_info *page = mfn_to_page(l2e_get_pfn(l2e));
+        unsigned int i;
+
+        for ( i = 0; i < (1u << PAGETABLE_ORDER); i++, page++ )
+            put_page_and_type(page);

With the removal of PV superpages, can this _PAGE_PSE check ever be hit?

Quoted 9 lines
xen/arch/x86/mm.c +1 -0
+    } else
         put_page_and_type(l2e_get_page(l2e));
 
     return 0;
xen/include/asm-x86/guest_pt.h +0 -0
index 72126d58d5..af18c90efa 100644

xen/include/asm-x86/guest_pt.h static inline bool guest_can_use_l2_superpages(const struct vcpu *v) · line 213

Quoted 5 lines
xen/include/asm-x86/guest_pt.h +1 -1
@@ -210,7 +210,7 @@ static inline bool guest_can_use_l2_superpages(const struct vcpu *v)
      * It's also used in the dummy PT for vcpus with CR0.PG cleared.
      */
     return (is_pv_vcpu(v)
-            ? opt_allow_superpage
+            ? false

This raises an interesting question. A PV guest likely has 2M superpages in the M2P mapping, irrespective of whether the PV guest is permitted to create its own 2M superpages or not.

In this context, I think it is a layering violation. The purpose of guest_walk() is to match what hardware does, whereas this check is superimposing PV policy.

I will submit a patch changing this in isolation, along with suitable justification.

xen/include/asm-x86/paging.h static inline unsigned int paging_max_paddr_bits(const struct domain *d) · line 375

Quoted 10 lines
xen/include/asm-x86/paging.h +1 -1
index 44e86d6a1f..6dcf5e9ca8 100644
@@ -372,7 +372,7 @@ static inline unsigned int paging_max_paddr_bits(const struct domain *d)
     unsigned int bits = paging_mode_hap(d) ? hap_paddr_bits : paddr_bits;
 
     if ( !IS_ENABLED(BIGMEM) && paging_mode_shadow(d) &&
-         (!is_pv_domain(d) || opt_allow_superpage) )
+         !is_pv_domain(d) )

Reflow onto the previous line?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by
#13 lore raw
In reply to Wei Liu
Quoted 30 lines · Wei Liu
Quoted 17 lines · Wei Liu
Quoted 16 lines · Andrew Cooper
Quoted 6 lines · Wei Liu
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Wei Liu

Wei Liu (3):
x86: nuke PV superpage option and code
tools: nuke superpage parameters in code
docs: delete PV superpage option

Quoted 6 lines
Quoted 5 lines

If you are doing this, can you modify xc_sr_save_x86_pv.c:normalise_pagetable() to fail immediately if a superpage is found. Currently, this condition is deferred until the live phase is complete.

Why was it done like that in the first place?

Because if a PV guest shatters all of its superpages during the live phase, it can be successfully moved.

Quoted 6 lines
Quoted 4 lines

This work was mixed up in the question of the time as to whether PV migraiton worked with superpages at all, seeing as the legacy code took a (non-working) stab at attempting the migration.

OK. This makes sense. I will submit a separate patch for the thing you asked for, since it is more like an improvement to the code.

---8<---
From fd4934b754eb3a1b8a98167aa4432a105caac185 Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Mon, 24 Jul 2017 16:35:09 +0100
Subject: [PATCH] libxc: bail immediately when PV superpage is discovered

Quoted 8 lines

The original code was added with the hope that PV superpage migration might work. But it was never proven that the code actually worked.

Now that PV superpage is gone, simplify the code by returning error immediately.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#3 lore raw

Re: [PATCH 1/3] x86: nuke PV superpage option and code

In reply to Andrew Cooper
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Wei Liu
xen/arch/x86/mm.c +0 -0
@@ -1317,8 +1285,13 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn)
         return 1;
 
Quoted 12 lines

xen/arch/x86/mm.c static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) · line 1293

Quoted 9 lines
xen/arch/x86/mm.c +6 -2
     if ( l2e_get_flags(l2e) & _PAGE_PSE )
-        put_superpage(l2e_get_pfn(l2e));
-    else
+    {
+        struct page_info *page = mfn_to_page(l2e_get_pfn(l2e));
+        unsigned int i;
+
+        for ( i = 0; i < (1u << PAGETABLE_ORDER); i++, page++ )
+            put_page_and_type(page);

With the removal of PV superpages, can this _PAGE_PSE check ever be hit?

Yes. It is hit when dom0 boots. My first version of this patch had an ASSERT(!(l2e_get_flags(l2e) & _PAGE_PSE)) and it was triggered.

Quoted 19 lines
Quoted 9 lines
xen/arch/x86/mm.c +1 -0
+    } else
         put_page_and_type(l2e_get_page(l2e));
 
     return 0;
xen/include/asm-x86/guest_pt.h +0 -0
index 72126d58d5..af18c90efa 100644

xen/include/asm-x86/guest_pt.h static inline bool guest_can_use_l2_superpages(const struct vcpu *v) · line 213

Quoted 5 lines
xen/include/asm-x86/guest_pt.h +1 -1
@@ -210,7 +210,7 @@ static inline bool guest_can_use_l2_superpages(const struct vcpu *v)
      * It's also used in the dummy PT for vcpus with CR0.PG cleared.
      */
     return (is_pv_vcpu(v)
-            ? opt_allow_superpage
+            ? false

This raises an interesting question. A PV guest likely has 2M superpages in the M2P mapping, irrespective of whether the PV guest is permitted to create its own 2M superpages or not.

Quoted 7 lines

In this context, I think it is a layering violation. The purpose of guest_walk() is to match what hardware does, whereas this check is superimposing PV policy.

I will submit a patch changing this in isolation, along with suitable justification.

OK.

Quoted 7 lines
Quoted 7 lines
xen/include/asm-x86/paging.h +0 -0
index 44e86d6a1f..6dcf5e9ca8 100644
@@ -372,7 +372,7 @@ static inline unsigned int paging_max_paddr_bits(const struct domain *d)
     unsigned int bits = paging_mode_hap(d) ? hap_paddr_bits : paddr_bits;
 
Quoted 6 lines

xen/include/asm-x86/paging.h static inline unsigned int paging_max_paddr_bits(const struct domain *d) · line 375

Quoted 3 lines
xen/include/asm-x86/paging.h +1 -1
     if ( !IS_ENABLED(BIGMEM) && paging_mode_shadow(d) &&
-         (!is_pv_domain(d) || opt_allow_superpage) )
+         !is_pv_domain(d) )

Reflow onto the previous line?

NP.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel