* [PATCH 1/2] libxc: replace INVALID_P2M_ENTRY by INVALID_PFN
2015-12-01 17:14 [PATCH 0/2] libxc: domain builder related enhancements Juergen Gross
@ 2015-12-01 17:14 ` Juergen Gross
2015-12-02 11:46 ` Wei Liu
2015-12-01 17:14 ` [PATCH 2/2] libxc: do proper return code checking of allocator in domain builder Juergen Gross
2015-12-02 15:52 ` [PATCH 0/2] libxc: domain builder related enhancements Ian Campbell
2 siblings, 1 reply; 6+ messages in thread
From: Juergen Gross @ 2015-12-01 17:14 UTC (permalink / raw)
To: xen-devel, Ian.Campbell, ian.jackson, stefano.stabellini,
wei.liu2
Cc: Juergen Gross
INVALID_P2M_ENTRY is defined as (xen_pfn_t)-1 and is often used
according to it's type for an invalid pfn. Change the name of the
macro to INVALID_PFN.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/libxc/include/xc_dom.h | 2 +-
tools/libxc/xc_compression.c | 10 +++++-----
tools/libxc/xc_core.c | 4 ++--
tools/libxc/xc_dom_arm.c | 2 +-
tools/libxc/xc_dom_core.c | 4 ++--
tools/libxc/xc_dom_x86.c | 2 +-
tools/libxc/xc_offline_page.c | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index 43a65ee..3c94b57 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -19,7 +19,7 @@
#include <xen/libelf/libelf.h>
#include <xenguest.h>
-#define INVALID_P2M_ENTRY ((xen_pfn_t)-1)
+#define INVALID_PFN ((xen_pfn_t)-1)
/* --- typedefs and structs ---------------------------------------- */
diff --git a/tools/libxc/xc_compression.c b/tools/libxc/xc_compression.c
index b1b16e8..89c1114 100644
--- a/tools/libxc/xc_compression.c
+++ b/tools/libxc/xc_compression.c
@@ -217,7 +217,7 @@ char *get_cache_page(comp_ctx *ctx, xen_pfn_t pfn,
/* If the list is full, evict a page from the tail end. */
item = ctx->page_list_tail;
- if (item->pfn != INVALID_P2M_ENTRY)
+ if (item->pfn != INVALID_PFN)
ctx->pfn2cache[item->pfn] = NULL;
item->pfn = pfn;
@@ -278,7 +278,7 @@ void invalidate_cache_page(comp_ctx *ctx, xen_pfn_t pfn)
ctx->page_list_tail = item;
}
ctx->pfn2cache[pfn] = NULL;
- (ctx->page_list_tail)->pfn = INVALID_P2M_ENTRY;
+ (ctx->page_list_tail)->pfn = INVALID_PFN;
}
}
@@ -295,7 +295,7 @@ int xc_compression_add_page(xc_interface *xch, comp_ctx *ctx,
/* pagetable page */
if (israw)
invalidate_cache_page(ctx, pfn);
- ctx->sendbuf_pfns[ctx->pfns_len] = israw ? INVALID_P2M_ENTRY : pfn;
+ ctx->sendbuf_pfns[ctx->pfns_len] = israw ? INVALID_PFN : pfn;
memcpy(ctx->inputbuf + ctx->pfns_len * XC_PAGE_SIZE, page, XC_PAGE_SIZE);
ctx->pfns_len++;
@@ -329,7 +329,7 @@ int xc_compression_compress_pages(xc_interface *xch, comp_ctx *ctx,
cache_copy = NULL;
current_page = ctx->inputbuf + ctx->pfns_index * XC_PAGE_SIZE;
- if (ctx->sendbuf_pfns[ctx->pfns_index] == INVALID_P2M_ENTRY)
+ if (ctx->sendbuf_pfns[ctx->pfns_index] == INVALID_PFN)
israw = 1;
else
cache_copy = get_cache_page(ctx,
@@ -518,7 +518,7 @@ comp_ctx *xc_compression_create_context(xc_interface *xch,
for (i = 0; i < num_cache_pages; i++)
{
- ctx->cache[i].pfn = INVALID_P2M_ENTRY;
+ ctx->cache[i].pfn = INVALID_PFN;
ctx->cache[i].page = ctx->cache_base + i * XC_PAGE_SIZE;
ctx->cache[i].prev = (i == 0) ? NULL : &(ctx->cache[i - 1]);
ctx->cache[i].next = ((i+1) == num_cache_pages)? NULL :
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
index 011336c..d792566 100644
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -808,13 +808,13 @@ xc_domain_dumpcore_via_callback(xc_interface *xch,
gmfn = p2m[i];
else
gmfn = ((uint64_t *)p2m)[i];
- if ( gmfn == INVALID_P2M_ENTRY )
+ if ( gmfn == INVALID_PFN )
continue;
}
else
{
gmfn = ((uint32_t *)p2m)[i];
- if ( gmfn == (uint32_t)INVALID_P2M_ENTRY )
+ if ( gmfn == (uint32_t)INVALID_PFN )
continue;
}
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index d9a6371..64a8b67 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -439,7 +439,7 @@ static int meminit(struct xc_dom_image *dom)
if ( dom->p2m_host == NULL )
return -EINVAL;
for ( pfn = 0; pfn < p2m_size; pfn++ )
- dom->p2m_host[pfn] = INVALID_P2M_ENTRY;
+ dom->p2m_host[pfn] = INVALID_PFN;
/* setup initial p2m and allocate guest memory */
for ( i = 0; i < GUEST_RAM_BANKS && dom->rambank_size[i]; i++ )
diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index 8967970..d0c6596 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -971,7 +971,7 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom)
__FUNCTION__, dom->p2m_size);
p2m_32 = dom->p2m_guest;
for ( i = 0; i < dom->p2m_size; i++ )
- if ( dom->p2m_host[i] != INVALID_P2M_ENTRY )
+ if ( dom->p2m_host[i] != INVALID_PFN )
p2m_32[i] = dom->p2m_host[i];
else
p2m_32[i] = (uint32_t) - 1;
@@ -981,7 +981,7 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom)
__FUNCTION__, dom->p2m_size);
p2m_64 = dom->p2m_guest;
for ( i = 0; i < dom->p2m_size; i++ )
- if ( dom->p2m_host[i] != INVALID_P2M_ENTRY )
+ if ( dom->p2m_host[i] != INVALID_PFN )
p2m_64[i] = dom->p2m_host[i];
else
p2m_64[i] = (uint64_t) - 1;
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 5ff33ca..7c77e69 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -1172,7 +1172,7 @@ static int meminit_pv(struct xc_dom_image *dom)
if ( dom->p2m_host == NULL )
return -EINVAL;
for ( pfn = 0; pfn < dom->p2m_size; pfn++ )
- dom->p2m_host[pfn] = INVALID_P2M_ENTRY;
+ dom->p2m_host[pfn] = INVALID_PFN;
/* allocate guest memory */
for ( i = 0; i < nr_vmemranges; i++ )
diff --git a/tools/libxc/xc_offline_page.c b/tools/libxc/xc_offline_page.c
index 7bb522f..bc91d51 100644
--- a/tools/libxc/xc_offline_page.c
+++ b/tools/libxc/xc_offline_page.c
@@ -282,7 +282,7 @@ static int change_pte(xc_interface *xch, int domid,
uint64_t pte, new_pte;
int j;
- if ( (table_mfn == INVALID_P2M_ENTRY) ||
+ if ( (table_mfn == INVALID_PFN) ||
((minfo->pfn_type[i] & XEN_DOMCTL_PFINFO_LTAB_MASK) ==
XEN_DOMCTL_PFINFO_XTAB) )
continue;
--
2.6.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] libxc: do proper return code checking of allocator in domain builder
2015-12-01 17:14 [PATCH 0/2] libxc: domain builder related enhancements Juergen Gross
2015-12-01 17:14 ` [PATCH 1/2] libxc: replace INVALID_P2M_ENTRY by INVALID_PFN Juergen Gross
@ 2015-12-01 17:14 ` Juergen Gross
2015-12-02 11:46 ` Wei Liu
2015-12-02 15:52 ` [PATCH 0/2] libxc: domain builder related enhancements Ian Campbell
2 siblings, 1 reply; 6+ messages in thread
From: Juergen Gross @ 2015-12-01 17:14 UTC (permalink / raw)
To: xen-devel, Ian.Campbell, ian.jackson, stefano.stabellini,
wei.liu2
Cc: Juergen Gross
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/libxc/xc_dom_core.c | 7 ++++++-
tools/libxc/xc_dom_x86.c | 10 ++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index d0c6596..841e7dc 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -630,7 +630,7 @@ xen_pfn_t xc_dom_alloc_page(struct xc_dom_image *dom, char *name)
pfn = dom->pfn_alloc_end - dom->rambase_pfn;
if ( xc_dom_chk_alloc_pages(dom, name, 1) )
- return (xen_pfn_t)-1;
+ return INVALID_PFN;
DOMPRINTF("%-20s: %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")",
__FUNCTION__, name, start, pfn);
@@ -1107,7 +1107,12 @@ int xc_dom_build_image(struct xc_dom_image *dom)
if ( dom->arch_hooks->alloc_pgtables(dom) != 0 )
goto err;
if ( dom->alloc_bootstack )
+ {
dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack");
+ if ( dom->bootstack_pfn == INVALID_PFN )
+ goto err;
+ }
+
DOMPRINTF("%-20s: virt_alloc_end : 0x%" PRIx64 "",
__FUNCTION__, dom->virt_alloc_end);
DOMPRINTF("%-20s: virt_pgtab_end : 0x%" PRIx64 "",
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 7c77e69..71b042e 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -537,10 +537,20 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
{
/* allocate special pages */
dom->start_info_pfn = xc_dom_alloc_page(dom, "start info");
+ if ( dom->start_info_pfn == INVALID_PFN )
+ return -1;
dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore");
+ if ( dom->xenstore_pfn == INVALID_PFN )
+ return -1;
dom->console_pfn = xc_dom_alloc_page(dom, "console");
+ if ( dom->console_pfn == INVALID_PFN )
+ return -1;
if ( xc_dom_feature_translated(dom) )
+ {
dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info");
+ if ( dom->shared_info_pfn == INVALID_PFN )
+ return -1;
+ }
dom->alloc_bootstack = 1;
return 0;
--
2.6.2
^ permalink raw reply related [flat|nested] 6+ messages in thread