# 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
|