[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Fix many uses of machine addresses in XenLinux. Primarily
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 1a0723cd37f1a7e2fb24021699d9df3625183dc0 # Parent 47d49e8b8042c15ed1409786701a16fcda02e91c 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@xxxxxxxxxxxxx> diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c Fri Aug 19 16:06:43 2005 @@ -569,7 +569,7 @@ 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)) diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c Fri Aug 19 16:06:43 2005 @@ -198,7 +198,7 @@ { 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 @@ /* 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); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c Fri Aug 19 16:06:43 2005 @@ -522,16 +522,15 @@ * 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 diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Fri Aug 19 16:06:43 2005 @@ -1604,11 +1604,10 @@ 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. diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c Fri Aug 19 16:06:43 2005 @@ -904,7 +904,7 @@ 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 @@ 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); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c Fri Aug 19 16:06:43 2005 @@ -306,7 +306,7 @@ { 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)++; diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c Fri Aug 19 16:06:43 2005 @@ -170,7 +170,7 @@ __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); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/kernel/reboot.c --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c Fri Aug 19 16:06:43 2005 @@ -247,7 +247,7 @@ /* 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 @@ 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(); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c Fri Aug 19 16:06:43 2005 @@ -453,8 +453,8 @@ #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++; \ } \ diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c Fri Aug 19 16:06:43 2005 @@ -795,7 +795,7 @@ 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]); } } diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c Fri Aug 19 16:06:43 2005 @@ -139,7 +139,7 @@ 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 / diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c Fri Aug 19 16:06:43 2005 @@ -780,7 +780,7 @@ 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 @@ 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); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c Fri Aug 19 16:06:43 2005 @@ -742,7 +742,7 @@ 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 diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Fri Aug 19 16:06:43 2005 @@ -1175,8 +1175,8 @@ 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 @@ } #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; diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c Fri Aug 19 16:06:43 2005 @@ -320,7 +320,7 @@ }; 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); } diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/netback/netback.c --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Fri Aug 19 16:06:43 2005 @@ -251,7 +251,7 @@ #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 @@ { 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 @@ 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 @@ 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 @@ __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 @@ 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 @@ /* 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; -#else - mdata = ((mmuext[0].mfn << PAGE_SHIFT) | - ((unsigned long)skb->data & ~PAGE_MASK)); + old_mfn = 0; /* XXX Fix this so we can free_mfn() on error! */ +#else + old_mfn = mmuext[0].mfn; #endif atomic_set(&(skb_shinfo(skb)->dataref), 1); skb_shinfo(skb)->nr_frags = 0; @@ -379,18 +376,20 @@ /* 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) ) { diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Fri Aug 19 16:06:43 2005 @@ -448,11 +448,10 @@ } 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 @@ 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); -#endif + 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 @@ 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 @@ * 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 @@ 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 @@ 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); diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c --- a/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c Fri Aug 19 16:06:43 2005 @@ -657,8 +657,8 @@ 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... */ diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c --- a/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c Fri Aug 19 16:06:43 2005 @@ -195,7 +195,7 @@ } 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 @@ #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 @@ 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 @@ 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 @@ 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 @@ 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; diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c Fri Aug 19 16:06:43 2005 @@ -48,13 +48,12 @@ 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 @@ } /* 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; } diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h Fri Aug 19 16:06:43 2005 @@ -93,7 +93,7 @@ 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 } diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h Fri Aug 19 16:06:43 2005 @@ -102,8 +102,8 @@ __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) diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h Fri Aug 19 16:06:43 2005 @@ -316,16 +316,17 @@ static inline int HYPERVISOR_update_descriptor( - unsigned long ma, unsigned long word1, unsigned long word2) -{ - int ret; - unsigned long ign1, ign2, ign3; - - __asm__ __volatile__ ( - TRAP_INSTR - : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3) - : "0" (__HYPERVISOR_update_descriptor), "1" (ma), "2" (word1), - "3" (word2) + u64 ma, u64 desc) +{ + int ret; + unsigned long ign1, ign2, ign3, ign4; + + __asm__ __volatile__ ( + TRAP_INSTR + : "=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; diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h Fri Aug 19 16:06:43 2005 @@ -63,20 +63,25 @@ 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; -#else -typedef unsigned long physaddr_t; -#endif -static inline physaddr_t phys_to_machine(physaddr_t phys) -{ - physaddr_t machine = pfn_to_mfn(phys >> PAGE_SHIFT); +typedef unsigned long long paddr_t; +typedef unsigned long long maddr_t; +#else +typedef unsigned long paddr_t; +typedef unsigned long maddr_t; +#endif + +static inline maddr_t phys_to_machine(paddr_t phys) +{ + 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) -{ - physaddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); +static inline paddr_t machine_to_phys(maddr_t machine) +{ + paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK); return phys; } @@ -233,8 +238,10 @@ 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__ */ diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h Fri Aug 19 16:06:43 2005 @@ -450,7 +450,7 @@ #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)); \ }) diff -r 47d49e8b8042 -r 1a0723cd37f1 linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h Fri Aug 19 15:47:19 2005 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h Fri Aug 19 16:06:43 2005 @@ -65,16 +65,21 @@ 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) -{ - unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT); + +/* 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) +{ + 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) -{ - unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT); +static inline paddr_t machine_to_phys(maddr_t machine) +{ + paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT); phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK); return phys; } @@ -211,8 +216,10 @@ #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 ) | \ diff -r 47d49e8b8042 -r 1a0723cd37f1 xen/arch/x86/mm.c --- a/xen/arch/x86/mm.c Fri Aug 19 15:47:19 2005 +++ b/xen/arch/x86/mm.c Fri Aug 19 16:06:43 2005 @@ -2689,22 +2689,24 @@ } -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) ) { _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |