[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] merge?
# HG changeset patch # User cl349@xxxxxxxxxxxxxxxxxxxx # Node ID b043928b08738e714900eef21cd8932934d09c45 # Parent 8fe8a99b1c2a6ea88624546ab625eaa0758e3a17 # Parent 7296ed60874f2fb1af6d961512ab3d76d34c9ebf merge? diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Aug 30 16:15:27 2005 @@ -115,9 +115,9 @@ if (swiotlb) return swiotlb_dma_supported(dev, mask); /* - * By default we'll BUG when an infeasible DMA is requested, and - * request swiotlb=force (see IOMMU_BUG_ON). - */ + * By default we'll BUG when an infeasible DMA is requested, and + * request swiotlb=force (see IOMMU_BUG_ON). + */ return 1; } EXPORT_SYMBOL(dma_supported); diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Tue Aug 30 16:15:27 2005 @@ -55,6 +55,7 @@ #include <asm/io.h> #include <asm-xen/hypervisor.h> #include <asm-xen/xen-public/physdev.h> +#include <asm-xen/xen-public/memory.h> #include "setup_arch_pre.h" #include <bios_ebda.h> @@ -1585,15 +1586,21 @@ (unsigned int *)xen_start_info.mfn_list, xen_start_info.nr_pages * sizeof(unsigned int)); } else { + struct xen_memory_reservation reservation = { + .extent_start = (unsigned long *)xen_start_info.mfn_list + max_pfn, + .nr_extents = xen_start_info.nr_pages - max_pfn, + .extent_order = 0, + .domid = DOMID_SELF + }; + memcpy(phys_to_machine_mapping, (unsigned int *)xen_start_info.mfn_list, max_pfn * sizeof(unsigned int)); /* N.B. below relies on sizeof(int) == sizeof(long). */ - if (HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation, - (unsigned long *)xen_start_info.mfn_list + max_pfn, - xen_start_info.nr_pages - max_pfn, 0) != - (xen_start_info.nr_pages - max_pfn)) BUG(); + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, + &reservation) != + (xen_start_info.nr_pages - max_pfn)); } free_bootmem( __pa(xen_start_info.mfn_list), diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Aug 30 16:15:27 2005 @@ -35,6 +35,7 @@ #include <asm/pgtable.h> #include <asm-xen/hypervisor.h> #include <asm-xen/balloon.h> +#include <asm-xen/xen-public/memory.h> #include <linux/module.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #include <linux/percpu.h> @@ -320,6 +321,12 @@ pmd_t *pmd; pte_t *pte; unsigned long mfn, i, flags; + struct xen_memory_reservation reservation = { + .extent_start = &mfn, + .nr_extents = 1, + .extent_order = 0, + .domid = DOMID_SELF + }; scrub_pages(vstart, 1 << order); @@ -336,13 +343,15 @@ vstart + (i*PAGE_SIZE), __pte_ma(0), 0)); phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = INVALID_P2M_ENTRY; - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, &reservation) != 1); } /* 2. Get a new contiguous memory extent. */ - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1); + reservation.extent_order = order; + reservation.address_bits = 31; /* aacraid limitation */ + BUG_ON(HYPERVISOR_memory_op( + XENMEM_increase_reservation, &reservation) != 1); /* 3. Map the new extent in place of old pages. */ for (i = 0; i < (1<<order); i++) { @@ -367,6 +376,12 @@ pmd_t *pmd; pte_t *pte; unsigned long mfn, i, flags; + struct xen_memory_reservation reservation = { + .extent_start = &mfn, + .nr_extents = 1, + .extent_order = 0, + .domid = DOMID_SELF + }; scrub_pages(vstart, 1 << order); @@ -385,14 +400,14 @@ vstart + (i*PAGE_SIZE), __pte_ma(0), 0)); phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = INVALID_P2M_ENTRY; - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, &reservation) != 1); } /* 2. Map new pages in place of old pages. */ for (i = 0; i < (1<<order); i++) { - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_increase_reservation, &mfn, 1, 0) != 1); + BUG_ON(HYPERVISOR_memory_op( + XENMEM_increase_reservation, &reservation) != 1); BUG_ON(HYPERVISOR_update_va_mapping( vstart + (i*PAGE_SIZE), pfn_pte_ma(mfn, PAGE_KERNEL), 0)); diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Tue Aug 30 16:15:27 2005 @@ -734,9 +734,9 @@ /* Make sure we have a large enough P->M table. */ if (end_pfn > xen_start_info.nr_pages) { phys_to_machine_mapping = alloc_bootmem( - max_pfn * sizeof(u32)); + end_pfn * sizeof(u32)); memset(phys_to_machine_mapping, ~0, - max_pfn * sizeof(u32)); + end_pfn * sizeof(u32)); memcpy(phys_to_machine_mapping, (u32 *)xen_start_info.mfn_list, xen_start_info.nr_pages * sizeof(u32)); @@ -749,11 +749,8 @@ pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE); for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(u32)), j++ ) - { pfn_to_mfn_frame_list[j] = virt_to_mfn(&phys_to_machine_mapping[i]); - } - } #endif diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Tue Aug 30 16:15:27 2005 @@ -466,7 +466,7 @@ return readonly; } -void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) +static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) { long i, j, k; unsigned long paddr; @@ -502,15 +502,16 @@ pte = alloc_low_page(&pte_phys); pte_save = pte; for (k = 0; k < PTRS_PER_PTE; pte++, k++, paddr += PTE_SIZE) { + if ((paddr >= end) || + ((paddr >> PAGE_SHIFT) + >= xen_start_info.nr_pages)) { + __set_pte(pte, __pte(0)); + continue; + } if (make_readonly(paddr)) { __set_pte(pte, __pte(paddr | (_KERNPG_TABLE & ~_PAGE_RW))); continue; - } - if (paddr >= end) { - for (; k < PTRS_PER_PTE; k++, pte++) - __set_pte(pte, __pte(0)); - break; } __set_pte(pte, __pte(paddr | _KERNPG_TABLE)); } diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Tue Aug 30 16:15:27 2005 @@ -44,6 +44,7 @@ #include <asm-xen/xen_proc.h> #include <asm-xen/hypervisor.h> #include <asm-xen/balloon.h> +#include <asm-xen/xen-public/memory.h> #include <asm/pgalloc.h> #include <asm/pgtable.h> #include <asm/uaccess.h> @@ -168,6 +169,11 @@ struct page *page; long credit, debt, rc; void *v; + struct xen_memory_reservation reservation = { + .address_bits = 0, + .extent_order = 0, + .domid = DOMID_SELF + }; down(&balloon_mutex); @@ -180,14 +186,18 @@ goto out; balloon_lock(flags); - rc = HYPERVISOR_dom_mem_op( - MEMOP_increase_reservation, mfn_list, credit, 0); + reservation.extent_start = mfn_list; + reservation.nr_extents = credit; + rc = HYPERVISOR_memory_op( + XENMEM_increase_reservation, &reservation); balloon_unlock(flags); if (rc < credit) { /* We hit the Xen hard limit: reprobe. */ - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation, - mfn_list, rc, 0) != rc); + reservation.extent_start = mfn_list; + reservation.nr_extents = rc; + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, + &reservation) != rc); hard_limit = current_pages + rc - driver_pages; vfree(mfn_list); goto retry; @@ -261,8 +271,10 @@ balloon_append(pfn_to_page(pfn)); } - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation,mfn_list, debt, 0) != debt); + reservation.extent_start = mfn_list; + reservation.nr_extents = debt; + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, &reservation) != debt); current_pages -= debt; } @@ -438,11 +450,17 @@ pte_t *pte, struct page *pte_page, unsigned long addr, void *data) { unsigned long mfn = pte_mfn(*pte); + struct xen_memory_reservation reservation = { + .extent_start = &mfn, + .nr_extents = 1, + .extent_order = 0, + .domid = DOMID_SELF + }; set_pte(pte, __pte_ma(0)); phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] = INVALID_P2M_ENTRY; - BUG_ON(HYPERVISOR_dom_mem_op( - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); + BUG_ON(HYPERVISOR_memory_op( + XENMEM_decrease_reservation, &reservation) != 1); return 0; } diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/netback/netback.c --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Tue Aug 30 16:15:27 2005 @@ -12,6 +12,7 @@ #include "common.h" #include <asm-xen/balloon.h> +#include <asm-xen/xen-public/memory.h> #if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX) #include <asm-xen/xen-public/grant_table.h> @@ -110,10 +111,16 @@ static unsigned long alloc_mfn(void) { unsigned long mfn = 0, flags; + struct xen_memory_reservation reservation = { + .extent_start = mfn_list, + .nr_extents = MAX_MFN_ALLOC, + .extent_order = 0, + .domid = DOMID_SELF + }; spin_lock_irqsave(&mfn_lock, flags); if ( unlikely(alloc_index == 0) ) - alloc_index = HYPERVISOR_dom_mem_op( - MEMOP_increase_reservation, mfn_list, MAX_MFN_ALLOC, 0); + alloc_index = HYPERVISOR_memory_op( + XENMEM_increase_reservation, &reservation); if ( alloc_index != 0 ) mfn = mfn_list[--alloc_index]; spin_unlock_irqrestore(&mfn_lock, flags); @@ -124,11 +131,17 @@ static void free_mfn(unsigned long mfn) { unsigned long flags; + struct xen_memory_reservation reservation = { + .extent_start = &mfn, + .nr_extents = 1, + .extent_order = 0, + .domid = DOMID_SELF + }; spin_lock_irqsave(&mfn_lock, flags); if ( alloc_index != MAX_MFN_ALLOC ) mfn_list[alloc_index++] = mfn; - else if ( HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, - &mfn, 1, 0) != 1 ) + else if ( HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation) + != 1 ) BUG(); spin_unlock_irqrestore(&mfn_lock, flags); } diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Aug 30 16:15:27 2005 @@ -50,6 +50,7 @@ #include <asm-xen/evtchn.h> #include <asm-xen/xenbus.h> #include <asm-xen/xen-public/io/netif.h> +#include <asm-xen/xen-public/memory.h> #include <asm-xen/balloon.h> #include <asm/page.h> #include <asm/uaccess.h> @@ -328,6 +329,7 @@ struct sk_buff *skb; int i, batch_target; NETIF_RING_IDX req_prod = np->rx->req_prod; + struct xen_memory_reservation reservation; #ifdef CONFIG_XEN_NETDEV_GRANT_RX int ref; #endif @@ -388,12 +390,15 @@ rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL; /* Give away a batch of pages. */ - rx_mcl[i].op = __HYPERVISOR_dom_mem_op; - rx_mcl[i].args[0] = MEMOP_decrease_reservation; - rx_mcl[i].args[1] = (unsigned long)rx_pfn_array; - rx_mcl[i].args[2] = (unsigned long)i; - rx_mcl[i].args[3] = 0; - rx_mcl[i].args[4] = DOMID_SELF; + rx_mcl[i].op = __HYPERVISOR_memory_op; + rx_mcl[i].args[0] = XENMEM_decrease_reservation; + rx_mcl[i].args[1] = (unsigned long)&reservation; + + reservation.extent_start = rx_pfn_array; + reservation.nr_extents = i; + reservation.extent_order = 0; + reservation.address_bits = 0; + reservation.domid = DOMID_SELF; /* Tell the ballon driver what is going on. */ balloon_update_driver_allowance(i); @@ -401,7 +406,7 @@ /* Zap PTEs and give away pages in one big multicall. */ (void)HYPERVISOR_multicall(rx_mcl, i+1); - /* Check return status of HYPERVISOR_dom_mem_op(). */ + /* Check return status of HYPERVISOR_memory_op(). */ if (unlikely(rx_mcl[i].result != i)) panic("Unable to reduce memory reservation\n"); diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Tue Aug 30 16:15:27 2005 @@ -66,7 +66,7 @@ { long ign1, ign2, ign3; __asm__ __volatile__ ( - "movq %5,%%r10; movq %6,%%r8;" TRAP_INSTR + "movq %8,%%r10; movq %9,%%r8;" TRAP_INSTR : "=a" (ret), "=D" (ign1), "=S" (ign2), "=d" (ign3) : "0" ((unsigned long)hypercall.op), "1" ((unsigned long)hypercall.arg[0]), diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 30 16:15:27 2005 @@ -209,6 +209,7 @@ { return xenbus_register_driver(drv, &xenbus_frontend); } +EXPORT_SYMBOL(xenbus_register_device); int xenbus_register_backend(struct xenbus_driver *drv) { diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Tue Aug 30 16:15:27 2005 @@ -246,6 +246,7 @@ { return xs_single(XS_READ, join(dir, node), len); } +EXPORT_SYMBOL(xenbus_read); /* Write the value of a single file. * Returns -err on failure. createflags can be 0, O_CREAT, or O_CREAT|O_EXCL. @@ -298,6 +299,7 @@ { return xs_error(xs_single(XS_TRANSACTION_START, subtree, NULL)); } +EXPORT_SYMBOL(xenbus_transaction_start); /* End a transaction. * If abandon is true, transaction is discarded instead of committed. @@ -312,6 +314,7 @@ strcpy(abortstr, "T"); return xs_error(xs_single(XS_TRANSACTION_END, abortstr, NULL)); } +EXPORT_SYMBOL(xenbus_transaction_end); /* Single read and scanf: returns -errno or num scanned. */ int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...) @@ -333,6 +336,7 @@ return -ERANGE; return ret; } +EXPORT_SYMBOL(xenbus_scanf); /* Single printf and write: returns -errno or 0. */ int xenbus_printf(const char *dir, const char *node, const char *fmt, ...) @@ -348,6 +352,7 @@ BUG_ON(ret > sizeof(printf_buffer)-1); return xenbus_write(dir, node, printf_buffer, O_CREAT); } +EXPORT_SYMBOL(xenbus_printf); /* Report a (negative) errno into the store, with explanation. */ void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...) @@ -369,6 +374,7 @@ printk("xenbus: failed to write error node for %s (%s)\n", dev->nodename, printf_buffer); } +EXPORT_SYMBOL(xenbus_dev_error); /* Clear any error. */ void xenbus_dev_ok(struct xenbus_device *dev) @@ -381,6 +387,7 @@ dev->has_error = 0; } } +EXPORT_SYMBOL(xenbus_dev_ok); /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */ int xenbus_gather(const char *dir, ...) @@ -410,6 +417,7 @@ va_end(ap); return ret; } +EXPORT_SYMBOL(xenbus_gather); static int xs_watch(const char *path, const char *token) { @@ -482,6 +490,7 @@ list_add(&watch->list, &watches); return err; } +EXPORT_SYMBOL(register_xenbus_watch); void unregister_xenbus_watch(struct xenbus_watch *watch) { @@ -499,6 +508,7 @@ "XENBUS Failed to release watch %s: %i\n", watch->node, err); } +EXPORT_SYMBOL(unregister_xenbus_watch); /* Re-register callbacks to all watches. */ void reregister_xenbus_watches(void) diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Tue Aug 30 16:15:27 2005 @@ -236,12 +236,10 @@ } static inline int -HYPERVISOR_dom_mem_op( - unsigned int op, unsigned long *extent_list, - unsigned long nr_extents, unsigned int extent_order) -{ - return _hypercall5(int, dom_mem_op, op, extent_list, - nr_extents, extent_order, DOMID_SELF); +HYPERVISOR_memory_op( + unsigned int cmd, void *arg) +{ + return _hypercall2(int, memory_op, cmd, arg); } static inline int diff -r 8fe8a99b1c2a -r b043928b0873 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h Tue Aug 30 16:14:53 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h Tue Aug 30 16:15:27 2005 @@ -231,12 +231,10 @@ } static inline int -HYPERVISOR_dom_mem_op( - unsigned int op, unsigned long *extent_list, - unsigned long nr_extents, unsigned int extent_order) -{ - return _hypercall5(int, dom_mem_op, op, extent_list, - nr_extents, extent_order, DOMID_SELF); +HYPERVISOR_memory_op( + unsigned int cmd, void *arg) +{ + return _hypercall2(int, memory_op, cmd, arg); } static inline int diff -r 8fe8a99b1c2a -r b043928b0873 tools/Makefile --- a/tools/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/Makefile Tue Aug 30 16:15:27 2005 @@ -7,14 +7,18 @@ SUBDIRS += misc SUBDIRS += examples SUBDIRS += xentrace -SUBDIRS += python SUBDIRS += xcs SUBDIRS += xcutils -#SUBDIRS += pygrub SUBDIRS += firmware SUBDIRS += security SUBDIRS += console SUBDIRS += xenstat + +# These don't cross-compile +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) +SUBDIRS += python +#SUBDIRS += pygrub +endif .PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean diff -r 8fe8a99b1c2a -r b043928b0873 tools/console/Makefile --- a/tools/console/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/console/Makefile Tue Aug 30 16:15:27 2005 @@ -9,8 +9,7 @@ INSTALL_PROG = $(INSTALL) -m0755 INSTALL_DIR = $(INSTALL) -d -m0755 -CC = gcc -CFLAGS = -Wall -Werror -g3 +CFLAGS += -Wall -Werror -g3 CFLAGS += -I $(XEN_XCS) CFLAGS += -I $(XEN_LIBXC) diff -r 8fe8a99b1c2a -r b043928b0873 tools/examples/Makefile --- a/tools/examples/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/examples/Makefile Tue Aug 30 16:15:27 2005 @@ -1,3 +1,6 @@ +XEN_ROOT = ../../ +include $(XEN_ROOT)/tools/Rules.mk + INSTALL = install INSTALL_DIR = $(INSTALL) -d -m0755 INSTALL_PROG = $(INSTALL) -m0755 diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_core.c --- a/tools/libxc/xc_core.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_core.c Tue Aug 30 16:15:27 2005 @@ -2,6 +2,7 @@ #define ELFSIZE 32 #include "xc_elf.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> /* number of pages to write at a time */ diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_domain.c Tue Aug 30 16:15:27 2005 @@ -7,6 +7,7 @@ */ #include "xc_private.h" +#include <xen/memory.h> int xc_domain_create(int xc_handle, u32 ssidref, @@ -265,9 +266,13 @@ { int err; unsigned int npages = mem_kb / (PAGE_SIZE/1024); - - err = xc_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL, - npages, 0, domid); + struct xen_memory_reservation reservation = { + .nr_extents = npages, + .extent_order = 0, + .domid = domid + }; + + err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation); if (err == npages) return 0; diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_linux_build.c Tue Aug 30 16:15:27 2005 @@ -17,6 +17,7 @@ #include "xc_elf.h" #include "xc_aout9.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #if defined(__i386__) diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_linux_restore.c --- a/tools/libxc/xc_linux_restore.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_linux_restore.c Tue Aug 30 16:15:27 2005 @@ -8,11 +8,10 @@ #include <stdlib.h> #include <unistd.h> - #include "xg_private.h" #include <xenctrl.h> - #include <xen/linux/suspend.h> +#include <xen/memory.h> #define MAX_BATCH_SIZE 1024 @@ -411,7 +410,8 @@ /* Get the list of PFNs that are not in the psuedo-phys map */ { - unsigned int count, *pfntab; + unsigned int count; + unsigned long *pfntab; int rc; if ( read_exact(io_fd, &count, sizeof(count)) != sizeof(count) ) @@ -443,9 +443,15 @@ if ( count > 0 ) { - if ( (rc = xc_dom_mem_op( xc_handle, - MEMOP_decrease_reservation, - pfntab, count, 0, dom )) <0 ) + struct xen_memory_reservation reservation = { + .extent_start = pfntab, + .nr_extents = count, + .extent_order = 0, + .domid = dom + }; + if ( (rc = xc_memory_op(xc_handle, + XENMEM_decrease_reservation, + &reservation)) != count ) { ERR("Could not decrease reservation : %d",rc); goto out; diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_private.c --- a/tools/libxc/xc_private.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_private.c Tue Aug 30 16:15:27 2005 @@ -6,6 +6,7 @@ #include <zlib.h> #include "xc_private.h" +#include <xen/memory.h> void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot, unsigned long *arr, int num ) @@ -187,28 +188,43 @@ return flush_mmu_updates(xc_handle, mmu); } -int xc_dom_mem_op(int xc_handle, - unsigned int memop, - unsigned int *extent_list, - unsigned int nr_extents, - unsigned int extent_order, - domid_t domid) +int xc_memory_op(int xc_handle, + int cmd, + void *arg) { privcmd_hypercall_t hypercall; + struct xen_memory_reservation *reservation = arg; long ret = -EINVAL; - hypercall.op = __HYPERVISOR_dom_mem_op; - hypercall.arg[0] = (unsigned long)memop; - hypercall.arg[1] = (unsigned long)extent_list; - hypercall.arg[2] = (unsigned long)nr_extents; - hypercall.arg[3] = (unsigned long)extent_order; - hypercall.arg[4] = (unsigned long)domid; - - if ( (extent_list != NULL) && - (mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0) ) - { - PERROR("Could not lock memory for Xen hypercall"); - goto out1; + hypercall.op = __HYPERVISOR_memory_op; + hypercall.arg[0] = (unsigned long)cmd; + hypercall.arg[1] = (unsigned long)arg; + + switch ( cmd ) + { + case XENMEM_increase_reservation: + case XENMEM_decrease_reservation: + if ( mlock(reservation, sizeof(*reservation)) != 0 ) + { + PERROR("Could not mlock"); + goto out1; + } + if ( (reservation->extent_start != NULL) && + (mlock(reservation->extent_start, + reservation->nr_extents * sizeof(unsigned long)) != 0) ) + { + PERROR("Could not mlock"); + safe_munlock(reservation, sizeof(*reservation)); + goto out1; + } + break; + case XENMEM_maximum_ram_page: + if ( mlock(arg, sizeof(unsigned long)) != 0 ) + { + PERROR("Could not mlock"); + goto out1; + } + break; } if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) @@ -217,8 +233,19 @@ " rebuild the user-space tool set?\n",ret,errno); } - if ( extent_list != NULL ) - safe_munlock(extent_list, nr_extents*sizeof(unsigned long)); + switch ( cmd ) + { + case XENMEM_increase_reservation: + case XENMEM_decrease_reservation: + safe_munlock(reservation, sizeof(*reservation)); + if ( reservation->extent_start != NULL ) + 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: return ret; diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xc_vmx_build.c --- a/tools/libxc/xc_vmx_build.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xc_vmx_build.c Tue Aug 30 16:15:27 2005 @@ -7,6 +7,7 @@ #define ELFSIZE 32 #include "xc_elf.h" #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #include <xen/io/ioreq.h> #include "linux_boot_params.h" diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xenctrl.h Tue Aug 30 16:15:27 2005 @@ -430,9 +430,7 @@ int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops, domid_t dom); -int xc_dom_mem_op(int xc_handle, unsigned int memop, unsigned int *extent_list, - unsigned int nr_extents, unsigned int extent_order, - domid_t domid); +int xc_memory_op(int xc_handle, int cmd, void *arg); int xc_get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr); diff -r 8fe8a99b1c2a -r b043928b0873 tools/libxc/xg_private.c --- a/tools/libxc/xg_private.c Tue Aug 30 16:14:53 2005 +++ b/tools/libxc/xg_private.c Tue Aug 30 16:15:27 2005 @@ -5,6 +5,7 @@ */ #include <stdlib.h> +#include <unistd.h> #include <zlib.h> #include "xg_private.h" diff -r 8fe8a99b1c2a -r b043928b0873 tools/misc/mbootpack/Makefile --- a/tools/misc/mbootpack/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/misc/mbootpack/Makefile Tue Aug 30 16:15:27 2005 @@ -20,8 +20,7 @@ INCS := -I. -I- DEFS := LDFLAGS := -CC := gcc -CFLAGS := -Wall -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format +CFLAGS := -Wall -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format CFLAGS += -Wmissing-prototypes #CFLAGS += -pipe -g -O0 -Wcast-align CFLAGS += -pipe -O3 @@ -34,7 +33,7 @@ DEPS = .*.d mbootpack: $(OBJS) - $(CC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) + $(HOSTCC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) clean: $(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c @@ -48,7 +47,7 @@ $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@ bin2c: bin2c.o - $(CC) -o $@ $^ + $(HOSTCC) -o $@ $^ bzimage_header.c: bootsect setup bin2c ./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c @@ -58,10 +57,10 @@ @ %.o: %.S - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ %.o: %.c - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ .PHONY: all clean gdb .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS) diff -r 8fe8a99b1c2a -r b043928b0873 tools/misc/mbootpack/buildimage.c --- a/tools/misc/mbootpack/buildimage.c Tue Aug 30 16:14:53 2005 +++ b/tools/misc/mbootpack/buildimage.c Tue Aug 30 16:15:27 2005 @@ -42,6 +42,7 @@ #include "mbootpack.h" #include "mb_header.h" + /* We will build an image that a bzImage-capable bootloader will load like * this: @@ -105,8 +106,8 @@ section_t *s; /* Patch the kernel and mbi addresses into the setup code */ - *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = entry; - *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = mbi; + *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry); + *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi); if (!quiet) printf("Kernel entry is %p, MBI is %p.\n", entry, mbi); /* Write out header and trampoline */ diff -r 8fe8a99b1c2a -r b043928b0873 tools/misc/mbootpack/mbootpack.c --- a/tools/misc/mbootpack/mbootpack.c Tue Aug 30 16:14:53 2005 +++ b/tools/misc/mbootpack/mbootpack.c Tue Aug 30 16:15:27 2005 @@ -252,20 +252,21 @@ for (i = 0; i <= MIN(len - 12, MULTIBOOT_SEARCH - 12); i += 4) { mbh = (struct multiboot_header *)(headerbuf + i); - if (mbh->magic != MULTIBOOT_MAGIC - || ((mbh->magic+mbh->flags+mbh->checksum) & 0xffffffff)) + if (eswap(mbh->magic) != MULTIBOOT_MAGIC + || ((eswap(mbh->magic)+eswap(mbh->flags)+eswap(mbh->checksum)) + & 0xffffffff)) { /* Not a multiboot header */ continue; } - if (mbh->flags & MULTIBOOT_UNSUPPORTED) { + if (eswap(mbh->flags) & MULTIBOOT_UNSUPPORTED) { /* Requires options we don't support */ printf("Fatal: found a multiboot header, but it " "requires multiboot options that I\n" "don't understand. Sorry.\n"); exit(1); } - if (mbh->flags & MULTIBOOT_VIDEO_MODE) { + if (eswap(mbh->flags) & MULTIBOOT_VIDEO_MODE) { /* Asked for screen mode information */ /* XXX carry on regardless */ printf("Warning: found a multiboot header which asks " @@ -275,22 +276,22 @@ } /* This kernel will do: place and load it */ - if (mbh->flags & MULTIBOOT_AOUT_KLUDGE) { + if (eswap(mbh->flags) & MULTIBOOT_AOUT_KLUDGE) { /* Load using the offsets in the multiboot header */ if(!quiet) printf("Loading %s using multiboot header.\n", filename); /* How much is there? */ - start = mbh->load_addr; - if (mbh->load_end_addr != 0) - loadsize = mbh->load_end_addr - mbh->load_addr; + start = eswap(mbh->load_addr); + if (eswap(mbh->load_end_addr) != 0) + loadsize = eswap(mbh->load_end_addr) - eswap(mbh->load_addr); else loadsize = sb.st_size; /* How much memory will it take up? */ - if (mbh->bss_end_addr != 0) - size = mbh->bss_end_addr - mbh->load_addr; + if (eswap(mbh->bss_end_addr) != 0) + size = eswap(mbh->bss_end_addr) - eswap(mbh->load_addr); else size = loadsize; @@ -335,32 +336,34 @@ /* Done. */ if (!quiet) printf("Loaded kernel from %s\n", filename); - return mbh->entry_addr; + return eswap(mbh->entry_addr); } else { /* Now look for an ELF32 header */ ehdr = (Elf32_Ehdr *)headerbuf; - if (*(unsigned long *)ehdr != 0x464c457f + if (*(unsigned long *)ehdr != eswap(0x464c457f) || ehdr->e_ident[EI_DATA] != ELFDATA2LSB || ehdr->e_ident[EI_CLASS] != ELFCLASS32 - || ehdr->e_machine != EM_386) + || eswap(ehdr->e_machine) != EM_386) { printf("Fatal: kernel has neither ELF32/x86 nor multiboot load" " headers.\n"); exit(1); } - if (ehdr->e_phoff + ehdr->e_phnum*sizeof(*phdr) > HEADERBUF_SIZE) { + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof(*phdr) + > HEADERBUF_SIZE) { /* Don't expect this will happen with sane kernels */ printf("Fatal: too much ELF for me. Try increasing " "HEADERBUF_SIZE in mbootpack.\n"); exit(1); } - if (ehdr->e_phoff + ehdr->e_phnum*sizeof (*phdr) > len) { + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof (*phdr) + > len) { printf("Fatal: malformed ELF header overruns EOF.\n"); exit(1); } - if (ehdr->e_phnum <= 0) { + if (eswap(ehdr->e_phnum) <= 0) { printf("Fatal: ELF kernel has no program headers.\n"); exit(1); } @@ -368,22 +371,22 @@ if(!quiet) printf("Loading %s using ELF header.\n", filename); - if (ehdr->e_type != ET_EXEC - || ehdr->e_version != EV_CURRENT - || ehdr->e_phentsize != sizeof (Elf32_Phdr)) { + if (eswap(ehdr->e_type) != ET_EXEC + || eswap(ehdr->e_version) != EV_CURRENT + || eswap(ehdr->e_phentsize) != sizeof (Elf32_Phdr)) { printf("Warning: funny-looking ELF header.\n"); } - phdr = (Elf32_Phdr *)(headerbuf + ehdr->e_phoff); + phdr = (Elf32_Phdr *)(headerbuf + eswap(ehdr->e_phoff)); /* Obey the program headers to load the kernel */ - for(i = 0; i < ehdr->e_phnum; i++) { - - start = phdr[i].p_paddr; - size = phdr[i].p_memsz; - if (phdr[i].p_type != PT_LOAD) + for(i = 0; i < eswap(ehdr->e_phnum); i++) { + + start = eswap(phdr[i].p_paddr); + size = eswap(phdr[i].p_memsz); + if (eswap(phdr[i].p_type) != PT_LOAD) loadsize = 0; else - loadsize = MIN((long int)phdr[i].p_filesz, size); + loadsize = MIN((long int)eswap(phdr[i].p_filesz), size); if ((buffer = malloc(size)) == NULL) { printf("Fatal: malloc() for kernel load failed: %s\n", @@ -396,7 +399,7 @@ /* Load section from file */ if (loadsize > 0) { - if (fseek(fp, phdr[i].p_offset, SEEK_SET) != 0) { + if (fseek(fp, eswap(phdr[i].p_offset), SEEK_SET) != 0) { printf("Fatal: seek failed in %s\n", strerror(errno)); exit(1); @@ -452,7 +455,7 @@ /* Done! */ if (!quiet) printf("Loaded kernel from %s\n", filename); - return ehdr->e_entry; + return eswap(ehdr->e_entry); } } @@ -568,12 +571,12 @@ /* Command line */ p = (char *)(mbi + 1); sprintf(p, "%s %s", imagename, command_line); - mbi->cmdline = ((address_t)p) + mbi_reloc_offset; + mbi->cmdline = eswap(((address_t)p) + mbi_reloc_offset); p += command_line_len; /* Bootloader ID */ sprintf(p, version_string); - mbi->boot_loader_name = ((address_t)p) + mbi_reloc_offset; + mbi->boot_loader_name = eswap(((address_t)p) + mbi_reloc_offset); p += strlen(version_string) + 1; /* Next is space for the module command lines */ @@ -582,17 +585,17 @@ /* Last come the module info structs */ modp = (struct mod_list *) ((((address_t)p + mod_command_line_space) + 3) & ~3); - mbi->mods_count = modules; - mbi->mods_addr = ((address_t)modp) + mbi_reloc_offset; + mbi->mods_count = eswap(modules); + mbi->mods_addr = eswap(((address_t)modp) + mbi_reloc_offset); /* Memory information will be added at boot time, by setup.S * or trampoline.S. */ - mbi->flags = MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME; + mbi->flags = eswap(MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME); /* Load the modules */ if (modules) { - mbi->flags |= MB_INFO_MODS; + mbi->flags = eswap(eswap(mbi->flags) | MB_INFO_MODS); /* Go back and parse the module command lines */ optind = opterr = 1; @@ -652,10 +655,10 @@ if (p != NULL) *p = ' '; /* Fill in the module info struct */ - modp->mod_start = start; - modp->mod_end = start + size; - modp->cmdline = (address_t)mod_clp + mbi_reloc_offset; - modp->pad = 0; + modp->mod_start = eswap(start); + modp->mod_end = eswap(start + size); + modp->cmdline = eswap((address_t)mod_clp + mbi_reloc_offset); + modp->pad = eswap(0); modp++; /* Store the module command line */ diff -r 8fe8a99b1c2a -r b043928b0873 tools/misc/mbootpack/mbootpack.h --- a/tools/misc/mbootpack/mbootpack.h Tue Aug 30 16:14:53 2005 +++ b/tools/misc/mbootpack/mbootpack.h Tue Aug 30 16:15:27 2005 @@ -31,6 +31,24 @@ #undef NDEBUG #include <stdio.h> + +#include <endian.h> +#include <byteswap.h> +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define eswap(x) (x) +#else +#define eswap(x) \ + ({ \ + typeof(x) y = (x); \ + switch(sizeof(y)) \ + { \ + case 2: y = __bswap_16(y); break; \ + case 4: y = __bswap_32(y); break; \ + case 8: y = __bswap_64(y); break; \ + } \ + y; \ + }) +#endif /* Flags */ extern int quiet; diff -r 8fe8a99b1c2a -r b043928b0873 tools/xcs/Makefile --- a/tools/xcs/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/xcs/Makefile Tue Aug 30 16:15:27 2005 @@ -10,8 +10,7 @@ INSTALL_PROG = $(INSTALL) -m0755 INSTALL_DIR = $(INSTALL) -d -m0755 -CC = gcc -CFLAGS = -Wall -Werror -g3 -D _XOPEN_SOURCE=600 +CFLAGS += -Wall -Werror -g3 -D _XOPEN_SOURCE=600 CFLAGS += -I $(XEN_XC) CFLAGS += -I $(XEN_LIBXC) diff -r 8fe8a99b1c2a -r b043928b0873 tools/xcutils/Makefile --- a/tools/xcutils/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/xcutils/Makefile Tue Aug 30 16:15:27 2005 @@ -18,8 +18,6 @@ PROGRAMS_INSTALL_DIR = /usr/libexec/xen INCLUDES += -I $(XEN_LIBXC) - -CC := gcc CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing CFLAGS += $(INCLUDES) diff -r 8fe8a99b1c2a -r b043928b0873 tools/xenstat/Makefile --- a/tools/xenstat/Makefile Tue Aug 30 16:14:53 2005 +++ b/tools/xenstat/Makefile Tue Aug 30 16:15:27 2005 @@ -3,7 +3,11 @@ SUBDIRS := SUBDIRS += libxenstat + +# This doesn't cross-compile (cross-compile environments rarely have curses) +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) SUBDIRS += xentop +endif .PHONY: all install clean diff -r 8fe8a99b1c2a -r b043928b0873 xen/arch/x86/x86_32/entry.S --- a/xen/arch/x86/x86_32/entry.S Tue Aug 30 16:14:53 2005 +++ b/xen/arch/x86/x86_32/entry.S Tue Aug 30 16:15:27 2005 @@ -790,7 +790,7 @@ .long do_get_debugreg .long do_update_descriptor /* 10 */ .long do_ni_hypercall - .long do_dom_mem_op + .long do_memory_op .long do_multicall .long do_update_va_mapping .long do_set_timer_op /* 15 */ @@ -823,7 +823,7 @@ .byte 1 /* do_get_debugreg */ .byte 4 /* do_update_descriptor */ /* 10 */ .byte 0 /* do_ni_hypercall */ - .byte 5 /* do_dom_mem_op */ + .byte 2 /* do_memory_op */ .byte 2 /* do_multicall */ .byte 4 /* do_update_va_mapping */ .byte 2 /* do_set_timer_op */ /* 15 */ diff -r 8fe8a99b1c2a -r b043928b0873 xen/arch/x86/x86_64/entry.S --- a/xen/arch/x86/x86_64/entry.S Tue Aug 30 16:14:53 2005 +++ b/xen/arch/x86/x86_64/entry.S Tue Aug 30 16:15:27 2005 @@ -616,7 +616,7 @@ .quad do_get_debugreg .quad do_update_descriptor /* 10 */ .quad do_ni_hypercall - .quad do_dom_mem_op + .quad do_memory_op .quad do_multicall .quad do_update_va_mapping .quad do_set_timer_op /* 15 */ @@ -649,7 +649,7 @@ .byte 1 /* do_get_debugreg */ .byte 2 /* do_update_descriptor */ /* 10 */ .byte 0 /* do_ni_hypercall */ - .byte 5 /* do_dom_mem_op */ + .byte 2 /* do_memory_op */ .byte 2 /* do_multicall */ .byte 3 /* do_update_va_mapping */ .byte 1 /* do_set_timer_op */ /* 15 */ diff -r 8fe8a99b1c2a -r b043928b0873 xen/common/Makefile --- a/xen/common/Makefile Tue Aug 30 16:14:53 2005 +++ b/xen/common/Makefile Tue Aug 30 16:15:27 2005 @@ -2,7 +2,6 @@ include $(BASEDIR)/Rules.mk ifeq ($(TARGET_ARCH),ia64) -#OBJS := $(subst dom_mem_ops.o,,$(OBJS)) OBJS := $(subst grant_table.o,,$(OBJS)) endif diff -r 8fe8a99b1c2a -r b043928b0873 xen/common/page_alloc.c --- a/xen/common/page_alloc.c Tue Aug 30 16:14:53 2005 +++ b/xen/common/page_alloc.c Tue Aug 30 16:15:27 2005 @@ -216,7 +216,7 @@ #define NR_ZONES 3 -#define MAX_DMADOM_PFN 0xFFFFF +#define MAX_DMADOM_PFN 0x7FFFF /* 31 addressable bits */ #define pfn_dom_zone_type(_pfn) \ (((_pfn) <= MAX_DMADOM_PFN) ? MEMZONE_DMADOM : MEMZONE_DOM) diff -r 8fe8a99b1c2a -r b043928b0873 xen/include/public/xen.h --- a/xen/include/public/xen.h Tue Aug 30 16:14:53 2005 +++ b/xen/include/public/xen.h Tue Aug 30 16:15:27 2005 @@ -42,7 +42,7 @@ #define __HYPERVISOR_set_debugreg 8 #define __HYPERVISOR_get_debugreg 9 #define __HYPERVISOR_update_descriptor 10 -#define __HYPERVISOR_dom_mem_op 12 +#define __HYPERVISOR_memory_op 12 #define __HYPERVISOR_multicall 13 #define __HYPERVISOR_update_va_mapping 14 #define __HYPERVISOR_set_timer_op 15 @@ -223,12 +223,6 @@ */ #define CONSOLEIO_write 0 #define CONSOLEIO_read 1 - -/* - * Commands to HYPERVISOR_dom_mem_op(). - */ -#define MEMOP_increase_reservation 0 -#define MEMOP_decrease_reservation 1 /* * Commands to HYPERVISOR_vm_assist(). diff -r 8fe8a99b1c2a -r b043928b0873 xen/common/memory.c --- /dev/null Tue Aug 30 16:14:53 2005 +++ b/xen/common/memory.c Tue Aug 30 16:15:27 2005 @@ -0,0 +1,205 @@ +/****************************************************************************** + * memory.c + * + * Code to handle memory-related requests. + * + * Copyright (c) 2003-2004, B Dragovic + * Copyright (c) 2003-2005, K A Fraser + */ + +#include <xen/config.h> +#include <xen/types.h> +#include <xen/lib.h> +#include <xen/mm.h> +#include <xen/perfc.h> +#include <xen/sched.h> +#include <xen/event.h> +#include <xen/shadow.h> +#include <asm/current.h> +#include <asm/hardirq.h> +#include <public/memory.h> + +static long +increase_reservation( + struct domain *d, + unsigned long *extent_list, + unsigned int nr_extents, + unsigned int extent_order, + unsigned int flags) +{ + struct pfn_info *page; + unsigned long i; + + if ( (extent_list != NULL) + && !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) + return 0; + + if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) ) + { + DPRINTK("Only I/O-capable domains may allocate > order-0 memory.\n"); + return 0; + } + + for ( i = 0; i < nr_extents; i++ ) + { + if ( hypercall_preempt_check() ) + return i; + + if ( unlikely((page = alloc_domheap_pages( + d, extent_order, flags)) == NULL) ) + { + DPRINTK("Could not allocate a frame\n"); + return i; + } + + /* Inform the domain of the new page's machine address. */ + if ( (extent_list != NULL) + && (__put_user(page_to_pfn(page), &extent_list[i]) != 0) ) + return i; + } + + return nr_extents; +} + +static long +decrease_reservation( + struct domain *d, + unsigned long *extent_list, + unsigned int nr_extents, + unsigned int extent_order, + unsigned int flags) +{ + struct pfn_info *page; + unsigned long i, j, mpfn; + + if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) + return 0; + + for ( i = 0; i < nr_extents; i++ ) + { + if ( hypercall_preempt_check() ) + return i; + + if ( unlikely(__get_user(mpfn, &extent_list[i]) != 0) ) + return i; + + for ( j = 0; j < (1 << extent_order); j++ ) + { + if ( unlikely((mpfn + j) >= max_page) ) + { + DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", + d->domain_id, mpfn + j, max_page); + return i; + } + + page = &frame_table[mpfn + j]; + if ( unlikely(!get_page(page, d)) ) + { + DPRINTK("Bad page free for domain %u\n", d->domain_id); + return i; + } + + if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) + put_page_and_type(page); + + if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) + put_page(page); + + shadow_sync_and_drop_references(d, page); + + put_page(page); + } + } + + return nr_extents; +} + +/* + * To allow safe resume of do_memory_op() after preemption, we need to know + * at what point in the page list to resume. For this purpose I steal the + * high-order bits of the @cmd parameter, which are otherwise unused and zero. + */ +#define START_EXTENT_SHIFT 4 /* cmd[:4] == start_extent */ + +long do_memory_op(int cmd, void *arg) +{ + struct domain *d; + int rc, start_extent, op, flags = 0; + struct xen_memory_reservation reservation; + + op = cmd & ((1 << START_EXTENT_SHIFT) - 1); + + switch ( op ) + { + case XENMEM_increase_reservation: + case XENMEM_decrease_reservation: + if ( copy_from_user(&reservation, arg, sizeof(reservation)) ) + return -EFAULT; + + start_extent = cmd >> START_EXTENT_SHIFT; + if ( unlikely(start_extent > reservation.nr_extents) ) + return -EINVAL; + + if ( reservation.extent_start != NULL ) + reservation.extent_start += start_extent; + reservation.nr_extents -= start_extent; + + if ( unlikely(reservation.address_bits != 0) + && (reservation.address_bits > (get_order(max_page)+PAGE_SHIFT)) ) + { + if ( reservation.address_bits < 31 ) + return -ENOMEM; + flags = ALLOC_DOM_DMA; + } + + if ( likely(reservation.domid == DOMID_SELF) ) + d = current->domain; + else if ( !IS_PRIV(current->domain) ) + return -EPERM; + else if ( (d = find_domain_by_id(reservation.domid)) == NULL ) + return -ESRCH; + + rc = ((op == XENMEM_increase_reservation) ? + increase_reservation : decrease_reservation)( + d, + reservation.extent_start, + reservation.nr_extents, + reservation.extent_order, + flags); + + if ( unlikely(reservation.domid != DOMID_SELF) ) + put_domain(d); + + rc += start_extent; + + if ( (rc != reservation.nr_extents) && hypercall_preempt_check() ) + return hypercall2_create_continuation( + __HYPERVISOR_memory_op, + op | (rc << START_EXTENT_SHIFT), + arg); + + break; + + case XENMEM_maximum_ram_page: + if ( put_user(max_page, (unsigned long *)arg) ) + return -EFAULT; + rc = -ENOSYS; + break; + + default: + rc = -ENOSYS; + break; + } + + return rc; +} + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff -r 8fe8a99b1c2a -r b043928b0873 xen/include/public/memory.h --- /dev/null Tue Aug 30 16:14:53 2005 +++ b/xen/include/public/memory.h Tue Aug 30 16:15:27 2005 @@ -0,0 +1,50 @@ +/****************************************************************************** + * memory.h + * + * Memory reservation and information. + * + * Copyright (c) 2005, Keir Fraser <keir@xxxxxxxxxxxxx> + */ + +#ifndef __XEN_PUBLIC_MEMORY_H__ +#define __XEN_PUBLIC_MEMORY_H__ + +/* 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 { + + /* + * MFN bases of extents to free (XENMEM_decrease_reservation). + * MFN bases of extents that were allocated (XENMEM_increase_reservation). + */ + unsigned long *extent_start; + + /* Number of extents, and size/alignment of each (2^extent_order pages). */ + unsigned long nr_extents; + unsigned int extent_order; + + /* + * XENMEM_increase_reservation: maximum # bits addressable by the user + * of the allocated region (e.g., I/O devices often have a 32-bit + * limitation even in 64-bit systems). If zero then the user has no + * addressing restriction. + * XENMEM_decrease_reservation: unused. + */ + unsigned int address_bits; + + /* + * Domain whose reservation is being changed. + * Unprivileged domains can specify only DOMID_SELF. + */ + domid_t domid; + +} xen_memory_reservation_t; + +#endif /* __XEN_PUBLIC_MEMORY_H__ */ diff -r 8fe8a99b1c2a -r b043928b0873 xen/common/dom_mem_ops.c --- a/xen/common/dom_mem_ops.c Tue Aug 30 16:14:53 2005 +++ /dev/null Tue Aug 30 16:15:27 2005 @@ -1,186 +0,0 @@ -/****************************************************************************** - * dom_mem_ops.c - * - * Code to handle memory related requests from domains eg. balloon driver. - * - * Copyright (c) 2003-2004, B Dragovic & K A Fraser. - */ - -#include <xen/config.h> -#include <xen/types.h> -#include <xen/lib.h> -#include <xen/mm.h> -#include <xen/perfc.h> -#include <xen/sched.h> -#include <xen/event.h> -#include <xen/shadow.h> -#include <asm/current.h> -#include <asm/hardirq.h> - -/* - * To allow safe resume of do_dom_mem_op() after preemption, we need to know - * at what point in the page list to resume. For this purpose I steal the - * high-order bits of the @op parameter, which are otherwise unused and zero. - */ -#define START_EXTENT_SHIFT 4 /* op[:4] == start_extent */ - -#define PREEMPT_CHECK(_op) \ - if ( hypercall_preempt_check() ) \ - return hypercall5_create_continuation( \ - __HYPERVISOR_dom_mem_op, \ - (_op) | (i << START_EXTENT_SHIFT), \ - extent_list, nr_extents, extent_order, \ - (d == current->domain) ? DOMID_SELF : d->domain_id); - -static long -alloc_dom_mem(struct domain *d, - unsigned long *extent_list, - unsigned long start_extent, - unsigned int nr_extents, - unsigned int extent_order, - unsigned int flags) -{ - struct pfn_info *page; - unsigned long i; - - if ( (extent_list != NULL) && - !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) - return start_extent; - - if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) ) - { - DPRINTK("Only I/O-capable domains may allocate > order-0 memory.\n"); - return start_extent; - } - - for ( i = start_extent; i < nr_extents; i++ ) - { - PREEMPT_CHECK(MEMOP_increase_reservation); - - if ( unlikely((page = alloc_domheap_pages(d, extent_order, - flags)) == NULL) ) - { - DPRINTK("Could not allocate a frame\n"); - return i; - } - - /* Inform the domain of the new page's machine address. */ - if ( (extent_list != NULL) && - (__put_user(page_to_pfn(page), &extent_list[i]) != 0) ) - return i; - } - - return i; -} - -static long -free_dom_mem(struct domain *d, - unsigned long *extent_list, - unsigned long start_extent, - unsigned int nr_extents, - unsigned int extent_order) -{ - struct pfn_info *page; - unsigned long i, j, mpfn; - - if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) - return start_extent; - - for ( i = start_extent; i < nr_extents; i++ ) - { - PREEMPT_CHECK(MEMOP_decrease_reservation); - - if ( unlikely(__get_user(mpfn, &extent_list[i]) != 0) ) - return i; - - for ( j = 0; j < (1 << extent_order); j++ ) - { - if ( unlikely((mpfn + j) >= max_page) ) - { - DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", - d->domain_id, mpfn + j, max_page); - return i; - } - - page = &frame_table[mpfn + j]; - if ( unlikely(!get_page(page, d)) ) - { - DPRINTK("Bad page free for domain %u\n", d->domain_id); - return i; - } - - if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) - put_page_and_type(page); - - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) - put_page(page); - - shadow_sync_and_drop_references(d, page); - - put_page(page); - } - } - - return i; -} - -long -do_dom_mem_op(unsigned long op, - unsigned long *extent_list, - unsigned int nr_extents, - unsigned int extent_order, - domid_t domid) -{ - struct domain *d; - unsigned long rc, start_extent; - unsigned int address_bits_order; - - /* Extract @start_extent from @op. */ - start_extent = op >> START_EXTENT_SHIFT; - op &= (1 << START_EXTENT_SHIFT) - 1; - - /* seperate extent_order and address_bits_order */ - address_bits_order = (extent_order >> 8) & 0xff; - extent_order &= 0xff; - - if ( unlikely(start_extent > nr_extents) ) - return -EINVAL; - - if ( likely(domid == DOMID_SELF) ) - d = current->domain; - else if ( unlikely(!IS_PRIV(current->domain)) ) - return -EPERM; - else if ( unlikely((d = find_domain_by_id(domid)) == NULL) ) - return -ESRCH; - - switch ( op ) - { - case MEMOP_increase_reservation: - rc = alloc_dom_mem( - d, extent_list, start_extent, nr_extents, extent_order, - (address_bits_order <= 32) ? ALLOC_DOM_DMA : 0); - break; - case MEMOP_decrease_reservation: - rc = free_dom_mem( - d, extent_list, start_extent, nr_extents, extent_order); - break; - default: - rc = -ENOSYS; - break; - } - - if ( unlikely(domid != DOMID_SELF) ) - put_domain(d); - - return rc; -} - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |