|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] xen/x86: Use mfn_to_gfn rather than mfn_to_gmfn
commit 87c12c7ec366118f02a6b6fa736fdb3af7a96d2f
Author: Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Sat Jan 26 15:58:48 2019 +0000
Commit: Julien Grall <julien.grall@xxxxxxx>
CommitDate: Mon Aug 19 15:09:19 2019 +0100
xen/x86: Use mfn_to_gfn rather than mfn_to_gmfn
mfn_to_gfn and mfn_to_gmfn are doing exactly the same except the former
is using mfn_t and gfn_t (return type).
Furthermore, the naming of the former is more consistent with the
current naming scheme (GFN/MFN). So replace mfn_to_gmfn with
mfn_to_gfn in x86 code.
Take the opportunity to convert some of the callers to use typesafe GFN and
format the message correctly.
No functional changes.
Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
--
Changes in v3:
- The hunk in x86/mm.c is not necessary anymore
- Update printk message to use GFN rather than frame when suitable
- Update commit message with some NITs
- Add Jan's reviewed-by
Changes in v2:
- mfn_to_gfn now returns a gfn_t
- Use %pd and PRI_gfn when possible in the message
- Don't split format string to help grep/ack.
---
xen/arch/x86/domain.c | 34 +++++++++++++++++++---------------
xen/arch/x86/pv/emul-priv-op.c | 4 ++--
xen/drivers/passthrough/x86/iommu.c | 16 +++++++++-------
3 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 9a6eb89ddc..bdaf16cd14 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -699,7 +699,7 @@ int arch_domain_soft_reset(struct domain *d)
int ret = 0;
struct domain *owner;
mfn_t mfn;
- unsigned long gfn;
+ gfn_t gfn;
p2m_type_t p2mt;
unsigned int i;
@@ -733,19 +733,20 @@ int arch_domain_soft_reset(struct domain *d)
ASSERT( owner == d );
mfn = page_to_mfn(page);
- gfn = mfn_to_gmfn(d, mfn_x(mfn));
+ gfn = mfn_to_gfn(d, mfn);
/*
* gfn == INVALID_GFN indicates that the shared_info page was never mapped
* to the domain's address space and there is nothing to replace.
*/
- if ( gfn == gfn_x(INVALID_GFN) )
+ if ( gfn_eq(gfn, INVALID_GFN) )
goto exit_put_page;
- if ( !mfn_eq(get_gfn_query(d, gfn, &p2mt), mfn) )
+ if ( !mfn_eq(get_gfn_query(d, gfn_x(gfn), &p2mt), mfn) )
{
- printk(XENLOG_G_ERR "Failed to get Dom%d's shared_info GFN (%lx)\n",
- d->domain_id, gfn);
+ printk(XENLOG_G_ERR
+ "Failed to get %pd's shared_info GFN (%"PRI_gfn")\n",
+ d, gfn_x(gfn));
ret = -EINVAL;
goto exit_put_gfn;
}
@@ -753,31 +754,34 @@ int arch_domain_soft_reset(struct domain *d)
new_page = alloc_domheap_page(d, 0);
if ( !new_page )
{
- printk(XENLOG_G_ERR "Failed to alloc a page to replace"
- " Dom%d's shared_info frame %lx\n", d->domain_id, gfn);
+ printk(XENLOG_G_ERR
+ "Failed to alloc a page to replace %pd's shared_info GFN
%"PRI_gfn"\n",
+ d, gfn_x(gfn));
ret = -ENOMEM;
goto exit_put_gfn;
}
- ret = guest_physmap_remove_page(d, _gfn(gfn), mfn, PAGE_ORDER_4K);
+ ret = guest_physmap_remove_page(d, gfn, mfn, PAGE_ORDER_4K);
if ( ret )
{
- printk(XENLOG_G_ERR "Failed to remove Dom%d's shared_info frame %lx\n",
- d->domain_id, gfn);
+ printk(XENLOG_G_ERR
+ "Failed to remove %pd's shared_info GFN %"PRI_gfn"\n",
+ d, gfn_x(gfn));
free_domheap_page(new_page);
goto exit_put_gfn;
}
- ret = guest_physmap_add_page(d, _gfn(gfn), page_to_mfn(new_page),
+ ret = guest_physmap_add_page(d, gfn, page_to_mfn(new_page),
PAGE_ORDER_4K);
if ( ret )
{
- printk(XENLOG_G_ERR "Failed to add a page to replace"
- " Dom%d's shared_info frame %lx\n", d->domain_id, gfn);
+ printk(XENLOG_G_ERR
+ "Failed to add a page to replace %pd's shared_info frame
%"PRI_gfn"\n",
+ d, gfn_x(gfn));
free_domheap_page(new_page);
}
exit_put_gfn:
- put_gfn(d, gfn);
+ put_gfn(d, gfn_x(gfn));
exit_put_page:
put_page(page);
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index ba63315306..8a4909bf4c 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -712,7 +712,7 @@ static int read_cr(unsigned int reg, unsigned long *val,
if ( !is_pv_32bit_domain(currd) )
{
mfn = pagetable_get_mfn(curr->arch.guest_table);
- *val = xen_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn)));
+ *val = xen_pfn_to_cr3(gfn_x(mfn_to_gfn(currd, mfn)));
}
else
{
@@ -721,7 +721,7 @@ static int read_cr(unsigned int reg, unsigned long *val,
mfn = l4e_get_mfn(*pl4e);
unmap_domain_page(pl4e);
- *val = compat_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn)));
+ *val = compat_pfn_to_cr3(gfn_x(mfn_to_gfn(currd, mfn)));
}
return X86EMUL_OKAY;
diff --git a/xen/drivers/passthrough/x86/iommu.c
b/xen/drivers/passthrough/x86/iommu.c
index fd05075bb5..92c1d01edf 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -96,15 +96,17 @@ int arch_iommu_populate_page_table(struct domain *d)
if ( is_hvm_domain(d) ||
(page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page )
{
- unsigned long mfn = mfn_x(page_to_mfn(page));
- unsigned long gfn = mfn_to_gmfn(d, mfn);
+ mfn_t mfn = page_to_mfn(page);
+ gfn_t gfn = mfn_to_gfn(d, mfn);
unsigned int flush_flags = 0;
- if ( gfn != gfn_x(INVALID_GFN) )
+ if ( !gfn_eq(gfn, INVALID_GFN) )
{
- ASSERT(!(gfn >> DEFAULT_DOMAIN_ADDRESS_WIDTH));
- BUG_ON(SHARED_M2P(gfn));
- rc = iommu_map(d, _dfn(gfn), _mfn(mfn), PAGE_ORDER_4K,
+ dfn_t dfn = _dfn(gfn_x(gfn));
+
+ ASSERT(!(gfn_x(gfn) >> DEFAULT_DOMAIN_ADDRESS_WIDTH));
+ BUG_ON(SHARED_M2P(gfn_x(gfn)));
+ rc = iommu_map(d, dfn, mfn, PAGE_ORDER_4K,
IOMMUF_readable | IOMMUF_writable,
&flush_flags);
@@ -122,7 +124,7 @@ int arch_iommu_populate_page_table(struct domain *d)
((page->u.inuse.type_info & PGT_type_mask) !=
PGT_writable_page) )
{
- rc = iommu_unmap(d, _dfn(gfn), PAGE_ORDER_4K,
&flush_flags);
+ rc = iommu_unmap(d, dfn, PAGE_ORDER_4K, &flush_flags);
/* If the type changed yet again, simply force a retry. */
if ( !rc && ((page->u.inuse.type_info & PGT_type_mask) ==
PGT_writable_page) )
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |