* [PATCH] tools/libxc: rename pfn_to_mfn to xc_pfn_to_mfn
@ 2014-06-18 12:57 Andrew Cooper
2014-06-18 16:04 ` Ian Campbell
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2014-06-18 12:57 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Ian Jackson, Ian Campbell
Also refactor the contents of xc_pfn_to_mfn(). It is functionally identical,
but contains less lisp, fewer magic numbers, and more description of why 32bit
guests are treated differently.
Note that this does not affect pfn_to_mfn() in xc_domain_save.c That was
already a macro which aliased pfn_to_mfn() in xg_private.h but without
actually using it.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxc/xc_domain.c | 4 ++--
tools/libxc/xc_offline_page.c | 4 ++--
tools/libxc/xg_private.h | 18 ++++++++++++------
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 26edbaf..ef470a5 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1879,8 +1879,8 @@ int xc_map_domain_meminfo(xc_interface *xch, int domid,
goto failed;
}
for ( i = 0; i < minfo->p2m_size; i++ )
- minfo->pfn_type[i] = pfn_to_mfn(i, minfo->p2m_table,
- minfo->guest_width);
+ minfo->pfn_type[i] = xc_pfn_to_mfn(i, minfo->p2m_table,
+ minfo->guest_width);
/* Retrieve PFN types in batches */
for ( i = 0; i < minfo->p2m_size ; i+=1024 )
diff --git a/tools/libxc/xc_offline_page.c b/tools/libxc/xc_offline_page.c
index 0b4cdf9..3147203 100644
--- a/tools/libxc/xc_offline_page.c
+++ b/tools/libxc/xc_offline_page.c
@@ -272,8 +272,8 @@ static int change_pte(xc_interface *xch, int domid,
for (i = 0; i < minfo->p2m_size; i++)
{
- xen_pfn_t table_mfn = pfn_to_mfn(i, minfo->p2m_table,
- minfo->guest_width);
+ xen_pfn_t table_mfn = xc_pfn_to_mfn(i, minfo->p2m_table,
+ minfo->guest_width);
uint64_t pte, new_pte;
int j;
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index f5755fd..e593364 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -132,13 +132,19 @@ struct domain_info_context {
unsigned long p2m_size;
};
-static inline xen_pfn_t pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m, int gwidth)
+static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m,
+ unsigned gwidth)
{
- return ((xen_pfn_t) ((gwidth==8)?
- (((uint64_t *)p2m)[(pfn)]):
- ((((uint32_t *)p2m)[(pfn)]) == 0xffffffffU ?
- (-1UL) :
- (((uint32_t *)p2m)[(pfn)]))));
+ if ( gwidth == sizeof(uint64_t) )
+ /* 64 bit guest. Need to truncate their pfns for 32 bit toolstacks. */
+ return ((uint64_t *)p2m)[pfn];
+ else
+ {
+ /* 32 bit guest. Need to expand INVALID_MFN for 64 bit toolstacks. */
+ uint32_t mfn = ((uint32_t *)p2m)[pfn];
+
+ return mfn == ~0U ? INVALID_MFN : mfn;
+ }
}
/* Number of xen_pfn_t in a page */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/libxc: rename pfn_to_mfn to xc_pfn_to_mfn
2014-06-18 12:57 [PATCH] tools/libxc: rename pfn_to_mfn to xc_pfn_to_mfn Andrew Cooper
@ 2014-06-18 16:04 ` Ian Campbell
0 siblings, 0 replies; 2+ messages in thread
From: Ian Campbell @ 2014-06-18 16:04 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Ian Jackson, Xen-devel
On Wed, 2014-06-18 at 13:57 +0100, Andrew Cooper wrote:
> It is functionally identical,
... if you say so...
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked + applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-18 16:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 12:57 [PATCH] tools/libxc: rename pfn_to_mfn to xc_pfn_to_mfn Andrew Cooper
2014-06-18 16:04 ` Ian Campbell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.