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>
这个提交包含在:
@@ -441,7 +441,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
|
||||
/* Update direct mapping, invalidate P2M, and add to balloon. */
|
||||
for (i = 0; i < nr_pages; i++) {
|
||||
pfn = frame_list[i];
|
||||
frame_list[i] = pfn_to_mfn(pfn);
|
||||
frame_list[i] = pfn_to_gfn(pfn);
|
||||
page = pfn_to_page(pfn);
|
||||
|
||||
#ifdef CONFIG_XEN_HAVE_PVMMU
|
||||
|
@@ -1688,7 +1688,7 @@ void __init xen_init_IRQ(void)
|
||||
struct physdev_pirq_eoi_gmfn eoi_gmfn;
|
||||
|
||||
pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
|
||||
eoi_gmfn.gmfn = virt_to_mfn(pirq_eoi_map);
|
||||
eoi_gmfn.gmfn = virt_to_gfn(pirq_eoi_map);
|
||||
rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
|
||||
/* TODO: No PVH support for PIRQ EOI */
|
||||
if (rc != 0) {
|
||||
|
@@ -111,7 +111,7 @@ static int init_control_block(int cpu,
|
||||
for (i = 0; i < EVTCHN_FIFO_MAX_QUEUES; i++)
|
||||
q->head[i] = 0;
|
||||
|
||||
init_control.control_gfn = virt_to_mfn(control_block);
|
||||
init_control.control_gfn = virt_to_gfn(control_block);
|
||||
init_control.offset = 0;
|
||||
init_control.vcpu = cpu;
|
||||
|
||||
@@ -167,7 +167,7 @@ static int evtchn_fifo_setup(struct irq_info *info)
|
||||
/* Mask all events in this page before adding it. */
|
||||
init_array_page(array_page);
|
||||
|
||||
expand_array.array_gfn = virt_to_mfn(array_page);
|
||||
expand_array.array_gfn = virt_to_gfn(array_page);
|
||||
|
||||
ret = HYPERVISOR_event_channel_op(EVTCHNOP_expand_array, &expand_array);
|
||||
if (ret < 0)
|
||||
|
@@ -142,7 +142,8 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
|
||||
|
||||
/* Grant foreign access to the page. */
|
||||
rc = gnttab_grant_foreign_access(op->domid,
|
||||
pfn_to_mfn(page_to_pfn(gref->page)), readonly);
|
||||
xen_page_to_gfn(gref->page),
|
||||
readonly);
|
||||
if (rc < 0)
|
||||
goto undo;
|
||||
gref_ids[i] = gref->gref_id = rc;
|
||||
|
@@ -80,7 +80,7 @@ static int xen_suspend(void *data)
|
||||
* is resuming in a new domain.
|
||||
*/
|
||||
si->cancelled = HYPERVISOR_suspend(xen_pv_domain()
|
||||
? virt_to_mfn(xen_start_info)
|
||||
? virt_to_gfn(xen_start_info)
|
||||
: 0);
|
||||
|
||||
xen_arch_post_suspend(si->cancelled);
|
||||
|
@@ -131,7 +131,7 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid,
|
||||
static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid,
|
||||
u32 index, unsigned long pfn)
|
||||
{
|
||||
unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn;
|
||||
unsigned long gmfn = pfn_to_gfn(pfn);
|
||||
|
||||
return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index,
|
||||
gmfn, 0, 0, 0);
|
||||
@@ -140,7 +140,7 @@ static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid,
|
||||
static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid,
|
||||
u32 index, unsigned long pfn)
|
||||
{
|
||||
unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn;
|
||||
unsigned long gmfn = pfn_to_gfn(pfn);
|
||||
|
||||
return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index,
|
||||
gmfn, 0, 0, 0);
|
||||
|
@@ -380,7 +380,7 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
|
||||
|
||||
for (i = 0; i < nr_pages; i++) {
|
||||
err = gnttab_grant_foreign_access(dev->otherend_id,
|
||||
virt_to_mfn(vaddr), 0);
|
||||
virt_to_gfn(vaddr), 0);
|
||||
if (err < 0) {
|
||||
xenbus_dev_fatal(dev, err,
|
||||
"granting access to ring page");
|
||||
|
@@ -49,7 +49,7 @@ static long xenbus_alloc(domid_t domid)
|
||||
goto out_err;
|
||||
|
||||
gnttab_grant_foreign_access_ref(GNTTAB_RESERVED_XENSTORE, domid,
|
||||
virt_to_mfn(xen_store_interface), 0 /* writable */);
|
||||
virt_to_gfn(xen_store_interface), 0 /* writable */);
|
||||
|
||||
arg.dom = DOMID_SELF;
|
||||
arg.remote_dom = domid;
|
||||
|
@@ -711,9 +711,7 @@ static int __init xenstored_local_init(void)
|
||||
if (!page)
|
||||
goto out_err;
|
||||
|
||||
xen_store_mfn = xen_start_info->store_mfn =
|
||||
pfn_to_mfn(virt_to_phys((void *)page) >>
|
||||
PAGE_SHIFT);
|
||||
xen_store_mfn = xen_start_info->store_mfn = virt_to_gfn((void *)page);
|
||||
|
||||
/* Next allocate a local port which xenstored can bind to */
|
||||
alloc_unbound.dom = DOMID_SELF;
|
||||
@@ -787,12 +785,12 @@ static int __init xenbus_init(void)
|
||||
err = xenstored_local_init();
|
||||
if (err)
|
||||
goto out_error;
|
||||
xen_store_interface = mfn_to_virt(xen_store_mfn);
|
||||
xen_store_interface = gfn_to_virt(xen_store_mfn);
|
||||
break;
|
||||
case XS_PV:
|
||||
xen_store_evtchn = xen_start_info->store_evtchn;
|
||||
xen_store_mfn = xen_start_info->store_mfn;
|
||||
xen_store_interface = mfn_to_virt(xen_store_mfn);
|
||||
xen_store_interface = gfn_to_virt(xen_store_mfn);
|
||||
break;
|
||||
case XS_HVM:
|
||||
err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
|
||||
|
在新工单中引用
屏蔽一个用户