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-ia64-devel

[Xen-devel] [PATCH 1/5] dump-core take 2: XENMEM_set_memory_map hypercal

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1/5] dump-core take 2: XENMEM_set_memory_map hypercall
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Thu, 18 Jan 2007 15:52:47 +0900
Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>, John Levon <levon@xxxxxxxxxxxxxxxxx>, Dave Anderson <anderson@xxxxxxxxxx>, xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 17 Jan 2007 22:54:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20070118065242.4302.39670.sendpatchset@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20070118065242.4302.39670.sendpatchset@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User yamahata@xxxxxxxxxxxxx
# Date 1168929639 -32400
# Node ID 280d35294b8968b262c37df4d01712e0af288451
# Parent  dd0989523d1700825a9feea3895811cec3c41bfa
implemented XENMEM_set_memory_map hypercall which is needed by dump-core
to know the area to dump.
PATCHNAME: xenmem_set_memory_map_xen_side

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r dd0989523d17 -r 280d35294b89 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Jan 17 16:42:34 2007 +0000
+++ b/xen/arch/x86/mm.c Tue Jan 16 15:40:39 2007 +0900
@@ -3045,10 +3045,12 @@ long arch_memory_op(int op, XEN_GUEST_HA
     }
 
     case XENMEM_set_memory_map:
+    case XENMEM_get_memory_map:
     {
         struct xen_foreign_memory_map fmap;
         struct domain *d;
-        int rc;
+        XEN_GUEST_HANDLE(e820entry_t) buffer;
+        int rc = 0;
 
         if ( copy_from_guest(&fmap, arg, 1) )
             return -EFAULT;
@@ -3066,10 +3068,40 @@ long arch_memory_op(int op, XEN_GUEST_HA
         else if ( (d = find_domain_by_id(fmap.domid)) == NULL )
             return -ESRCH;
 
-        rc = copy_from_guest(&d->arch.e820[0], fmap.map.buffer,
-                             fmap.map.nr_entries) ? -EFAULT : 0;
-        d->arch.nr_e820 = fmap.map.nr_entries;
-
+        LOCK_BIGLOCK(d);
+        switch ( op )
+        {
+        case XENMEM_set_memory_map:
+            rc = copy_from_guest(&d->arch.e820[0], fmap.map.buffer,
+                                 fmap.map.nr_entries) ? -EFAULT : 0;
+            d->arch.nr_e820 = fmap.map.nr_entries;
+            break;
+            
+        case XENMEM_get_memory_map:
+            /* Backwards compatibility. */
+            if ( d->arch.nr_e820 == 0 )
+            {
+                rc = -ENOSYS;
+                break;
+            }
+
+            buffer = guest_handle_cast(fmap.map.buffer, e820entry_t);
+            if ( fmap.map.nr_entries < d->arch.nr_e820 + 1 )
+            {
+                rc = -EINVAL;
+                break;
+            }
+
+            fmap.map.nr_entries = d->arch.nr_e820;
+            if ( copy_to_guest(buffer, &d->arch.e820[0],
+                               fmap.map.nr_entries) ||
+                 copy_to_guest(arg, &fmap, 1) )
+            {
+                rc = -EFAULT;
+                break;
+            }
+        }
+        UNLOCK_BIGLOCK(d);
         put_domain(d);
         return rc;
     }
@@ -3079,18 +3111,29 @@ long arch_memory_op(int op, XEN_GUEST_HA
         struct xen_memory_map map;
         struct domain *d = current->domain;
 
+        LOCK_BIGLOCK(d);
         /* Backwards compatibility. */
         if ( d->arch.nr_e820 == 0 )
+        {
+            UNLOCK_BIGLOCK(d);
             return -ENOSYS;
+        }
 
         if ( copy_from_guest(&map, arg, 1) )
+        {
+            UNLOCK_BIGLOCK(d);
             return -EFAULT;
+        }
 
         map.nr_entries = min(map.nr_entries, d->arch.nr_e820);
         if ( copy_to_guest(map.buffer, &d->arch.e820[0], map.nr_entries) ||
              copy_to_guest(arg, &map, 1) )
+        {
+            UNLOCK_BIGLOCK(d);
             return -EFAULT;
-
+        }
+
+        UNLOCK_BIGLOCK(d);
         return 0;
     }
 
diff -r dd0989523d17 -r 280d35294b89 xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h      Wed Jan 17 16:42:34 2007 +0000
+++ b/xen/include/asm-x86/domain.h      Tue Jan 16 15:40:39 2007 +0900
@@ -116,7 +116,8 @@ struct arch_domain
     unsigned long max_mapped_pfn;
 
     /* Pseudophysical e820 map (XENMEM_memory_map).  */
-    struct e820entry e820[3];
+#define MAX_E820        5 /* xc_hvm_build.c setups 5 e820 map */
+    struct e820entry e820[MAX_E820];
     unsigned int nr_e820;
 } __cacheline_aligned;
 
diff -r dd0989523d17 -r 280d35294b89 xen/include/public/memory.h
--- a/xen/include/public/memory.h       Wed Jan 17 16:42:34 2007 +0000
+++ b/xen/include/public/memory.h       Tue Jan 16 15:40:39 2007 +0900
@@ -263,6 +263,11 @@ typedef struct xen_foreign_memory_map xe
 typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
 DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
 
+/*
+ * Get the pseudo-physical memory mao fo a domain
+ */
+#define XENMEM_get_memory_map       14
+
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
 /*
--
yamahata

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