aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Grall <julien.grall@citrix.com>2015-08-07 12:34:37 -0400
committerJulien Grall <julien.grall@citrix.com>2015-09-08 13:03:49 -0400
commit0df4f266b3af90442bbeb5e685a84a80745beba0 (patch)
tree6516dbebc85a0e204b1e619466b3fbff6d14c3f3
parent5192b35de47e47a0f736fe30da199f32030680e7 (diff)
xen: Use correctly the Xen memory terminologies
Based on include/xen/mm.h [1], Linux is mistakenly using MFN when GFN is meant, I suspect this is because the first support for Xen was for PV. This resulted in some misimplementation of helpers on ARM and confused developers about the expected behavior. For instance, with pfn_to_mfn, we expect to get an MFN based on the name. Although, if we look at the implementation on x86, it's returning a GFN. For clarity and avoid new confusion, replace any reference to mfn with gfn in any helpers used by PV drivers. The x86 code will still keep some reference of pfn_to_mfn which may be used by all kind of guests No changes as been made in the hypercall field, even though they may be invalid, in order to keep the same as the defintion in xen repo. Note that page_to_mfn has been renamed to xen_page_to_gfn to avoid a name to close to the KVM function gfn_to_page. Take also the opportunity to simplify simple construction such as pfn_to_mfn(page_to_pfn(page)) into xen_page_to_gfn. More complex clean up will come in follow-up patches. [1] http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=e758ed14f390342513405dd766e874934573e6cb Signed-off-by: Julien Grall <julien.grall@citrix.com> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
-rw-r--r--arch/arm/include/asm/xen/page.h13
-rw-r--r--arch/x86/include/asm/xen/page.h35
-rw-r--r--arch/x86/xen/smp.c2
-rw-r--r--drivers/block/xen-blkfront.c6
-rw-r--r--drivers/input/misc/xen-kbdfront.c4
-rw-r--r--drivers/net/xen-netback/netback.c4
-rw-r--r--drivers/net/xen-netfront.c12
-rw-r--r--drivers/scsi/xen-scsifront.c10
-rw-r--r--drivers/tty/hvc/hvc_xen.c5
-rw-r--r--drivers/video/fbdev/xen-fbfront.c4
-rw-r--r--drivers/xen/balloon.c2
-rw-r--r--drivers/xen/events/events_base.c2
-rw-r--r--drivers/xen/events/events_fifo.c4
-rw-r--r--drivers/xen/gntalloc.c3
-rw-r--r--drivers/xen/manage.c2
-rw-r--r--drivers/xen/tmem.c4
-rw-r--r--drivers/xen/xenbus/xenbus_client.c2
-rw-r--r--drivers/xen/xenbus/xenbus_dev_backend.c2
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c8
-rw-r--r--include/xen/page.h4
20 files changed, 81 insertions, 47 deletions
diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 911d62b4df26..127956353b00 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -34,14 +34,15 @@ typedef struct xpaddr {
34unsigned long __pfn_to_mfn(unsigned long pfn); 34unsigned long __pfn_to_mfn(unsigned long pfn);
35extern struct rb_root phys_to_mach; 35extern struct rb_root phys_to_mach;
36 36
37static inline unsigned long pfn_to_mfn(unsigned long pfn) 37/* Pseudo-physical <-> Guest conversion */
38static inline unsigned long pfn_to_gfn(unsigned long pfn)
38{ 39{
39 return pfn; 40 return pfn;
40} 41}
41 42
42static inline unsigned long mfn_to_pfn(unsigned long mfn) 43static inline unsigned long gfn_to_pfn(unsigned long gfn)
43{ 44{
44 return mfn; 45 return gfn;
45} 46}
46 47
47/* Pseudo-physical <-> BUS conversion */ 48/* Pseudo-physical <-> BUS conversion */
@@ -65,9 +66,9 @@ static inline unsigned long bfn_to_pfn(unsigned long bfn)
65 66
66#define bfn_to_local_pfn(bfn) bfn_to_pfn(bfn) 67#define bfn_to_local_pfn(bfn) bfn_to_pfn(bfn)
67 68
68/* VIRT <-> MACHINE conversion */ 69/* VIRT <-> GUEST conversion */
69#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v))) 70#define virt_to_gfn(v) (pfn_to_gfn(virt_to_pfn(v)))
70#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) 71#define gfn_to_virt(m) (__va(gfn_to_pfn(m) << PAGE_SHIFT))
71 72
72/* Only used in PV code. But ARM guests are always HVM. */ 73/* Only used in PV code. But ARM guests are always HVM. */
73static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr) 74static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 724bffbde54d..0679e11d2cf7 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -101,6 +101,11 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
101{ 101{
102 unsigned long mfn; 102 unsigned long mfn;
103 103
104 /*
105 * Some x86 code are still using pfn_to_mfn instead of
106 * pfn_to_mfn. This will have to be removed when we figured
107 * out which call.
108 */
104 if (xen_feature(XENFEAT_auto_translated_physmap)) 109 if (xen_feature(XENFEAT_auto_translated_physmap))
105 return pfn; 110 return pfn;
106 111
@@ -147,6 +152,11 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
147{ 152{
148 unsigned long pfn; 153 unsigned long pfn;
149 154
155 /*
156 * Some x86 code are still using mfn_to_pfn instead of
157 * gfn_to_pfn. This will have to be removed when we figure
158 * out which call.
159 */
150 if (xen_feature(XENFEAT_auto_translated_physmap)) 160 if (xen_feature(XENFEAT_auto_translated_physmap))
151 return mfn; 161 return mfn;
152 162
@@ -176,9 +186,26 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
176 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); 186 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
177} 187}
178 188
189/* Pseudo-physical <-> Guest conversion */
190static inline unsigned long pfn_to_gfn(unsigned long pfn)
191{
192 if (xen_feature(XENFEAT_auto_translated_physmap))
193 return pfn;
194 else
195 return pfn_to_mfn(pfn);
196}
197
198static inline unsigned long gfn_to_pfn(unsigned long gfn)
199{
200 if (xen_feature(XENFEAT_auto_translated_physmap))
201 return gfn;
202 else
203 return mfn_to_pfn(gfn);
204}
205
179/* Pseudo-physical <-> Bus conversion */ 206/* Pseudo-physical <-> Bus conversion */
180#define pfn_to_bfn(pfn) pfn_to_mfn(pfn) 207#define pfn_to_bfn(pfn) pfn_to_gfn(pfn)
181#define bfn_to_pfn(bfn) mfn_to_pfn(bfn) 208#define bfn_to_pfn(bfn) gfn_to_pfn(bfn)
182 209
183/* 210/*
184 * We detect special mappings in one of two ways: 211 * We detect special mappings in one of two ways:
@@ -219,6 +246,10 @@ static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
219#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v))) 246#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
220#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) 247#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
221 248
249/* VIRT <-> GUEST conversion */
250#define virt_to_gfn(v) (pfn_to_gfn(virt_to_pfn(v)))
251#define gfn_to_virt(g) (__va(gfn_to_pfn(g) << PAGE_SHIFT))
252
222static inline unsigned long pte_mfn(pte_t pte) 253static inline unsigned long pte_mfn(pte_t pte)
223{ 254{
224 return (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT; 255 return (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT;
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 2a9ff7342791..3f4ebf0261f2 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -453,7 +453,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
453 } 453 }
454#endif 454#endif
455 ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs); 455 ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
456 ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir)); 456 ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_gfn(swapper_pg_dir));
457 if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt)) 457 if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt))
458 BUG(); 458 BUG();
459 459
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 5dd591d6c859..432e1058721f 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -250,7 +250,7 @@ static struct grant *get_grant(grant_ref_t *gref_head,
250 struct blkfront_info *info) 250 struct blkfront_info *info)
251{ 251{
252 struct grant *gnt_list_entry; 252 struct grant *gnt_list_entry;
253 unsigned long buffer_mfn; 253 unsigned long buffer_gfn;
254 254
255 BUG_ON(list_empty(&info->grants)); 255 BUG_ON(list_empty(&info->grants));
256 gnt_list_entry = list_first_entry(&info->grants, struct grant, 256 gnt_list_entry = list_first_entry(&info->grants, struct grant,
@@ -269,10 +269,10 @@ static struct grant *get_grant(grant_ref_t *gref_head,
269 BUG_ON(!pfn); 269 BUG_ON(!pfn);
270 gnt_list_entry->pfn = pfn; 270 gnt_list_entry->pfn = pfn;
271 } 271 }
272 buffer_mfn = pfn_to_mfn(gnt_list_entry->pfn); 272 buffer_gfn = pfn_to_gfn(gnt_list_entry->pfn);
273 gnttab_grant_foreign_access_ref(gnt_list_entry->gref, 273 gnttab_grant_foreign_access_ref(gnt_list_entry->gref,
274 info->xbdev->otherend_id, 274 info->xbdev->otherend_id,
275 buffer_mfn, 0); 275 buffer_gfn, 0);
276 return gnt_list_entry; 276 return gnt_list_entry;
277} 277}
278 278
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 95599e478e19..23d0549539d4 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -232,7 +232,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
232 struct xenbus_transaction xbt; 232 struct xenbus_transaction xbt;
233 233
234 ret = gnttab_grant_foreign_access(dev->otherend_id, 234 ret = gnttab_grant_foreign_access(dev->otherend_id,
235 virt_to_mfn(info->page), 0); 235 virt_to_gfn(info->page), 0);
236 if (ret < 0) 236 if (ret < 0)
237 return ret; 237 return ret;
238 info->gref = ret; 238 info->gref = ret;
@@ -255,7 +255,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
255 goto error_irqh; 255 goto error_irqh;
256 } 256 }
257 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", 257 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
258 virt_to_mfn(info->page)); 258 virt_to_gfn(info->page));
259 if (ret) 259 if (ret)
260 goto error_xenbus; 260 goto error_xenbus;
261 ret = xenbus_printf(xbt, dev->nodename, "page-gref", "%u", info->gref); 261 ret = xenbus_printf(xbt, dev->nodename, "page-gref", "%u", info->gref);
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 3f44b522b831..7c64c74711e8 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -314,7 +314,7 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
314 } else { 314 } else {
315 copy_gop->source.domid = DOMID_SELF; 315 copy_gop->source.domid = DOMID_SELF;
316 copy_gop->source.u.gmfn = 316 copy_gop->source.u.gmfn =
317 virt_to_mfn(page_address(page)); 317 virt_to_gfn(page_address(page));
318 } 318 }
319 copy_gop->source.offset = offset; 319 copy_gop->source.offset = offset;
320 320
@@ -1296,7 +1296,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
1296 queue->tx_copy_ops[*copy_ops].source.offset = txreq.offset; 1296 queue->tx_copy_ops[*copy_ops].source.offset = txreq.offset;
1297 1297
1298 queue->tx_copy_ops[*copy_ops].dest.u.gmfn = 1298 queue->tx_copy_ops[*copy_ops].dest.u.gmfn =
1299 virt_to_mfn(skb->data); 1299 virt_to_gfn(skb->data);
1300 queue->tx_copy_ops[*copy_ops].dest.domid = DOMID_SELF; 1300 queue->tx_copy_ops[*copy_ops].dest.domid = DOMID_SELF;
1301 queue->tx_copy_ops[*copy_ops].dest.offset = 1301 queue->tx_copy_ops[*copy_ops].dest.offset =
1302 offset_in_page(skb->data); 1302 offset_in_page(skb->data);
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f948c46d5132..47f791e60851 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -291,7 +291,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
291 struct sk_buff *skb; 291 struct sk_buff *skb;
292 unsigned short id; 292 unsigned short id;
293 grant_ref_t ref; 293 grant_ref_t ref;
294 unsigned long pfn; 294 unsigned long gfn;
295 struct xen_netif_rx_request *req; 295 struct xen_netif_rx_request *req;
296 296
297 skb = xennet_alloc_one_rx_buffer(queue); 297 skb = xennet_alloc_one_rx_buffer(queue);
@@ -307,12 +307,12 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
307 BUG_ON((signed short)ref < 0); 307 BUG_ON((signed short)ref < 0);
308 queue->grant_rx_ref[id] = ref; 308 queue->grant_rx_ref[id] = ref;
309 309
310 pfn = page_to_pfn(skb_frag_page(&skb_shinfo(skb)->frags[0])); 310 gfn = xen_page_to_gfn(skb_frag_page(&skb_shinfo(skb)->frags[0]));
311 311
312 req = RING_GET_REQUEST(&queue->rx, req_prod); 312 req = RING_GET_REQUEST(&queue->rx, req_prod);
313 gnttab_grant_foreign_access_ref(ref, 313 gnttab_grant_foreign_access_ref(ref,
314 queue->info->xbdev->otherend_id, 314 queue->info->xbdev->otherend_id,
315 pfn_to_mfn(pfn), 315 gfn,
316 0); 316 0);
317 317
318 req->id = id; 318 req->id = id;
@@ -430,8 +430,10 @@ static struct xen_netif_tx_request *xennet_make_one_txreq(
430 ref = gnttab_claim_grant_reference(&queue->gref_tx_head); 430 ref = gnttab_claim_grant_reference(&queue->gref_tx_head);
431 BUG_ON((signed short)ref < 0); 431 BUG_ON((signed short)ref < 0);
432 432
433 gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, 433 gnttab_grant_foreign_access_ref(ref,
434 page_to_mfn(page), GNTMAP_readonly); 434 queue->info->xbdev->otherend_id,
435 xen_page_to_gfn(page),
436 GNTMAP_readonly);
435 437
436 queue->tx_skbs[id].skb = skb; 438 queue->tx_skbs[id].skb = skb;
437 queue->grant_tx_page[id] = page; 439 queue->grant_tx_page[id] = page;
diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index fad22caf0eff..9dc8687bf048 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -377,7 +377,6 @@ static int map_data_for_request(struct vscsifrnt_info *info,
377 unsigned int data_len = scsi_bufflen(sc); 377 unsigned int data_len = scsi_bufflen(sc);
378 unsigned int data_grants = 0, seg_grants = 0; 378 unsigned int data_grants = 0, seg_grants = 0;
379 struct scatterlist *sg; 379 struct scatterlist *sg;
380 unsigned long mfn;
381 struct scsiif_request_segment *seg; 380 struct scsiif_request_segment *seg;
382 381
383 ring_req->nr_segments = 0; 382 ring_req->nr_segments = 0;
@@ -420,9 +419,9 @@ static int map_data_for_request(struct vscsifrnt_info *info,
420 ref = gnttab_claim_grant_reference(&gref_head); 419 ref = gnttab_claim_grant_reference(&gref_head);
421 BUG_ON(ref == -ENOSPC); 420 BUG_ON(ref == -ENOSPC);
422 421
423 mfn = pfn_to_mfn(page_to_pfn(page));
424 gnttab_grant_foreign_access_ref(ref, 422 gnttab_grant_foreign_access_ref(ref,
425 info->dev->otherend_id, mfn, 1); 423 info->dev->otherend_id,
424 xen_page_to_gfn(page), 1);
426 shadow->gref[ref_cnt] = ref; 425 shadow->gref[ref_cnt] = ref;
427 ring_req->seg[ref_cnt].gref = ref; 426 ring_req->seg[ref_cnt].gref = ref;
428 ring_req->seg[ref_cnt].offset = (uint16_t)off; 427 ring_req->seg[ref_cnt].offset = (uint16_t)off;
@@ -454,9 +453,10 @@ static int map_data_for_request(struct vscsifrnt_info *info,
454 ref = gnttab_claim_grant_reference(&gref_head); 453 ref = gnttab_claim_grant_reference(&gref_head);
455 BUG_ON(ref == -ENOSPC); 454 BUG_ON(ref == -ENOSPC);
456 455
457 mfn = pfn_to_mfn(page_to_pfn(page));
458 gnttab_grant_foreign_access_ref(ref, 456 gnttab_grant_foreign_access_ref(ref,
459 info->dev->otherend_id, mfn, grant_ro); 457 info->dev->otherend_id,
458 xen_page_to_gfn(page),
459 grant_ro);
460 460
461 shadow->gref[ref_cnt] = ref; 461 shadow->gref[ref_cnt] = ref;
462 seg->gref = ref; 462 seg->gref = ref;
diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index a9d837f83ce8..efe5124a368d 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -265,7 +265,8 @@ static int xen_pv_console_init(void)
265 return 0; 265 return 0;
266 } 266 }
267 info->evtchn = xen_start_info->console.domU.evtchn; 267 info->evtchn = xen_start_info->console.domU.evtchn;
268 info->intf = mfn_to_virt(xen_start_info->console.domU.mfn); 268 /* GFN == MFN for PV guest */
269 info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
269 info->vtermno = HVC_COOKIE; 270 info->vtermno = HVC_COOKIE;
270 271
271 spin_lock(&xencons_lock); 272 spin_lock(&xencons_lock);
@@ -390,7 +391,7 @@ static int xencons_connect_backend(struct xenbus_device *dev,
390 if (IS_ERR(info->hvc)) 391 if (IS_ERR(info->hvc))
391 return PTR_ERR(info->hvc); 392 return PTR_ERR(info->hvc);
392 if (xen_pv_domain()) 393 if (xen_pv_domain())
393 mfn = virt_to_mfn(info->intf); 394 mfn = virt_to_gfn(info->intf);
394 else 395 else
395 mfn = __pa(info->intf) >> PAGE_SHIFT; 396 mfn = __pa(info->intf) >> PAGE_SHIFT;
396 ret = gnttab_alloc_grant_references(1, &gref_head); 397 ret = gnttab_alloc_grant_references(1, &gref_head);
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c
index 09dc44736c1a..25e3cce0c35f 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -539,7 +539,7 @@ static int xenfb_remove(struct xenbus_device *dev)
539 539
540static unsigned long vmalloc_to_mfn(void *address) 540static unsigned long vmalloc_to_mfn(void *address)
541{ 541{
542 return pfn_to_mfn(vmalloc_to_pfn(address)); 542 return pfn_to_gfn(vmalloc_to_pfn(address));
543} 543}
544 544
545static void xenfb_init_shared_page(struct xenfb_info *info, 545static void xenfb_init_shared_page(struct xenfb_info *info,
@@ -586,7 +586,7 @@ static int xenfb_connect_backend(struct xenbus_device *dev,
586 goto unbind_irq; 586 goto unbind_irq;
587 } 587 }
588 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", 588 ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
589 virt_to_mfn(info->page)); 589 virt_to_gfn(info->page));
590 if (ret) 590 if (ret)
591 goto error_xenbus; 591 goto error_xenbus;
592 ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u", 592 ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 1fa633b2d556..c79329fcfa78 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -441,7 +441,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
441 /* Update direct mapping, invalidate P2M, and add to balloon. */ 441 /* Update direct mapping, invalidate P2M, and add to balloon. */
442 for (i = 0; i < nr_pages; i++) { 442 for (i = 0; i < nr_pages; i++) {
443 pfn = frame_list[i]; 443 pfn = frame_list[i];
444 frame_list[i] = pfn_to_mfn(pfn); 444 frame_list[i] = pfn_to_gfn(pfn);
445 page = pfn_to_page(pfn); 445 page = pfn_to_page(pfn);
446 446
447#ifdef CONFIG_XEN_HAVE_PVMMU 447#ifdef CONFIG_XEN_HAVE_PVMMU
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index ed620e5857a1..c49bb7a5be8f 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1688,7 +1688,7 @@ void __init xen_init_IRQ(void)
1688 struct physdev_pirq_eoi_gmfn eoi_gmfn; 1688 struct physdev_pirq_eoi_gmfn eoi_gmfn;
1689 1689
1690 pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); 1690 pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
1691 eoi_gmfn.gmfn = virt_to_mfn(pirq_eoi_map); 1691 eoi_gmfn.gmfn = virt_to_gfn(pirq_eoi_map);
1692 rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn); 1692 rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
1693 /* TODO: No PVH support for PIRQ EOI */ 1693 /* TODO: No PVH support for PIRQ EOI */
1694 if (rc != 0) { 1694 if (rc != 0) {
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index ed673e1acd61..1d4baf56c36b 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -111,7 +111,7 @@ static int init_control_block(int cpu,
111 for (i = 0; i < EVTCHN_FIFO_MAX_QUEUES; i++) 111 for (i = 0; i < EVTCHN_FIFO_MAX_QUEUES; i++)
112 q->head[i] = 0; 112 q->head[i] = 0;
113 113
114 init_control.control_gfn = virt_to_mfn(control_block); 114 init_control.control_gfn = virt_to_gfn(control_block);
115 init_control.offset = 0; 115 init_control.offset = 0;
116 init_control.vcpu = cpu; 116 init_control.vcpu = cpu;
117 117
@@ -167,7 +167,7 @@ static int evtchn_fifo_setup(struct irq_info *info)
167 /* Mask all events in this page before adding it. */ 167 /* Mask all events in this page before adding it. */
168 init_array_page(array_page); 168 init_array_page(array_page);
169 169
170 expand_array.array_gfn = virt_to_mfn(array_page); 170 expand_array.array_gfn = virt_to_gfn(array_page);
171 171
172 ret = HYPERVISOR_event_channel_op(EVTCHNOP_expand_array, &expand_array); 172 ret = HYPERVISOR_event_channel_op(EVTCHNOP_expand_array, &expand_array);
173 if (ret < 0) 173 if (ret < 0)
diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
index e53fe191738c..14370df9ac1c 100644
--- a/drivers/xen/gntalloc.c
+++ b/drivers/xen/gntalloc.c
@@ -142,7 +142,8 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
142 142
143 /* Grant foreign access to the page. */ 143 /* Grant foreign access to the page. */
144 rc = gnttab_grant_foreign_access(op->domid, 144 rc = gnttab_grant_foreign_access(op->domid,
145 pfn_to_mfn(page_to_pfn(gref->page)), readonly); 145 xen_page_to_gfn(gref->page),
146 readonly);
146 if (rc < 0) 147 if (rc < 0)
147 goto undo; 148 goto undo;
148 gref_ids[i] = gref->gref_id = rc; 149 gref_ids[i] = gref->gref_id = rc;
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index d10effee9b9e..e12bd3635f83 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -80,7 +80,7 @@ static int xen_suspend(void *data)
80 * is resuming in a new domain. 80 * is resuming in a new domain.
81 */ 81 */
82 si->cancelled = HYPERVISOR_suspend(xen_pv_domain() 82 si->cancelled = HYPERVISOR_suspend(xen_pv_domain()
83 ? virt_to_mfn(xen_start_info) 83 ? virt_to_gfn(xen_start_info)
84 : 0); 84 : 0);
85 85
86 xen_arch_post_suspend(si->cancelled); 86 xen_arch_post_suspend(si->cancelled);
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
index 239738f944ba..28c97ff606f4 100644
--- a/drivers/xen/tmem.c
+++ b/drivers/xen/tmem.c
@@ -131,7 +131,7 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid,
131static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid, 131static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid,
132 u32 index, unsigned long pfn) 132 u32 index, unsigned long pfn)
133{ 133{
134 unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn; 134 unsigned long gmfn = pfn_to_gfn(pfn);
135 135
136 return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index, 136 return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index,
137 gmfn, 0, 0, 0); 137 gmfn, 0, 0, 0);
@@ -140,7 +140,7 @@ static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid,
140static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid, 140static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid,
141 u32 index, unsigned long pfn) 141 u32 index, unsigned long pfn)
142{ 142{
143 unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn; 143 unsigned long gmfn = pfn_to_gfn(pfn);
144 144
145 return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index, 145 return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index,
146 gmfn, 0, 0, 0); 146 gmfn, 0, 0, 0);
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index e30353575d5d..2ba09c1195c8 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -380,7 +380,7 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
380 380
381 for (i = 0; i < nr_pages; i++) { 381 for (i = 0; i < nr_pages; i++) {
382 err = gnttab_grant_foreign_access(dev->otherend_id, 382 err = gnttab_grant_foreign_access(dev->otherend_id,
383 virt_to_mfn(vaddr), 0); 383 virt_to_gfn(vaddr), 0);
384 if (err < 0) { 384 if (err < 0) {
385 xenbus_dev_fatal(dev, err, 385 xenbus_dev_fatal(dev, err,
386 "granting access to ring page"); 386 "granting access to ring page");
diff --git a/drivers/xen/xenbus/xenbus_dev_backend.c b/drivers/xen/xenbus/xenbus_dev_backend.c
index b17707ee07d4..ee6d9efd7b76 100644
--- a/drivers/xen/xenbus/xenbus_dev_backend.c
+++ b/drivers/xen/xenbus/xenbus_dev_backend.c
@@ -49,7 +49,7 @@ static long xenbus_alloc(domid_t domid)
49 goto out_err; 49 goto out_err;
50 50
51 gnttab_grant_foreign_access_ref(GNTTAB_RESERVED_XENSTORE, domid, 51 gnttab_grant_foreign_access_ref(GNTTAB_RESERVED_XENSTORE, domid,
52 virt_to_mfn(xen_store_interface), 0 /* writable */); 52 virt_to_gfn(xen_store_interface), 0 /* writable */);
53 53
54 arg.dom = DOMID_SELF; 54 arg.dom = DOMID_SELF;
55 arg.remote_dom = domid; 55 arg.remote_dom = domid;
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 4308fb3cf7c2..b3870f4ca1d0 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -711,9 +711,7 @@ static int __init xenstored_local_init(void)
711 if (!page) 711 if (!page)
712 goto out_err; 712 goto out_err;
713 713
714 xen_store_mfn = xen_start_info->store_mfn = 714 xen_store_mfn = xen_start_info->store_mfn = virt_to_gfn((void *)page);
715 pfn_to_mfn(virt_to_phys((void *)page) >>
716 PAGE_SHIFT);
717 715
718 /* Next allocate a local port which xenstored can bind to */ 716 /* Next allocate a local port which xenstored can bind to */
719 alloc_unbound.dom = DOMID_SELF; 717 alloc_unbound.dom = DOMID_SELF;
@@ -787,12 +785,12 @@ static int __init xenbus_init(void)
787 err = xenstored_local_init(); 785 err = xenstored_local_init();
788 if (err) 786 if (err)
789 goto out_error; 787 goto out_error;
790 xen_store_interface = mfn_to_virt(xen_store_mfn); 788 xen_store_interface = gfn_to_virt(xen_store_mfn);
791 break; 789 break;
792 case XS_PV: 790 case XS_PV:
793 xen_store_evtchn = xen_start_info->store_evtchn; 791 xen_store_evtchn = xen_start_info->store_evtchn;
794 xen_store_mfn = xen_start_info->store_mfn; 792 xen_store_mfn = xen_start_info->store_mfn;
795 xen_store_interface = mfn_to_virt(xen_store_mfn); 793 xen_store_interface = gfn_to_virt(xen_store_mfn);
796 break; 794 break;
797 case XS_HVM: 795 case XS_HVM:
798 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); 796 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
diff --git a/include/xen/page.h b/include/xen/page.h
index a5983da2f5cd..1daae485e336 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -3,9 +3,9 @@
3 3
4#include <asm/xen/page.h> 4#include <asm/xen/page.h>
5 5
6static inline unsigned long page_to_mfn(struct page *page) 6static inline unsigned long xen_page_to_gfn(struct page *page)
7{ 7{
8 return pfn_to_mfn(page_to_pfn(page)); 8 return pfn_to_gfn(page_to_pfn(page));
9} 9}
10 10
11struct xen_memory_region { 11struct xen_memory_region {