Fix many uses of machine addresses in XenLinux. Primarily
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 19 Aug 2005 16:06:43 +0000 (16:06 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 19 Aug 2005 16:06:43 +0000 (16:06 +0000)
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>
27 files changed:
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/page.h
xen/arch/x86/mm.c

index dd1f64f830dc096ba45d8e6b7606f88bf163bc04..7a072454bf46308138ed443c746df4cf3a41469e 100644 (file)
@@ -569,7 +569,7 @@ void __init cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
        for (va = gdt_descr->address, f = 0;
             va < gdt_descr->address + gdt_descr->size;
             va += PAGE_SIZE, f++) {
-               frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
+               frames[f] = virt_to_mfn(va);
                make_page_readonly((void *)va);
        }
        if (HYPERVISOR_set_gdt(frames, gdt_descr->size / 8))
index 363010f1ed1751d7649d91c6d45fbb2cd0d8a404..905dcd3928a2ae939972bbee0930b5b1b4910330 100644 (file)
@@ -198,7 +198,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
 {
        struct mm_struct * mm = current->mm;
        __u32 entry_1, entry_2, *lp;
-       unsigned long mach_lp;
+       maddr_t mach_lp;
        int error;
        struct user_desc ldt_info;
 
@@ -245,7 +245,8 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
 
        /* Install the new entry ...  */
 install:
-       error = HYPERVISOR_update_descriptor(mach_lp, entry_1, entry_2);
+       error = HYPERVISOR_update_descriptor(
+               mach_lp, (u64)entry_1 | ((u64)entry_2<<32));
 
 out_unlock:
        up(&mm->context.sem);
index 88004e76bd66c976396396a0a8b7795623036212..298b0183343fad280a5b289ebe3776a486b7cb50 100644 (file)
@@ -522,16 +522,15 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
         * Load the per-thread Thread-Local Storage descriptor.
         * This is load_TLS(next, cpu) with multicalls.
         */
-#define C(i) do {                                                       \
-       if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||    \
-                    next->tls_array[i].b != prev->tls_array[i].b)) {   \
-               mcl->op      = __HYPERVISOR_update_descriptor;          \
-               mcl->args[0] = virt_to_machine(&get_cpu_gdt_table(cpu)  \
-                                        [GDT_ENTRY_TLS_MIN + i]);      \
-               mcl->args[1] = ((u32 *)&next->tls_array[i])[0];         \
-               mcl->args[2] = ((u32 *)&next->tls_array[i])[1];         \
-               mcl++;                                                  \
-       }                                                               \
+#define C(i) do {                                                      \
+       if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||    \
+                    next->tls_array[i].b != prev->tls_array[i].b)) {   \
+               mcl->op = __HYPERVISOR_update_descriptor;               \
+               *(u64 *)&mcl->args[0] = virt_to_machine(                \
+                       &get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]);\
+               *(u64 *)&mcl->args[2] = *(u64 *)&next->tls_array[i];    \
+               mcl++;                                                  \
+       }                                                               \
 } while (0)
        C(0); C(1); C(2);
 #undef C
index 93b97453868db747e8fc2b084fe5f4bd2a62240f..25c69332ac570509cc21320392ab678e3aeec479 100644 (file)
@@ -1604,11 +1604,10 @@ void __init setup_arch(char **cmdline_p)
        for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
        {       
             pfn_to_mfn_frame_list[j] = 
-                 virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
+                 virt_to_mfn(&phys_to_machine_mapping[i]);
        }
        HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
-            virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
-
+            virt_to_mfn(pfn_to_mfn_frame_list);
 
        /*
         * NOTE: at this point the bootmem allocator is fully available.
index f47e809e607b7c517c5f8204765c022804f189d4..b879cf5a8d92a56e561b85ae7cbe8cbb4db2f10d 100644 (file)
@@ -904,7 +904,7 @@ static int __init do_boot_cpu(int apicid)
                for (va = cpu_gdt_descr[cpu].address, f = 0;
                     va < cpu_gdt_descr[cpu].address + cpu_gdt_descr[cpu].size;
                     va += PAGE_SIZE, f++) {
-                       ctxt.gdt_frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
+                       ctxt.gdt_frames[f] = virt_to_mfn(va);
                        make_page_readonly((void *)va);
                }
                ctxt.gdt_ents = cpu_gdt_descr[cpu].size / 8;
@@ -920,7 +920,7 @@ static int __init do_boot_cpu(int apicid)
        ctxt.failsafe_callback_cs  = __KERNEL_CS;
        ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
 
-       ctxt.ctrlreg[3] = (unsigned long)virt_to_machine(swapper_pg_dir);
+       ctxt.ctrlreg[3] = virt_to_mfn(swapper_pg_dir) << PAGE_SHIFT;
 
        boot_error = HYPERVISOR_boot_vcpu(cpu, &ctxt);
        printk("boot error: %ld\n", boot_error);
index 1af61e6ed13b4aaee19972d4daae59e38a1e5335..26a69baa6c3e4e4d286a04dc65b16de804d2a4d0 100644 (file)
@@ -306,7 +306,7 @@ static int direct_remap_area_pte_fn(pte_t *pte,
 {
        mmu_update_t **v = (mmu_update_t **)data;
 
-       (*v)->ptr = ((physaddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
+       (*v)->ptr = ((maddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
                     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
        (*v)++;
 
index 5f50fbfd5ff7611a03c4ac422e34817af7686750..e46d69df0db7e3b1733c8db1152da5274703d661 100644 (file)
@@ -170,7 +170,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
        __flush_tlb_one(vaddr);
 }
 
-void __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
+void __set_fixmap (enum fixed_addresses idx, maddr_t phys, pgprot_t flags)
 {
        unsigned long address = __fix_to_virt(idx);
 
index 10f6bf7ec14e8866957dfa3e8973d987a1a09de3..937292776eb7b7795c43c1dfa397e9a4f5c6d7d9 100644 (file)
@@ -247,7 +247,7 @@ static int __do_suspend(void *ignore)
 
     /* We'll stop somewhere inside this hypercall.  When it returns,
        we'll start resuming after the restore. */
-    HYPERVISOR_suspend(virt_to_machine(suspend_record) >> PAGE_SHIFT);
+    HYPERVISOR_suspend(virt_to_mfn(suspend_record));
 
     shutting_down = SHUTDOWN_INVALID; 
 
@@ -263,10 +263,10 @@ static int __do_suspend(void *ignore)
     for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
     {
         pfn_to_mfn_frame_list[j] = 
-            virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
+            virt_to_mfn(&phys_to_machine_mapping[i]);
     }
     HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
-        virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
+        virt_to_mfn(pfn_to_mfn_frame_list);
 
     gnttab_resume();
 
index 9aae8ef74aba94bce590330de4fe3a82f2bbf543..ee10b8d8b83c82bbc584e49a08d8ba14b9b69241 100644 (file)
@@ -453,8 +453,8 @@ struct task_struct *__switch_to(struct task_struct *prev_p, struct task_struct *
 #define C(i) do {                                                      \
        if (unlikely(next->tls_array[i] != prev->tls_array[i])) {       \
                mcl->op      = __HYPERVISOR_update_descriptor;          \
-               mcl->args[0] = virt_to_machine(&get_cpu_gdt_table(cpu)  \
-                                              [GDT_ENTRY_TLS_MIN + i]); \
+               mcl->args[0] = virt_to_machine(                         \
+                       &get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]);\
                mcl->args[1] = next->tls_array[i];                      \
                mcl++;                                                  \
        }                                                               \
index 7a7d01dfc23f87d56d0b4fad5ed011a1692dadc7..f76b91e01ecfa4261cd8c1f5cf9efebefe720416 100644 (file)
@@ -795,7 +795,7 @@ void __init setup_arch(char **cmdline_p)
                for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
                {       
                        pfn_to_mfn_frame_list[j] = 
-                               virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
+                               virt_to_mfn(&phys_to_machine_mapping[i]);
                }
 
        }
index 1b0e1e00470e6f67b763b43b153b59d0a887ceb8..bb2f550330d2d869f34fd89579164b81e5b289db 100644 (file)
@@ -139,7 +139,7 @@ void __init cpu_gdt_init(struct desc_ptr *gdt_descr)
        for (va = gdt_descr->address, f = 0;
             va < gdt_descr->address + gdt_descr->size;
             va += PAGE_SIZE, f++) {
-               frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
+               frames[f] = virt_to_mfn(va);
                make_page_readonly((void *)va);
        }
        if (HYPERVISOR_set_gdt(frames, gdt_descr->size /
index c4247881a7f3a79f50f694c654bfc265ed35a562..a8f95211b68bc4bf5c2023987e0ff6d3502bd43a 100644 (file)
@@ -780,7 +780,7 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
                for (va = cpu_gdt_descr[cpu].address, f = 0;
                     va < cpu_gdt_descr[cpu].address + cpu_gdt_descr[cpu].size;
                     va += PAGE_SIZE, f++) {
-                       ctxt.gdt_frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
+                       ctxt.gdt_frames[f] = virt_to_mfn(va);
                        make_page_readonly((void *)va);
                }
                ctxt.gdt_ents = GDT_ENTRIES;
@@ -795,7 +795,7 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
        ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
        ctxt.syscall_callback_eip  = (unsigned long)system_call;
 
-       ctxt.ctrlreg[3] = (unsigned long)virt_to_machine(init_level4_pgt);
+       ctxt.ctrlreg[3] = virt_to_mfn(init_level4_pgt) << PAGE_SHIFT;
 
        boot_error = HYPERVISOR_boot_vcpu(cpu, &ctxt);
 
index a2a386b99d94fb47fb051d9ec060f28fea68c88c..859c9e72ca7a0c1c7d108a60ad149df7e063ae81 100644 (file)
@@ -742,7 +742,7 @@ void __init paging_init(void)
                                set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
                        else
                                __set_fixmap(FIX_ISAMAP_BEGIN - i,
-                                            virt_to_machine(empty_zero_page),
+                                            virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
                                             PAGE_KERNEL_RO);
        }
 #endif
index 14d1a1c0f021cfcf6a266bb6e1de02e761a71dd2..0e3d172aedd57dc0958a28f37045b804b3a48bcf 100644 (file)
@@ -1175,8 +1175,8 @@ static int setup_blkring(struct xenbus_device *dev, unsigned int backend_id)
        ASSERT(shmem_ref != -ENOSPC);
        gnttab_grant_foreign_access_ref(shmem_ref,
                                        backend_id,
-                                       virt_to_machine(blk_ring.sring)
-                                       >> PAGE_SHIFT, 0);
+                                       virt_to_mfn(blk_ring.sring),
+                                       0);
 #endif
 
        op.u.alloc_unbound.dom = backend_id;
@@ -1245,7 +1245,7 @@ static int talk_to_backend(struct xenbus_device *dev,
        }
 #else
        err = xenbus_printf(dev->nodename, "shared-frame", "%lu",
-                           virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
+                           virt_to_mfn(blk_ring.sring));
        if (err) {
                message = "writing shared-frame";
                goto abort_transaction;
index dd42630dbef38c5e2cb198604f6219cf145e8953..dd39aff7dd9ddb2743f4d89ffccf8f63d159186e 100644 (file)
@@ -320,7 +320,7 @@ static void blkif_ptbe_send_interface_connect(void)
     };
     blkif_fe_interface_connect_t *msg = (void*)cmsg.msg;
     msg->handle      = 0;
-    msg->shmem_frame = virt_to_machine(blktap_be_ring.sring) >> PAGE_SHIFT;
+    msg->shmem_frame = virt_to_mfn(blktap_be_ring.sring);
     
     ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
 }
index 0de0b0b0643bc630a43cf7881ce6736b02a29623..2315e8862bc43ea1c916f137a2a7949666396758 100644 (file)
@@ -251,7 +251,7 @@ static void net_rx_action(unsigned long unused)
 #else
     struct mmuext_op *mmuext;
 #endif
-    unsigned long vdata, mdata, new_mfn;
+    unsigned long vdata, old_mfn, new_mfn;
     struct sk_buff_head rxq;
     struct sk_buff *skb;
     u16 notify_list[NETIF_RX_RING_SIZE];
@@ -271,7 +271,7 @@ static void net_rx_action(unsigned long unused)
     {
         netif   = netdev_priv(skb->dev);
         vdata   = (unsigned long)skb->data;
-        mdata   = virt_to_machine(vdata);
+        old_mfn = virt_to_mfn(vdata);
 
         /* Memory squeeze? Back off for an arbitrary while. */
         if ( (new_mfn = alloc_mfn()) == 0 )
@@ -293,7 +293,7 @@ static void net_rx_action(unsigned long unused)
         mcl++;
 
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
-        gop->mfn = mdata >> PAGE_SHIFT;
+        gop->mfn = old_mfn;
         gop->domid = netif->domid;
         gop->handle = netif->rx->ring[
         MASK_NETIF_RX_IDX(netif->rx_resp_prod_copy)].req.gref;
@@ -308,7 +308,7 @@ static void net_rx_action(unsigned long unused)
         mcl++;
 
         mmuext->cmd = MMUEXT_REASSIGN_PAGE;
-        mmuext->mfn = mdata >> PAGE_SHIFT;
+        mmuext->mfn = old_mfn;
         mmuext++;
 #endif
         mmu->ptr = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
@@ -318,7 +318,7 @@ static void net_rx_action(unsigned long unused)
         __skb_queue_tail(&rxq, skb);
 
 #ifdef DEBUG_GRANT
-        dump_packet('a', mdata, vdata);
+        dump_packet('a', old_mfn, vdata);
 #endif
         /* Filled the batch queue? */
         if ( (mcl - rx_mcl) == ARRAY_SIZE(rx_mcl) )
@@ -345,10 +345,8 @@ static void net_rx_action(unsigned long unused)
 
     mcl = rx_mcl;
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
-    if (unlikely(HYPERVISOR_grant_table_op(GNTTABOP_donate,
-                                           grant_rx_op, gop - grant_rx_op))) {
-        BUG();
-    }
+    BUG_ON(HYPERVISOR_grant_table_op(
+        GNTTABOP_donate, grant_rx_op, gop - grant_rx_op));
     gop = grant_rx_op;
 #else
     mmuext = rx_mmuext;
@@ -361,10 +359,9 @@ static void net_rx_action(unsigned long unused)
         /* Rederive the machine addresses. */
         new_mfn = mcl[0].args[1] >> PAGE_SHIFT;
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
-        mdata = (unsigned long)skb->data & ~PAGE_MASK;
+        old_mfn = 0; /* XXX Fix this so we can free_mfn() on error! */
 #else
-        mdata   = ((mmuext[0].mfn << PAGE_SHIFT) |
-                   ((unsigned long)skb->data & ~PAGE_MASK));
+        old_mfn = mmuext[0].mfn;
 #endif
         atomic_set(&(skb_shinfo(skb)->dataref), 1);
         skb_shinfo(skb)->nr_frags = 0;
@@ -379,18 +376,20 @@ static void net_rx_action(unsigned long unused)
         /* Check the reassignment error code. */
         status = NETIF_RSP_OKAY;
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
-        BUG_ON(gop->status != 0);
+        BUG_ON(gop->status != 0); /* XXX */
 #else
         if ( unlikely(mcl[1].result != 0) )
         {
             DPRINTK("Failed MMU update transferring to DOM%u\n", netif->domid);
-            free_mfn(mdata >> PAGE_SHIFT);
+            free_mfn(old_mfn);
             status = NETIF_RSP_ERROR;
         }
 #endif
         evtchn = netif->evtchn;
         id = netif->rx->ring[MASK_NETIF_RX_IDX(netif->rx_resp_prod)].req.id;
-        if ( make_rx_response(netif, id, status, mdata,
+        if ( make_rx_response(netif, id, status,
+                              (old_mfn << PAGE_SHIFT) | /* XXX */
+                              ((unsigned long)skb->data & ~PAGE_MASK),
                               size, skb->proto_csum_valid) &&
              (rx_notify[evtchn] == 0) )
         {
index 0c72a408bf37fd9f59519737932b3bb9e44f4a24..1426cb549838db9c52399c49fba75afc052329f7 100644 (file)
@@ -448,11 +448,10 @@ static void network_alloc_rx_buffers(struct net_device *dev)
         }
         grant_rx_ref[id] = ref;
         gnttab_grant_foreign_transfer_ref(ref, rdomid,
-                                          virt_to_machine(
-                                              skb->head) >> PAGE_SHIFT);
+                                          virt_to_mfn(skb->head));
         np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.gref = ref;
 #endif
-        rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
+        rx_pfn_array[i] = virt_to_mfn(skb->head);
 
        /* Remove this page from pseudo phys map before passing back to Xen. */
        phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
@@ -543,13 +542,14 @@ static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
         printk(KERN_ALERT "#### netfront can't claim tx grant reference\n");
         BUG();
     }
-    mfn = virt_to_machine(skb->data) >> PAGE_SHIFT;
+    mfn = virt_to_mfn(skb->data);
     gnttab_grant_foreign_access_ref(ref, rdomid, mfn, GNTMAP_readonly);
-    tx->addr = (ref << PAGE_SHIFT) | ((unsigned long)skb->data & ~PAGE_MASK);
+    tx->addr = ref << PAGE_SHIFT;
     grant_tx_ref[id] = ref;
 #else
-    tx->addr = virt_to_machine(skb->data);
+    tx->addr = virt_to_mfn(skb->data) << PAGE_SHIFT;
 #endif
+    tx->addr |= (unsigned long)skb->data & ~PAGE_MASK;
     tx->size = skb->len;
     tx->csum_blank = (skb->ip_summed == CHECKSUM_HW);
 
@@ -720,7 +720,7 @@ static int netif_poll(struct net_device *dev, int *pbudget)
     while ((skb = __skb_dequeue(&rxq)) != NULL) {
 #ifdef GRANT_DEBUG
         printk(KERN_ALERT "#### rx_poll     dequeue vdata=%p mfn=%lu\n",
-               skb->data, virt_to_machine(skb->data)>>PAGE_SHIFT);
+               skb->data, virt_to_mfn(skb->data));
         dump_packet('d', skb->data, (unsigned long)skb->data);
 #endif
         /*
@@ -854,18 +854,23 @@ static void network_connect(struct net_device *dev,
      * interface has been down.
      */
     for (requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++) {
-            if ((unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET) {
-                struct sk_buff *skb = np->tx_skbs[i];
-                
-                tx = &np->tx->ring[requeue_idx++].req;
-                
-                tx->id   = i;
-                tx->addr = virt_to_machine(skb->data);
-                tx->size = skb->len;
-                
-                np->stats.tx_bytes += skb->len;
-                np->stats.tx_packets++;
-            }
+        if ((unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET) {
+            struct sk_buff *skb = np->tx_skbs[i];
+
+            tx = &np->tx->ring[requeue_idx++].req;
+
+            tx->id   = i;
+#ifdef CONFIG_XEN_NETDEV_GRANT_TX
+            tx->addr = 0; /*(ref << PAGE_SHIFT) |*/
+#else
+            tx->addr = virt_to_mfn(skb->data) << PAGE_SHIFT;
+#endif
+            tx->addr |= (unsigned long)skb->data & ~PAGE_MASK;
+            tx->size = skb->len;
+
+            np->stats.tx_bytes += skb->len;
+            np->stats.tx_packets++;
+        }
     }
     wmb();
     np->tx->req_prod = requeue_idx;
@@ -922,7 +927,7 @@ static void send_interface_connect(struct net_private *np)
     netif_fe_interface_connect_t *msg = (void*)cmsg.msg;
 
     msg->handle = np->handle;
-    msg->tx_shmem_frame = (virt_to_machine(np->tx) >> PAGE_SHIFT);
+    msg->tx_shmem_frame = virt_to_mfn(np->tx);
 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
     msg->tx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_tx_head, 
                                                             gref_tx_terminal);
@@ -934,7 +939,7 @@ static void send_interface_connect(struct net_private *np)
                                      msg->tx_shmem_frame, 0);
 #endif
 
-    msg->rx_shmem_frame = (virt_to_machine(np->rx) >> PAGE_SHIFT);
+    msg->rx_shmem_frame = virt_to_mfn(np->rx);
 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
     msg->rx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_rx_head, 
                                                             gref_rx_terminal);
index 6ea151281bde71ef3e77cefe476ee83bb6200d06..8cc82606ac55d4a8dcde39ba6f5d0e8cd5fffd7f 100644 (file)
@@ -657,8 +657,8 @@ static void dispatch_usb_io(usbif_priv_t *up, usbif_request_t *req)
         phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
             FOREIGN_FRAME((buffer_mach + offset) >> PAGE_SHIFT);
 
-        ASSERT(virt_to_machine(MMAP_VADDR(pending_idx, i))
-               == buffer_mach + i << PAGE_SHIFT);
+        ASSERT(virt_to_mfn(MMAP_VADDR(pending_idx, i))
+               == ((buffer_mach >> PAGE_SHIFT) + i));
     }
 
     if ( req->pipe_type == 0 && req->num_iso > 0 ) /* Maybe schedule ISO... */
index 2801818afb35a1922b6b8743dd0e3e224bc81c53..b745c1d695a05b3c88d792b37bc0521ceca65c5b 100644 (file)
@@ -195,7 +195,7 @@ static int xhci_construct_isoc(usbif_request_t *req, struct urb *urb)
         }
 
         urb_priv->schedule = schedule;
-       req->iso_schedule = virt_to_machine(schedule);
+       req->iso_schedule = virt_to_mfn(schedule) << PAGE_SHIFT;
 
         return 0;
 }
@@ -212,7 +212,7 @@ static int xhci_queue_req(struct urb *urb)
 #if DEBUG
         printk(KERN_DEBUG
                "usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
-               usbif, usbif->req_prod, virt_to_machine(&usbif->req_prod),
+               usbif, usbif->req_prod, virt_to_mfn(&usbif->req_prod),
                usbif->resp_prod, xhci->usb_resp_cons);
 #endif
         
@@ -232,7 +232,7 @@ static int xhci_queue_req(struct urb *urb)
         req->operation       = USBIF_OP_IO;
         req->port            = 0; /* We don't care what the port is. */
         req->id              = (unsigned long) urb->hcpriv;
-        req->transfer_buffer = virt_to_machine(urb->transfer_buffer);
+        req->transfer_buffer = virt_to_mfn(urb->transfer_buffer) << PAGE_SHIFT;
        req->devnum          = usb_pipedevice(urb->pipe);
         req->direction       = usb_pipein(urb->pipe);
        req->speed           = usb_pipeslow(urb->pipe);
@@ -280,7 +280,7 @@ static inline usbif_request_t *xhci_queue_probe(usbif_vdev_t port)
        printk(KERN_DEBUG
                "queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, "
                "resp_cons = %d\n", usbif->req_prod,
-               virt_to_machine(&usbif->req_prod),
+               virt_to_mfn(&usbif->req_prod),
               usbif->resp_prod, xhci->usb_resp_cons);
 #endif
  
@@ -1555,7 +1555,7 @@ static void usbif_status_change(usbif_fe_interface_status_changed_t *status)
         cmsg.type      = CMSG_USBIF_FE;
         cmsg.subtype   = CMSG_USBIF_FE_INTERFACE_CONNECT;
         cmsg.length    = sizeof(usbif_fe_interface_connect_t);
-        up.shmem_frame = virt_to_machine(sring) >> PAGE_SHIFT;
+        up.shmem_frame = virt_to_mfn(sring);
         memcpy(cmsg.msg, &up, sizeof(up));
         
         /* Tell the controller to bring up the interface. */
@@ -1599,7 +1599,7 @@ static void usbif_status_change(usbif_fe_interface_status_changed_t *status)
 
        DPRINTK(KERN_INFO __FILE__
                 ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d\n",
-                xhci->usb_ring.sring, virt_to_machine(xhci->usbif),
+                xhci->usb_ring.sring, virt_to_mfn(xhci->usbif),
                 xhci->evtchn);
 
         xhci->state = USBIF_STATE_CONNECTED;
index 7a69359482ab4621b047505954d3c22eccd8d648..6ea32b5394d17e27d98021fc4dbf4d5755bf889f 100644 (file)
@@ -48,13 +48,12 @@ DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 
 static inline struct ringbuf_head *outbuf(void)
 {
-       return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT);
+       return mfn_to_virt(xen_start_info.store_mfn);
 }
 
 static inline struct ringbuf_head *inbuf(void)
 {
-       return machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT)
-               + PAGE_SIZE/2;
+       return mfn_to_virt(xen_start_info.store_mfn) + PAGE_SIZE/2;
 }
 
 static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs)
@@ -219,8 +218,7 @@ int xb_init_comms(void)
        }
 
        /* FIXME zero out page -- domain builder should probably do this*/
-       memset(machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT),
-              0, PAGE_SIZE);
+       memset(mfn_to_virt(xen_start_info.store_mfn), 0, PAGE_SIZE);
 
        return 0;
 }
index e2e13a9579d8a4eebff7e94f5ba4daa69160b2b8..3c3b1d2d90e037e16fcb7d6058b9f1ec3473a0a4 100644 (file)
@@ -93,7 +93,7 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
 
 static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
 {
-#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])
+#define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), *(u64 *)&t->tls_array[i])
        C(0); C(1); C(2);
 #undef C
 }
index 2bd859ff5f307e3fb63f7b7ed549e6c265bdcaab..c2dcf5a33efb04105b5d4ab69def92045a26d968 100644 (file)
@@ -102,8 +102,8 @@ enum fixed_addresses {
        __end_of_fixed_addresses
 };
 
-extern void __set_fixmap (enum fixed_addresses idx,
-                                       unsigned long phys, pgprot_t flags);
+extern void __set_fixmap(
+       enum fixed_addresses idx, maddr_t phys, pgprot_t flags);
 
 #define set_fixmap(idx, phys) \
                __set_fixmap(idx, phys, PAGE_KERNEL)
index cec6e2b9b25a71ee0b2de638f83afc2a8dfab0f3..b8191cc3e34325a786c71a2a20eca98826846d3c 100644 (file)
@@ -316,16 +316,17 @@ HYPERVISOR_get_debugreg(
 
 static inline int
 HYPERVISOR_update_descriptor(
-    unsigned long ma, unsigned long word1, unsigned long word2)
+    u64 ma, u64 desc)
 {
     int ret;
-    unsigned long ign1, ign2, ign3;
+    unsigned long ign1, ign2, ign3, ign4;
 
     __asm__ __volatile__ (
         TRAP_INSTR
-        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
-       : "0" (__HYPERVISOR_update_descriptor), "1" (ma), "2" (word1),
-         "3" (word2)
+        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
+       : "0" (__HYPERVISOR_update_descriptor),
+         "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
+         "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
        : "memory" );
 
     return ret;
index f02fd2e4021d835b2df855d32ad4ee46d1fc4bc1..a8979242a47d2d6c5ae94f2d376fd778f9d36aab 100644 (file)
 extern unsigned int *phys_to_machine_mapping;
 #define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
 #define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
+
+/* Definitions for machine and pseudophysical addresses. */
 #ifdef CONFIG_X86_PAE
-typedef unsigned long long physaddr_t;
+typedef unsigned long long paddr_t;
+typedef unsigned long long maddr_t;
 #else
-typedef unsigned long physaddr_t;
+typedef unsigned long paddr_t;
+typedef unsigned long maddr_t;
 #endif
-static inline physaddr_t phys_to_machine(physaddr_t phys)
+
+static inline maddr_t phys_to_machine(paddr_t phys)
 {
-       physaddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
+       maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
        machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
        return machine;
 }
-static inline physaddr_t machine_to_phys(physaddr_t machine)
+static inline paddr_t machine_to_phys(maddr_t machine)
 {
-       physaddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
+       paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
        phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
        return phys;
 }
@@ -233,8 +238,10 @@ extern int sysctl_legacy_va_layout;
                 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
 
 /* VIRT <-> MACHINE conversion */
-#define virt_to_machine(_a)    (phys_to_machine(__pa(_a)))
-#define machine_to_virt(_m)    (__va(machine_to_phys(_m)))
+#define virt_to_machine(v)     (phys_to_machine(__pa(v)))
+#define machine_to_virt(m)     (__va(machine_to_phys(m)))
+#define virt_to_mfn(v)         (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
+#define mfn_to_virt(m)         (__va(mfn_to_pfn(m) << PAGE_SHIFT))
 
 #endif /* __KERNEL__ */
 
index d326f7903ac69a90ef36f122267d99a3c98bdd0e..b1c425c22107dcbcfb8091aa000cb1a235dbfdd6 100644 (file)
@@ -450,7 +450,7 @@ void make_pages_writable(void *va, unsigned int nr);
 #define arbitrary_virt_to_machine(__va)                                        \
 ({                                                                     \
        pte_t *__pte = virt_to_ptep(__va);                              \
-       unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;     \
+       maddr_t __pa = (maddr_t)pte_mfn(*__pte) << PAGE_SHIFT;          \
        __pa | ((unsigned long)(__va) & (PAGE_SIZE-1));                 \
 })
 
index f1a45ec1a9b32f74561971d0f3c8f5bba652b829..2447b9792c6cf2d40ab8d5d655a4c7c81d2b7f3a 100644 (file)
@@ -65,16 +65,21 @@ void copy_page(void *, void *);
 extern u32 *phys_to_machine_mapping;
 #define pfn_to_mfn(_pfn) ((unsigned long) phys_to_machine_mapping[(unsigned int)(_pfn)])
 #define mfn_to_pfn(_mfn) ((unsigned long) machine_to_phys_mapping[(unsigned int)(_mfn)])
-static inline unsigned long phys_to_machine(unsigned long phys)
+
+/* Definitions for machine and pseudophysical addresses. */
+typedef unsigned long paddr_t;
+typedef unsigned long maddr_t;
+
+static inline maddr_t phys_to_machine(paddr_t phys)
 {
-       unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
+       maddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT);
        machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
        return machine;
 }
 
-static inline unsigned long machine_to_phys(unsigned long machine)
+static inline paddr_t machine_to_phys(maddr_t machine)
 {
-       unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
+       paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
        phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
        return phys;
 }
@@ -211,8 +216,10 @@ extern __inline__ int get_order(unsigned long size)
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 
 /* VIRT <-> MACHINE conversion */
-#define virt_to_machine(_a)    (phys_to_machine(__pa(_a)))
-#define machine_to_virt(_m)    (__va(machine_to_phys(_m)))
+#define virt_to_machine(v)     (phys_to_machine(__pa(v)))
+#define machine_to_virt(m)     (__va(machine_to_phys(m)))
+#define virt_to_mfn(v)         (pfn_to_mfn(__pa(v) >> PAGE_SHIFT))
+#define mfn_to_virt(m)         (__va(mfn_to_pfn(m) << PAGE_SHIFT))
 
 #define VM_DATA_DEFAULT_FLAGS \
        (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
index 0d48be74e95f99df63b08027c559f3964ed1725a..62c0a06d5f592d1af94248ee9874482a4ca7a8f8 100644 (file)
@@ -2689,22 +2689,24 @@ long do_set_gdt(unsigned long *frame_list, unsigned int entries)
 }
 
 
-long do_update_descriptor(unsigned long pa, u64 desc)
+long do_update_descriptor(u64 pa, u64 desc)
 {
     struct domain *dom = current->domain;
     unsigned long gpfn = pa >> PAGE_SHIFT;
     unsigned long mfn;
-    unsigned int  offset = (pa & ~PAGE_MASK) / sizeof(struct desc_struct);
+    unsigned int  offset;
     struct desc_struct *gdt_pent, d;
     struct pfn_info *page;
     long ret = -EINVAL;
 
+    offset = ((unsigned int)pa & ~PAGE_MASK) / sizeof(struct desc_struct);
+
     *(u64 *)&d = desc;
 
     LOCK_BIGLOCK(dom);
 
     if ( !VALID_MFN(mfn = __gpfn_to_mfn(dom, gpfn)) ||
-         ((pa % sizeof(struct desc_struct)) != 0) ||
+         (((unsigned int)pa % sizeof(struct desc_struct)) != 0) ||
          (mfn >= max_page) ||
          !check_descriptor(&d) )
     {