ia64/xen-unstable
changeset 6493:b043928b0873
merge?
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Aug 30 16:14:53 2005 +0000 1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c Tue Aug 30 16:15:27 2005 +0000 1.3 @@ -115,9 +115,9 @@ dma_supported(struct device *dev, u64 ma 1.4 if (swiotlb) 1.5 return swiotlb_dma_supported(dev, mask); 1.6 /* 1.7 - * By default we'll BUG when an infeasible DMA is requested, and 1.8 - * request swiotlb=force (see IOMMU_BUG_ON). 1.9 - */ 1.10 + * By default we'll BUG when an infeasible DMA is requested, and 1.11 + * request swiotlb=force (see IOMMU_BUG_ON). 1.12 + */ 1.13 return 1; 1.14 } 1.15 EXPORT_SYMBOL(dma_supported);
2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Tue Aug 30 16:14:53 2005 +0000 2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Tue Aug 30 16:15:27 2005 +0000 2.3 @@ -55,6 +55,7 @@ 2.4 #include <asm/io.h> 2.5 #include <asm-xen/hypervisor.h> 2.6 #include <asm-xen/xen-public/physdev.h> 2.7 +#include <asm-xen/xen-public/memory.h> 2.8 #include "setup_arch_pre.h" 2.9 #include <bios_ebda.h> 2.10 2.11 @@ -1585,15 +1586,21 @@ void __init setup_arch(char **cmdline_p) 2.12 (unsigned int *)xen_start_info.mfn_list, 2.13 xen_start_info.nr_pages * sizeof(unsigned int)); 2.14 } else { 2.15 + struct xen_memory_reservation reservation = { 2.16 + .extent_start = (unsigned long *)xen_start_info.mfn_list + max_pfn, 2.17 + .nr_extents = xen_start_info.nr_pages - max_pfn, 2.18 + .extent_order = 0, 2.19 + .domid = DOMID_SELF 2.20 + }; 2.21 + 2.22 memcpy(phys_to_machine_mapping, 2.23 (unsigned int *)xen_start_info.mfn_list, 2.24 max_pfn * sizeof(unsigned int)); 2.25 /* N.B. below relies on sizeof(int) == sizeof(long). */ 2.26 - if (HYPERVISOR_dom_mem_op( 2.27 - MEMOP_decrease_reservation, 2.28 - (unsigned long *)xen_start_info.mfn_list + max_pfn, 2.29 - xen_start_info.nr_pages - max_pfn, 0) != 2.30 - (xen_start_info.nr_pages - max_pfn)) BUG(); 2.31 + BUG_ON(HYPERVISOR_memory_op( 2.32 + XENMEM_decrease_reservation, 2.33 + &reservation) != 2.34 + (xen_start_info.nr_pages - max_pfn)); 2.35 } 2.36 free_bootmem( 2.37 __pa(xen_start_info.mfn_list),
3.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Aug 30 16:14:53 2005 +0000 3.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c Tue Aug 30 16:15:27 2005 +0000 3.3 @@ -35,6 +35,7 @@ 3.4 #include <asm/pgtable.h> 3.5 #include <asm-xen/hypervisor.h> 3.6 #include <asm-xen/balloon.h> 3.7 +#include <asm-xen/xen-public/memory.h> 3.8 #include <linux/module.h> 3.9 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 3.10 #include <linux/percpu.h> 3.11 @@ -320,6 +321,12 @@ void xen_create_contiguous_region(unsign 3.12 pmd_t *pmd; 3.13 pte_t *pte; 3.14 unsigned long mfn, i, flags; 3.15 + struct xen_memory_reservation reservation = { 3.16 + .extent_start = &mfn, 3.17 + .nr_extents = 1, 3.18 + .extent_order = 0, 3.19 + .domid = DOMID_SELF 3.20 + }; 3.21 3.22 scrub_pages(vstart, 1 << order); 3.23 3.24 @@ -336,13 +343,15 @@ void xen_create_contiguous_region(unsign 3.25 vstart + (i*PAGE_SIZE), __pte_ma(0), 0)); 3.26 phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = 3.27 INVALID_P2M_ENTRY; 3.28 - BUG_ON(HYPERVISOR_dom_mem_op( 3.29 - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); 3.30 + BUG_ON(HYPERVISOR_memory_op( 3.31 + XENMEM_decrease_reservation, &reservation) != 1); 3.32 } 3.33 3.34 /* 2. Get a new contiguous memory extent. */ 3.35 - BUG_ON(HYPERVISOR_dom_mem_op( 3.36 - MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1); 3.37 + reservation.extent_order = order; 3.38 + reservation.address_bits = 31; /* aacraid limitation */ 3.39 + BUG_ON(HYPERVISOR_memory_op( 3.40 + XENMEM_increase_reservation, &reservation) != 1); 3.41 3.42 /* 3. Map the new extent in place of old pages. */ 3.43 for (i = 0; i < (1<<order); i++) { 3.44 @@ -367,6 +376,12 @@ void xen_destroy_contiguous_region(unsig 3.45 pmd_t *pmd; 3.46 pte_t *pte; 3.47 unsigned long mfn, i, flags; 3.48 + struct xen_memory_reservation reservation = { 3.49 + .extent_start = &mfn, 3.50 + .nr_extents = 1, 3.51 + .extent_order = 0, 3.52 + .domid = DOMID_SELF 3.53 + }; 3.54 3.55 scrub_pages(vstart, 1 << order); 3.56 3.57 @@ -385,14 +400,14 @@ void xen_destroy_contiguous_region(unsig 3.58 vstart + (i*PAGE_SIZE), __pte_ma(0), 0)); 3.59 phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = 3.60 INVALID_P2M_ENTRY; 3.61 - BUG_ON(HYPERVISOR_dom_mem_op( 3.62 - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); 3.63 + BUG_ON(HYPERVISOR_memory_op( 3.64 + XENMEM_decrease_reservation, &reservation) != 1); 3.65 } 3.66 3.67 /* 2. Map new pages in place of old pages. */ 3.68 for (i = 0; i < (1<<order); i++) { 3.69 - BUG_ON(HYPERVISOR_dom_mem_op( 3.70 - MEMOP_increase_reservation, &mfn, 1, 0) != 1); 3.71 + BUG_ON(HYPERVISOR_memory_op( 3.72 + XENMEM_increase_reservation, &reservation) != 1); 3.73 BUG_ON(HYPERVISOR_update_va_mapping( 3.74 vstart + (i*PAGE_SIZE), 3.75 pfn_pte_ma(mfn, PAGE_KERNEL), 0));
4.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Tue Aug 30 16:14:53 2005 +0000 4.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Tue Aug 30 16:15:27 2005 +0000 4.3 @@ -734,9 +734,9 @@ void __init setup_arch(char **cmdline_p) 4.4 /* Make sure we have a large enough P->M table. */ 4.5 if (end_pfn > xen_start_info.nr_pages) { 4.6 phys_to_machine_mapping = alloc_bootmem( 4.7 - max_pfn * sizeof(u32)); 4.8 + end_pfn * sizeof(u32)); 4.9 memset(phys_to_machine_mapping, ~0, 4.10 - max_pfn * sizeof(u32)); 4.11 + end_pfn * sizeof(u32)); 4.12 memcpy(phys_to_machine_mapping, 4.13 (u32 *)xen_start_info.mfn_list, 4.14 xen_start_info.nr_pages * sizeof(u32)); 4.15 @@ -749,11 +749,8 @@ void __init setup_arch(char **cmdline_p) 4.16 pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE); 4.17 4.18 for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(u32)), j++ ) 4.19 - { 4.20 pfn_to_mfn_frame_list[j] = 4.21 virt_to_mfn(&phys_to_machine_mapping[i]); 4.22 - } 4.23 - 4.24 } 4.25 #endif 4.26
5.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Tue Aug 30 16:14:53 2005 +0000 5.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Tue Aug 30 16:15:27 2005 +0000 5.3 @@ -466,7 +466,7 @@ static inline int make_readonly(unsigned 5.4 return readonly; 5.5 } 5.6 5.7 -void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) 5.8 +static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) 5.9 { 5.10 long i, j, k; 5.11 unsigned long paddr; 5.12 @@ -502,16 +502,17 @@ void __init phys_pud_init(pud_t *pud, un 5.13 pte = alloc_low_page(&pte_phys); 5.14 pte_save = pte; 5.15 for (k = 0; k < PTRS_PER_PTE; pte++, k++, paddr += PTE_SIZE) { 5.16 + if ((paddr >= end) || 5.17 + ((paddr >> PAGE_SHIFT) 5.18 + >= xen_start_info.nr_pages)) { 5.19 + __set_pte(pte, __pte(0)); 5.20 + continue; 5.21 + } 5.22 if (make_readonly(paddr)) { 5.23 __set_pte(pte, 5.24 __pte(paddr | (_KERNPG_TABLE & ~_PAGE_RW))); 5.25 continue; 5.26 } 5.27 - if (paddr >= end) { 5.28 - for (; k < PTRS_PER_PTE; k++, pte++) 5.29 - __set_pte(pte, __pte(0)); 5.30 - break; 5.31 - } 5.32 __set_pte(pte, __pte(paddr | _KERNPG_TABLE)); 5.33 } 5.34 pte = pte_save;
6.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Tue Aug 30 16:14:53 2005 +0000 6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c Tue Aug 30 16:15:27 2005 +0000 6.3 @@ -44,6 +44,7 @@ 6.4 #include <asm-xen/xen_proc.h> 6.5 #include <asm-xen/hypervisor.h> 6.6 #include <asm-xen/balloon.h> 6.7 +#include <asm-xen/xen-public/memory.h> 6.8 #include <asm/pgalloc.h> 6.9 #include <asm/pgtable.h> 6.10 #include <asm/uaccess.h> 6.11 @@ -168,6 +169,11 @@ static void balloon_process(void *unused 6.12 struct page *page; 6.13 long credit, debt, rc; 6.14 void *v; 6.15 + struct xen_memory_reservation reservation = { 6.16 + .address_bits = 0, 6.17 + .extent_order = 0, 6.18 + .domid = DOMID_SELF 6.19 + }; 6.20 6.21 down(&balloon_mutex); 6.22 6.23 @@ -180,14 +186,18 @@ static void balloon_process(void *unused 6.24 goto out; 6.25 6.26 balloon_lock(flags); 6.27 - rc = HYPERVISOR_dom_mem_op( 6.28 - MEMOP_increase_reservation, mfn_list, credit, 0); 6.29 + reservation.extent_start = mfn_list; 6.30 + reservation.nr_extents = credit; 6.31 + rc = HYPERVISOR_memory_op( 6.32 + XENMEM_increase_reservation, &reservation); 6.33 balloon_unlock(flags); 6.34 if (rc < credit) { 6.35 /* We hit the Xen hard limit: reprobe. */ 6.36 - BUG_ON(HYPERVISOR_dom_mem_op( 6.37 - MEMOP_decrease_reservation, 6.38 - mfn_list, rc, 0) != rc); 6.39 + reservation.extent_start = mfn_list; 6.40 + reservation.nr_extents = rc; 6.41 + BUG_ON(HYPERVISOR_memory_op( 6.42 + XENMEM_decrease_reservation, 6.43 + &reservation) != rc); 6.44 hard_limit = current_pages + rc - driver_pages; 6.45 vfree(mfn_list); 6.46 goto retry; 6.47 @@ -261,8 +271,10 @@ static void balloon_process(void *unused 6.48 balloon_append(pfn_to_page(pfn)); 6.49 } 6.50 6.51 - BUG_ON(HYPERVISOR_dom_mem_op( 6.52 - MEMOP_decrease_reservation,mfn_list, debt, 0) != debt); 6.53 + reservation.extent_start = mfn_list; 6.54 + reservation.nr_extents = debt; 6.55 + BUG_ON(HYPERVISOR_memory_op( 6.56 + XENMEM_decrease_reservation, &reservation) != debt); 6.57 6.58 current_pages -= debt; 6.59 } 6.60 @@ -438,11 +450,17 @@ static int dealloc_pte_fn( 6.61 pte_t *pte, struct page *pte_page, unsigned long addr, void *data) 6.62 { 6.63 unsigned long mfn = pte_mfn(*pte); 6.64 + struct xen_memory_reservation reservation = { 6.65 + .extent_start = &mfn, 6.66 + .nr_extents = 1, 6.67 + .extent_order = 0, 6.68 + .domid = DOMID_SELF 6.69 + }; 6.70 set_pte(pte, __pte_ma(0)); 6.71 phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] = 6.72 INVALID_P2M_ENTRY; 6.73 - BUG_ON(HYPERVISOR_dom_mem_op( 6.74 - MEMOP_decrease_reservation, &mfn, 1, 0) != 1); 6.75 + BUG_ON(HYPERVISOR_memory_op( 6.76 + XENMEM_decrease_reservation, &reservation) != 1); 6.77 return 0; 6.78 } 6.79
9.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Tue Aug 30 16:14:53 2005 +0000 9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Tue Aug 30 16:15:27 2005 +0000 9.3 @@ -12,6 +12,7 @@ 9.4 9.5 #include "common.h" 9.6 #include <asm-xen/balloon.h> 9.7 +#include <asm-xen/xen-public/memory.h> 9.8 9.9 #if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX) 9.10 #include <asm-xen/xen-public/grant_table.h> 9.11 @@ -110,10 +111,16 @@ static spinlock_t mfn_lock = SPIN_LOCK_U 9.12 static unsigned long alloc_mfn(void) 9.13 { 9.14 unsigned long mfn = 0, flags; 9.15 + struct xen_memory_reservation reservation = { 9.16 + .extent_start = mfn_list, 9.17 + .nr_extents = MAX_MFN_ALLOC, 9.18 + .extent_order = 0, 9.19 + .domid = DOMID_SELF 9.20 + }; 9.21 spin_lock_irqsave(&mfn_lock, flags); 9.22 if ( unlikely(alloc_index == 0) ) 9.23 - alloc_index = HYPERVISOR_dom_mem_op( 9.24 - MEMOP_increase_reservation, mfn_list, MAX_MFN_ALLOC, 0); 9.25 + alloc_index = HYPERVISOR_memory_op( 9.26 + XENMEM_increase_reservation, &reservation); 9.27 if ( alloc_index != 0 ) 9.28 mfn = mfn_list[--alloc_index]; 9.29 spin_unlock_irqrestore(&mfn_lock, flags); 9.30 @@ -124,11 +131,17 @@ static unsigned long alloc_mfn(void) 9.31 static void free_mfn(unsigned long mfn) 9.32 { 9.33 unsigned long flags; 9.34 + struct xen_memory_reservation reservation = { 9.35 + .extent_start = &mfn, 9.36 + .nr_extents = 1, 9.37 + .extent_order = 0, 9.38 + .domid = DOMID_SELF 9.39 + }; 9.40 spin_lock_irqsave(&mfn_lock, flags); 9.41 if ( alloc_index != MAX_MFN_ALLOC ) 9.42 mfn_list[alloc_index++] = mfn; 9.43 - else if ( HYPERVISOR_dom_mem_op(MEMOP_decrease_reservation, 9.44 - &mfn, 1, 0) != 1 ) 9.45 + else if ( HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation) 9.46 + != 1 ) 9.47 BUG(); 9.48 spin_unlock_irqrestore(&mfn_lock, flags); 9.49 }
10.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Aug 30 16:14:53 2005 +0000 10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue Aug 30 16:15:27 2005 +0000 10.3 @@ -50,6 +50,7 @@ 10.4 #include <asm-xen/evtchn.h> 10.5 #include <asm-xen/xenbus.h> 10.6 #include <asm-xen/xen-public/io/netif.h> 10.7 +#include <asm-xen/xen-public/memory.h> 10.8 #include <asm-xen/balloon.h> 10.9 #include <asm/page.h> 10.10 #include <asm/uaccess.h> 10.11 @@ -328,6 +329,7 @@ static void network_alloc_rx_buffers(str 10.12 struct sk_buff *skb; 10.13 int i, batch_target; 10.14 NETIF_RING_IDX req_prod = np->rx->req_prod; 10.15 + struct xen_memory_reservation reservation; 10.16 #ifdef CONFIG_XEN_NETDEV_GRANT_RX 10.17 int ref; 10.18 #endif 10.19 @@ -388,12 +390,15 @@ static void network_alloc_rx_buffers(str 10.20 rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL; 10.21 10.22 /* Give away a batch of pages. */ 10.23 - rx_mcl[i].op = __HYPERVISOR_dom_mem_op; 10.24 - rx_mcl[i].args[0] = MEMOP_decrease_reservation; 10.25 - rx_mcl[i].args[1] = (unsigned long)rx_pfn_array; 10.26 - rx_mcl[i].args[2] = (unsigned long)i; 10.27 - rx_mcl[i].args[3] = 0; 10.28 - rx_mcl[i].args[4] = DOMID_SELF; 10.29 + rx_mcl[i].op = __HYPERVISOR_memory_op; 10.30 + rx_mcl[i].args[0] = XENMEM_decrease_reservation; 10.31 + rx_mcl[i].args[1] = (unsigned long)&reservation; 10.32 + 10.33 + reservation.extent_start = rx_pfn_array; 10.34 + reservation.nr_extents = i; 10.35 + reservation.extent_order = 0; 10.36 + reservation.address_bits = 0; 10.37 + reservation.domid = DOMID_SELF; 10.38 10.39 /* Tell the ballon driver what is going on. */ 10.40 balloon_update_driver_allowance(i); 10.41 @@ -401,7 +406,7 @@ static void network_alloc_rx_buffers(str 10.42 /* Zap PTEs and give away pages in one big multicall. */ 10.43 (void)HYPERVISOR_multicall(rx_mcl, i+1); 10.44 10.45 - /* Check return status of HYPERVISOR_dom_mem_op(). */ 10.46 + /* Check return status of HYPERVISOR_memory_op(). */ 10.47 if (unlikely(rx_mcl[i].result != i)) 10.48 panic("Unable to reduce memory reservation\n"); 10.49
11.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Tue Aug 30 16:14:53 2005 +0000 11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Tue Aug 30 16:15:27 2005 +0000 11.3 @@ -66,7 +66,7 @@ static int privcmd_ioctl(struct inode *i 11.4 { 11.5 long ign1, ign2, ign3; 11.6 __asm__ __volatile__ ( 11.7 - "movq %5,%%r10; movq %6,%%r8;" TRAP_INSTR 11.8 + "movq %8,%%r10; movq %9,%%r8;" TRAP_INSTR 11.9 : "=a" (ret), "=D" (ign1), "=S" (ign2), "=d" (ign3) 11.10 : "0" ((unsigned long)hypercall.op), 11.11 "1" ((unsigned long)hypercall.arg[0]),
12.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 30 16:14:53 2005 +0000 12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Aug 30 16:15:27 2005 +0000 12.3 @@ -209,6 +209,7 @@ int xenbus_register_device(struct xenbus 12.4 { 12.5 return xenbus_register_driver(drv, &xenbus_frontend); 12.6 } 12.7 +EXPORT_SYMBOL(xenbus_register_device); 12.8 12.9 int xenbus_register_backend(struct xenbus_driver *drv) 12.10 {
13.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Tue Aug 30 16:14:53 2005 +0000 13.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c Tue Aug 30 16:15:27 2005 +0000 13.3 @@ -246,6 +246,7 @@ void *xenbus_read(const char *dir, const 13.4 { 13.5 return xs_single(XS_READ, join(dir, node), len); 13.6 } 13.7 +EXPORT_SYMBOL(xenbus_read); 13.8 13.9 /* Write the value of a single file. 13.10 * Returns -err on failure. createflags can be 0, O_CREAT, or O_CREAT|O_EXCL. 13.11 @@ -298,6 +299,7 @@ int xenbus_transaction_start(const char 13.12 { 13.13 return xs_error(xs_single(XS_TRANSACTION_START, subtree, NULL)); 13.14 } 13.15 +EXPORT_SYMBOL(xenbus_transaction_start); 13.16 13.17 /* End a transaction. 13.18 * If abandon is true, transaction is discarded instead of committed. 13.19 @@ -312,6 +314,7 @@ int xenbus_transaction_end(int abort) 13.20 strcpy(abortstr, "T"); 13.21 return xs_error(xs_single(XS_TRANSACTION_END, abortstr, NULL)); 13.22 } 13.23 +EXPORT_SYMBOL(xenbus_transaction_end); 13.24 13.25 /* Single read and scanf: returns -errno or num scanned. */ 13.26 int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...) 13.27 @@ -333,6 +336,7 @@ int xenbus_scanf(const char *dir, const 13.28 return -ERANGE; 13.29 return ret; 13.30 } 13.31 +EXPORT_SYMBOL(xenbus_scanf); 13.32 13.33 /* Single printf and write: returns -errno or 0. */ 13.34 int xenbus_printf(const char *dir, const char *node, const char *fmt, ...) 13.35 @@ -348,6 +352,7 @@ int xenbus_printf(const char *dir, const 13.36 BUG_ON(ret > sizeof(printf_buffer)-1); 13.37 return xenbus_write(dir, node, printf_buffer, O_CREAT); 13.38 } 13.39 +EXPORT_SYMBOL(xenbus_printf); 13.40 13.41 /* Report a (negative) errno into the store, with explanation. */ 13.42 void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...) 13.43 @@ -369,6 +374,7 @@ void xenbus_dev_error(struct xenbus_devi 13.44 printk("xenbus: failed to write error node for %s (%s)\n", 13.45 dev->nodename, printf_buffer); 13.46 } 13.47 +EXPORT_SYMBOL(xenbus_dev_error); 13.48 13.49 /* Clear any error. */ 13.50 void xenbus_dev_ok(struct xenbus_device *dev) 13.51 @@ -381,6 +387,7 @@ void xenbus_dev_ok(struct xenbus_device 13.52 dev->has_error = 0; 13.53 } 13.54 } 13.55 +EXPORT_SYMBOL(xenbus_dev_ok); 13.56 13.57 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */ 13.58 int xenbus_gather(const char *dir, ...) 13.59 @@ -410,6 +417,7 @@ int xenbus_gather(const char *dir, ...) 13.60 va_end(ap); 13.61 return ret; 13.62 } 13.63 +EXPORT_SYMBOL(xenbus_gather); 13.64 13.65 static int xs_watch(const char *path, const char *token) 13.66 { 13.67 @@ -482,6 +490,7 @@ int register_xenbus_watch(struct xenbus_ 13.68 list_add(&watch->list, &watches); 13.69 return err; 13.70 } 13.71 +EXPORT_SYMBOL(register_xenbus_watch); 13.72 13.73 void unregister_xenbus_watch(struct xenbus_watch *watch) 13.74 { 13.75 @@ -499,6 +508,7 @@ void unregister_xenbus_watch(struct xenb 13.76 "XENBUS Failed to release watch %s: %i\n", 13.77 watch->node, err); 13.78 } 13.79 +EXPORT_SYMBOL(unregister_xenbus_watch); 13.80 13.81 /* Re-register callbacks to all watches. */ 13.82 void reregister_xenbus_watches(void)
14.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Tue Aug 30 16:14:53 2005 +0000 14.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Tue Aug 30 16:15:27 2005 +0000 14.3 @@ -236,12 +236,10 @@ HYPERVISOR_update_descriptor( 14.4 } 14.5 14.6 static inline int 14.7 -HYPERVISOR_dom_mem_op( 14.8 - unsigned int op, unsigned long *extent_list, 14.9 - unsigned long nr_extents, unsigned int extent_order) 14.10 +HYPERVISOR_memory_op( 14.11 + unsigned int cmd, void *arg) 14.12 { 14.13 - return _hypercall5(int, dom_mem_op, op, extent_list, 14.14 - nr_extents, extent_order, DOMID_SELF); 14.15 + return _hypercall2(int, memory_op, cmd, arg); 14.16 } 14.17 14.18 static inline int
15.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h Tue Aug 30 16:14:53 2005 +0000 15.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h Tue Aug 30 16:15:27 2005 +0000 15.3 @@ -231,12 +231,10 @@ HYPERVISOR_update_descriptor( 15.4 } 15.5 15.6 static inline int 15.7 -HYPERVISOR_dom_mem_op( 15.8 - unsigned int op, unsigned long *extent_list, 15.9 - unsigned long nr_extents, unsigned int extent_order) 15.10 +HYPERVISOR_memory_op( 15.11 + unsigned int cmd, void *arg) 15.12 { 15.13 - return _hypercall5(int, dom_mem_op, op, extent_list, 15.14 - nr_extents, extent_order, DOMID_SELF); 15.15 + return _hypercall2(int, memory_op, cmd, arg); 15.16 } 15.17 15.18 static inline int
16.1 --- a/tools/Makefile Tue Aug 30 16:14:53 2005 +0000 16.2 +++ b/tools/Makefile Tue Aug 30 16:15:27 2005 +0000 16.3 @@ -7,15 +7,19 @@ SUBDIRS += xenstore 16.4 SUBDIRS += misc 16.5 SUBDIRS += examples 16.6 SUBDIRS += xentrace 16.7 -SUBDIRS += python 16.8 SUBDIRS += xcs 16.9 SUBDIRS += xcutils 16.10 -#SUBDIRS += pygrub 16.11 SUBDIRS += firmware 16.12 SUBDIRS += security 16.13 SUBDIRS += console 16.14 SUBDIRS += xenstat 16.15 16.16 +# These don't cross-compile 16.17 +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 16.18 +SUBDIRS += python 16.19 +#SUBDIRS += pygrub 16.20 +endif 16.21 + 16.22 .PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean 16.23 16.24 all: check
17.1 --- a/tools/console/Makefile Tue Aug 30 16:14:53 2005 +0000 17.2 +++ b/tools/console/Makefile Tue Aug 30 16:15:27 2005 +0000 17.3 @@ -9,8 +9,7 @@ INSTALL = install 17.4 INSTALL_PROG = $(INSTALL) -m0755 17.5 INSTALL_DIR = $(INSTALL) -d -m0755 17.6 17.7 -CC = gcc 17.8 -CFLAGS = -Wall -Werror -g3 17.9 +CFLAGS += -Wall -Werror -g3 17.10 17.11 CFLAGS += -I $(XEN_XCS) 17.12 CFLAGS += -I $(XEN_LIBXC)
20.1 --- a/tools/examples/Makefile Tue Aug 30 16:14:53 2005 +0000 20.2 +++ b/tools/examples/Makefile Tue Aug 30 16:15:27 2005 +0000 20.3 @@ -1,3 +1,6 @@ 20.4 +XEN_ROOT = ../../ 20.5 +include $(XEN_ROOT)/tools/Rules.mk 20.6 + 20.7 INSTALL = install 20.8 INSTALL_DIR = $(INSTALL) -d -m0755 20.9 INSTALL_PROG = $(INSTALL) -m0755
21.1 --- a/tools/libxc/xc_core.c Tue Aug 30 16:14:53 2005 +0000 21.2 +++ b/tools/libxc/xc_core.c Tue Aug 30 16:15:27 2005 +0000 21.3 @@ -2,6 +2,7 @@ 21.4 #define ELFSIZE 32 21.5 #include "xc_elf.h" 21.6 #include <stdlib.h> 21.7 +#include <unistd.h> 21.8 #include <zlib.h> 21.9 21.10 /* number of pages to write at a time */
22.1 --- a/tools/libxc/xc_domain.c Tue Aug 30 16:14:53 2005 +0000 22.2 +++ b/tools/libxc/xc_domain.c Tue Aug 30 16:15:27 2005 +0000 22.3 @@ -7,6 +7,7 @@ 22.4 */ 22.5 22.6 #include "xc_private.h" 22.7 +#include <xen/memory.h> 22.8 22.9 int xc_domain_create(int xc_handle, 22.10 u32 ssidref, 22.11 @@ -265,9 +266,13 @@ int xc_domain_memory_increase_reservatio 22.12 { 22.13 int err; 22.14 unsigned int npages = mem_kb / (PAGE_SIZE/1024); 22.15 + struct xen_memory_reservation reservation = { 22.16 + .nr_extents = npages, 22.17 + .extent_order = 0, 22.18 + .domid = domid 22.19 + }; 22.20 22.21 - err = xc_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL, 22.22 - npages, 0, domid); 22.23 + err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation); 22.24 if (err == npages) 22.25 return 0; 22.26
23.1 --- a/tools/libxc/xc_linux_build.c Tue Aug 30 16:14:53 2005 +0000 23.2 +++ b/tools/libxc/xc_linux_build.c Tue Aug 30 16:15:27 2005 +0000 23.3 @@ -17,6 +17,7 @@ 23.4 #include "xc_elf.h" 23.5 #include "xc_aout9.h" 23.6 #include <stdlib.h> 23.7 +#include <unistd.h> 23.8 #include <zlib.h> 23.9 23.10 #if defined(__i386__)
24.1 --- a/tools/libxc/xc_linux_restore.c Tue Aug 30 16:14:53 2005 +0000 24.2 +++ b/tools/libxc/xc_linux_restore.c Tue Aug 30 16:15:27 2005 +0000 24.3 @@ -8,11 +8,10 @@ 24.4 24.5 #include <stdlib.h> 24.6 #include <unistd.h> 24.7 - 24.8 #include "xg_private.h" 24.9 #include <xenctrl.h> 24.10 - 24.11 #include <xen/linux/suspend.h> 24.12 +#include <xen/memory.h> 24.13 24.14 #define MAX_BATCH_SIZE 1024 24.15 24.16 @@ -411,7 +410,8 @@ int xc_linux_restore(int xc_handle, int 24.17 24.18 /* Get the list of PFNs that are not in the psuedo-phys map */ 24.19 { 24.20 - unsigned int count, *pfntab; 24.21 + unsigned int count; 24.22 + unsigned long *pfntab; 24.23 int rc; 24.24 24.25 if ( read_exact(io_fd, &count, sizeof(count)) != sizeof(count) ) 24.26 @@ -443,9 +443,15 @@ int xc_linux_restore(int xc_handle, int 24.27 24.28 if ( count > 0 ) 24.29 { 24.30 - if ( (rc = xc_dom_mem_op( xc_handle, 24.31 - MEMOP_decrease_reservation, 24.32 - pfntab, count, 0, dom )) <0 ) 24.33 + struct xen_memory_reservation reservation = { 24.34 + .extent_start = pfntab, 24.35 + .nr_extents = count, 24.36 + .extent_order = 0, 24.37 + .domid = dom 24.38 + }; 24.39 + if ( (rc = xc_memory_op(xc_handle, 24.40 + XENMEM_decrease_reservation, 24.41 + &reservation)) != count ) 24.42 { 24.43 ERR("Could not decrease reservation : %d",rc); 24.44 goto out;
25.1 --- a/tools/libxc/xc_private.c Tue Aug 30 16:14:53 2005 +0000 25.2 +++ b/tools/libxc/xc_private.c Tue Aug 30 16:15:27 2005 +0000 25.3 @@ -6,6 +6,7 @@ 25.4 25.5 #include <zlib.h> 25.6 #include "xc_private.h" 25.7 +#include <xen/memory.h> 25.8 25.9 void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot, 25.10 unsigned long *arr, int num ) 25.11 @@ -187,28 +188,43 @@ int xc_finish_mmu_updates(int xc_handle, 25.12 return flush_mmu_updates(xc_handle, mmu); 25.13 } 25.14 25.15 -int xc_dom_mem_op(int xc_handle, 25.16 - unsigned int memop, 25.17 - unsigned int *extent_list, 25.18 - unsigned int nr_extents, 25.19 - unsigned int extent_order, 25.20 - domid_t domid) 25.21 +int xc_memory_op(int xc_handle, 25.22 + int cmd, 25.23 + void *arg) 25.24 { 25.25 privcmd_hypercall_t hypercall; 25.26 + struct xen_memory_reservation *reservation = arg; 25.27 long ret = -EINVAL; 25.28 25.29 - hypercall.op = __HYPERVISOR_dom_mem_op; 25.30 - hypercall.arg[0] = (unsigned long)memop; 25.31 - hypercall.arg[1] = (unsigned long)extent_list; 25.32 - hypercall.arg[2] = (unsigned long)nr_extents; 25.33 - hypercall.arg[3] = (unsigned long)extent_order; 25.34 - hypercall.arg[4] = (unsigned long)domid; 25.35 + hypercall.op = __HYPERVISOR_memory_op; 25.36 + hypercall.arg[0] = (unsigned long)cmd; 25.37 + hypercall.arg[1] = (unsigned long)arg; 25.38 25.39 - if ( (extent_list != NULL) && 25.40 - (mlock(extent_list, nr_extents*sizeof(unsigned long)) != 0) ) 25.41 + switch ( cmd ) 25.42 { 25.43 - PERROR("Could not lock memory for Xen hypercall"); 25.44 - goto out1; 25.45 + case XENMEM_increase_reservation: 25.46 + case XENMEM_decrease_reservation: 25.47 + if ( mlock(reservation, sizeof(*reservation)) != 0 ) 25.48 + { 25.49 + PERROR("Could not mlock"); 25.50 + goto out1; 25.51 + } 25.52 + if ( (reservation->extent_start != NULL) && 25.53 + (mlock(reservation->extent_start, 25.54 + reservation->nr_extents * sizeof(unsigned long)) != 0) ) 25.55 + { 25.56 + PERROR("Could not mlock"); 25.57 + safe_munlock(reservation, sizeof(*reservation)); 25.58 + goto out1; 25.59 + } 25.60 + break; 25.61 + case XENMEM_maximum_ram_page: 25.62 + if ( mlock(arg, sizeof(unsigned long)) != 0 ) 25.63 + { 25.64 + PERROR("Could not mlock"); 25.65 + goto out1; 25.66 + } 25.67 + break; 25.68 } 25.69 25.70 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 ) 25.71 @@ -217,8 +233,19 @@ int xc_dom_mem_op(int xc_handle, 25.72 " rebuild the user-space tool set?\n",ret,errno); 25.73 } 25.74 25.75 - if ( extent_list != NULL ) 25.76 - safe_munlock(extent_list, nr_extents*sizeof(unsigned long)); 25.77 + switch ( cmd ) 25.78 + { 25.79 + case XENMEM_increase_reservation: 25.80 + case XENMEM_decrease_reservation: 25.81 + safe_munlock(reservation, sizeof(*reservation)); 25.82 + if ( reservation->extent_start != NULL ) 25.83 + safe_munlock(reservation->extent_start, 25.84 + reservation->nr_extents * sizeof(unsigned long)); 25.85 + break; 25.86 + case XENMEM_maximum_ram_page: 25.87 + safe_munlock(arg, sizeof(unsigned long)); 25.88 + break; 25.89 + } 25.90 25.91 out1: 25.92 return ret;
26.1 --- a/tools/libxc/xc_vmx_build.c Tue Aug 30 16:14:53 2005 +0000 26.2 +++ b/tools/libxc/xc_vmx_build.c Tue Aug 30 16:15:27 2005 +0000 26.3 @@ -7,6 +7,7 @@ 26.4 #define ELFSIZE 32 26.5 #include "xc_elf.h" 26.6 #include <stdlib.h> 26.7 +#include <unistd.h> 26.8 #include <zlib.h> 26.9 #include <xen/io/ioreq.h> 26.10 #include "linux_boot_params.h"
27.1 --- a/tools/libxc/xenctrl.h Tue Aug 30 16:14:53 2005 +0000 27.2 +++ b/tools/libxc/xenctrl.h Tue Aug 30 16:15:27 2005 +0000 27.3 @@ -430,9 +430,7 @@ int xc_ia64_get_pfn_list(int xc_handle, 27.4 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops, 27.5 domid_t dom); 27.6 27.7 -int xc_dom_mem_op(int xc_handle, unsigned int memop, unsigned int *extent_list, 27.8 - unsigned int nr_extents, unsigned int extent_order, 27.9 - domid_t domid); 27.10 +int xc_memory_op(int xc_handle, int cmd, void *arg); 27.11 27.12 int xc_get_pfn_type_batch(int xc_handle, u32 dom, int num, unsigned long *arr); 27.13
29.1 --- a/tools/libxc/xg_private.c Tue Aug 30 16:14:53 2005 +0000 29.2 +++ b/tools/libxc/xg_private.c Tue Aug 30 16:15:27 2005 +0000 29.3 @@ -5,6 +5,7 @@ 29.4 */ 29.5 29.6 #include <stdlib.h> 29.7 +#include <unistd.h> 29.8 #include <zlib.h> 29.9 29.10 #include "xg_private.h"
30.1 --- a/tools/misc/mbootpack/Makefile Tue Aug 30 16:14:53 2005 +0000 30.2 +++ b/tools/misc/mbootpack/Makefile Tue Aug 30 16:15:27 2005 +0000 30.3 @@ -20,8 +20,7 @@ GDB := gdb 30.4 INCS := -I. -I- 30.5 DEFS := 30.6 LDFLAGS := 30.7 -CC := gcc 30.8 -CFLAGS := -Wall -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format 30.9 +CFLAGS := -Wall -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format 30.10 CFLAGS += -Wmissing-prototypes 30.11 #CFLAGS += -pipe -g -O0 -Wcast-align 30.12 CFLAGS += -pipe -O3 30.13 @@ -34,7 +33,7 @@ DEPFLAGS = -Wp,-MD,.$(@F).d 30.14 DEPS = .*.d 30.15 30.16 mbootpack: $(OBJS) 30.17 - $(CC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) 30.18 + $(HOSTCC) -o $@ $(filter-out %.a, $^) $(LDFLAGS) 30.19 30.20 clean: 30.21 $(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c 30.22 @@ -48,7 +47,7 @@ setup: setup.S 30.23 $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@ 30.24 30.25 bin2c: bin2c.o 30.26 - $(CC) -o $@ $^ 30.27 + $(HOSTCC) -o $@ $^ 30.28 30.29 bzimage_header.c: bootsect setup bin2c 30.30 ./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c 30.31 @@ -58,10 +57,10 @@ buildimage.c: bzimage_header.c 30.32 @ 30.33 30.34 %.o: %.S 30.35 - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ 30.36 + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ 30.37 30.38 %.o: %.c 30.39 - $(CC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ 30.40 + $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ 30.41 30.42 .PHONY: all clean gdb 30.43 .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS)
31.1 --- a/tools/misc/mbootpack/buildimage.c Tue Aug 30 16:14:53 2005 +0000 31.2 +++ b/tools/misc/mbootpack/buildimage.c Tue Aug 30 16:15:27 2005 +0000 31.3 @@ -43,6 +43,7 @@ 31.4 #include "mbootpack.h" 31.5 #include "mb_header.h" 31.6 31.7 + 31.8 /* We will build an image that a bzImage-capable bootloader will load like 31.9 * this: 31.10 * 31.11 @@ -105,8 +106,8 @@ void make_bzImage(section_t *sections, 31.12 section_t *s; 31.13 31.14 /* Patch the kernel and mbi addresses into the setup code */ 31.15 - *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = entry; 31.16 - *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = mbi; 31.17 + *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry); 31.18 + *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi); 31.19 if (!quiet) printf("Kernel entry is %p, MBI is %p.\n", entry, mbi); 31.20 31.21 /* Write out header and trampoline */
32.1 --- a/tools/misc/mbootpack/mbootpack.c Tue Aug 30 16:14:53 2005 +0000 32.2 +++ b/tools/misc/mbootpack/mbootpack.c Tue Aug 30 16:15:27 2005 +0000 32.3 @@ -252,20 +252,21 @@ static address_t load_kernel(const char 32.4 for (i = 0; i <= MIN(len - 12, MULTIBOOT_SEARCH - 12); i += 4) 32.5 { 32.6 mbh = (struct multiboot_header *)(headerbuf + i); 32.7 - if (mbh->magic != MULTIBOOT_MAGIC 32.8 - || ((mbh->magic+mbh->flags+mbh->checksum) & 0xffffffff)) 32.9 + if (eswap(mbh->magic) != MULTIBOOT_MAGIC 32.10 + || ((eswap(mbh->magic)+eswap(mbh->flags)+eswap(mbh->checksum)) 32.11 + & 0xffffffff)) 32.12 { 32.13 /* Not a multiboot header */ 32.14 continue; 32.15 } 32.16 - if (mbh->flags & MULTIBOOT_UNSUPPORTED) { 32.17 + if (eswap(mbh->flags) & MULTIBOOT_UNSUPPORTED) { 32.18 /* Requires options we don't support */ 32.19 printf("Fatal: found a multiboot header, but it " 32.20 "requires multiboot options that I\n" 32.21 "don't understand. Sorry.\n"); 32.22 exit(1); 32.23 } 32.24 - if (mbh->flags & MULTIBOOT_VIDEO_MODE) { 32.25 + if (eswap(mbh->flags) & MULTIBOOT_VIDEO_MODE) { 32.26 /* Asked for screen mode information */ 32.27 /* XXX carry on regardless */ 32.28 printf("Warning: found a multiboot header which asks " 32.29 @@ -275,22 +276,22 @@ static address_t load_kernel(const char 32.30 } 32.31 /* This kernel will do: place and load it */ 32.32 32.33 - if (mbh->flags & MULTIBOOT_AOUT_KLUDGE) { 32.34 + if (eswap(mbh->flags) & MULTIBOOT_AOUT_KLUDGE) { 32.35 32.36 /* Load using the offsets in the multiboot header */ 32.37 if(!quiet) 32.38 printf("Loading %s using multiboot header.\n", filename); 32.39 32.40 /* How much is there? */ 32.41 - start = mbh->load_addr; 32.42 - if (mbh->load_end_addr != 0) 32.43 - loadsize = mbh->load_end_addr - mbh->load_addr; 32.44 + start = eswap(mbh->load_addr); 32.45 + if (eswap(mbh->load_end_addr) != 0) 32.46 + loadsize = eswap(mbh->load_end_addr) - eswap(mbh->load_addr); 32.47 else 32.48 loadsize = sb.st_size; 32.49 32.50 /* How much memory will it take up? */ 32.51 - if (mbh->bss_end_addr != 0) 32.52 - size = mbh->bss_end_addr - mbh->load_addr; 32.53 + if (eswap(mbh->bss_end_addr) != 0) 32.54 + size = eswap(mbh->bss_end_addr) - eswap(mbh->load_addr); 32.55 else 32.56 size = loadsize; 32.57 32.58 @@ -335,32 +336,34 @@ static address_t load_kernel(const char 32.59 32.60 /* Done. */ 32.61 if (!quiet) printf("Loaded kernel from %s\n", filename); 32.62 - return mbh->entry_addr; 32.63 + return eswap(mbh->entry_addr); 32.64 32.65 } else { 32.66 32.67 /* Now look for an ELF32 header */ 32.68 ehdr = (Elf32_Ehdr *)headerbuf; 32.69 - if (*(unsigned long *)ehdr != 0x464c457f 32.70 + if (*(unsigned long *)ehdr != eswap(0x464c457f) 32.71 || ehdr->e_ident[EI_DATA] != ELFDATA2LSB 32.72 || ehdr->e_ident[EI_CLASS] != ELFCLASS32 32.73 - || ehdr->e_machine != EM_386) 32.74 + || eswap(ehdr->e_machine) != EM_386) 32.75 { 32.76 printf("Fatal: kernel has neither ELF32/x86 nor multiboot load" 32.77 " headers.\n"); 32.78 exit(1); 32.79 } 32.80 - if (ehdr->e_phoff + ehdr->e_phnum*sizeof(*phdr) > HEADERBUF_SIZE) { 32.81 + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof(*phdr) 32.82 + > HEADERBUF_SIZE) { 32.83 /* Don't expect this will happen with sane kernels */ 32.84 printf("Fatal: too much ELF for me. Try increasing " 32.85 "HEADERBUF_SIZE in mbootpack.\n"); 32.86 exit(1); 32.87 } 32.88 - if (ehdr->e_phoff + ehdr->e_phnum*sizeof (*phdr) > len) { 32.89 + if (eswap(ehdr->e_phoff) + eswap(ehdr->e_phnum)*sizeof (*phdr) 32.90 + > len) { 32.91 printf("Fatal: malformed ELF header overruns EOF.\n"); 32.92 exit(1); 32.93 } 32.94 - if (ehdr->e_phnum <= 0) { 32.95 + if (eswap(ehdr->e_phnum) <= 0) { 32.96 printf("Fatal: ELF kernel has no program headers.\n"); 32.97 exit(1); 32.98 } 32.99 @@ -368,22 +371,22 @@ static address_t load_kernel(const char 32.100 if(!quiet) 32.101 printf("Loading %s using ELF header.\n", filename); 32.102 32.103 - if (ehdr->e_type != ET_EXEC 32.104 - || ehdr->e_version != EV_CURRENT 32.105 - || ehdr->e_phentsize != sizeof (Elf32_Phdr)) { 32.106 + if (eswap(ehdr->e_type) != ET_EXEC 32.107 + || eswap(ehdr->e_version) != EV_CURRENT 32.108 + || eswap(ehdr->e_phentsize) != sizeof (Elf32_Phdr)) { 32.109 printf("Warning: funny-looking ELF header.\n"); 32.110 } 32.111 - phdr = (Elf32_Phdr *)(headerbuf + ehdr->e_phoff); 32.112 + phdr = (Elf32_Phdr *)(headerbuf + eswap(ehdr->e_phoff)); 32.113 32.114 /* Obey the program headers to load the kernel */ 32.115 - for(i = 0; i < ehdr->e_phnum; i++) { 32.116 + for(i = 0; i < eswap(ehdr->e_phnum); i++) { 32.117 32.118 - start = phdr[i].p_paddr; 32.119 - size = phdr[i].p_memsz; 32.120 - if (phdr[i].p_type != PT_LOAD) 32.121 + start = eswap(phdr[i].p_paddr); 32.122 + size = eswap(phdr[i].p_memsz); 32.123 + if (eswap(phdr[i].p_type) != PT_LOAD) 32.124 loadsize = 0; 32.125 else 32.126 - loadsize = MIN((long int)phdr[i].p_filesz, size); 32.127 + loadsize = MIN((long int)eswap(phdr[i].p_filesz), size); 32.128 32.129 if ((buffer = malloc(size)) == NULL) { 32.130 printf("Fatal: malloc() for kernel load failed: %s\n", 32.131 @@ -396,7 +399,7 @@ static address_t load_kernel(const char 32.132 32.133 /* Load section from file */ 32.134 if (loadsize > 0) { 32.135 - if (fseek(fp, phdr[i].p_offset, SEEK_SET) != 0) { 32.136 + if (fseek(fp, eswap(phdr[i].p_offset), SEEK_SET) != 0) { 32.137 printf("Fatal: seek failed in %s\n", 32.138 strerror(errno)); 32.139 exit(1); 32.140 @@ -452,7 +455,7 @@ static address_t load_kernel(const char 32.141 32.142 /* Done! */ 32.143 if (!quiet) printf("Loaded kernel from %s\n", filename); 32.144 - return ehdr->e_entry; 32.145 + return eswap(ehdr->e_entry); 32.146 } 32.147 32.148 } 32.149 @@ -568,12 +571,12 @@ int main(int argc, char **argv) 32.150 /* Command line */ 32.151 p = (char *)(mbi + 1); 32.152 sprintf(p, "%s %s", imagename, command_line); 32.153 - mbi->cmdline = ((address_t)p) + mbi_reloc_offset; 32.154 + mbi->cmdline = eswap(((address_t)p) + mbi_reloc_offset); 32.155 p += command_line_len; 32.156 32.157 /* Bootloader ID */ 32.158 sprintf(p, version_string); 32.159 - mbi->boot_loader_name = ((address_t)p) + mbi_reloc_offset; 32.160 + mbi->boot_loader_name = eswap(((address_t)p) + mbi_reloc_offset); 32.161 p += strlen(version_string) + 1; 32.162 32.163 /* Next is space for the module command lines */ 32.164 @@ -582,17 +585,17 @@ int main(int argc, char **argv) 32.165 /* Last come the module info structs */ 32.166 modp = (struct mod_list *) 32.167 ((((address_t)p + mod_command_line_space) + 3) & ~3); 32.168 - mbi->mods_count = modules; 32.169 - mbi->mods_addr = ((address_t)modp) + mbi_reloc_offset; 32.170 + mbi->mods_count = eswap(modules); 32.171 + mbi->mods_addr = eswap(((address_t)modp) + mbi_reloc_offset); 32.172 32.173 /* Memory information will be added at boot time, by setup.S 32.174 * or trampoline.S. */ 32.175 - mbi->flags = MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME; 32.176 + mbi->flags = eswap(MB_INFO_CMDLINE | MB_INFO_BOOT_LOADER_NAME); 32.177 32.178 32.179 /* Load the modules */ 32.180 if (modules) { 32.181 - mbi->flags |= MB_INFO_MODS; 32.182 + mbi->flags = eswap(eswap(mbi->flags) | MB_INFO_MODS); 32.183 32.184 /* Go back and parse the module command lines */ 32.185 optind = opterr = 1; 32.186 @@ -652,10 +655,10 @@ int main(int argc, char **argv) 32.187 if (p != NULL) *p = ' '; 32.188 32.189 /* Fill in the module info struct */ 32.190 - modp->mod_start = start; 32.191 - modp->mod_end = start + size; 32.192 - modp->cmdline = (address_t)mod_clp + mbi_reloc_offset; 32.193 - modp->pad = 0; 32.194 + modp->mod_start = eswap(start); 32.195 + modp->mod_end = eswap(start + size); 32.196 + modp->cmdline = eswap((address_t)mod_clp + mbi_reloc_offset); 32.197 + modp->pad = eswap(0); 32.198 modp++; 32.199 32.200 /* Store the module command line */
33.1 --- a/tools/misc/mbootpack/mbootpack.h Tue Aug 30 16:14:53 2005 +0000 33.2 +++ b/tools/misc/mbootpack/mbootpack.h Tue Aug 30 16:15:27 2005 +0000 33.3 @@ -32,6 +32,24 @@ 33.4 #undef NDEBUG 33.5 #include <stdio.h> 33.6 33.7 +#include <endian.h> 33.8 +#include <byteswap.h> 33.9 +#if __BYTE_ORDER == __LITTLE_ENDIAN 33.10 +#define eswap(x) (x) 33.11 +#else 33.12 +#define eswap(x) \ 33.13 + ({ \ 33.14 + typeof(x) y = (x); \ 33.15 + switch(sizeof(y)) \ 33.16 + { \ 33.17 + case 2: y = __bswap_16(y); break; \ 33.18 + case 4: y = __bswap_32(y); break; \ 33.19 + case 8: y = __bswap_64(y); break; \ 33.20 + } \ 33.21 + y; \ 33.22 + }) 33.23 +#endif 33.24 + 33.25 /* Flags */ 33.26 extern int quiet; 33.27
37.1 --- a/tools/xcs/Makefile Tue Aug 30 16:14:53 2005 +0000 37.2 +++ b/tools/xcs/Makefile Tue Aug 30 16:15:27 2005 +0000 37.3 @@ -10,8 +10,7 @@ INSTALL = install 37.4 INSTALL_PROG = $(INSTALL) -m0755 37.5 INSTALL_DIR = $(INSTALL) -d -m0755 37.6 37.7 -CC = gcc 37.8 -CFLAGS = -Wall -Werror -g3 -D _XOPEN_SOURCE=600 37.9 +CFLAGS += -Wall -Werror -g3 -D _XOPEN_SOURCE=600 37.10 37.11 CFLAGS += -I $(XEN_XC) 37.12 CFLAGS += -I $(XEN_LIBXC)
38.1 --- a/tools/xcutils/Makefile Tue Aug 30 16:14:53 2005 +0000 38.2 +++ b/tools/xcutils/Makefile Tue Aug 30 16:15:27 2005 +0000 38.3 @@ -19,8 +19,6 @@ PROGRAMS_INSTALL_DIR = /usr/libexec/xen 38.4 38.5 INCLUDES += -I $(XEN_LIBXC) 38.6 38.7 -CC := gcc 38.8 - 38.9 CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing 38.10 CFLAGS += $(INCLUDES) 38.11
39.1 --- a/tools/xenstat/Makefile Tue Aug 30 16:14:53 2005 +0000 39.2 +++ b/tools/xenstat/Makefile Tue Aug 30 16:15:27 2005 +0000 39.3 @@ -3,7 +3,11 @@ include $(XEN_ROOT)/tools/Rules.mk 39.4 39.5 SUBDIRS := 39.6 SUBDIRS += libxenstat 39.7 + 39.8 +# This doesn't cross-compile (cross-compile environments rarely have curses) 39.9 +ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 39.10 SUBDIRS += xentop 39.11 +endif 39.12 39.13 .PHONY: all install clean 39.14
40.1 --- a/xen/arch/x86/x86_32/entry.S Tue Aug 30 16:14:53 2005 +0000 40.2 +++ b/xen/arch/x86/x86_32/entry.S Tue Aug 30 16:15:27 2005 +0000 40.3 @@ -790,7 +790,7 @@ ENTRY(hypercall_table) 40.4 .long do_get_debugreg 40.5 .long do_update_descriptor /* 10 */ 40.6 .long do_ni_hypercall 40.7 - .long do_dom_mem_op 40.8 + .long do_memory_op 40.9 .long do_multicall 40.10 .long do_update_va_mapping 40.11 .long do_set_timer_op /* 15 */ 40.12 @@ -823,7 +823,7 @@ ENTRY(hypercall_args_table) 40.13 .byte 1 /* do_get_debugreg */ 40.14 .byte 4 /* do_update_descriptor */ /* 10 */ 40.15 .byte 0 /* do_ni_hypercall */ 40.16 - .byte 5 /* do_dom_mem_op */ 40.17 + .byte 2 /* do_memory_op */ 40.18 .byte 2 /* do_multicall */ 40.19 .byte 4 /* do_update_va_mapping */ 40.20 .byte 2 /* do_set_timer_op */ /* 15 */
41.1 --- a/xen/arch/x86/x86_64/entry.S Tue Aug 30 16:14:53 2005 +0000 41.2 +++ b/xen/arch/x86/x86_64/entry.S Tue Aug 30 16:15:27 2005 +0000 41.3 @@ -616,7 +616,7 @@ ENTRY(hypercall_table) 41.4 .quad do_get_debugreg 41.5 .quad do_update_descriptor /* 10 */ 41.6 .quad do_ni_hypercall 41.7 - .quad do_dom_mem_op 41.8 + .quad do_memory_op 41.9 .quad do_multicall 41.10 .quad do_update_va_mapping 41.11 .quad do_set_timer_op /* 15 */ 41.12 @@ -649,7 +649,7 @@ ENTRY(hypercall_args_table) 41.13 .byte 1 /* do_get_debugreg */ 41.14 .byte 2 /* do_update_descriptor */ /* 10 */ 41.15 .byte 0 /* do_ni_hypercall */ 41.16 - .byte 5 /* do_dom_mem_op */ 41.17 + .byte 2 /* do_memory_op */ 41.18 .byte 2 /* do_multicall */ 41.19 .byte 3 /* do_update_va_mapping */ 41.20 .byte 1 /* do_set_timer_op */ /* 15 */
42.1 --- a/xen/common/Makefile Tue Aug 30 16:14:53 2005 +0000 42.2 +++ b/xen/common/Makefile Tue Aug 30 16:15:27 2005 +0000 42.3 @@ -2,7 +2,6 @@ 42.4 include $(BASEDIR)/Rules.mk 42.5 42.6 ifeq ($(TARGET_ARCH),ia64) 42.7 -#OBJS := $(subst dom_mem_ops.o,,$(OBJS)) 42.8 OBJS := $(subst grant_table.o,,$(OBJS)) 42.9 endif 42.10
43.1 --- a/xen/common/dom_mem_ops.c Tue Aug 30 16:14:53 2005 +0000 43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 43.3 @@ -1,186 +0,0 @@ 43.4 -/****************************************************************************** 43.5 - * dom_mem_ops.c 43.6 - * 43.7 - * Code to handle memory related requests from domains eg. balloon driver. 43.8 - * 43.9 - * Copyright (c) 2003-2004, B Dragovic & K A Fraser. 43.10 - */ 43.11 - 43.12 -#include <xen/config.h> 43.13 -#include <xen/types.h> 43.14 -#include <xen/lib.h> 43.15 -#include <xen/mm.h> 43.16 -#include <xen/perfc.h> 43.17 -#include <xen/sched.h> 43.18 -#include <xen/event.h> 43.19 -#include <xen/shadow.h> 43.20 -#include <asm/current.h> 43.21 -#include <asm/hardirq.h> 43.22 - 43.23 -/* 43.24 - * To allow safe resume of do_dom_mem_op() after preemption, we need to know 43.25 - * at what point in the page list to resume. For this purpose I steal the 43.26 - * high-order bits of the @op parameter, which are otherwise unused and zero. 43.27 - */ 43.28 -#define START_EXTENT_SHIFT 4 /* op[:4] == start_extent */ 43.29 - 43.30 -#define PREEMPT_CHECK(_op) \ 43.31 - if ( hypercall_preempt_check() ) \ 43.32 - return hypercall5_create_continuation( \ 43.33 - __HYPERVISOR_dom_mem_op, \ 43.34 - (_op) | (i << START_EXTENT_SHIFT), \ 43.35 - extent_list, nr_extents, extent_order, \ 43.36 - (d == current->domain) ? DOMID_SELF : d->domain_id); 43.37 - 43.38 -static long 43.39 -alloc_dom_mem(struct domain *d, 43.40 - unsigned long *extent_list, 43.41 - unsigned long start_extent, 43.42 - unsigned int nr_extents, 43.43 - unsigned int extent_order, 43.44 - unsigned int flags) 43.45 -{ 43.46 - struct pfn_info *page; 43.47 - unsigned long i; 43.48 - 43.49 - if ( (extent_list != NULL) && 43.50 - !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) 43.51 - return start_extent; 43.52 - 43.53 - if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) ) 43.54 - { 43.55 - DPRINTK("Only I/O-capable domains may allocate > order-0 memory.\n"); 43.56 - return start_extent; 43.57 - } 43.58 - 43.59 - for ( i = start_extent; i < nr_extents; i++ ) 43.60 - { 43.61 - PREEMPT_CHECK(MEMOP_increase_reservation); 43.62 - 43.63 - if ( unlikely((page = alloc_domheap_pages(d, extent_order, 43.64 - flags)) == NULL) ) 43.65 - { 43.66 - DPRINTK("Could not allocate a frame\n"); 43.67 - return i; 43.68 - } 43.69 - 43.70 - /* Inform the domain of the new page's machine address. */ 43.71 - if ( (extent_list != NULL) && 43.72 - (__put_user(page_to_pfn(page), &extent_list[i]) != 0) ) 43.73 - return i; 43.74 - } 43.75 - 43.76 - return i; 43.77 -} 43.78 - 43.79 -static long 43.80 -free_dom_mem(struct domain *d, 43.81 - unsigned long *extent_list, 43.82 - unsigned long start_extent, 43.83 - unsigned int nr_extents, 43.84 - unsigned int extent_order) 43.85 -{ 43.86 - struct pfn_info *page; 43.87 - unsigned long i, j, mpfn; 43.88 - 43.89 - if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) 43.90 - return start_extent; 43.91 - 43.92 - for ( i = start_extent; i < nr_extents; i++ ) 43.93 - { 43.94 - PREEMPT_CHECK(MEMOP_decrease_reservation); 43.95 - 43.96 - if ( unlikely(__get_user(mpfn, &extent_list[i]) != 0) ) 43.97 - return i; 43.98 - 43.99 - for ( j = 0; j < (1 << extent_order); j++ ) 43.100 - { 43.101 - if ( unlikely((mpfn + j) >= max_page) ) 43.102 - { 43.103 - DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", 43.104 - d->domain_id, mpfn + j, max_page); 43.105 - return i; 43.106 - } 43.107 - 43.108 - page = &frame_table[mpfn + j]; 43.109 - if ( unlikely(!get_page(page, d)) ) 43.110 - { 43.111 - DPRINTK("Bad page free for domain %u\n", d->domain_id); 43.112 - return i; 43.113 - } 43.114 - 43.115 - if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) 43.116 - put_page_and_type(page); 43.117 - 43.118 - if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) 43.119 - put_page(page); 43.120 - 43.121 - shadow_sync_and_drop_references(d, page); 43.122 - 43.123 - put_page(page); 43.124 - } 43.125 - } 43.126 - 43.127 - return i; 43.128 -} 43.129 - 43.130 -long 43.131 -do_dom_mem_op(unsigned long op, 43.132 - unsigned long *extent_list, 43.133 - unsigned int nr_extents, 43.134 - unsigned int extent_order, 43.135 - domid_t domid) 43.136 -{ 43.137 - struct domain *d; 43.138 - unsigned long rc, start_extent; 43.139 - unsigned int address_bits_order; 43.140 - 43.141 - /* Extract @start_extent from @op. */ 43.142 - start_extent = op >> START_EXTENT_SHIFT; 43.143 - op &= (1 << START_EXTENT_SHIFT) - 1; 43.144 - 43.145 - /* seperate extent_order and address_bits_order */ 43.146 - address_bits_order = (extent_order >> 8) & 0xff; 43.147 - extent_order &= 0xff; 43.148 - 43.149 - if ( unlikely(start_extent > nr_extents) ) 43.150 - return -EINVAL; 43.151 - 43.152 - if ( likely(domid == DOMID_SELF) ) 43.153 - d = current->domain; 43.154 - else if ( unlikely(!IS_PRIV(current->domain)) ) 43.155 - return -EPERM; 43.156 - else if ( unlikely((d = find_domain_by_id(domid)) == NULL) ) 43.157 - return -ESRCH; 43.158 - 43.159 - switch ( op ) 43.160 - { 43.161 - case MEMOP_increase_reservation: 43.162 - rc = alloc_dom_mem( 43.163 - d, extent_list, start_extent, nr_extents, extent_order, 43.164 - (address_bits_order <= 32) ? ALLOC_DOM_DMA : 0); 43.165 - break; 43.166 - case MEMOP_decrease_reservation: 43.167 - rc = free_dom_mem( 43.168 - d, extent_list, start_extent, nr_extents, extent_order); 43.169 - break; 43.170 - default: 43.171 - rc = -ENOSYS; 43.172 - break; 43.173 - } 43.174 - 43.175 - if ( unlikely(domid != DOMID_SELF) ) 43.176 - put_domain(d); 43.177 - 43.178 - return rc; 43.179 -} 43.180 - 43.181 -/* 43.182 - * Local variables: 43.183 - * mode: C 43.184 - * c-set-style: "BSD" 43.185 - * c-basic-offset: 4 43.186 - * tab-width: 4 43.187 - * indent-tabs-mode: nil 43.188 - * End: 43.189 - */
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/xen/common/memory.c Tue Aug 30 16:15:27 2005 +0000 44.3 @@ -0,0 +1,205 @@ 44.4 +/****************************************************************************** 44.5 + * memory.c 44.6 + * 44.7 + * Code to handle memory-related requests. 44.8 + * 44.9 + * Copyright (c) 2003-2004, B Dragovic 44.10 + * Copyright (c) 2003-2005, K A Fraser 44.11 + */ 44.12 + 44.13 +#include <xen/config.h> 44.14 +#include <xen/types.h> 44.15 +#include <xen/lib.h> 44.16 +#include <xen/mm.h> 44.17 +#include <xen/perfc.h> 44.18 +#include <xen/sched.h> 44.19 +#include <xen/event.h> 44.20 +#include <xen/shadow.h> 44.21 +#include <asm/current.h> 44.22 +#include <asm/hardirq.h> 44.23 +#include <public/memory.h> 44.24 + 44.25 +static long 44.26 +increase_reservation( 44.27 + struct domain *d, 44.28 + unsigned long *extent_list, 44.29 + unsigned int nr_extents, 44.30 + unsigned int extent_order, 44.31 + unsigned int flags) 44.32 +{ 44.33 + struct pfn_info *page; 44.34 + unsigned long i; 44.35 + 44.36 + if ( (extent_list != NULL) 44.37 + && !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) 44.38 + return 0; 44.39 + 44.40 + if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) ) 44.41 + { 44.42 + DPRINTK("Only I/O-capable domains may allocate > order-0 memory.\n"); 44.43 + return 0; 44.44 + } 44.45 + 44.46 + for ( i = 0; i < nr_extents; i++ ) 44.47 + { 44.48 + if ( hypercall_preempt_check() ) 44.49 + return i; 44.50 + 44.51 + if ( unlikely((page = alloc_domheap_pages( 44.52 + d, extent_order, flags)) == NULL) ) 44.53 + { 44.54 + DPRINTK("Could not allocate a frame\n"); 44.55 + return i; 44.56 + } 44.57 + 44.58 + /* Inform the domain of the new page's machine address. */ 44.59 + if ( (extent_list != NULL) 44.60 + && (__put_user(page_to_pfn(page), &extent_list[i]) != 0) ) 44.61 + return i; 44.62 + } 44.63 + 44.64 + return nr_extents; 44.65 +} 44.66 + 44.67 +static long 44.68 +decrease_reservation( 44.69 + struct domain *d, 44.70 + unsigned long *extent_list, 44.71 + unsigned int nr_extents, 44.72 + unsigned int extent_order, 44.73 + unsigned int flags) 44.74 +{ 44.75 + struct pfn_info *page; 44.76 + unsigned long i, j, mpfn; 44.77 + 44.78 + if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) 44.79 + return 0; 44.80 + 44.81 + for ( i = 0; i < nr_extents; i++ ) 44.82 + { 44.83 + if ( hypercall_preempt_check() ) 44.84 + return i; 44.85 + 44.86 + if ( unlikely(__get_user(mpfn, &extent_list[i]) != 0) ) 44.87 + return i; 44.88 + 44.89 + for ( j = 0; j < (1 << extent_order); j++ ) 44.90 + { 44.91 + if ( unlikely((mpfn + j) >= max_page) ) 44.92 + { 44.93 + DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", 44.94 + d->domain_id, mpfn + j, max_page); 44.95 + return i; 44.96 + } 44.97 + 44.98 + page = &frame_table[mpfn + j]; 44.99 + if ( unlikely(!get_page(page, d)) ) 44.100 + { 44.101 + DPRINTK("Bad page free for domain %u\n", d->domain_id); 44.102 + return i; 44.103 + } 44.104 + 44.105 + if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) 44.106 + put_page_and_type(page); 44.107 + 44.108 + if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) 44.109 + put_page(page); 44.110 + 44.111 + shadow_sync_and_drop_references(d, page); 44.112 + 44.113 + put_page(page); 44.114 + } 44.115 + } 44.116 + 44.117 + return nr_extents; 44.118 +} 44.119 + 44.120 +/* 44.121 + * To allow safe resume of do_memory_op() after preemption, we need to know 44.122 + * at what point in the page list to resume. For this purpose I steal the 44.123 + * high-order bits of the @cmd parameter, which are otherwise unused and zero. 44.124 + */ 44.125 +#define START_EXTENT_SHIFT 4 /* cmd[:4] == start_extent */ 44.126 + 44.127 +long do_memory_op(int cmd, void *arg) 44.128 +{ 44.129 + struct domain *d; 44.130 + int rc, start_extent, op, flags = 0; 44.131 + struct xen_memory_reservation reservation; 44.132 + 44.133 + op = cmd & ((1 << START_EXTENT_SHIFT) - 1); 44.134 + 44.135 + switch ( op ) 44.136 + { 44.137 + case XENMEM_increase_reservation: 44.138 + case XENMEM_decrease_reservation: 44.139 + if ( copy_from_user(&reservation, arg, sizeof(reservation)) ) 44.140 + return -EFAULT; 44.141 + 44.142 + start_extent = cmd >> START_EXTENT_SHIFT; 44.143 + if ( unlikely(start_extent > reservation.nr_extents) ) 44.144 + return -EINVAL; 44.145 + 44.146 + if ( reservation.extent_start != NULL ) 44.147 + reservation.extent_start += start_extent; 44.148 + reservation.nr_extents -= start_extent; 44.149 + 44.150 + if ( unlikely(reservation.address_bits != 0) 44.151 + && (reservation.address_bits > (get_order(max_page)+PAGE_SHIFT)) ) 44.152 + { 44.153 + if ( reservation.address_bits < 31 ) 44.154 + return -ENOMEM; 44.155 + flags = ALLOC_DOM_DMA; 44.156 + } 44.157 + 44.158 + if ( likely(reservation.domid == DOMID_SELF) ) 44.159 + d = current->domain; 44.160 + else if ( !IS_PRIV(current->domain) ) 44.161 + return -EPERM; 44.162 + else if ( (d = find_domain_by_id(reservation.domid)) == NULL ) 44.163 + return -ESRCH; 44.164 + 44.165 + rc = ((op == XENMEM_increase_reservation) ? 44.166 + increase_reservation : decrease_reservation)( 44.167 + d, 44.168 + reservation.extent_start, 44.169 + reservation.nr_extents, 44.170 + reservation.extent_order, 44.171 + flags); 44.172 + 44.173 + if ( unlikely(reservation.domid != DOMID_SELF) ) 44.174 + put_domain(d); 44.175 + 44.176 + rc += start_extent; 44.177 + 44.178 + if ( (rc != reservation.nr_extents) && hypercall_preempt_check() ) 44.179 + return hypercall2_create_continuation( 44.180 + __HYPERVISOR_memory_op, 44.181 + op | (rc << START_EXTENT_SHIFT), 44.182 + arg); 44.183 + 44.184 + break; 44.185 + 44.186 + case XENMEM_maximum_ram_page: 44.187 + if ( put_user(max_page, (unsigned long *)arg) ) 44.188 + return -EFAULT; 44.189 + rc = -ENOSYS; 44.190 + break; 44.191 + 44.192 + default: 44.193 + rc = -ENOSYS; 44.194 + break; 44.195 + } 44.196 + 44.197 + return rc; 44.198 +} 44.199 + 44.200 +/* 44.201 + * Local variables: 44.202 + * mode: C 44.203 + * c-set-style: "BSD" 44.204 + * c-basic-offset: 4 44.205 + * tab-width: 4 44.206 + * indent-tabs-mode: nil 44.207 + * End: 44.208 + */
45.1 --- a/xen/common/page_alloc.c Tue Aug 30 16:14:53 2005 +0000 45.2 +++ b/xen/common/page_alloc.c Tue Aug 30 16:15:27 2005 +0000 45.3 @@ -216,7 +216,7 @@ unsigned long alloc_boot_pages(unsigned 45.4 #define NR_ZONES 3 45.5 45.6 45.7 -#define MAX_DMADOM_PFN 0xFFFFF 45.8 +#define MAX_DMADOM_PFN 0x7FFFF /* 31 addressable bits */ 45.9 #define pfn_dom_zone_type(_pfn) \ 45.10 (((_pfn) <= MAX_DMADOM_PFN) ? MEMZONE_DMADOM : MEMZONE_DOM) 45.11
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/xen/include/public/memory.h Tue Aug 30 16:15:27 2005 +0000 46.3 @@ -0,0 +1,50 @@ 46.4 +/****************************************************************************** 46.5 + * memory.h 46.6 + * 46.7 + * Memory reservation and information. 46.8 + * 46.9 + * Copyright (c) 2005, Keir Fraser <keir@xensource.com> 46.10 + */ 46.11 + 46.12 +#ifndef __XEN_PUBLIC_MEMORY_H__ 46.13 +#define __XEN_PUBLIC_MEMORY_H__ 46.14 + 46.15 +/* arg == addr of struct xen_memory_reservation. */ 46.16 +#define XENMEM_increase_reservation 0 46.17 + 46.18 +/* arg == addr of struct xen_memory_reservation. */ 46.19 +#define XENMEM_decrease_reservation 1 46.20 + 46.21 +/* arg == addr of unsigned long. */ 46.22 +#define XENMEM_maximum_ram_page 2 46.23 + 46.24 +typedef struct xen_memory_reservation { 46.25 + 46.26 + /* 46.27 + * MFN bases of extents to free (XENMEM_decrease_reservation). 46.28 + * MFN bases of extents that were allocated (XENMEM_increase_reservation). 46.29 + */ 46.30 + unsigned long *extent_start; 46.31 + 46.32 + /* Number of extents, and size/alignment of each (2^extent_order pages). */ 46.33 + unsigned long nr_extents; 46.34 + unsigned int extent_order; 46.35 + 46.36 + /* 46.37 + * XENMEM_increase_reservation: maximum # bits addressable by the user 46.38 + * of the allocated region (e.g., I/O devices often have a 32-bit 46.39 + * limitation even in 64-bit systems). If zero then the user has no 46.40 + * addressing restriction. 46.41 + * XENMEM_decrease_reservation: unused. 46.42 + */ 46.43 + unsigned int address_bits; 46.44 + 46.45 + /* 46.46 + * Domain whose reservation is being changed. 46.47 + * Unprivileged domains can specify only DOMID_SELF. 46.48 + */ 46.49 + domid_t domid; 46.50 + 46.51 +} xen_memory_reservation_t; 46.52 + 46.53 +#endif /* __XEN_PUBLIC_MEMORY_H__ */
47.1 --- a/xen/include/public/xen.h Tue Aug 30 16:14:53 2005 +0000 47.2 +++ b/xen/include/public/xen.h Tue Aug 30 16:15:27 2005 +0000 47.3 @@ -42,7 +42,7 @@ 47.4 #define __HYPERVISOR_set_debugreg 8 47.5 #define __HYPERVISOR_get_debugreg 9 47.6 #define __HYPERVISOR_update_descriptor 10 47.7 -#define __HYPERVISOR_dom_mem_op 12 47.8 +#define __HYPERVISOR_memory_op 12 47.9 #define __HYPERVISOR_multicall 13 47.10 #define __HYPERVISOR_update_va_mapping 14 47.11 #define __HYPERVISOR_set_timer_op 15 47.12 @@ -225,12 +225,6 @@ struct mmuext_op { 47.13 #define CONSOLEIO_read 1 47.14 47.15 /* 47.16 - * Commands to HYPERVISOR_dom_mem_op(). 47.17 - */ 47.18 -#define MEMOP_increase_reservation 0 47.19 -#define MEMOP_decrease_reservation 1 47.20 - 47.21 -/* 47.22 * Commands to HYPERVISOR_vm_assist(). 47.23 */ 47.24 #define VMASST_CMD_enable 0