mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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>
This commit is contained in:
1 parent
7cdf0f6407
commit
9ba9cbdb3f
7 files changed
+46
-27
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+20
-2
@@ -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:
|
||||
|
||||
@@ -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__ */
|
||||
|
||||
/*
|
||||
|
||||