ia64/xen-unstable

changeset 6294:1a0723cd37f1

Fix many uses of machine addresses in XenLinux. Primarily
this fixes users of virt_to_machine/machine_to_virt to
use virt_to_mfn/mfn_to_virt where that is more appropriate.

This should be a big step to improved PAE stability.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Aug 19 16:06:43 2005 +0000 (2005-08-19)
parents 47d49e8b8042
children 74044b8186a9 e8c2c3123ec6
files linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6-xen-sparse/arch/xen/kernel/reboot.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.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/usbback/usbback.c linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/desc.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h xen/arch/x86/mm.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Fri Aug 19 15:47:19 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Fri Aug 19 16:06:43 2005 +0000
     1.3 @@ -569,7 +569,7 @@ void __init cpu_gdt_init(struct Xgt_desc
     1.4  	for (va = gdt_descr->address, f = 0;
     1.5  	     va < gdt_descr->address + gdt_descr->size;
     1.6  	     va += PAGE_SIZE, f++) {
     1.7 -		frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
     1.8 +		frames[f] = virt_to_mfn(va);
     1.9  		make_page_readonly((void *)va);
    1.10  	}
    1.11  	if (HYPERVISOR_set_gdt(frames, gdt_descr->size / 8))
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c	Fri Aug 19 15:47:19 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c	Fri Aug 19 16:06:43 2005 +0000
     2.3 @@ -198,7 +198,7 @@ static int write_ldt(void __user * ptr, 
     2.4  {
     2.5  	struct mm_struct * mm = current->mm;
     2.6  	__u32 entry_1, entry_2, *lp;
     2.7 -	unsigned long mach_lp;
     2.8 +	maddr_t mach_lp;
     2.9  	int error;
    2.10  	struct user_desc ldt_info;
    2.11  
    2.12 @@ -245,7 +245,8 @@ static int write_ldt(void __user * ptr, 
    2.13  
    2.14  	/* Install the new entry ...  */
    2.15  install:
    2.16 -	error = HYPERVISOR_update_descriptor(mach_lp, entry_1, entry_2);
    2.17 +	error = HYPERVISOR_update_descriptor(
    2.18 +		mach_lp, (u64)entry_1 | ((u64)entry_2<<32));
    2.19  
    2.20  out_unlock:
    2.21  	up(&mm->context.sem);
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Aug 19 15:47:19 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Aug 19 16:06:43 2005 +0000
     3.3 @@ -522,16 +522,15 @@ struct task_struct fastcall * __switch_t
     3.4  	 * Load the per-thread Thread-Local Storage descriptor.
     3.5  	 * This is load_TLS(next, cpu) with multicalls.
     3.6  	 */
     3.7 -#define C(i) do {                                                       \
     3.8 -	if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||    \
     3.9 -		     next->tls_array[i].b != prev->tls_array[i].b)) {   \
    3.10 -		mcl->op      = __HYPERVISOR_update_descriptor;          \
    3.11 -		mcl->args[0] = virt_to_machine(&get_cpu_gdt_table(cpu)  \
    3.12 -					 [GDT_ENTRY_TLS_MIN + i]);      \
    3.13 -		mcl->args[1] = ((u32 *)&next->tls_array[i])[0];         \
    3.14 -		mcl->args[2] = ((u32 *)&next->tls_array[i])[1];         \
    3.15 -		mcl++;                                                  \
    3.16 -	}                                                               \
    3.17 +#define C(i) do {							\
    3.18 +	if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||	\
    3.19 +		     next->tls_array[i].b != prev->tls_array[i].b)) {	\
    3.20 +		mcl->op = __HYPERVISOR_update_descriptor;		\
    3.21 +		*(u64 *)&mcl->args[0] =	virt_to_machine(		\
    3.22 +			&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]);\
    3.23 +		*(u64 *)&mcl->args[2] = *(u64 *)&next->tls_array[i];	\
    3.24 +		mcl++;							\
    3.25 +	}								\
    3.26  } while (0)
    3.27  	C(0); C(1); C(2);
    3.28  #undef C
     4.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Aug 19 15:47:19 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Aug 19 16:06:43 2005 +0000
     4.3 @@ -1604,11 +1604,10 @@ void __init setup_arch(char **cmdline_p)
     4.4  	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
     4.5  	{	
     4.6  	     pfn_to_mfn_frame_list[j] = 
     4.7 -		  virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
     4.8 +		  virt_to_mfn(&phys_to_machine_mapping[i]);
     4.9  	}
    4.10  	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
    4.11 -	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
    4.12 -
    4.13 +	     virt_to_mfn(pfn_to_mfn_frame_list);
    4.14  
    4.15  	/*
    4.16  	 * NOTE: at this point the bootmem allocator is fully available.
     5.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Aug 19 15:47:19 2005 +0000
     5.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Aug 19 16:06:43 2005 +0000
     5.3 @@ -904,7 +904,7 @@ static int __init do_boot_cpu(int apicid
     5.4  		for (va = cpu_gdt_descr[cpu].address, f = 0;
     5.5  		     va < cpu_gdt_descr[cpu].address + cpu_gdt_descr[cpu].size;
     5.6  		     va += PAGE_SIZE, f++) {
     5.7 -			ctxt.gdt_frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
     5.8 +			ctxt.gdt_frames[f] = virt_to_mfn(va);
     5.9  			make_page_readonly((void *)va);
    5.10  		}
    5.11  		ctxt.gdt_ents = cpu_gdt_descr[cpu].size / 8;
    5.12 @@ -920,7 +920,7 @@ static int __init do_boot_cpu(int apicid
    5.13  	ctxt.failsafe_callback_cs  = __KERNEL_CS;
    5.14  	ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
    5.15  
    5.16 -	ctxt.ctrlreg[3] = (unsigned long)virt_to_machine(swapper_pg_dir);
    5.17 +	ctxt.ctrlreg[3] = virt_to_mfn(swapper_pg_dir) << PAGE_SHIFT;
    5.18  
    5.19  	boot_error = HYPERVISOR_boot_vcpu(cpu, &ctxt);
    5.20  	printk("boot error: %ld\n", boot_error);
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Aug 19 15:47:19 2005 +0000
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Aug 19 16:06:43 2005 +0000
     6.3 @@ -306,7 +306,7 @@ static int direct_remap_area_pte_fn(pte_
     6.4  {
     6.5  	mmu_update_t **v = (mmu_update_t **)data;
     6.6  
     6.7 -	(*v)->ptr = ((physaddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
     6.8 +	(*v)->ptr = ((maddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
     6.9  		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
    6.10  	(*v)++;
    6.11  
     7.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Aug 19 15:47:19 2005 +0000
     7.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Fri Aug 19 16:06:43 2005 +0000
     7.3 @@ -170,7 +170,7 @@ void set_pmd_pfn(unsigned long vaddr, un
     7.4  	__flush_tlb_one(vaddr);
     7.5  }
     7.6  
     7.7 -void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
     7.8 +void __set_fixmap (enum fixed_addresses idx, maddr_t phys, pgprot_t flags)
     7.9  {
    7.10  	unsigned long address = __fix_to_virt(idx);
    7.11  
     8.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug 19 15:47:19 2005 +0000
     8.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Aug 19 16:06:43 2005 +0000
     8.3 @@ -247,7 +247,7 @@ static int __do_suspend(void *ignore)
     8.4  
     8.5      /* We'll stop somewhere inside this hypercall.  When it returns,
     8.6         we'll start resuming after the restore. */
     8.7 -    HYPERVISOR_suspend(virt_to_machine(suspend_record) >> PAGE_SHIFT);
     8.8 +    HYPERVISOR_suspend(virt_to_mfn(suspend_record));
     8.9  
    8.10      shutting_down = SHUTDOWN_INVALID; 
    8.11  
    8.12 @@ -263,10 +263,10 @@ static int __do_suspend(void *ignore)
    8.13      for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    8.14      {
    8.15          pfn_to_mfn_frame_list[j] = 
    8.16 -            virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
    8.17 +            virt_to_mfn(&phys_to_machine_mapping[i]);
    8.18      }
    8.19      HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
    8.20 -        virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
    8.21 +        virt_to_mfn(pfn_to_mfn_frame_list);
    8.22  
    8.23      gnttab_resume();
    8.24  
     9.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Aug 19 15:47:19 2005 +0000
     9.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c	Fri Aug 19 16:06:43 2005 +0000
     9.3 @@ -453,8 +453,8 @@ struct task_struct *__switch_to(struct t
     9.4  #define C(i) do {							\
     9.5  	if (unlikely(next->tls_array[i] != prev->tls_array[i])) {	\
     9.6  		mcl->op      = __HYPERVISOR_update_descriptor;		\
     9.7 -		mcl->args[0] = virt_to_machine(&get_cpu_gdt_table(cpu)	\
     9.8 -					       [GDT_ENTRY_TLS_MIN + i]); \
     9.9 +		mcl->args[0] = virt_to_machine(				\
    9.10 +			&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]);\
    9.11  		mcl->args[1] = next->tls_array[i];			\
    9.12  		mcl++;							\
    9.13  	}								\
    10.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Aug 19 15:47:19 2005 +0000
    10.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Aug 19 16:06:43 2005 +0000
    10.3 @@ -795,7 +795,7 @@ void __init setup_arch(char **cmdline_p)
    10.4  		for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    10.5  		{	
    10.6  			pfn_to_mfn_frame_list[j] = 
    10.7 -				virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
    10.8 +				virt_to_mfn(&phys_to_machine_mapping[i]);
    10.9  		}
   10.10  
   10.11  	}
    11.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Fri Aug 19 15:47:19 2005 +0000
    11.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Fri Aug 19 16:06:43 2005 +0000
    11.3 @@ -139,7 +139,7 @@ void __init cpu_gdt_init(struct desc_ptr
    11.4  	for (va = gdt_descr->address, f = 0;
    11.5  	     va < gdt_descr->address + gdt_descr->size;
    11.6  	     va += PAGE_SIZE, f++) {
    11.7 -		frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
    11.8 +		frames[f] = virt_to_mfn(va);
    11.9  		make_page_readonly((void *)va);
   11.10  	}
   11.11  	if (HYPERVISOR_set_gdt(frames, gdt_descr->size /
    12.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Fri Aug 19 15:47:19 2005 +0000
    12.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Fri Aug 19 16:06:43 2005 +0000
    12.3 @@ -780,7 +780,7 @@ static int __cpuinit do_boot_cpu(int cpu
    12.4  		for (va = cpu_gdt_descr[cpu].address, f = 0;
    12.5  		     va < cpu_gdt_descr[cpu].address + cpu_gdt_descr[cpu].size;
    12.6  		     va += PAGE_SIZE, f++) {
    12.7 -			ctxt.gdt_frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
    12.8 +			ctxt.gdt_frames[f] = virt_to_mfn(va);
    12.9  			make_page_readonly((void *)va);
   12.10  		}
   12.11  		ctxt.gdt_ents = GDT_ENTRIES;
   12.12 @@ -795,7 +795,7 @@ static int __cpuinit do_boot_cpu(int cpu
   12.13  	ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
   12.14  	ctxt.syscall_callback_eip  = (unsigned long)system_call;
   12.15  
   12.16 -	ctxt.ctrlreg[3] = (unsigned long)virt_to_machine(init_level4_pgt);
   12.17 +	ctxt.ctrlreg[3] = virt_to_mfn(init_level4_pgt) << PAGE_SHIFT;
   12.18  
   12.19  	boot_error = HYPERVISOR_boot_vcpu(cpu, &ctxt);
   12.20  
    13.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Aug 19 15:47:19 2005 +0000
    13.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Aug 19 16:06:43 2005 +0000
    13.3 @@ -742,7 +742,7 @@ void __init paging_init(void)
    13.4  				set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
    13.5  			else
    13.6  				__set_fixmap(FIX_ISAMAP_BEGIN - i,
    13.7 -					     virt_to_machine(empty_zero_page),
    13.8 +					     virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
    13.9  					     PAGE_KERNEL_RO);
   13.10  	}
   13.11  #endif
    14.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug 19 15:47:19 2005 +0000
    14.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Aug 19 16:06:43 2005 +0000
    14.3 @@ -1175,8 +1175,8 @@ static int setup_blkring(struct xenbus_d
    14.4  	ASSERT(shmem_ref != -ENOSPC);
    14.5  	gnttab_grant_foreign_access_ref(shmem_ref,
    14.6  					backend_id,
    14.7 -					virt_to_machine(blk_ring.sring)
    14.8 -					>> PAGE_SHIFT, 0);
    14.9 +					virt_to_mfn(blk_ring.sring),
   14.10 +					0);
   14.11  #endif
   14.12  
   14.13  	op.u.alloc_unbound.dom = backend_id;
   14.14 @@ -1245,7 +1245,7 @@ static int talk_to_backend(struct xenbus
   14.15  	}
   14.16  #else
   14.17  	err = xenbus_printf(dev->nodename, "shared-frame", "%lu",
   14.18 -			    virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
   14.19 +			    virt_to_mfn(blk_ring.sring));
   14.20  	if (err) {
   14.21  		message = "writing shared-frame";
   14.22  		goto abort_transaction;
    15.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Fri Aug 19 15:47:19 2005 +0000
    15.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Fri Aug 19 16:06:43 2005 +0000
    15.3 @@ -320,7 +320,7 @@ static void blkif_ptbe_send_interface_co
    15.4      };
    15.5      blkif_fe_interface_connect_t *msg = (void*)cmsg.msg;
    15.6      msg->handle      = 0;
    15.7 -    msg->shmem_frame = virt_to_machine(blktap_be_ring.sring) >> PAGE_SHIFT;
    15.8 +    msg->shmem_frame = virt_to_mfn(blktap_be_ring.sring);
    15.9      
   15.10      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   15.11  }
    16.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Aug 19 15:47:19 2005 +0000
    16.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Aug 19 16:06:43 2005 +0000
    16.3 @@ -251,7 +251,7 @@ static void net_rx_action(unsigned long 
    16.4  #else
    16.5      struct mmuext_op *mmuext;
    16.6  #endif
    16.7 -    unsigned long vdata, mdata, new_mfn;
    16.8 +    unsigned long vdata, old_mfn, new_mfn;
    16.9      struct sk_buff_head rxq;
   16.10      struct sk_buff *skb;
   16.11      u16 notify_list[NETIF_RX_RING_SIZE];
   16.12 @@ -271,7 +271,7 @@ static void net_rx_action(unsigned long 
   16.13      {
   16.14          netif   = netdev_priv(skb->dev);
   16.15          vdata   = (unsigned long)skb->data;
   16.16 -        mdata   = virt_to_machine(vdata);
   16.17 +        old_mfn = virt_to_mfn(vdata);
   16.18  
   16.19          /* Memory squeeze? Back off for an arbitrary while. */
   16.20          if ( (new_mfn = alloc_mfn()) == 0 )
   16.21 @@ -293,7 +293,7 @@ static void net_rx_action(unsigned long 
   16.22          mcl++;
   16.23  
   16.24  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   16.25 -        gop->mfn = mdata >> PAGE_SHIFT;
   16.26 +        gop->mfn = old_mfn;
   16.27          gop->domid = netif->domid;
   16.28          gop->handle = netif->rx->ring[
   16.29          MASK_NETIF_RX_IDX(netif->rx_resp_prod_copy)].req.gref;
   16.30 @@ -308,7 +308,7 @@ static void net_rx_action(unsigned long 
   16.31          mcl++;
   16.32  
   16.33          mmuext->cmd = MMUEXT_REASSIGN_PAGE;
   16.34 -        mmuext->mfn = mdata >> PAGE_SHIFT;
   16.35 +        mmuext->mfn = old_mfn;
   16.36          mmuext++;
   16.37  #endif
   16.38          mmu->ptr = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   16.39 @@ -318,7 +318,7 @@ static void net_rx_action(unsigned long 
   16.40          __skb_queue_tail(&rxq, skb);
   16.41  
   16.42  #ifdef DEBUG_GRANT
   16.43 -        dump_packet('a', mdata, vdata);
   16.44 +        dump_packet('a', old_mfn, vdata);
   16.45  #endif
   16.46          /* Filled the batch queue? */
   16.47          if ( (mcl - rx_mcl) == ARRAY_SIZE(rx_mcl) )
   16.48 @@ -345,10 +345,8 @@ static void net_rx_action(unsigned long 
   16.49  
   16.50      mcl = rx_mcl;
   16.51  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   16.52 -    if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_donate,
   16.53 -                                           grant_rx_op, gop - grant_rx_op))) {
   16.54 -        BUG();
   16.55 -    }
   16.56 +    BUG_ON(HYPERVISOR_grant_table_op(
   16.57 +        GNTTABOP_donate, grant_rx_op, gop - grant_rx_op));
   16.58      gop = grant_rx_op;
   16.59  #else
   16.60      mmuext = rx_mmuext;
   16.61 @@ -361,10 +359,9 @@ static void net_rx_action(unsigned long 
   16.62          /* Rederive the machine addresses. */
   16.63          new_mfn = mcl[0].args[1] >> PAGE_SHIFT;
   16.64  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   16.65 -        mdata = (unsigned long)skb->data & ~PAGE_MASK;
   16.66 +        old_mfn = 0; /* XXX Fix this so we can free_mfn() on error! */
   16.67  #else
   16.68 -        mdata   = ((mmuext[0].mfn << PAGE_SHIFT) |
   16.69 -                   ((unsigned long)skb->data & ~PAGE_MASK));
   16.70 +        old_mfn = mmuext[0].mfn;
   16.71  #endif
   16.72          atomic_set(&(skb_shinfo(skb)->dataref), 1);
   16.73          skb_shinfo(skb)->nr_frags = 0;
   16.74 @@ -379,18 +376,20 @@ static void net_rx_action(unsigned long 
   16.75          /* Check the reassignment error code. */
   16.76          status = NETIF_RSP_OKAY;
   16.77  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   16.78 -        BUG_ON(gop->status != 0);
   16.79 +        BUG_ON(gop->status != 0); /* XXX */
   16.80  #else
   16.81          if ( unlikely(mcl[1].result != 0) )
   16.82          {
   16.83              DPRINTK("Failed MMU update transferring to DOM%u\n", netif->domid);
   16.84 -            free_mfn(mdata >> PAGE_SHIFT);
   16.85 +            free_mfn(old_mfn);
   16.86              status = NETIF_RSP_ERROR;
   16.87          }
   16.88  #endif
   16.89          evtchn = netif->evtchn;
   16.90          id = netif->rx->ring[MASK_NETIF_RX_IDX(netif->rx_resp_prod)].req.id;
   16.91 -        if ( make_rx_response(netif, id, status, mdata,
   16.92 +        if ( make_rx_response(netif, id, status,
   16.93 +                              (old_mfn << PAGE_SHIFT) | /* XXX */
   16.94 +                              ((unsigned long)skb->data & ~PAGE_MASK),
   16.95                                size, skb->proto_csum_valid) &&
   16.96               (rx_notify[evtchn] == 0) )
   16.97          {
    17.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug 19 15:47:19 2005 +0000
    17.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug 19 16:06:43 2005 +0000
    17.3 @@ -448,11 +448,10 @@ static void network_alloc_rx_buffers(str
    17.4          }
    17.5          grant_rx_ref[id] = ref;
    17.6          gnttab_grant_foreign_transfer_ref(ref, rdomid,
    17.7 -                                          virt_to_machine(
    17.8 -                                              skb->head) >> PAGE_SHIFT);
    17.9 +                                          virt_to_mfn(skb->head));
   17.10          np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.gref = ref;
   17.11  #endif
   17.12 -        rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
   17.13 +        rx_pfn_array[i] = virt_to_mfn(skb->head);
   17.14  
   17.15  	/* Remove this page from pseudo phys map before passing back to Xen. */
   17.16  	phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
   17.17 @@ -543,13 +542,14 @@ static int network_start_xmit(struct sk_
   17.18          printk(KERN_ALERT "#### netfront can't claim tx grant reference\n");
   17.19          BUG();
   17.20      }
   17.21 -    mfn = virt_to_machine(skb->data) >> PAGE_SHIFT;
   17.22 +    mfn = virt_to_mfn(skb->data);
   17.23      gnttab_grant_foreign_access_ref(ref, rdomid, mfn, GNTMAP_readonly);
   17.24 -    tx->addr = (ref << PAGE_SHIFT) | ((unsigned long)skb->data & ~PAGE_MASK);
   17.25 +    tx->addr = ref << PAGE_SHIFT;
   17.26      grant_tx_ref[id] = ref;
   17.27  #else
   17.28 -    tx->addr = virt_to_machine(skb->data);
   17.29 +    tx->addr = virt_to_mfn(skb->data) << PAGE_SHIFT;
   17.30  #endif
   17.31 +    tx->addr |= (unsigned long)skb->data & ~PAGE_MASK;
   17.32      tx->size = skb->len;
   17.33      tx->csum_blank = (skb->ip_summed == CHECKSUM_HW);
   17.34  
   17.35 @@ -720,7 +720,7 @@ static int netif_poll(struct net_device 
   17.36      while ((skb = __skb_dequeue(&rxq)) != NULL) {
   17.37  #ifdef GRANT_DEBUG
   17.38          printk(KERN_ALERT "#### rx_poll     dequeue vdata=%p mfn=%lu\n",
   17.39 -               skb->data, virt_to_machine(skb->data)>>PAGE_SHIFT);
   17.40 +               skb->data, virt_to_mfn(skb->data));
   17.41          dump_packet('d', skb->data, (unsigned long)skb->data);
   17.42  #endif
   17.43          /*
   17.44 @@ -854,18 +854,23 @@ static void network_connect(struct net_d
   17.45       * interface has been down.
   17.46       */
   17.47      for (requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++) {
   17.48 -            if ((unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET) {
   17.49 -                struct sk_buff *skb = np->tx_skbs[i];
   17.50 -                
   17.51 -                tx = &np->tx->ring[requeue_idx++].req;
   17.52 -                
   17.53 -                tx->id   = i;
   17.54 -                tx->addr = virt_to_machine(skb->data);
   17.55 -                tx->size = skb->len;
   17.56 -                
   17.57 -                np->stats.tx_bytes += skb->len;
   17.58 -                np->stats.tx_packets++;
   17.59 -            }
   17.60 +        if ((unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET) {
   17.61 +            struct sk_buff *skb = np->tx_skbs[i];
   17.62 +
   17.63 +            tx = &np->tx->ring[requeue_idx++].req;
   17.64 +
   17.65 +            tx->id   = i;
   17.66 +#ifdef CONFIG_XEN_NETDEV_GRANT_TX
   17.67 +            tx->addr = 0; /*(ref << PAGE_SHIFT) |*/
   17.68 +#else
   17.69 +            tx->addr = virt_to_mfn(skb->data) << PAGE_SHIFT;
   17.70 +#endif
   17.71 +            tx->addr |= (unsigned long)skb->data & ~PAGE_MASK;
   17.72 +            tx->size = skb->len;
   17.73 +
   17.74 +            np->stats.tx_bytes += skb->len;
   17.75 +            np->stats.tx_packets++;
   17.76 +        }
   17.77      }
   17.78      wmb();
   17.79      np->tx->req_prod = requeue_idx;
   17.80 @@ -922,7 +927,7 @@ static void send_interface_connect(struc
   17.81      netif_fe_interface_connect_t *msg = (void*)cmsg.msg;
   17.82  
   17.83      msg->handle = np->handle;
   17.84 -    msg->tx_shmem_frame = (virt_to_machine(np->tx) >> PAGE_SHIFT);
   17.85 +    msg->tx_shmem_frame = virt_to_mfn(np->tx);
   17.86  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
   17.87      msg->tx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_tx_head, 
   17.88                                                              gref_tx_terminal);
   17.89 @@ -934,7 +939,7 @@ static void send_interface_connect(struc
   17.90                                       msg->tx_shmem_frame, 0);
   17.91  #endif
   17.92  
   17.93 -    msg->rx_shmem_frame = (virt_to_machine(np->rx) >> PAGE_SHIFT);
   17.94 +    msg->rx_shmem_frame = virt_to_mfn(np->rx);
   17.95  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   17.96      msg->rx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_rx_head, 
   17.97                                                              gref_rx_terminal);
    18.1 --- a/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c	Fri Aug 19 15:47:19 2005 +0000
    18.2 +++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c	Fri Aug 19 16:06:43 2005 +0000
    18.3 @@ -657,8 +657,8 @@ static void dispatch_usb_io(usbif_priv_t
    18.4          phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
    18.5              FOREIGN_FRAME((buffer_mach + offset) >> PAGE_SHIFT);
    18.6  
    18.7 -        ASSERT(virt_to_machine(MMAP_VADDR(pending_idx, i))
    18.8 -               == buffer_mach + i << PAGE_SHIFT);
    18.9 +        ASSERT(virt_to_mfn(MMAP_VADDR(pending_idx, i))
   18.10 +               == ((buffer_mach >> PAGE_SHIFT) + i));
   18.11      }
   18.12  
   18.13      if ( req->pipe_type == 0 && req->num_iso > 0 ) /* Maybe schedule ISO... */
    19.1 --- a/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Aug 19 15:47:19 2005 +0000
    19.2 +++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Aug 19 16:06:43 2005 +0000
    19.3 @@ -195,7 +195,7 @@ static int xhci_construct_isoc(usbif_req
    19.4          }
    19.5  
    19.6          urb_priv->schedule = schedule;
    19.7 -	req->iso_schedule = virt_to_machine(schedule);
    19.8 +	req->iso_schedule = virt_to_mfn(schedule) << PAGE_SHIFT;
    19.9  
   19.10          return 0;
   19.11  }
   19.12 @@ -212,7 +212,7 @@ static int xhci_queue_req(struct urb *ur
   19.13  #if DEBUG
   19.14          printk(KERN_DEBUG
   19.15                 "usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
   19.16 -               usbif, usbif->req_prod, virt_to_machine(&usbif->req_prod),
   19.17 +               usbif, usbif->req_prod, virt_to_mfn(&usbif->req_prod),
   19.18                 usbif->resp_prod, xhci->usb_resp_cons);
   19.19  #endif
   19.20          
   19.21 @@ -232,7 +232,7 @@ static int xhci_queue_req(struct urb *ur
   19.22          req->operation       = USBIF_OP_IO;
   19.23          req->port            = 0; /* We don't care what the port is. */
   19.24          req->id              = (unsigned long) urb->hcpriv;
   19.25 -        req->transfer_buffer = virt_to_machine(urb->transfer_buffer);
   19.26 +        req->transfer_buffer = virt_to_mfn(urb->transfer_buffer) << PAGE_SHIFT;
   19.27  	req->devnum          = usb_pipedevice(urb->pipe);
   19.28          req->direction       = usb_pipein(urb->pipe);
   19.29  	req->speed           = usb_pipeslow(urb->pipe);
   19.30 @@ -280,7 +280,7 @@ static inline usbif_request_t *xhci_queu
   19.31  	printk(KERN_DEBUG
   19.32                 "queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, "
   19.33                 "resp_cons = %d\n", usbif->req_prod,
   19.34 -               virt_to_machine(&usbif->req_prod),
   19.35 +               virt_to_mfn(&usbif->req_prod),
   19.36  	       usbif->resp_prod, xhci->usb_resp_cons);
   19.37  #endif
   19.38   
   19.39 @@ -1555,7 +1555,7 @@ static void usbif_status_change(usbif_fe
   19.40          cmsg.type      = CMSG_USBIF_FE;
   19.41          cmsg.subtype   = CMSG_USBIF_FE_INTERFACE_CONNECT;
   19.42          cmsg.length    = sizeof(usbif_fe_interface_connect_t);
   19.43 -        up.shmem_frame = virt_to_machine(sring) >> PAGE_SHIFT;
   19.44 +        up.shmem_frame = virt_to_mfn(sring);
   19.45          memcpy(cmsg.msg, &up, sizeof(up));
   19.46          
   19.47          /* Tell the controller to bring up the interface. */
   19.48 @@ -1599,7 +1599,7 @@ static void usbif_status_change(usbif_fe
   19.49  
   19.50  	DPRINTK(KERN_INFO __FILE__
   19.51                  ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d\n",
   19.52 -                xhci->usb_ring.sring, virt_to_machine(xhci->usbif),
   19.53 +                xhci->usb_ring.sring, virt_to_mfn(xhci->usbif),
   19.54                  xhci->evtchn);
   19.55  
   19.56          xhci->state = USBIF_STATE_CONNECTED;
    20.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Aug 19 15:47:19 2005 +0000
    20.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Fri Aug 19 16:06:43 2005 +0000
    20.3 @@ -48,13 +48,12 @@ DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
    20.4  
    20.5  static inline struct ringbuf_head *outbuf(void)
    20.6  {
    20.7 -	return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
    20.8 +	return mfn_to_virt(xen_start_info.store_mfn);
    20.9  }
   20.10  
   20.11  static inline struct ringbuf_head *inbuf(void)
   20.12  {
   20.13 -	return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT)
   20.14 -		+ PAGE_SIZE/2;
   20.15 +	return mfn_to_virt(xen_start_info.store_mfn) + PAGE_SIZE/2;
   20.16  }
   20.17  
   20.18  static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs)
   20.19 @@ -219,8 +218,7 @@ int xb_init_comms(void)
   20.20  	}
   20.21  
   20.22  	/* FIXME zero out page -- domain builder should probably do this*/
   20.23 -	memset(machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT),
   20.24 -	       0, PAGE_SIZE);
   20.25 +	memset(mfn_to_virt(xen_start_info.store_mfn), 0, PAGE_SIZE);
   20.26  
   20.27  	return 0;
   20.28  }
    21.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h	Fri Aug 19 15:47:19 2005 +0000
    21.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h	Fri Aug 19 16:06:43 2005 +0000
    21.3 @@ -93,7 +93,7 @@ static inline void set_ldt_desc(unsigned
    21.4  
    21.5  static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
    21.6  {
    21.7 -#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), ((u32 *)&t->tls_array[i])[0], ((u32 *)&t->tls_array[i])[1])
    21.8 +#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i])
    21.9  	C(0); C(1); C(2);
   21.10  #undef C
   21.11  }
    22.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Fri Aug 19 15:47:19 2005 +0000
    22.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Fri Aug 19 16:06:43 2005 +0000
    22.3 @@ -102,8 +102,8 @@ enum fixed_addresses {
    22.4  	__end_of_fixed_addresses
    22.5  };
    22.6  
    22.7 -extern void __set_fixmap (enum fixed_addresses idx,
    22.8 -					unsigned long phys, pgprot_t flags);
    22.9 +extern void __set_fixmap(
   22.10 +	enum fixed_addresses idx, maddr_t phys, pgprot_t flags);
   22.11  
   22.12  #define set_fixmap(idx, phys) \
   22.13  		__set_fixmap(idx, phys, PAGE_KERNEL)
    23.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h	Fri Aug 19 15:47:19 2005 +0000
    23.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h	Fri Aug 19 16:06:43 2005 +0000
    23.3 @@ -316,16 +316,17 @@ HYPERVISOR_get_debugreg(
    23.4  
    23.5  static inline int
    23.6  HYPERVISOR_update_descriptor(
    23.7 -    unsigned long ma, unsigned long word1, unsigned long word2)
    23.8 +    u64 ma, u64 desc)
    23.9  {
   23.10      int ret;
   23.11 -    unsigned long ign1, ign2, ign3;
   23.12 +    unsigned long ign1, ign2, ign3, ign4;
   23.13  
   23.14      __asm__ __volatile__ (
   23.15          TRAP_INSTR
   23.16 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
   23.17 -	: "0" (__HYPERVISOR_update_descriptor), "1" (ma), "2" (word1),
   23.18 -	  "3" (word2)
   23.19 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   23.20 +	: "0" (__HYPERVISOR_update_descriptor),
   23.21 +	  "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
   23.22 +	  "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
   23.23  	: "memory" );
   23.24  
   23.25      return ret;
    24.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Fri Aug 19 15:47:19 2005 +0000
    24.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Fri Aug 19 16:06:43 2005 +0000
    24.3 @@ -63,20 +63,25 @@
    24.4  extern unsigned int *phys_to_machine_mapping;
    24.5  #define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
    24.6  #define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
    24.7 +
    24.8 +/* Definitions for machine and pseudophysical addresses. */
    24.9  #ifdef CONFIG_X86_PAE
   24.10 -typedef unsigned long long physaddr_t;
   24.11 +typedef unsigned long long paddr_t;
   24.12 +typedef unsigned long long maddr_t;
   24.13  #else
   24.14 -typedef unsigned long physaddr_t;
   24.15 +typedef unsigned long paddr_t;
   24.16 +typedef unsigned long maddr_t;
   24.17  #endif
   24.18 -static inline physaddr_t phys_to_machine(physaddr_t phys)
   24.19 +
   24.20 +static inline maddr_t phys_to_machine(paddr_t phys)
   24.21  {
   24.22 -	physaddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   24.23 +	maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   24.24  	machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
   24.25  	return machine;
   24.26  }
   24.27 -static inline physaddr_t machine_to_phys(physaddr_t machine)
   24.28 +static inline paddr_t machine_to_phys(maddr_t machine)
   24.29  {
   24.30 -	physaddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   24.31 +	paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   24.32  	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
   24.33  	return phys;
   24.34  }
   24.35 @@ -233,8 +238,10 @@ extern int sysctl_legacy_va_layout;
   24.36  		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
   24.37  
   24.38  /* VIRT <-> MACHINE conversion */
   24.39 -#define virt_to_machine(_a)	(phys_to_machine(__pa(_a)))
   24.40 -#define machine_to_virt(_m)	(__va(machine_to_phys(_m)))
   24.41 +#define virt_to_machine(v)	(phys_to_machine(__pa(v)))
   24.42 +#define machine_to_virt(m)	(__va(machine_to_phys(m)))
   24.43 +#define virt_to_mfn(v)		(pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
   24.44 +#define mfn_to_virt(m)		(__va(mfn_to_pfn(m) << PAGE_SHIFT))
   24.45  
   24.46  #endif /* __KERNEL__ */
   24.47  
    25.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug 19 15:47:19 2005 +0000
    25.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug 19 16:06:43 2005 +0000
    25.3 @@ -450,7 +450,7 @@ void make_pages_writable(void *va, unsig
    25.4  #define arbitrary_virt_to_machine(__va)					\
    25.5  ({									\
    25.6  	pte_t *__pte = virt_to_ptep(__va);				\
    25.7 -	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
    25.8 +	maddr_t __pa = (maddr_t)pte_mfn(*__pte) << PAGE_SHIFT;		\
    25.9  	__pa | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
   25.10  })
   25.11  
    27.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Fri Aug 19 15:47:19 2005 +0000
    27.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Fri Aug 19 16:06:43 2005 +0000
    27.3 @@ -65,16 +65,21 @@ void copy_page(void *, void *);
    27.4  extern u32 *phys_to_machine_mapping;
    27.5  #define pfn_to_mfn(_pfn) ((unsigned long) phys_to_machine_mapping[(unsigned int)(_pfn)])
    27.6  #define mfn_to_pfn(_mfn) ((unsigned long) machine_to_phys_mapping[(unsigned int)(_mfn)])
    27.7 -static inline unsigned long phys_to_machine(unsigned long phys)
    27.8 +
    27.9 +/* Definitions for machine and pseudophysical addresses. */
   27.10 +typedef unsigned long paddr_t;
   27.11 +typedef unsigned long maddr_t;
   27.12 +
   27.13 +static inline maddr_t phys_to_machine(paddr_t phys)
   27.14  {
   27.15 -	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   27.16 +	maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   27.17  	machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
   27.18  	return machine;
   27.19  }
   27.20  
   27.21 -static inline unsigned long machine_to_phys(unsigned long machine)
   27.22 +static inline paddr_t machine_to_phys(maddr_t machine)
   27.23  {
   27.24 -	unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   27.25 +	paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   27.26  	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
   27.27  	return phys;
   27.28  }
   27.29 @@ -211,8 +216,10 @@ extern __inline__ int get_order(unsigned
   27.30  #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
   27.31  
   27.32  /* VIRT <-> MACHINE conversion */
   27.33 -#define virt_to_machine(_a)	(phys_to_machine(__pa(_a)))
   27.34 -#define machine_to_virt(_m)	(__va(machine_to_phys(_m)))
   27.35 +#define virt_to_machine(v)	(phys_to_machine(__pa(v)))
   27.36 +#define machine_to_virt(m)	(__va(machine_to_phys(m)))
   27.37 +#define virt_to_mfn(v)		(pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
   27.38 +#define mfn_to_virt(m)		(__va(mfn_to_pfn(m) << PAGE_SHIFT))
   27.39  
   27.40  #define VM_DATA_DEFAULT_FLAGS \
   27.41  	(((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
    28.1 --- a/xen/arch/x86/mm.c	Fri Aug 19 15:47:19 2005 +0000
    28.2 +++ b/xen/arch/x86/mm.c	Fri Aug 19 16:06:43 2005 +0000
    28.3 @@ -2689,22 +2689,24 @@ long do_set_gdt(unsigned long *frame_lis
    28.4  }
    28.5  
    28.6  
    28.7 -long do_update_descriptor(unsigned long pa, u64 desc)
    28.8 +long do_update_descriptor(u64 pa, u64 desc)
    28.9  {
   28.10      struct domain *dom = current->domain;
   28.11      unsigned long gpfn = pa >> PAGE_SHIFT;
   28.12      unsigned long mfn;
   28.13 -    unsigned int  offset = (pa & ~PAGE_MASK) / sizeof(struct desc_struct);
   28.14 +    unsigned int  offset;
   28.15      struct desc_struct *gdt_pent, d;
   28.16      struct pfn_info *page;
   28.17      long ret = -EINVAL;
   28.18  
   28.19 +    offset = ((unsigned int)pa & ~PAGE_MASK) / sizeof(struct desc_struct);
   28.20 +
   28.21      *(u64 *)&d = desc;
   28.22  
   28.23      LOCK_BIGLOCK(dom);
   28.24  
   28.25      if ( !VALID_MFN(mfn = __gpfn_to_mfn(dom, gpfn)) ||
   28.26 -         ((pa % sizeof(struct desc_struct)) != 0) ||
   28.27 +         (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
   28.28           (mfn >= max_page) ||
   28.29           !check_descriptor(&d) )
   28.30      {