ia64/xen-unstable

changeset 10002:d86236cb824a

[IA64] linux: remove dom0vp_populate_physmap hypercall

dom0 vp model: remove populate_physmap hypercall which becomes unnecesarry
because xenmem operation is fully supported by the previous patch.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Fri May 12 08:53:49 2006 -0600 (2006-05-12)
parents 8c0d89f8d0f7
children 8b2295822e0d
files linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c linux-2.6-xen-sparse/arch/ia64/xen/util.c linux-2.6-xen-sparse/include/asm-ia64/hypercall.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Fri May 12 08:49:40 2006 -0600
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Fri May 12 08:53:49 2006 -0600
     1.3 @@ -8,7 +8,7 @@ obj-y	+= core/
     1.4  #obj-y	+= char/
     1.5  obj-y	+= console/
     1.6  obj-y	+= evtchn/
     1.7 -#obj-y	+= balloon/
     1.8 +obj-$(CONFIG_XEN_IA64_DOM0_VP)	+= balloon/
     1.9  obj-y	+= privcmd/
    1.10  obj-y	+= xenbus/
    1.11  
     2.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Fri May 12 08:49:40 2006 -0600
     2.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Fri May 12 08:53:49 2006 -0600
     2.3 @@ -26,14 +26,8 @@
     2.4  #include <asm/page.h>
     2.5  #include <asm/hypervisor.h>
     2.6  #include <asm/hypercall.h>
     2.7 -
     2.8 -#define XEN_IA64_BALLOON_IS_NOT_YET
     2.9 -#ifndef XEN_IA64_BALLOON_IS_NOT_YET
    2.10 +#include <xen/interface/memory.h>
    2.11  #include <xen/balloon.h>
    2.12 -#else
    2.13 -#define balloon_lock(flags)	((void)flags)
    2.14 -#define balloon_unlock(flags)	((void)flags)
    2.15 -#endif
    2.16  
    2.17  //XXX xen/ia64 copy_from_guest() is broken.
    2.18  //    This is a temporal work around until it is fixed.
    2.19 @@ -148,6 +142,39 @@ static void contiguous_bitmap_clear(
    2.20  	}
    2.21  }
    2.22  
    2.23 +static unsigned long
    2.24 +HYPERVISOR_populate_physmap(unsigned long gpfn, unsigned int extent_order,
    2.25 +			    unsigned int address_bits)
    2.26 +{
    2.27 +	unsigned long ret;
    2.28 +        struct xen_memory_reservation reservation = {
    2.29 +		.nr_extents   = 1,
    2.30 +                .address_bits = address_bits,
    2.31 +                .extent_order = extent_order,
    2.32 +                .domid        = DOMID_SELF
    2.33 +        };
    2.34 +	set_xen_guest_handle(reservation.extent_start, &gpfn);
    2.35 +	ret = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
    2.36 +	BUG_ON(ret != 1);
    2.37 +	return 0;
    2.38 +}
    2.39 +
    2.40 +static unsigned long
    2.41 +HYPERVISOR_remove_physmap(unsigned long gpfn, unsigned int extent_order)
    2.42 +{
    2.43 +	unsigned long ret;
    2.44 +	struct xen_memory_reservation reservation = {
    2.45 +		.nr_extents   = 1,
    2.46 +		.address_bits = 0,
    2.47 +		.extent_order = extent_order,
    2.48 +		.domid        = DOMID_SELF
    2.49 +	};
    2.50 +	set_xen_guest_handle(reservation.extent_start, &gpfn);
    2.51 +	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    2.52 +	BUG_ON(ret != 1);
    2.53 +	return 0;
    2.54 +}
    2.55 +
    2.56  /* Ensure multi-page extents are contiguous in machine memory. */
    2.57  int
    2.58  __xen_create_contiguous_region(unsigned long vstart,
    2.59 @@ -156,29 +183,29 @@ int
    2.60  	unsigned long error = 0;
    2.61  	unsigned long gphys = __pa(vstart);
    2.62  	unsigned long start_gpfn = gphys >> PAGE_SHIFT;
    2.63 -	unsigned long num_pfn = 1 << order;
    2.64 +	unsigned long num_gpfn = 1 << order;
    2.65  	unsigned long i;
    2.66  	unsigned long flags;
    2.67  
    2.68 -	scrub_pages(vstart, 1 << order);
    2.69 +	scrub_pages(vstart, num_gpfn);
    2.70  
    2.71  	balloon_lock(flags);
    2.72  
    2.73 -	//XXX order
    2.74 -	for (i = 0; i < num_pfn; i++) {
    2.75 -		error = HYPERVISOR_zap_physmap(start_gpfn + i, 0);
    2.76 -		if (error) {
    2.77 -			goto out;
    2.78 -		}
    2.79 +	error = HYPERVISOR_remove_physmap(start_gpfn, order);
    2.80 +	if (error) {
    2.81 +		goto fail;
    2.82  	}
    2.83  
    2.84  	error = HYPERVISOR_populate_physmap(start_gpfn, order, address_bits);
    2.85 -	contiguous_bitmap_set(start_gpfn, 1UL << order);
    2.86 +	if (error) {
    2.87 +		goto fail;
    2.88 +	}
    2.89 +	contiguous_bitmap_set(start_gpfn, num_gpfn);
    2.90  #if 0
    2.91  	{
    2.92  	unsigned long mfn;
    2.93  	unsigned long mfn_prev = ~0UL;
    2.94 -	for (i = 0; i < 1 << order; i++) {
    2.95 +	for (i = 0; i < num_gpfn; i++) {
    2.96  		mfn = pfn_to_mfn_for_dma(start_gpfn + i);
    2.97  		if (mfn_prev != ~0UL && mfn != mfn_prev + 1) {
    2.98  			xprintk("\n");
    2.99 @@ -188,7 +215,7 @@ int
   2.100  				vstart, virt_to_bus((void*)vstart),
   2.101  				phys_to_machine_for_dma(gphys));
   2.102  			xprintk("mfn: ");
   2.103 -			for (i = 0; i < 1 << order; i++) {
   2.104 +			for (i = 0; i < num_gpfn; i++) {
   2.105  				mfn = pfn_to_mfn_for_dma(start_gpfn + i);
   2.106  				xprintk("0x%lx ", mfn);
   2.107  			}
   2.108 @@ -202,44 +229,73 @@ int
   2.109  out:
   2.110  	balloon_unlock(flags);
   2.111  	return error;
   2.112 +
   2.113 +fail:
   2.114 +	for (i = 0; i < num_gpfn; i++) {
   2.115 +		error = HYPERVISOR_populate_physmap(start_gpfn + i, 0, 0);
   2.116 +		if (error) {
   2.117 +			BUG();//XXX
   2.118 +		}
   2.119 +	}
   2.120 +	goto out;
   2.121  }
   2.122  
   2.123  void
   2.124  __xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
   2.125  {
   2.126 +	unsigned long flags;
   2.127  	unsigned long error = 0;
   2.128 -	unsigned long gphys = __pa(vstart);
   2.129 -	unsigned long start_gpfn = gphys >> PAGE_SHIFT;
   2.130 -	unsigned long num_pfn = 1 << order;
   2.131 +	unsigned long start_gpfn = __pa(vstart) >> PAGE_SHIFT;
   2.132 +	unsigned long num_gpfn = 1UL << order;
   2.133 +	unsigned long* gpfns;
   2.134 +	struct xen_memory_reservation reservation;
   2.135  	unsigned long i;
   2.136 -	unsigned long flags;
   2.137  
   2.138 -	scrub_pages(vstart, 1 << order);
   2.139 +	gpfns = kmalloc(sizeof(gpfns[0]) * num_gpfn,
   2.140 +			GFP_KERNEL | __GFP_NOFAIL);
   2.141 +	for (i = 0; i < num_gpfn; i++) {
   2.142 +		gpfns[i] = start_gpfn + i;
   2.143 +	}
   2.144 +
   2.145 +	scrub_pages(vstart, num_gpfn);
   2.146  
   2.147  	balloon_lock(flags);
   2.148  
   2.149 -	contiguous_bitmap_clear(start_gpfn, 1UL << order);
   2.150 -
   2.151 -	//XXX order
   2.152 -	for (i = 0; i < num_pfn; i++) {
   2.153 -		error = HYPERVISOR_zap_physmap(start_gpfn + i, 0);
   2.154 -		if (error) {
   2.155 -			goto out;
   2.156 -		}
   2.157 +	contiguous_bitmap_clear(start_gpfn, num_gpfn);
   2.158 +	error = HYPERVISOR_remove_physmap(start_gpfn, order);
   2.159 +	if (error) {
   2.160 +		goto fail;
   2.161  	}
   2.162  
   2.163 -	for (i = 0; i < num_pfn; i++) {
   2.164 -		error = HYPERVISOR_populate_physmap(start_gpfn + i, 0, 0);
   2.165 -		if (error) {
   2.166 -			goto out;
   2.167 +	set_xen_guest_handle(reservation.extent_start, gpfns);
   2.168 +	reservation.nr_extents   = num_gpfn;
   2.169 +	reservation.address_bits = 0;
   2.170 +	reservation.extent_order = 0;
   2.171 +	reservation.domid        = DOMID_SELF;
   2.172 +	error = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
   2.173 +	if (error != num_gpfn) {
   2.174 +		error = -EFAULT;//XXX
   2.175 +		goto fail;
   2.176 +	}
   2.177 +	error = 0;
   2.178 +out:
   2.179 +	balloon_unlock(flags);
   2.180 +	kfree(gpfns);
   2.181 +	if (error) {
   2.182 +		// error can't be returned.
   2.183 +		BUG();//XXX
   2.184 +	}
   2.185 +	return;
   2.186 +
   2.187 +fail:
   2.188 +	for (i = 0; i < num_gpfn; i++) {
   2.189 +		int tmp_error;// don't overwrite error.
   2.190 +		tmp_error = HYPERVISOR_populate_physmap(start_gpfn + i, 0, 0);
   2.191 +		if (tmp_error) {
   2.192 +			BUG();//XXX
   2.193  		}
   2.194  	}
   2.195 -
   2.196 -out:
   2.197 -	balloon_unlock(flags);
   2.198 -	if (error) {
   2.199 -		//XXX
   2.200 -	}
   2.201 +	goto out;
   2.202  }
   2.203  
   2.204  
   2.205 @@ -297,38 +353,6 @@ HYPERVISOR_grant_table_op(unsigned int c
   2.206  
   2.207  
   2.208  ///////////////////////////////////////////////////////////////////////////
   2.209 -//XXX taken from balloon.c
   2.210 -//    temporal hack until balloon driver support.
   2.211 -#include <linux/module.h>
   2.212 -
   2.213 -struct page *balloon_alloc_empty_page_range(unsigned long nr_pages)
   2.214 -{
   2.215 -	unsigned long vstart;
   2.216 -	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
   2.217 -
   2.218 -	vstart = __get_free_pages(GFP_KERNEL, order);
   2.219 -	if (vstart == 0)
   2.220 -		return NULL;
   2.221 -
   2.222 -	return virt_to_page(vstart);
   2.223 -}
   2.224 -
   2.225 -void balloon_dealloc_empty_page_range(
   2.226 -	struct page *page, unsigned long nr_pages)
   2.227 -{
   2.228 -	__free_pages(page, get_order(nr_pages * PAGE_SIZE));
   2.229 -}
   2.230 -
   2.231 -void balloon_update_driver_allowance(long delta)
   2.232 -{
   2.233 -}
   2.234 -
   2.235 -EXPORT_SYMBOL(balloon_alloc_empty_page_range);
   2.236 -EXPORT_SYMBOL(balloon_dealloc_empty_page_range);
   2.237 -EXPORT_SYMBOL(balloon_update_driver_allowance);
   2.238 -
   2.239 -
   2.240 -///////////////////////////////////////////////////////////////////////////
   2.241  // PageForeign(), SetPageForeign(), ClearPageForeign()
   2.242  
   2.243  struct address_space xen_ia64_foreign_dummy_mapping;
     3.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Fri May 12 08:49:40 2006 -0600
     3.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Fri May 12 08:53:49 2006 -0600
     3.3 @@ -74,13 +74,18 @@ void free_vm_area(struct vm_struct *area
     3.4  	// This area is used for foreign page mappping.
     3.5  	// So underlying machine page may not be assigned.
     3.6  	for (i = 0; i < (1 << order); i++) {
     3.7 -		unsigned long error;
     3.8 -		error = HYPERVISOR_populate_physmap(
     3.9 -			(area->phys_addr >> PAGE_SHIFT) + i, 0, 0);
    3.10 -		if (error) {
    3.11 -			BUG();//XXX
    3.12 -			return;
    3.13 -		}
    3.14 +		unsigned long ret;
    3.15 +		unsigned long gpfn = (area->phys_addr >> PAGE_SHIFT) + i;
    3.16 +		struct xen_memory_reservation reservation = {
    3.17 +			.nr_extents   = 1,
    3.18 +			.address_bits = 0,
    3.19 +			.extent_order = 0,
    3.20 +			.domid        = DOMID_SELF
    3.21 +		};
    3.22 +		set_xen_guest_handle(reservation.extent_start, &gpfn);
    3.23 +		ret = HYPERVISOR_memory_op(XENMEM_populate_physmap,
    3.24 +					   &reservation);
    3.25 +		BUG_ON(ret != 1);
    3.26  	}
    3.27  	free_pages((unsigned long)area->addr, order);
    3.28  	kfree(area);
     4.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Fri May 12 08:49:40 2006 -0600
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Fri May 12 08:53:49 2006 -0600
     4.3 @@ -458,27 +458,6 @@ HYPERVISOR_machtophys(unsigned long mfn)
     4.4  }
     4.5  
     4.6  static inline unsigned long
     4.7 -__HYPERVISOR_populate_physmap(unsigned long gpfn, unsigned int extent_order,
     4.8 -			      unsigned int address_bits)
     4.9 -{
    4.10 -	return _hypercall_imm3(unsigned long, ia64_dom0vp_op,
    4.11 -			       IA64_DOM0VP_populate_physmap, gpfn, 
    4.12 -			       extent_order, address_bits);
    4.13 -}
    4.14 -
    4.15 -static inline unsigned long
    4.16 -HYPERVISOR_populate_physmap(unsigned long gpfn, unsigned int extent_order,
    4.17 -			    unsigned int address_bits)
    4.18 -{
    4.19 -	unsigned long ret = 0;
    4.20 -	if (running_on_xen) {
    4.21 -		ret = __HYPERVISOR_populate_physmap(gpfn, extent_order,
    4.22 -						    address_bits);
    4.23 -	}
    4.24 -	return ret;
    4.25 -}
    4.26 -
    4.27 -static inline unsigned long
    4.28  __HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
    4.29  {
    4.30  	return _hypercall_imm2(unsigned long, ia64_dom0vp_op,
    4.31 @@ -503,6 +482,7 @@ static inline unsigned long
    4.32  			       IA64_DOM0VP_add_physmap, gpfn, mfn, flags,
    4.33  			       domid);
    4.34  }
    4.35 +
    4.36  static inline unsigned long
    4.37  HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
    4.38  		       unsigned int flags, domid_t domid)
    4.39 @@ -522,8 +502,6 @@ HYPERVISOR_add_physmap(unsigned long gpf
    4.40  #define HYPERVISOR_ioremap(ioaddr, size)		(ioaddr)
    4.41  #define HYPERVISOR_phystomach(gpfn)			(gpfn)
    4.42  #define HYPERVISOR_machtophys(mfn)			(mfn)
    4.43 -#define HYPERVISOR_populate_physmap(gpfn, extent_order, address_bits) \
    4.44 -							(0)
    4.45  #define HYPERVISOR_zap_physmap(gpfn, extent_order)	(0)
    4.46  #define HYPERVISOR_add_physmap(gpfn, mfn, flags)	(0)
    4.47  #endif