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] [xen-unstable] x86: make the pv-only e820 array be dynam

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: make the pv-only e820 array be dynamic.
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Thu, 14 Apr 2011 11:20:10 +0100
Delivery-date: Thu, 14 Apr 2011 03:20:51 -0700
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 Keir Fraser <keir@xxxxxxx>
# Date 1302707426 -3600
# Node ID 3f00c5faa12aed4d0993391f71b7f12cf92f0208
# Parent  3b2182100ba2fa5c4a3a450e473717e2300aa8f1
x86: make the pv-only e820 array be dynamic.

During creation of the PV domain we allocate the E820 structure to
have the amount of E820 entries on the machine, plus the number three.

This will allow the tool stack to fill the E820 with more than three
entries. Specifically the use cases is , where the toolstack retrieves
the E820, sanitizes it, and then sets it for the PV guest (for PCI
passthrough), this dynamic number of E820 is just right.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 3b2182100ba2 -r 3f00c5faa12a xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Wed Apr 13 14:14:59 2011 +0100
+++ b/xen/arch/x86/domain.c     Wed Apr 13 16:10:26 2011 +0100
@@ -657,6 +657,8 @@
         /* 32-bit PV guest by default only if Xen is not 64-bit. */
         d->arch.is_32bit_pv = d->arch.has_32bit_shinfo =
             (CONFIG_PAGING_LEVELS != 4);
+
+        spin_lock_init(&d->arch.pv_domain.e820_lock);
     }
 
     /* initialize default tsc behavior in case tools don't */
@@ -696,6 +698,8 @@
 
     if ( is_hvm_domain(d) )
         hvm_domain_destroy(d);
+    else
+        xfree(d->arch.pv_domain.e820);
 
     vmce_destroy_msr(d);
     pci_release_devices(d);
diff -r 3b2182100ba2 -r 3f00c5faa12a xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Apr 13 14:14:59 2011 +0100
+++ b/xen/arch/x86/mm.c Wed Apr 13 16:10:26 2011 +0100
@@ -100,6 +100,7 @@
 #include <xen/iocap.h>
 #include <xen/guest_access.h>
 #include <xen/pfn.h>
+#include <xen/xmalloc.h>
 #include <asm/paging.h>
 #include <asm/shadow.h>
 #include <asm/page.h>
@@ -4713,11 +4714,12 @@
     {
         struct xen_foreign_memory_map fmap;
         struct domain *d;
+        struct e820entry *e820;
 
         if ( copy_from_guest(&fmap, arg, 1) )
             return -EFAULT;
 
-        if ( fmap.map.nr_entries > ARRAY_SIZE(d->arch.pv_domain.e820) )
+        if ( fmap.map.nr_entries > E820MAX )
             return -EINVAL;
 
         rc = rcu_lock_target_domain_by_id(fmap.domid, &d);
@@ -4737,9 +4739,25 @@
             return -EPERM;
         }
 
-        rc = copy_from_guest(d->arch.pv_domain.e820, fmap.map.buffer,
-                             fmap.map.nr_entries) ? -EFAULT : 0;
+        e820 = xmalloc_array(e820entry_t, fmap.map.nr_entries);
+        if ( e820 == NULL )
+        {
+            rcu_unlock_domain(d);
+            return -ENOMEM;
+        }
+        
+        if ( copy_from_guest(e820, fmap.map.buffer, fmap.map.nr_entries) )
+        {
+            xfree(e820);
+            rcu_unlock_domain(d);
+            return -EFAULT;
+        }
+
+        spin_lock(&d->arch.pv_domain.e820_lock);
+        xfree(d->arch.pv_domain.e820);
+        d->arch.pv_domain.e820 = e820;
         d->arch.pv_domain.nr_e820 = fmap.map.nr_entries;
+        spin_unlock(&d->arch.pv_domain.e820_lock);
 
         rcu_unlock_domain(d);
         return rc;
@@ -4750,19 +4768,29 @@
         struct xen_memory_map map;
         struct domain *d = current->domain;
 
-        /* Backwards compatibility. */
-        if ( d->arch.pv_domain.nr_e820 == 0 )
-            return -ENOSYS;
-
         if ( copy_from_guest(&map, arg, 1) )
             return -EFAULT;
 
+        spin_lock(&d->arch.pv_domain.e820_lock);
+
+        /* Backwards compatibility. */
+        if ( (d->arch.pv_domain.nr_e820 == 0) ||
+             (d->arch.pv_domain.e820 == NULL) )
+        {
+            spin_unlock(&d->arch.pv_domain.e820_lock);
+            return -ENOSYS;
+        }
+
         map.nr_entries = min(map.nr_entries, d->arch.pv_domain.nr_e820);
         if ( copy_to_guest(map.buffer, d->arch.pv_domain.e820,
                            map.nr_entries) ||
              copy_to_guest(arg, &map, 1) )
+        {
+            spin_unlock(&d->arch.pv_domain.e820_lock);
             return -EFAULT;
-
+        }
+
+        spin_unlock(&d->arch.pv_domain.e820_lock);
         return 0;
     }
 
diff -r 3b2182100ba2 -r 3f00c5faa12a xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h      Wed Apr 13 14:14:59 2011 +0100
+++ b/xen/include/asm-x86/domain.h      Wed Apr 13 16:10:26 2011 +0100
@@ -241,7 +241,8 @@
     unsigned long pirq_eoi_map_mfn;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
-    struct e820entry e820[3];
+    spinlock_t e820_lock;
+    struct e820entry *e820;
     unsigned int nr_e820;
 };
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: make the pv-only e820 array be dynamic., Xen patchbot-unstable <=