aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-06-02 09:23:55 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-06-02 09:23:55 +0000
commit7118797d4e08217a611a9c9039785064e1d6ef33 (patch)
tree7456558a76ebdeb89795ce5a2db50328f39ca998 /xen
parentcc689a5f6a3d4449dc0fcc213c4f811904d77000 (diff)
downloadxen-7118797d4e08217a611a9c9039785064e1d6ef33.tar.gz
xen-7118797d4e08217a611a9c9039785064e1d6ef33.tar.bz2
xen-7118797d4e08217a611a9c9039785064e1d6ef33.zip
bitkeeper revision 1.926 (40bd9cabtHdCYn95rortVN7FyCSxgg)
Clean up dom_mem_op hypercall.
Diffstat (limited to 'xen')
-rw-r--r--xen/common/dom_mem_ops.c50
-rw-r--r--xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h2
-rw-r--r--xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h10
-rw-r--r--xen/include/hypervisor-ifs/dom_mem_ops.h30
-rw-r--r--xen/include/hypervisor-ifs/hypervisor-if.h9
5 files changed, 32 insertions, 69 deletions
diff --git a/xen/common/dom_mem_ops.c b/xen/common/dom_mem_ops.c
index fcc4977bee..97b2ffc0f1 100644
--- a/xen/common/dom_mem_ops.c
+++ b/xen/common/dom_mem_ops.c
@@ -10,20 +10,21 @@
#include <xen/types.h>
#include <xen/lib.h>
#include <xen/mm.h>
-#include <hypervisor-ifs/dom_mem_ops.h>
#include <xen/perfc.h>
#include <xen/sched.h>
#include <xen/event.h>
#include <asm/domain_page.h>
-static long alloc_dom_mem(struct task_struct *p, reservation_increase_t op)
+static long alloc_dom_mem(struct task_struct *p,
+ unsigned long *pages,
+ unsigned long nr_pages)
{
struct pfn_info *page;
unsigned long i;
/* Leave some slack pages; e.g., for the network. */
- if ( unlikely(free_pfns < (op.size + (SLACK_DOMAIN_MEM_KILOBYTES >>
- (PAGE_SHIFT-10)))) )
+ if ( unlikely(free_pfns < (nr_pages + (SLACK_DOMAIN_MEM_KILOBYTES >>
+ (PAGE_SHIFT-10)))) )
{
DPRINTK("Not enough slack: %u %u\n",
free_pfns,
@@ -31,7 +32,7 @@ static long alloc_dom_mem(struct task_struct *p, reservation_increase_t op)
return 0;
}
- for ( i = 0; i < op.size; i++ )
+ for ( i = 0; i < nr_pages; i++ )
{
/* NB. 'alloc_domain_page' does limit-checking on pages per domain. */
if ( unlikely((page = alloc_domain_page(p)) == NULL) )
@@ -41,22 +42,24 @@ static long alloc_dom_mem(struct task_struct *p, reservation_increase_t op)
}
/* Inform the domain of the new page's machine address. */
- if ( unlikely(put_user(page_to_pfn(page), &op.pages[i]) != 0) )
+ if ( unlikely(put_user(page_to_pfn(page), &pages[i]) != 0) )
break;
}
return i;
}
-static long free_dom_mem(struct task_struct *p, reservation_decrease_t op)
+static long free_dom_mem(struct task_struct *p,
+ unsigned long *pages,
+ unsigned long nr_pages)
{
struct pfn_info *page;
unsigned long i, mpfn;
long rc = 0;
- for ( i = 0; i < op.size; i++ )
+ for ( i = 0; i < nr_pages; i++ )
{
- if ( unlikely(get_user(mpfn, &op.pages[i]) != 0) )
+ if ( unlikely(get_user(mpfn, &pages[i]) != 0) )
break;
if ( unlikely(mpfn >= max_page) )
@@ -84,31 +87,16 @@ static long free_dom_mem(struct task_struct *p, reservation_decrease_t op)
put_page(page);
}
- return rc ? rc : op.size;
+ return rc ? rc : nr_pages;
}
-long do_dom_mem_op(dom_mem_op_t *mem_op)
+long do_dom_mem_op(unsigned int op, void *pages, unsigned long nr_pages)
{
- dom_mem_op_t dmop;
- unsigned long ret;
+ if ( op == MEMOP_increase_reservation )
+ return alloc_dom_mem(current, pages, nr_pages);
- if ( copy_from_user(&dmop, mem_op, sizeof(dom_mem_op_t)) )
- return -EFAULT;
+ if ( op == MEMOP_decrease_reservation )
+ return free_dom_mem(current, pages, nr_pages);
- switch ( dmop.op )
- {
- case MEMOP_RESERVATION_INCREASE:
- ret = alloc_dom_mem(current, dmop.u.increase);
- break;
-
- case MEMOP_RESERVATION_DECREASE:
- ret = free_dom_mem(current, dmop.u.decrease);
- break;
-
- default:
- ret = -ENOSYS;
- break;
- }
-
- return ret;
+ return -ENOSYS;
}
diff --git a/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h b/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h
index b1860260e5..e660a0438d 100644
--- a/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h
+++ b/xen/include/hypervisor-ifs/arch-i386/hypervisor-if.h
@@ -66,7 +66,7 @@ typedef struct trap_info_st
{
unsigned char vector; /* exception vector */
unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */
- unsigned short cs; /* code selector */
+ unsigned short cs; /* code selector */
unsigned long address; /* code address */
} trap_info_t;
diff --git a/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h b/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h
index 932efab07d..12cc5f6b1c 100644
--- a/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h
+++ b/xen/include/hypervisor-ifs/arch-x86_64/hypervisor-if.h
@@ -31,9 +31,9 @@
* installing their own GDT.
*/
-#define FLAT_RING3_CS32 0x0823 /* GDT index 260 */
-#define FLAT_RING3_CS64 0x082b /* GDT index 261 */
-#define FLAT_RING3_DS 0x0833 /* GDT index 262 */
+#define FLAT_RING3_CS32 0x0823 /* GDT index 260 */
+#define FLAT_RING3_CS64 0x082b /* GDT index 261 */
+#define FLAT_RING3_DS 0x0833 /* GDT index 262 */
#define FLAT_GUESTOS_DS FLAT_RING3_DS
#define FLAT_GUESTOS_CS FLAT_RING3_CS64
@@ -46,7 +46,7 @@
/* And the trap vector is... */
#define TRAP_INSTR "syscall"
-
+/* The machine->physical mapping table starts at this address, read-only. */
#ifndef machine_to_phys_mapping
#define machine_to_phys_mapping ((unsigned long *)0xffff810000000000ULL)
#endif
@@ -64,7 +64,7 @@ typedef struct trap_info_st
{
unsigned char vector; /* exception vector */
unsigned char flags; /* 0-3: privilege level; 4: clear event enable? */
- unsigned short cs; /* code selector */
+ unsigned short cs; /* code selector */
unsigned long address; /* code address */
} trap_info_t;
diff --git a/xen/include/hypervisor-ifs/dom_mem_ops.h b/xen/include/hypervisor-ifs/dom_mem_ops.h
deleted file mode 100644
index e93a0c4d18..0000000000
--- a/xen/include/hypervisor-ifs/dom_mem_ops.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/******************************************************************************
- * dom_mem_ops.h
- *
- * Guest OS operations dealing with physical memory reservations.
- *
- * Copyright (c) 2003, B Dragovic & K A Fraser.
- */
-
-#define MEMOP_RESERVATION_INCREASE 0
-#define MEMOP_RESERVATION_DECREASE 1
-
-typedef struct reservation_increase {
- unsigned long size;
- unsigned long * pages;
-} reservation_increase_t;
-
-typedef struct reservation_decrease {
- unsigned long size;
- unsigned long * pages;
-} reservation_decrease_t;
-
-typedef struct dom_mem_op
-{
- unsigned int op;
- union
- {
- reservation_increase_t increase;
- reservation_decrease_t decrease;
- } u;
-} dom_mem_op_t;
diff --git a/xen/include/hypervisor-ifs/hypervisor-if.h b/xen/include/hypervisor-ifs/hypervisor-if.h
index efe34e2184..57b9dff13f 100644
--- a/xen/include/hypervisor-ifs/hypervisor-if.h
+++ b/xen/include/hypervisor-ifs/hypervisor-if.h
@@ -56,7 +56,6 @@
*
* Virtual interrupts that a guest OS may receive from the hypervisor.
*/
-
#define VIRQ_BLKDEV 0 /* A block device response has been queued. */
#define VIRQ_TIMER 1 /* A timeout has been updated. */
#define VIRQ_DIE 2 /* OS is about to be killed. Clean up please! */
@@ -169,7 +168,7 @@
/*
- * SCHEDOP_* - Scheduler hypercall operations.
+ * Commands to HYPERVISOR_sched_op().
*/
#define SCHEDOP_yield 0 /* Give up the CPU voluntarily. */
#define SCHEDOP_block 1 /* Block until an event is received. */
@@ -182,6 +181,12 @@
#define CONSOLEIO_write 0
#define CONSOLEIO_read 1
+/*
+ * Commands to HYPERVISOR_dom_mem_op().
+ */
+#define MEMOP_increase_reservation 0
+#define MEMOP_decrease_reservation 1
+
#ifndef __ASSEMBLY__
typedef u64 domid_t;