ia64/xen-unstable

changeset 7767:4982559d8fde

Indirect writes to phys_to_machine_mapping array through an inline
function defined in page.h.

For self-migration, I need the ability to trap writes to the p2m map
during migration, because I keep a dictionary mapping mfns to pfns,
which I use for remapping the page tables once I am on the other side.

Signed-off-by: Jacob Gorm Hansen <jacobg@diku.dk>
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 10 15:16:01 2005 +0100 (2005-11-10)
parents d916497135ac
children 975aa9e4def3
files linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Nov 10 15:03:33 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Nov 10 15:16:01 2005 +0100
     1.3 @@ -342,8 +342,8 @@ int xen_create_contiguous_region(
     1.4  		mfn = pte_mfn(*pte);
     1.5  		BUG_ON(HYPERVISOR_update_va_mapping(
     1.6  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
     1.7 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
     1.8 -			INVALID_P2M_ENTRY;
     1.9 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
    1.10 +			INVALID_P2M_ENTRY);
    1.11  		BUG_ON(HYPERVISOR_memory_op(
    1.12  			XENMEM_decrease_reservation, &reservation) != 1);
    1.13  	}
    1.14 @@ -361,7 +361,7 @@ int xen_create_contiguous_region(
    1.15  			vstart + (i*PAGE_SIZE),
    1.16  			pfn_pte_ma(mfn+i, PAGE_KERNEL), 0));
    1.17  		xen_machphys_update(mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
    1.18 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn+i;
    1.19 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn+i);
    1.20  	}
    1.21  
    1.22  	flush_tlb_all();
    1.23 @@ -383,7 +383,7 @@ int xen_create_contiguous_region(
    1.24  			vstart + (i*PAGE_SIZE),
    1.25  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
    1.26  		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
    1.27 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
    1.28 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
    1.29  	}
    1.30  
    1.31  	flush_tlb_all();
    1.32 @@ -422,8 +422,8 @@ void xen_destroy_contiguous_region(unsig
    1.33  		mfn = pte_mfn(*pte);
    1.34  		BUG_ON(HYPERVISOR_update_va_mapping(
    1.35  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
    1.36 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
    1.37 -			INVALID_P2M_ENTRY;
    1.38 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
    1.39 +			INVALID_P2M_ENTRY);
    1.40  		BUG_ON(HYPERVISOR_memory_op(
    1.41  			XENMEM_decrease_reservation, &reservation) != 1);
    1.42  	}
    1.43 @@ -436,7 +436,7 @@ void xen_destroy_contiguous_region(unsig
    1.44  			vstart + (i*PAGE_SIZE),
    1.45  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
    1.46  		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
    1.47 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
    1.48 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
    1.49  	}
    1.50  
    1.51  	flush_tlb_all();
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Nov 10 15:03:33 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Nov 10 15:16:01 2005 +0100
     2.3 @@ -210,7 +210,7 @@ static int increase_reservation(unsigned
     2.4  		BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
     2.5  
     2.6  		/* Update P->M and M->P tables. */
     2.7 -		phys_to_machine_mapping[pfn] = mfn_list[i];
     2.8 +		set_phys_to_machine(pfn, mfn_list[i]);
     2.9  		xen_machphys_update(mfn_list[i], pfn);
    2.10              
    2.11  		/* Link back into the page tables if not highmem. */
    2.12 @@ -295,7 +295,7 @@ static int decrease_reservation(unsigned
    2.13  	/* No more mappings: invalidate P2M and add to balloon. */
    2.14  	for (i = 0; i < nr_pages; i++) {
    2.15  		pfn = mfn_to_pfn(mfn_list[i]);
    2.16 -		phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
    2.17 +		set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
    2.18  		balloon_append(pfn_to_page(pfn));
    2.19  	}
    2.20  
    2.21 @@ -515,8 +515,7 @@ static int dealloc_pte_fn(
    2.22  		.domid        = DOMID_SELF
    2.23  	};
    2.24  	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
    2.25 -	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
    2.26 -		INVALID_P2M_ENTRY;
    2.27 +	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
    2.28  	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    2.29  	BUG_ON(ret != 1);
    2.30  	return 0;
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Nov 10 15:03:33 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Nov 10 15:16:01 2005 +0100
     3.3 @@ -386,9 +386,9 @@ static void dispatch_rw_block_io(blkif_t
     3.4  #ifdef __ia64__
     3.5  			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
     3.6  #else
     3.7 -			phys_to_machine_mapping[__pa(MMAP_VADDR(
     3.8 -				pending_idx, i)) >> PAGE_SHIFT] =
     3.9 -				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
    3.10 +			set_phys_to_machine(__pa(MMAP_VADDR(
    3.11 +				pending_idx, i)) >> PAGE_SHIFT,
    3.12 +				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
    3.13  #endif
    3.14  			fas        = req->frame_and_sects[i];
    3.15  			seg[i].buf = map[i].dev_bus_addr | 
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Nov 10 15:03:33 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Nov 10 15:16:01 2005 +0100
     4.3 @@ -777,8 +777,8 @@ static void dispatch_rw_block_io(blkif_t
     4.4  		/* Set the necessary mappings in p2m and in the VM_FOREIGN 
     4.5  		 * vm_area_struct to allow user vaddr -> struct page lookups
     4.6  		 * to work.  This is needed for direct IO to foreign pages. */
     4.7 -		phys_to_machine_mapping[__pa(kvaddr) >> PAGE_SHIFT] =
     4.8 -			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
     4.9 +		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
    4.10 +				FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
    4.11  
    4.12  		offset = (uvaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
    4.13  		((struct page **)blktap_vma->vm_private_data)[offset] =
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Nov 10 15:03:33 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Nov 10 15:16:01 2005 +0100
     5.3 @@ -248,8 +248,7 @@ static void net_rx_action(unsigned long 
     5.4  		 * Set the new P2M table entry before reassigning the old data
     5.5  		 * page. Heed the comment in pgtable-2level.h:pte_page(). :-)
     5.6  		 */
     5.7 -		phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] =
     5.8 -			new_mfn;
     5.9 +		set_phys_to_machine(__pa(skb->data) >> PAGE_SHIFT, new_mfn);
    5.10  
    5.11  		MULTI_update_va_mapping(mcl, vdata,
    5.12  					pfn_pte_ma(new_mfn, PAGE_KERNEL), 0);
    5.13 @@ -631,9 +630,9 @@ static void net_tx_action(unsigned long 
    5.14  				pending_idx;
    5.15  			continue;
    5.16  		}
    5.17 -		phys_to_machine_mapping[
    5.18 -			__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
    5.19 -			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT);
    5.20 +		set_phys_to_machine(
    5.21 +			__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
    5.22 +			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
    5.23  		grant_tx_ref[pending_idx] = mop->handle;
    5.24  
    5.25  		data_len = (txreq.size > PKT_PROT_LEN) ?
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 10 15:03:33 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 10 15:16:01 2005 +0100
     6.3 @@ -342,8 +342,7 @@ static void network_alloc_rx_buffers(str
     6.4  		rx_pfn_array[i] = virt_to_mfn(skb->head);
     6.5  
     6.6  		/* Remove this page from map before passing back to Xen. */
     6.7 -		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
     6.8 -			= INVALID_P2M_ENTRY;
     6.9 +		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
    6.10  
    6.11  		MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
    6.12  					__pte(0), 0);
    6.13 @@ -570,7 +569,7 @@ static int netif_poll(struct net_device 
    6.14  					pfn_pte_ma(mfn, PAGE_KERNEL), 0);
    6.15  		mcl++;
    6.16  
    6.17 -		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
    6.18 +		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, mfn);
    6.19  
    6.20  		__skb_queue_tail(&rxq, skb);
    6.21  	}
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Nov 10 15:03:33 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Nov 10 15:16:01 2005 +0100
     7.3 @@ -296,9 +296,8 @@ static int
     7.4  			DPRINTK(" Grant table operation failure !\n");
     7.5  			return 0;
     7.6  		}
     7.7 -		phys_to_machine_mapping[__pa(MMAP_VADDR(tpmif,i)) >>
     7.8 -					PAGE_SHIFT] =
     7.9 -			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT);
    7.10 +		set_phys_to_machine(__pa(MMAP_VADDR(tpmif,i)) >> PAGE_SHIFT,
    7.11 +			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT));
    7.12  
    7.13  		tocopy = MIN(size - offset, PAGE_SIZE);
    7.14  
     8.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Nov 10 15:03:33 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Nov 10 15:16:01 2005 +0100
     8.3 @@ -86,6 +86,11 @@ static inline unsigned long mfn_to_pfn(u
     8.4  	return pfn;
     8.5  }
     8.6  
     8.7 +static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
     8.8 +{
     8.9 +	phys_to_machine_mapping[pfn] = mfn;
    8.10 +}
    8.11 +
    8.12  /* Definitions for machine and pseudophysical addresses. */
    8.13  #ifdef CONFIG_X86_PAE
    8.14  typedef unsigned long long paddr_t;
     9.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Thu Nov 10 15:03:33 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Thu Nov 10 15:16:01 2005 +0100
     9.3 @@ -88,6 +88,11 @@ static inline unsigned long mfn_to_pfn(u
     9.4  	return pfn;
     9.5  }
     9.6  
     9.7 +static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
     9.8 +{
     9.9 +	phys_to_machine_mapping[pfn] = mfn;
    9.10 +}
    9.11 +
    9.12  /* Definitions for machine and pseudophysical addresses. */
    9.13  typedef unsigned long paddr_t;
    9.14  typedef unsigned long maddr_t;