Skip to content

Commit

Permalink
Merge tag 'for-linus-4.3-rc0b-tag' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/xen/tip

Pull xen terminology fixes from David Vrabel:
 "Use the correct GFN/BFN terms more consistently"

* tag 'for-linus-4.3-rc0b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen/xenbus: Rename the variable xen_store_mfn to xen_store_gfn
  xen/privcmd: Further s/MFN/GFN/ clean-up
  hvc/xen: Further s/MFN/GFN clean-up
  video/xen-fbfront: Further s/MFN/GFN clean-up
  xen/tmem: Use xen_page_to_gfn rather than pfn_to_gfn
  xen: Use correctly the Xen memory terminologies
  arm/xen: implement correctly pfn_to_mfn
  xen: Make clear that swiotlb and biomerge are dealing with DMA address
  • Loading branch information
Linus Torvalds committed Sep 10, 2015
2 parents 573c577 + 5f51042 commit 06ab838
Show file tree
Hide file tree
Showing 29 changed files with 198 additions and 158 deletions.
28 changes: 20 additions & 8 deletions arch/arm/include/asm/xen/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ typedef struct xpaddr {
unsigned long __pfn_to_mfn(unsigned long pfn);
extern struct rb_root phys_to_mach;

static inline unsigned long pfn_to_mfn(unsigned long pfn)
/* Pseudo-physical <-> Guest conversion */
static inline unsigned long pfn_to_gfn(unsigned long pfn)
{
return pfn;
}

static inline unsigned long gfn_to_pfn(unsigned long gfn)
{
return gfn;
}

/* Pseudo-physical <-> BUS conversion */
static inline unsigned long pfn_to_bfn(unsigned long pfn)
{
unsigned long mfn;

Expand All @@ -47,16 +59,16 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
return pfn;
}

static inline unsigned long mfn_to_pfn(unsigned long mfn)
static inline unsigned long bfn_to_pfn(unsigned long bfn)
{
return mfn;
return bfn;
}

#define mfn_to_local_pfn(mfn) mfn_to_pfn(mfn)
#define bfn_to_local_pfn(bfn) bfn_to_pfn(bfn)

/* VIRT <-> MACHINE conversion */
#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
/* VIRT <-> GUEST conversion */
#define virt_to_gfn(v) (pfn_to_gfn(virt_to_pfn(v)))
#define gfn_to_virt(m) (__va(gfn_to_pfn(m) << PAGE_SHIFT))

/* Only used in PV code. But ARM guests are always HVM. */
static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
Expand Down Expand Up @@ -96,7 +108,7 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)

bool xen_arch_need_swiotlb(struct device *dev,
unsigned long pfn,
unsigned long mfn);
unsigned long bfn);
unsigned long xen_get_swiotlb_free_pages(unsigned int order);

#endif /* _ASM_ARM_XEN_PAGE_H */
18 changes: 9 additions & 9 deletions arch/arm/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ static __read_mostly unsigned int xen_events_irq;

static __initdata struct device_node *xen_node;

int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
unsigned long addr,
xen_pfn_t *mfn, int nr,
xen_pfn_t *gfn, int nr,
int *err_ptr, pgprot_t prot,
unsigned domid,
struct page **pages)
{
return xen_xlate_remap_gfn_array(vma, addr, mfn, nr, err_ptr,
return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr,
prot, domid, pages);
}
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_array);
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);

/* Not used by XENFEAT_auto_translated guests. */
int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
unsigned long addr,
xen_pfn_t mfn, int nr,
xen_pfn_t gfn, int nr,
pgprot_t prot, unsigned domid,
struct page **pages)
{
return -ENOSYS;
}
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);

int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
int nr, struct page **pages)
{
return xen_xlate_unmap_gfn_range(vma, nr, pages);
}
EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range);

static void xen_percpu_init(void)
{
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/xen/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ void __xen_dma_sync_single_for_device(struct device *hwdev,

bool xen_arch_need_swiotlb(struct device *dev,
unsigned long pfn,
unsigned long mfn)
unsigned long bfn)
{
return (!hypercall_cflush && (pfn != mfn) && !is_device_dma_coherent(dev));
return (!hypercall_cflush && (pfn != bfn) && !is_device_dma_coherent(dev));
}

int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
Expand Down
39 changes: 37 additions & 2 deletions arch/x86/include/asm/xen/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
{
unsigned long mfn;

/*
* Some x86 code are still using pfn_to_mfn instead of
* pfn_to_mfn. This will have to be removed when we figured
* out which call.
*/
if (xen_feature(XENFEAT_auto_translated_physmap))
return pfn;

Expand Down Expand Up @@ -147,6 +152,11 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
{
unsigned long pfn;

/*
* Some x86 code are still using mfn_to_pfn instead of
* gfn_to_pfn. This will have to be removed when we figure
* out which call.
*/
if (xen_feature(XENFEAT_auto_translated_physmap))
return mfn;

Expand Down Expand Up @@ -176,6 +186,27 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
}

/* Pseudo-physical <-> Guest conversion */
static inline unsigned long pfn_to_gfn(unsigned long pfn)
{
if (xen_feature(XENFEAT_auto_translated_physmap))
return pfn;
else
return pfn_to_mfn(pfn);
}

static inline unsigned long gfn_to_pfn(unsigned long gfn)
{
if (xen_feature(XENFEAT_auto_translated_physmap))
return gfn;
else
return mfn_to_pfn(gfn);
}

/* Pseudo-physical <-> Bus conversion */
#define pfn_to_bfn(pfn) pfn_to_gfn(pfn)
#define bfn_to_pfn(bfn) gfn_to_pfn(bfn)

/*
* We detect special mappings in one of two ways:
* 1. If the MFN is an I/O page then Xen will set the m2p entry
Expand All @@ -196,7 +227,7 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine)
* require. In all the cases we care about, the FOREIGN_FRAME bit is
* masked (e.g., pfn_to_mfn()) so behaviour there is correct.
*/
static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
static inline unsigned long bfn_to_local_pfn(unsigned long mfn)
{
unsigned long pfn;

Expand All @@ -215,6 +246,10 @@ static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))

/* VIRT <-> GUEST conversion */
#define virt_to_gfn(v) (pfn_to_gfn(virt_to_pfn(v)))
#define gfn_to_virt(g) (__va(gfn_to_pfn(g) << PAGE_SHIFT))

static inline unsigned long pte_mfn(pte_t pte)
{
return (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT;
Expand Down Expand Up @@ -262,7 +297,7 @@ void make_lowmem_page_readwrite(void *vaddr);

static inline bool xen_arch_need_swiotlb(struct device *dev,
unsigned long pfn,
unsigned long mfn)
unsigned long bfn)
{
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions arch/x86/xen/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2812,9 +2812,9 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
return 0;
}

static int do_remap_mfn(struct vm_area_struct *vma,
static int do_remap_gfn(struct vm_area_struct *vma,
unsigned long addr,
xen_pfn_t *mfn, int nr,
xen_pfn_t *gfn, int nr,
int *err_ptr, pgprot_t prot,
unsigned domid,
struct page **pages)
Expand All @@ -2830,14 +2830,14 @@ static int do_remap_mfn(struct vm_area_struct *vma,
if (xen_feature(XENFEAT_auto_translated_physmap)) {
#ifdef CONFIG_XEN_PVH
/* We need to update the local page tables and the xen HAP */
return xen_xlate_remap_gfn_array(vma, addr, mfn, nr, err_ptr,
return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr,
prot, domid, pages);
#else
return -EINVAL;
#endif
}

rmd.mfn = mfn;
rmd.mfn = gfn;
rmd.prot = prot;
/* We use the err_ptr to indicate if there we are doing a contigious
* mapping or a discontigious mapping. */
Expand Down Expand Up @@ -2865,8 +2865,8 @@ static int do_remap_mfn(struct vm_area_struct *vma,
batch_left, &done, domid);

/*
* @err_ptr may be the same buffer as @mfn, so
* only clear it after each chunk of @mfn is
* @err_ptr may be the same buffer as @gfn, so
* only clear it after each chunk of @gfn is
* used.
*/
if (err_ptr) {
Expand Down Expand Up @@ -2896,19 +2896,19 @@ static int do_remap_mfn(struct vm_area_struct *vma,
return err < 0 ? err : mapped;
}

int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
unsigned long addr,
xen_pfn_t mfn, int nr,
xen_pfn_t gfn, int nr,
pgprot_t prot, unsigned domid,
struct page **pages)
{
return do_remap_mfn(vma, addr, &mfn, nr, NULL, prot, domid, pages);
return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages);
}
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);

int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
unsigned long addr,
xen_pfn_t *mfn, int nr,
xen_pfn_t *gfn, int nr,
int *err_ptr, pgprot_t prot,
unsigned domid, struct page **pages)
{
Expand All @@ -2917,13 +2917,13 @@ int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
* cause of "wrong memory was mapped in".
*/
BUG_ON(err_ptr == NULL);
return do_remap_mfn(vma, addr, mfn, nr, err_ptr, prot, domid, pages);
return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid, pages);
}
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_array);
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);


/* Returns: 0 success */
int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
int numpgs, struct page **pages)
{
if (!pages || !xen_feature(XENFEAT_auto_translated_physmap))
Expand All @@ -2935,4 +2935,4 @@ int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
return -EINVAL;
#endif
}
EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range);
2 changes: 1 addition & 1 deletion arch/x86/xen/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
}
#endif
ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir));
ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_gfn(swapper_pg_dir));
if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt))
BUG();

Expand Down
6 changes: 3 additions & 3 deletions drivers/block/xen-blkfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static struct grant *get_grant(grant_ref_t *gref_head,
struct blkfront_info *info)
{
struct grant *gnt_list_entry;
unsigned long buffer_mfn;
unsigned long buffer_gfn;

BUG_ON(list_empty(&info->grants));
gnt_list_entry = list_first_entry(&info->grants, struct grant,
Expand All @@ -268,10 +268,10 @@ static struct grant *get_grant(grant_ref_t *gref_head,
BUG_ON(!pfn);
gnt_list_entry->pfn = pfn;
}
buffer_mfn = pfn_to_mfn(gnt_list_entry->pfn);
buffer_gfn = pfn_to_gfn(gnt_list_entry->pfn);
gnttab_grant_foreign_access_ref(gnt_list_entry->gref,
info->xbdev->otherend_id,
buffer_mfn, 0);
buffer_gfn, 0);
return gnt_list_entry;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/input/misc/xen-kbdfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
struct xenbus_transaction xbt;

ret = gnttab_grant_foreign_access(dev->otherend_id,
virt_to_mfn(info->page), 0);
virt_to_gfn(info->page), 0);
if (ret < 0)
return ret;
info->gref = ret;
Expand All @@ -255,7 +255,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev,
goto error_irqh;
}
ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu",
virt_to_mfn(info->page));
virt_to_gfn(info->page));
if (ret)
goto error_xenbus;
ret = xenbus_printf(xbt, dev->nodename, "page-gref", "%u", info->gref);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/xen-netback/netback.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff *skb
} else {
copy_gop->source.domid = DOMID_SELF;
copy_gop->source.u.gmfn =
virt_to_mfn(page_address(page));
virt_to_gfn(page_address(page));
}
copy_gop->source.offset = offset;

Expand Down Expand Up @@ -1406,7 +1406,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
queue->tx_copy_ops[*copy_ops].source.offset = txreq.offset;

queue->tx_copy_ops[*copy_ops].dest.u.gmfn =
virt_to_mfn(skb->data);
virt_to_gfn(skb->data);
queue->tx_copy_ops[*copy_ops].dest.domid = DOMID_SELF;
queue->tx_copy_ops[*copy_ops].dest.offset =
offset_in_page(skb->data);
Expand Down
12 changes: 7 additions & 5 deletions drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
struct sk_buff *skb;
unsigned short id;
grant_ref_t ref;
unsigned long pfn;
unsigned long gfn;
struct xen_netif_rx_request *req;

skb = xennet_alloc_one_rx_buffer(queue);
Expand All @@ -307,12 +307,12 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
BUG_ON((signed short)ref < 0);
queue->grant_rx_ref[id] = ref;

pfn = page_to_pfn(skb_frag_page(&skb_shinfo(skb)->frags[0]));
gfn = xen_page_to_gfn(skb_frag_page(&skb_shinfo(skb)->frags[0]));

req = RING_GET_REQUEST(&queue->rx, req_prod);
gnttab_grant_foreign_access_ref(ref,
queue->info->xbdev->otherend_id,
pfn_to_mfn(pfn),
gfn,
0);

req->id = id;
Expand Down Expand Up @@ -430,8 +430,10 @@ static struct xen_netif_tx_request *xennet_make_one_txreq(
ref = gnttab_claim_grant_reference(&queue->gref_tx_head);
BUG_ON((signed short)ref < 0);

gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id,
page_to_mfn(page), GNTMAP_readonly);
gnttab_grant_foreign_access_ref(ref,
queue->info->xbdev->otherend_id,
xen_page_to_gfn(page),
GNTMAP_readonly);

queue->tx_skbs[id].skb = skb;
queue->grant_tx_page[id] = page;
Expand Down
Loading

0 comments on commit 06ab838

Please sign in to comment.