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

[Xen-devel] [PATCH] libxc: drop relics of running on non-PAE 32-bit hosts


  • To: "xen-devel" <xen-devel@xxxxxxxxxxxxx>
  • From: "Jan Beulich" <JBeulich@xxxxxxxx>
  • Date: Wed, 23 Jan 2013 14:00:15 +0000
  • Delivery-date: Wed, 23 Jan 2013 14:00:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Additionally drop unused (and dangerous) defines and typedefs, plus
a minor legibility improvement to setup_pgtables_x86_{32_pae,64}().

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/tools/libxc/xc_domain_restore.c
+++ b/tools/libxc/xc_domain_restore.c
@@ -172,15 +172,12 @@ static int uncanonicalize_pagetable(
     uint64_t pte;
     struct domain_info_context *dinfo = &ctx->dinfo;
 
-    pte_last = PAGE_SIZE / ((ctx->pt_levels == 2)? 4 : 8);
+    pte_last = PAGE_SIZE / 8;
 
     /* First pass: work out how many (if any) MFNs we need to alloc */
     for ( i = 0; i < pte_last; i++ )
     {
-        if ( ctx->pt_levels == 2 )
-            pte = ((uint32_t *)page)[i];
-        else
-            pte = ((uint64_t *)page)[i];
+        pte = ((uint64_t *)page)[i];
 
         /* XXX SMH: below needs fixing for PROT_NONE etc */
         if ( !(pte & _PAGE_PRESENT) )
@@ -226,10 +223,7 @@ static int uncanonicalize_pagetable(
     nr_mfns = 0;
     for ( i = 0; i < pte_last; i++ )
     {
-        if ( ctx->pt_levels == 2 )
-            pte = ((uint32_t *)page)[i];
-        else
-            pte = ((uint64_t *)page)[i];
+        pte = ((uint64_t *)page)[i];
         
         /* XXX SMH: below needs fixing for PROT_NONE etc */
         if ( !(pte & _PAGE_PRESENT) )
@@ -243,10 +237,7 @@ static int uncanonicalize_pagetable(
         pte &= ~MADDR_MASK_X86;
         pte |= (uint64_t)ctx->p2m[pfn] << PAGE_SHIFT;
 
-        if ( ctx->pt_levels == 2 )
-            ((uint32_t *)page)[i] = (uint32_t)pte;
-        else
-            ((uint64_t *)page)[i] = (uint64_t)pte;
+        ((uint64_t *)page)[i] = (uint64_t)pte;
     }
 
     return 1;
@@ -304,8 +295,7 @@ static xen_pfn_t *load_p2m_frame_list(
                 if ( chunk_bytes == sizeof (ctxt.x32) )
                 {
                     dinfo->guest_width = 4;
-                    if ( ctx->pt_levels > 2 ) 
-                        ctx->pt_levels = 3; 
+                    ctx->pt_levels = 3;
                 }
                 else if ( chunk_bytes == sizeof (ctxt.x64) )
                 {
@@ -1508,7 +1498,7 @@ int xc_domain_restore(xc_interface *xch,
      * assume the guest will be the same as we are.  We'll fix that later
      * if we discover otherwise. */
     dinfo->guest_width = sizeof(unsigned long);
-    ctx->pt_levels = (dinfo->guest_width == 8) ? 4 : (ctx->pt_levels == 2) ? 2 
: 3; 
+    ctx->pt_levels = (dinfo->guest_width == 8) ? 4 : 3;
     
     if ( !hvm ) 
     {
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -423,10 +423,7 @@ static int canonicalize_pagetable(struct
     ** reserved hypervisor mappings. This depends on the current
     ** page table type as well as the number of paging levels.
     */
-    xen_start = xen_end = pte_last = PAGE_SIZE / ((ctx->pt_levels == 2) ? 4 : 
8);
-
-    if ( (ctx->pt_levels == 2) && (type == XEN_DOMCTL_PFINFO_L2TAB) )
-        xen_start = (ctx->hvirt_start >> L2_PAGETABLE_SHIFT);
+    xen_start = xen_end = pte_last = PAGE_SIZE / 8;
 
     if ( (ctx->pt_levels == 3) && (type == XEN_DOMCTL_PFINFO_L3TAB) )
         xen_start = L3_PAGETABLE_ENTRIES_PAE;
@@ -474,10 +471,7 @@ static int canonicalize_pagetable(struct
     {
         unsigned long pfn, mfn;
 
-        if ( ctx->pt_levels == 2 )
-            pte = ((const uint32_t*)spage)[i];
-        else
-            pte = ((const uint64_t*)spage)[i];
+        pte = ((const uint64_t*)spage)[i];
 
         if ( (i >= xen_start) && (i < xen_end) )
             pte = 0;
@@ -515,10 +509,7 @@ static int canonicalize_pagetable(struct
                 pte &= ~(_PAGE_USER|_PAGE_RW|_PAGE_ACCESSED);
         }
 
-        if ( ctx->pt_levels == 2 )
-            ((uint32_t*)dpage)[i] = pte;
-        else
-            ((uint64_t*)dpage)[i] = pte;
+        ((uint64_t*)dpage)[i] = pte;
     }
 
     return race;
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -133,11 +133,6 @@ static int count_pgtables(struct xc_dom_
 #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
 #define L3_PROT (_PAGE_PRESENT)
 
-static int count_pgtables_x86_32(struct xc_dom_image *dom)
-{
-    return count_pgtables(dom, 0, 0, 0, 32, L2_PAGETABLE_SHIFT_I386);
-}
-
 static int count_pgtables_x86_32_pae(struct xc_dom_image *dom)
 {
     return count_pgtables(dom, 1, 0, 32,
@@ -146,43 +141,6 @@ static int count_pgtables_x86_32_pae(str
 
 #define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86)
 
-static int setup_pgtables_x86_32(struct xc_dom_image *dom)
-{
-    xen_pfn_t l2pfn = dom->pgtables_seg.pfn;
-    xen_pfn_t l1pfn = dom->pgtables_seg.pfn + dom->pg_l2;
-    l2_pgentry_32_t *l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1);
-    l1_pgentry_32_t *l1tab = NULL;
-    unsigned long l2off, l1off;
-    xen_vaddr_t addr;
-    xen_pfn_t pgpfn;
-
-    for ( addr = dom->parms.virt_base; addr < dom->virt_pgtab_end;
-          addr += PAGE_SIZE_X86 )
-    {
-        if ( l1tab == NULL )
-        {
-            /* get L1 tab, make L2 entry */
-            l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1);
-            l2off = l2_table_offset_i386(addr);
-            l2tab[l2off] =
-                pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT;
-            l1pfn++;
-        }
-
-        /* make L1 entry */
-        l1off = l1_table_offset_i386(addr);
-        pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
-        l1tab[l1off] =
-            pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
-        if ( (addr >= dom->pgtables_seg.vstart) && 
-             (addr < dom->pgtables_seg.vend) )
-            l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
-        if ( l1off == (L1_PAGETABLE_ENTRIES_I386 - 1) )
-            l1tab = NULL;
-    }
-    return 0;
-}
-
 /*
  * Move the l3 page table page below 4G for guests which do not
  * support the extended-cr3 format.  The l3 is currently empty so we
@@ -248,8 +206,8 @@ static xen_pfn_t move_l3_below_4G(struct
 static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom)
 {
     xen_pfn_t l3pfn = dom->pgtables_seg.pfn;
-    xen_pfn_t l2pfn = dom->pgtables_seg.pfn + dom->pg_l3;
-    xen_pfn_t l1pfn = dom->pgtables_seg.pfn + dom->pg_l3 + dom->pg_l2;
+    xen_pfn_t l2pfn = l3pfn + dom->pg_l3;
+    xen_pfn_t l1pfn = l2pfn + dom->pg_l2;
     l3_pgentry_64_t *l3tab;
     l2_pgentry_64_t *l2tab = NULL;
     l1_pgentry_64_t *l1tab = NULL;
@@ -344,10 +302,9 @@ static int count_pgtables_x86_64(struct 
 static int setup_pgtables_x86_64(struct xc_dom_image *dom)
 {
     xen_pfn_t l4pfn = dom->pgtables_seg.pfn;
-    xen_pfn_t l3pfn = dom->pgtables_seg.pfn + dom->pg_l4;
-    xen_pfn_t l2pfn = dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3;
-    xen_pfn_t l1pfn =
-        dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3 + dom->pg_l2;
+    xen_pfn_t l3pfn = l4pfn + dom->pg_l4;
+    xen_pfn_t l2pfn = l3pfn + dom->pg_l3;
+    xen_pfn_t l1pfn = l2pfn + dom->pg_l2;
     l4_pgentry_64_t *l4tab = xc_dom_pfn_to_ptr(dom, l4pfn, 1);
     l3_pgentry_64_t *l3tab = NULL;
     l2_pgentry_64_t *l2tab = NULL;
@@ -620,18 +577,6 @@ static int vcpu_x86_64(struct xc_dom_ima
 
 /* ------------------------------------------------------------------------ */
 
-static struct xc_dom_arch xc_dom_32 = {
-    .guest_type = "xen-3.0-x86_32",
-    .native_protocol = XEN_IO_PROTO_ABI_X86_32,
-    .page_shift = PAGE_SHIFT_X86,
-    .sizeof_pfn = 4,
-    .alloc_magic_pages = alloc_magic_pages,
-    .count_pgtables = count_pgtables_x86_32,
-    .setup_pgtables = setup_pgtables_x86_32,
-    .start_info = start_info_x86_32,
-    .shared_info = shared_info_x86_32,
-    .vcpu = vcpu_x86_32,
-};
 static struct xc_dom_arch xc_dom_32_pae = {
     .guest_type = "xen-3.0-x86_32p",
     .native_protocol = XEN_IO_PROTO_ABI_X86_32,
@@ -660,7 +605,6 @@ static struct xc_dom_arch xc_dom_64 = {
 
 static void __init register_arch_hooks(void)
 {
-    xc_dom_register_arch_hooks(&xc_dom_32);
     xc_dom_register_arch_hooks(&xc_dom_32_pae);
     xc_dom_register_arch_hooks(&xc_dom_64);
 }
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -84,22 +84,6 @@ unsigned long csum_page (void * page);
 #define L3_PAGETABLE_ENTRIES_X86_64  512
 #define L4_PAGETABLE_ENTRIES_X86_64  512
 
-#if defined(__i386__)
-#define L1_PAGETABLE_SHIFT     L1_PAGETABLE_SHIFT_I386
-#define L2_PAGETABLE_SHIFT     L2_PAGETABLE_SHIFT_I386
-#define L1_PAGETABLE_ENTRIES   L1_PAGETABLE_ENTRIES_I386
-#define L2_PAGETABLE_ENTRIES   L2_PAGETABLE_ENTRIES_I386
-#elif defined(__x86_64__)
-#define L1_PAGETABLE_SHIFT     L1_PAGETABLE_SHIFT_X86_64
-#define L2_PAGETABLE_SHIFT     L2_PAGETABLE_SHIFT_X86_64
-#define L3_PAGETABLE_SHIFT     L3_PAGETABLE_SHIFT_X86_64
-#define L4_PAGETABLE_SHIFT     L4_PAGETABLE_SHIFT_X86_64
-#define L1_PAGETABLE_ENTRIES   L1_PAGETABLE_ENTRIES_X86_64
-#define L2_PAGETABLE_ENTRIES   L2_PAGETABLE_ENTRIES_X86_64
-#define L3_PAGETABLE_ENTRIES   L3_PAGETABLE_ENTRIES_X86_64
-#define L4_PAGETABLE_ENTRIES   L4_PAGETABLE_ENTRIES_X86_64
-#endif
-
 typedef uint32_t l1_pgentry_32_t;
 typedef uint32_t l2_pgentry_32_t;
 typedef uint64_t l1_pgentry_64_t;
@@ -107,16 +91,6 @@ typedef uint64_t l2_pgentry_64_t;
 typedef uint64_t l3_pgentry_64_t;
 typedef uint64_t l4_pgentry_64_t;
 
-#if defined(__i386__)
-typedef l1_pgentry_32_t l1_pgentry_t;
-typedef l2_pgentry_32_t l2_pgentry_t;
-#elif defined(__x86_64__)
-typedef l1_pgentry_64_t l1_pgentry_t;
-typedef l2_pgentry_64_t l2_pgentry_t;
-typedef l3_pgentry_64_t l3_pgentry_t;
-typedef l4_pgentry_64_t l4_pgentry_t;
-#endif
-
 #define l1_table_offset_i386(_a) \
   (((_a) >> L1_PAGETABLE_SHIFT_I386) & (L1_PAGETABLE_ENTRIES_I386 - 1))
 #define l2_table_offset_i386(_a) \
@@ -138,16 +112,6 @@ typedef l4_pgentry_64_t l4_pgentry_t;
 #define l4_table_offset_x86_64(_a) \
   (((_a) >> L4_PAGETABLE_SHIFT_X86_64) & (L4_PAGETABLE_ENTRIES_X86_64 - 1))
 
-#if defined(__i386__)
-#define l1_table_offset(_a) l1_table_offset_i386(_a)
-#define l2_table_offset(_a) l2_table_offset_i386(_a)
-#elif defined(__x86_64__)
-#define l1_table_offset(_a) l1_table_offset_x86_64(_a)
-#define l2_table_offset(_a) l2_table_offset_x86_64(_a)
-#define l3_table_offset(_a) l3_table_offset_x86_64(_a)
-#define l4_table_offset(_a) l4_table_offset_x86_64(_a)
-#endif
-
 #define PAGE_SHIFT_ARM          12
 #define PAGE_SIZE_ARM           (1UL << PAGE_SHIFT_ARM)
 #define PAGE_MASK_ARM           (~(PAGE_SIZE_ARM-1))
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -334,8 +334,6 @@ static inline int get_platform_info(xc_i
         *pt_levels = ( (*guest_width == 8) ? 4 : 3 );
     else if (strstr(xen_caps, "xen-3.0-x86_32p"))
         *pt_levels = 3;
-    else if (strstr(xen_caps, "xen-3.0-x86_32"))
-        *pt_levels = 2;
     else
         return 0;
 


Attachment: libxc-x86-pv-build-pt-cleanup.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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