ia64/xen-unstable

changeset 13991:c4ed5b740a8d

linux: remove {lock,unlock}_vm_area(). Instead use vmalloc_sync_all()
in alloc_vm_area().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Feb 16 11:24:10 2007 +0000 (2007-02-16)
parents cd03d7c23aa7
children eecd0361df4a
files linux-2.6-xen-sparse/arch/ia64/xen/util.c linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/blktap/interface.c linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c linux-2.6-xen-sparse/drivers/xen/util.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c linux-2.6-xen-sparse/include/xen/driver_util.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Fri Feb 16 09:57:25 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Fri Feb 16 11:24:10 2007 +0000
     1.3 @@ -95,18 +95,6 @@ void free_vm_area(struct vm_struct *area
     1.4  }
     1.5  EXPORT_SYMBOL_GPL(free_vm_area);
     1.6  
     1.7 -void lock_vm_area(struct vm_struct *area)
     1.8 -{
     1.9 -	// nothing
    1.10 -}
    1.11 -EXPORT_SYMBOL_GPL(lock_vm_area);
    1.12 -
    1.13 -void unlock_vm_area(struct vm_struct *area)
    1.14 -{
    1.15 -	// nothing
    1.16 -}
    1.17 -EXPORT_SYMBOL_GPL(unlock_vm_area);
    1.18 -
    1.19  /*
    1.20   * Local variables:
    1.21   *  c-file-style: "linux"
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Fri Feb 16 09:57:25 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Fri Feb 16 11:24:10 2007 +0000
     2.3 @@ -58,15 +58,12 @@ blkif_t *blkif_alloc(domid_t domid)
     2.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
     2.5  {
     2.6  	struct gnttab_map_grant_ref op;
     2.7 -	int ret;
     2.8  
     2.9  	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
    2.10  			  GNTMAP_host_map, shared_page, blkif->domid);
    2.11  
    2.12 -	lock_vm_area(blkif->blk_ring_area);
    2.13 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    2.14 -	unlock_vm_area(blkif->blk_ring_area);
    2.15 -	BUG_ON(ret);
    2.16 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    2.17 +		BUG();
    2.18  
    2.19  	if (op.status) {
    2.20  		DPRINTK(" Grant table operation failure !\n");
    2.21 @@ -82,15 +79,12 @@ static int map_frontend_page(blkif_t *bl
    2.22  static void unmap_frontend_page(blkif_t *blkif)
    2.23  {
    2.24  	struct gnttab_unmap_grant_ref op;
    2.25 -	int ret;
    2.26  
    2.27  	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
    2.28  			    GNTMAP_host_map, blkif->shmem_handle);
    2.29  
    2.30 -	lock_vm_area(blkif->blk_ring_area);
    2.31 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    2.32 -	unlock_vm_area(blkif->blk_ring_area);
    2.33 -	BUG_ON(ret);
    2.34 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    2.35 +		BUG();
    2.36  }
    2.37  
    2.38  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Fri Feb 16 09:57:25 2007 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Fri Feb 16 11:24:10 2007 +0000
     3.3 @@ -58,15 +58,12 @@ blkif_t *tap_alloc_blkif(domid_t domid)
     3.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
     3.5  {
     3.6  	struct gnttab_map_grant_ref op;
     3.7 -	int ret;
     3.8  
     3.9  	gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
    3.10  			  GNTMAP_host_map, shared_page, blkif->domid);
    3.11  
    3.12 -	lock_vm_area(blkif->blk_ring_area);
    3.13 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    3.14 -	unlock_vm_area(blkif->blk_ring_area);
    3.15 -	BUG_ON(ret);
    3.16 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    3.17 +		BUG();
    3.18  
    3.19  	if (op.status) {
    3.20  		DPRINTK(" Grant table operation failure !\n");
    3.21 @@ -82,15 +79,12 @@ static int map_frontend_page(blkif_t *bl
    3.22  static void unmap_frontend_page(blkif_t *blkif)
    3.23  {
    3.24  	struct gnttab_unmap_grant_ref op;
    3.25 -	int ret;
    3.26  
    3.27  	gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
    3.28  			    GNTMAP_host_map, blkif->shmem_handle);
    3.29  
    3.30 -	lock_vm_area(blkif->blk_ring_area);
    3.31 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    3.32 -	unlock_vm_area(blkif->blk_ring_area);
    3.33 -	BUG_ON(ret);
    3.34 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    3.35 +		BUG();
    3.36  }
    3.37  
    3.38  int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Fri Feb 16 09:57:25 2007 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Fri Feb 16 11:24:10 2007 +0000
     4.3 @@ -194,15 +194,12 @@ static int map_frontend_pages(
     4.4  	netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
     4.5  {
     4.6  	struct gnttab_map_grant_ref op;
     4.7 -	int ret;
     4.8  
     4.9  	gnttab_set_map_op(&op, (unsigned long)netif->tx_comms_area->addr,
    4.10  			  GNTMAP_host_map, tx_ring_ref, netif->domid);
    4.11      
    4.12 -	lock_vm_area(netif->tx_comms_area);
    4.13 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    4.14 -	unlock_vm_area(netif->tx_comms_area);
    4.15 -	BUG_ON(ret);
    4.16 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    4.17 +		BUG();
    4.18  
    4.19  	if (op.status) { 
    4.20  		DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
    4.21 @@ -215,10 +212,8 @@ static int map_frontend_pages(
    4.22  	gnttab_set_map_op(&op, (unsigned long)netif->rx_comms_area->addr,
    4.23  			  GNTMAP_host_map, rx_ring_ref, netif->domid);
    4.24  
    4.25 -	lock_vm_area(netif->rx_comms_area);
    4.26 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    4.27 -	unlock_vm_area(netif->rx_comms_area);
    4.28 -	BUG_ON(ret);
    4.29 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    4.30 +		BUG();
    4.31  
    4.32  	if (op.status) {
    4.33  		DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
    4.34 @@ -234,23 +229,18 @@ static int map_frontend_pages(
    4.35  static void unmap_frontend_pages(netif_t *netif)
    4.36  {
    4.37  	struct gnttab_unmap_grant_ref op;
    4.38 -	int ret;
    4.39  
    4.40  	gnttab_set_unmap_op(&op, (unsigned long)netif->tx_comms_area->addr,
    4.41  			    GNTMAP_host_map, netif->tx_shmem_handle);
    4.42  
    4.43 -	lock_vm_area(netif->tx_comms_area);
    4.44 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    4.45 -	unlock_vm_area(netif->tx_comms_area);
    4.46 -	BUG_ON(ret);
    4.47 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    4.48 +		BUG();
    4.49  
    4.50  	gnttab_set_unmap_op(&op, (unsigned long)netif->rx_comms_area->addr,
    4.51  			    GNTMAP_host_map, netif->rx_shmem_handle);
    4.52  
    4.53 -	lock_vm_area(netif->rx_comms_area);
    4.54 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    4.55 -	unlock_vm_area(netif->rx_comms_area);
    4.56 -	BUG_ON(ret);
    4.57 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    4.58 +		BUG();
    4.59  }
    4.60  
    4.61  int netif_map(netif_t *netif, unsigned long tx_ring_ref,
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Fri Feb 16 09:57:25 2007 +0000
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Fri Feb 16 11:24:10 2007 +0000
     5.3 @@ -79,16 +79,13 @@ tpmif_t *tpmif_find(domid_t domid, struc
     5.4  
     5.5  static int map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
     5.6  {
     5.7 -	int ret;
     5.8  	struct gnttab_map_grant_ref op;
     5.9  
    5.10  	gnttab_set_map_op(&op, (unsigned long)tpmif->tx_area->addr,
    5.11  			  GNTMAP_host_map, shared_page, tpmif->domid);
    5.12  
    5.13 -	lock_vm_area(tpmif->tx_area);
    5.14 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    5.15 -	unlock_vm_area(tpmif->tx_area);
    5.16 -	BUG_ON(ret);
    5.17 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    5.18 +		BUG();
    5.19  
    5.20  	if (op.status) {
    5.21  		DPRINTK(" Grant table operation failure !\n");
    5.22 @@ -104,15 +101,12 @@ static int map_frontend_page(tpmif_t *tp
    5.23  static void unmap_frontend_page(tpmif_t *tpmif)
    5.24  {
    5.25  	struct gnttab_unmap_grant_ref op;
    5.26 -	int ret;
    5.27  
    5.28  	gnttab_set_unmap_op(&op, (unsigned long)tpmif->tx_area->addr,
    5.29  			    GNTMAP_host_map, tpmif->shmem_handle);
    5.30  
    5.31 -	lock_vm_area(tpmif->tx_area);
    5.32 -	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    5.33 -	unlock_vm_area(tpmif->tx_area);
    5.34 -	BUG_ON(ret);
    5.35 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    5.36 +		BUG();
    5.37  }
    5.38  
    5.39  int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/util.c	Fri Feb 16 09:57:25 2007 +0000
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/util.c	Fri Feb 16 11:24:10 2007 +0000
     6.3 @@ -30,6 +30,9 @@ struct vm_struct *alloc_vm_area(unsigned
     6.4  		return NULL;
     6.5  	}
     6.6  
     6.7 +	/* Map page directories into every address space. */
     6.8 +	vmalloc_sync_all();
     6.9 +
    6.10  	return area;
    6.11  }
    6.12  EXPORT_SYMBOL_GPL(alloc_vm_area);
    6.13 @@ -42,29 +45,3 @@ void free_vm_area(struct vm_struct *area
    6.14  	kfree(area);
    6.15  }
    6.16  EXPORT_SYMBOL_GPL(free_vm_area);
    6.17 -
    6.18 -void lock_vm_area(struct vm_struct *area)
    6.19 -{
    6.20 -	unsigned long i;
    6.21 -	char c;
    6.22 -
    6.23 -	/*
    6.24 -	 * Prevent context switch to a lazy mm that doesn't have this area
    6.25 -	 * mapped into its page tables.
    6.26 -	 */
    6.27 -	preempt_disable();
    6.28 -
    6.29 -	/*
    6.30 -	 * Ensure that the page tables are mapped into the current mm. The
    6.31 -	 * page-fault path will copy the page directory pointers from init_mm.
    6.32 -	 */
    6.33 -	for (i = 0; i < area->size; i += PAGE_SIZE)
    6.34 -		(void)__get_user(c, (char __user *)area->addr + i);
    6.35 -}
    6.36 -EXPORT_SYMBOL_GPL(lock_vm_area);
    6.37 -
    6.38 -void unlock_vm_area(struct vm_struct *area)
    6.39 -{
    6.40 -	preempt_enable();
    6.41 -}
    6.42 -EXPORT_SYMBOL_GPL(unlock_vm_area);
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Fri Feb 16 09:57:25 2007 +0000
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Fri Feb 16 11:24:10 2007 +0000
     7.3 @@ -48,9 +48,8 @@ struct vm_struct *xenbus_map_ring_valloc
     7.4  	gnttab_set_map_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
     7.5  			  gnt_ref, dev->otherend_id);
     7.6  	
     7.7 -	lock_vm_area(area);
     7.8 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
     7.9 -	unlock_vm_area(area);
    7.10 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    7.11 +		BUG();
    7.12  
    7.13  	if (op.status != GNTST_okay) {
    7.14  		free_vm_area(area);
    7.15 @@ -76,7 +75,8 @@ int xenbus_map_ring(struct xenbus_device
    7.16  	
    7.17  	gnttab_set_map_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
    7.18  			  gnt_ref, dev->otherend_id);
    7.19 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
    7.20 +	if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
    7.21 +		BUG();
    7.22  
    7.23  	if (op.status != GNTST_okay) {
    7.24  		xenbus_dev_fatal(dev, op.status,
    7.25 @@ -98,9 +98,8 @@ int xenbus_unmap_ring_vfree(struct xenbu
    7.26  	gnttab_set_unmap_op(&op, (unsigned long)area->addr, GNTMAP_host_map,
    7.27  			    (grant_handle_t)area->phys_addr);
    7.28  
    7.29 -	lock_vm_area(area);
    7.30 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    7.31 -	unlock_vm_area(area);
    7.32 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    7.33 +		BUG();
    7.34  
    7.35  	if (op.status == GNTST_okay)
    7.36  		free_vm_area(area);
    7.37 @@ -121,7 +120,8 @@ int xenbus_unmap_ring(struct xenbus_devi
    7.38  
    7.39  	gnttab_set_unmap_op(&op, (unsigned long)vaddr, GNTMAP_host_map,
    7.40  			    handle);
    7.41 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    7.42 +	if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
    7.43 +		BUG();
    7.44  
    7.45  	if (op.status != GNTST_okay)
    7.46  		xenbus_dev_error(dev, op.status,
     8.1 --- a/linux-2.6-xen-sparse/include/xen/driver_util.h	Fri Feb 16 09:57:25 2007 +0000
     8.2 +++ b/linux-2.6-xen-sparse/include/xen/driver_util.h	Fri Feb 16 11:24:10 2007 +0000
     8.3 @@ -9,8 +9,4 @@
     8.4  extern struct vm_struct *alloc_vm_area(unsigned long size);
     8.5  extern void free_vm_area(struct vm_struct *area);
     8.6  
     8.7 -/* Lock an area so that PTEs are accessible in the current address space. */
     8.8 -extern void lock_vm_area(struct vm_struct *area);
     8.9 -extern void unlock_vm_area(struct vm_struct *area);
    8.10 -
    8.11  #endif /* __ASM_XEN_DRIVER_UTIL_H__ */