aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-11-21 16:56:39 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-11-21 16:56:39 +0100
commit9ba9cbdb3fb55274a25092f52d60545474beae4d (patch)
tree6521742490be4984e0e2b156b39dfbd8e2b506c4
parent7cdf0f64076d05bab8edaac9aa02ddfef510afb5 (diff)
downloadxen-9ba9cbdb3fb55274a25092f52d60545474beae4d.tar.gz
xen-9ba9cbdb3fb55274a25092f52d60545474beae4d.tar.bz2
xen-9ba9cbdb3fb55274a25092f52d60545474beae4d.zip
Update the memory_op() hypercall. Add two new subcommands, to
query a domain's current and maximum memory reservation. Also, XENMEM_maximum_ram_page now returns the max_page directly, rather than writing through a passed-in pointer. Also, disable PAE in the default config (accidentally checked in two changesets ago). Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r--Config.mk2
-rw-r--r--linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c6
-rw-r--r--linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c2
-rw-r--r--tools/libxc/xc_private.c10
-rw-r--r--tools/libxc/xg_save_restore.h4
-rw-r--r--xen/common/memory.c22
-rw-r--r--xen/include/public/memory.h27
7 files changed, 46 insertions, 27 deletions
diff --git a/Config.mk b/Config.mk
index 645457376a..3b24b07abe 100644
--- a/Config.mk
+++ b/Config.mk
@@ -3,7 +3,7 @@
# Currently supported architectures: x86_32, x86_64
XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/)
XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH)
-XEN_TARGET_X86_PAE ?= y
+XEN_TARGET_X86_PAE ?= n
# Tools to run on system hosting the build
HOSTCC = gcc
diff --git a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c
index 7a50607f05..7ec30325dd 100644
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c
@@ -178,6 +178,8 @@ swiotlb_init_with_default_size (size_t default_size)
void
swiotlb_init(void)
{
+ long ram_end;
+
/* The user can forcibly enable swiotlb. */
if (swiotlb_force)
swiotlb = 1;
@@ -187,9 +189,7 @@ swiotlb_init(void)
* which we take to mean more than 2GB.
*/
if (xen_start_info->flags & SIF_INITDOMAIN) {
- unsigned long ram_end;
- if (HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &ram_end))
- BUG();
+ ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
if (ram_end > 0x7ffff)
swiotlb = 1;
}
diff --git a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c
index 8aff532d39..f2a7160a0e 100644
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c
@@ -586,7 +586,7 @@ void __init e820_reserve_resources(void)
free_bootmem(__pa(map), PAGE_SIZE);
if (!found) {
- HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &gapstart);
+ gapstart = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 904dddc5d1..526d77b337 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -214,13 +214,6 @@ int xc_memory_op(int xc_handle,
goto out1;
}
break;
- case XENMEM_maximum_ram_page:
- if ( mlock(arg, sizeof(unsigned long)) != 0 )
- {
- PERROR("Could not mlock");
- goto out1;
- }
- break;
}
ret = do_xen_hypercall(xc_handle, &hypercall);
@@ -234,9 +227,6 @@ int xc_memory_op(int xc_handle,
safe_munlock(reservation->extent_start,
reservation->nr_extents * sizeof(unsigned long));
break;
- case XENMEM_maximum_ram_page:
- safe_munlock(arg, sizeof(unsigned long));
- break;
}
out1:
diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
index c735deab41..b9a4d38122 100644
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -64,7 +64,6 @@ static int get_platform_info(int xc_handle, uint32_t dom,
{
xen_capabilities_info_t xen_caps = "";
xen_platform_parameters_t xen_params;
-
if (xc_version(xc_handle, XENVER_platform_parameters, &xen_params) != 0)
return 0;
@@ -72,8 +71,7 @@ static int get_platform_info(int xc_handle, uint32_t dom,
if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0)
return 0;
- if (xc_memory_op(xc_handle, XENMEM_maximum_ram_page, max_mfn) != 0)
- return 0;
+ *max_mfn = xc_memory_op(xc_handle, XENMEM_maximum_ram_page, NULL);
*hvirt_start = xen_params.virt_start;
diff --git a/xen/common/memory.c b/xen/common/memory.c
index ceef1886f6..79d6dca2e3 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -136,6 +136,7 @@ long do_memory_op(int cmd, void *arg)
struct domain *d;
int rc, start_extent, op, flags = 0, preempted = 0;
struct xen_memory_reservation reservation;
+ domid_t domid;
op = cmd & ((1 << START_EXTENT_SHIFT) - 1);
@@ -191,9 +192,26 @@ long do_memory_op(int cmd, void *arg)
break;
case XENMEM_maximum_ram_page:
- if ( put_user(max_page, (unsigned long *)arg) )
+ rc = max_page;
+ break;
+
+ case XENMEM_current_reservation:
+ case XENMEM_maximum_reservation:
+ if ( get_user(domid, (domid_t *)arg) )
return -EFAULT;
- rc = 0;
+
+ if ( likely((domid = (unsigned long)arg) == DOMID_SELF) )
+ d = current->domain;
+ else if ( !IS_PRIV(current->domain) )
+ return -EPERM;
+ else if ( (d = find_domain_by_id(domid)) == NULL )
+ return -ESRCH;
+
+ rc = (op == XENMEM_current_reservation) ? d->tot_pages : d->max_pages;
+
+ if ( unlikely(domid != DOMID_SELF) )
+ put_domain(d);
+
break;
default:
diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index 8a5f70c5b1..767f10ac39 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -9,15 +9,13 @@
#ifndef __XEN_PUBLIC_MEMORY_H__
#define __XEN_PUBLIC_MEMORY_H__
-/* arg == addr of struct xen_memory_reservation. */
+/*
+ * Increase or decrease the specified domain's memory reservation. Returns a
+ * -ve errcode on failure, or the # extents successfully allocated or freed.
+ * arg == addr of struct xen_memory_reservation.
+ */
#define XENMEM_increase_reservation 0
-
-/* arg == addr of struct xen_memory_reservation. */
#define XENMEM_decrease_reservation 1
-
-/* arg == addr of unsigned long. */
-#define XENMEM_maximum_ram_page 2
-
typedef struct xen_memory_reservation {
/*
@@ -47,6 +45,21 @@ typedef struct xen_memory_reservation {
} xen_memory_reservation_t;
+/*
+ * Returns the maximum machine frame number of mapped RAM in this system.
+ * This command always succeeds (it never returns an error code).
+ * arg == NULL.
+ */
+#define XENMEM_maximum_ram_page 2
+
+/*
+ * Returns the current or maximum memory reservation, in pages, of the
+ * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
+ * arg == addr of domid_t.
+ */
+#define XENMEM_current_reservation 3
+#define XENMEM_maximum_reservation 4
+
#endif /* __XEN_PUBLIC_MEMORY_H__ */
/*