WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Improved "PGDs must be under 4GB" handling for PAE.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Improved "PGDs must be under 4GB" handling for PAE.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 08 Sep 2005 17:44:10 +0000
Delivery-date: Thu, 08 Sep 2005 17:42:39 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User iap10@xxxxxxxxxxxxxxxxxxxxx
# Node ID 5db85ba1c4e034a84aaea053052719320cefebfb
# Parent  1f4863861d18ded485b5f126d592e2aad87a831d
Improved "PGDs must be under 4GB" handling for PAE.
Signed-off-by: ian@xxxxxxxxxxxxx

diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Thu Sep  8 17:35:44 2005
+++ b/tools/libxc/xc_domain.c   Thu Sep  8 17:36:23 2005
@@ -262,28 +262,66 @@
 
 int xc_domain_memory_increase_reservation(int xc_handle,
                                           u32 domid, 
-                                          unsigned long mem_kb,
+                                          unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned int address_bits)
+                                          unsigned int address_bits,
+                                         unsigned long *extent_start)
 {
     int err;
-    unsigned int npages = mem_kb / (PAGE_SIZE/1024);
     struct xen_memory_reservation reservation = {
-        .nr_extents   = npages,
-        .extent_order = extent_order,
+        .extent_start = extent_start, /* may be NULL */
+        .nr_extents   = nr_extents,
+        .extent_order = extent_order,  
         .address_bits = address_bits,
         .domid        = domid
     };
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
-    if (err == npages)
+    if (err == nr_extents)
         return 0;
 
     if (err > 0) {
-        fprintf(stderr,"Failed alocation for dom %d : %d pages order %d 
addr_bits %d\n",
-                                 domid, npages, extent_order, address_bits);
+        fprintf(stderr,"Failed alocation for dom %d : %ld pages order %d 
addr_bits %d\n",
+                                 domid, nr_extents, extent_order, 
address_bits);
         errno = ENOMEM;
         err = -1;
     }
     return err;
 }
+
+int xc_domain_memory_decrease_reservation(int xc_handle,
+                                          u32 domid, 
+                                          unsigned long nr_extents,
+                                          unsigned int extent_order,
+                                         unsigned long *extent_start)
+{
+    int err;
+    struct xen_memory_reservation reservation = {
+        .extent_start = extent_start, 
+        .nr_extents   = nr_extents,
+        .extent_order = extent_order,  
+        .address_bits = 0,
+        .domid        = domid
+    };
+
+    if (extent_start == NULL)
+    {
+        fprintf(stderr,"decrease_reservation extent_start is NULL!\n");
+        errno = EINVAL;
+        err = -1;
+       goto out;
+    }
+
+    err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
+    if (err == nr_extents)
+        return 0;
+
+    if (err > 0) {
+        fprintf(stderr,"Failed de-alocation for dom %d : %ld pages order %d\n",
+                                 domid, nr_extents, extent_order);
+        errno = EBUSY;
+        err = -1;
+    }
+out:
+    return err;
+}
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Thu Sep  8 17:35:44 2005
+++ b/tools/libxc/xc_linux_build.c      Thu Sep  8 17:36:23 2005
@@ -136,11 +136,24 @@
 
     /* First allocate page for page dir. */
     ppt_alloc = (vpt_start - dsi_v_start) >> PAGE_SHIFT;
+
+    if ( page_array[ppt_alloc] > 0xfffff )
+    {
+       unsigned long nmfn;
+       nmfn = xc_make_page_below_4G( xc_handle, dom, page_array[ppt_alloc] );
+       if ( nmfn == 0 )
+       {
+           fprintf(stderr, "Couldn't get a page below 4GB :-(\n");
+           goto error_out;
+       }
+       page_array[ppt_alloc] = nmfn;
+    }
+
     alloc_pt(l3tab, vl3tab);
     vl3e = &vl3tab[l3_table_offset_pae(dsi_v_start)];
     ctxt->ctrlreg[3] = l3tab;
 
-    if(l3tab>0xfffff000)
+    if(l3tab>0xfffff000ULL)
     {
         fprintf(stderr,"L3TAB = %llx above 4GB!\n",l3tab);
         goto error_out;
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Thu Sep  8 17:35:44 2005
+++ b/tools/libxc/xc_linux_restore.c    Thu Sep  8 17:36:23 2005
@@ -149,7 +149,7 @@
     }
 
     err = xc_domain_memory_increase_reservation(xc_handle, dom,
-                                                nr_pfns * PAGE_SIZE / 1024, 0, 
0); //FIX ME
+                                                nr_pfns, 0, 0, NULL);
     if (err != 0) {
         ERR("Failed to increase reservation by %lx\n", 
             nr_pfns * PAGE_SIZE / 1024); 
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Thu Sep  8 17:35:44 2005
+++ b/tools/libxc/xc_private.c  Thu Sep  8 17:36:23 2005
@@ -427,3 +427,21 @@
 {
     return do_xen_version(xc_handle, cmd, arg);
 }
+
+unsigned long xc_make_page_below_4G(int xc_handle, u32 domid, 
+                                   unsigned long mfn)
+{
+    unsigned long new_mfn;
+    if ( xc_domain_memory_decrease_reservation( 
+       xc_handle, domid, 1, 0, &mfn ) != 1 )
+    {
+       fprintf(stderr,"xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
+       return 0;
+    }
+    if ( xc_domain_memory_increase_reservation( xc_handle, domid, 1, 0, 32, 
&new_mfn ) != 1 )
+    {
+       fprintf(stderr,"xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
+       return 0;
+    }
+    return new_mfn;
+}
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Thu Sep  8 17:35:44 2005
+++ b/tools/libxc/xenctrl.h     Thu Sep  8 17:36:23 2005
@@ -387,9 +387,19 @@
 
 int xc_domain_memory_increase_reservation(int xc_handle,
                                           u32 domid, 
-                                          unsigned long mem_kb,
+                                          unsigned long nr_extents,
                                           unsigned int extent_order,
-                                          unsigned int address_bits);
+                                          unsigned int address_bits,
+                                         unsigned long *extent_start);
+
+int xc_domain_memory_decrease_reservation(int xc_handle,
+                                          u32 domid, 
+                                          unsigned long nr_extents,
+                                          unsigned int extent_order,
+                                         unsigned long *extent_start);
+
+unsigned long xc_make_page_below_4G(int xc_handle, u32 domid, 
+                                   unsigned long mfn);
 
 typedef dom0_perfc_desc_t xc_perfc_desc_t;
 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Thu Sep  8 17:35:44 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Sep  8 17:36:23 2005
@@ -842,6 +842,7 @@
     u32 dom;
     unsigned long mem_kb;
     unsigned int extent_order = 0 , address_bits = 0;
+    unsigned long nr_extents;
 
     static char *kwd_list[] = { "dom", "mem_kb", "extent_order", 
"address_bits", NULL };
 
@@ -849,8 +850,12 @@
                                       &dom, &mem_kb, &extent_order, 
&address_bits) )
         return NULL;
 
+    /* round down to nearest power of 2. Assume callers using extent_order>0
+       know what they are doing */
+    nr_extents = (mem_kb / (XC_PAGE_SIZE/1024)) >> extent_order;
     if ( xc_domain_memory_increase_reservation(xc->xc_handle, dom, 
-                                     mem_kb, extent_order, address_bits) )
+                                              nr_extents, extent_order, 
+                                              address_bits, NULL) )
         return PyErr_SetFromErrno(xc_error);
     
     Py_INCREF(zero);
diff -r 1f4863861d18 -r 5db85ba1c4e0 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Sep  8 17:35:44 2005
+++ b/tools/python/xen/xend/image.py    Thu Sep  8 17:36:23 2005
@@ -160,8 +160,9 @@
 
         try:
             # Give the domain some memory below 4GB
-            lmem_kb = 4096
-            xc.domain_memory_increase_reservation(dom, min(lmem_kb,mem_kb), 0, 
32)
+            lmem_kb = 0
+            if lmem_kb > 0:
+                xc.domain_memory_increase_reservation(dom, 
min(lmem_kb,mem_kb), 0, 32)
             if mem_kb > lmem_kb:
                 xc.domain_memory_increase_reservation(dom, mem_kb-lmem_kb, 0, 
0)
         except:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Improved "PGDs must be under 4GB" handling for PAE., Xen patchbot -unstable <=