mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
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>
This commit is contained in:
1 parent
df3303d149
commit
4e4ffc8edf
27 files changed
+127
-109
No files matched your search
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)++;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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++; \
|
||||
} \
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 /
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) )
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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... */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
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__ */
|
||||
|
||||
|
||||
@@ -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)); \
|
||||
})
|
||||
|
||||
|
||||
@@ -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 ) | \
|
||||
|
||||
+5
-3
@@ -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) )
|
||||
{
|
||||
|
||||