aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2007-09-06 15:32:54 -0600
committerAlex Williamson <alex.williamson@hp.com>2007-09-06 15:32:54 -0600
commit254e1c190243a8db25288ed67fd59d47b7b30d9e (patch)
treebf4b6f4792dec9961f02e2841bffaeb6afe802ba /tools
parent29581d5ed30fde59ed8094c76be34acaeb4e0caa (diff)
downloadxen-254e1c190243a8db25288ed67fd59d47b7b30d9e.tar.gz
xen-254e1c190243a8db25288ed67fd59d47b7b30d9e.tar.bz2
xen-254e1c190243a8db25288ed67fd59d47b7b30d9e.zip
[IA64] Foreign p2m: xc_core: ia64 xc_core_arch_gpfn_may_present()
Prevent warning message when xm dump-core Using foreign p2m exposure, we can avoid to map the page which isn't allocated. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxc/xc_core_ia64.c70
-rw-r--r--tools/libxc/xc_core_ia64.h9
2 files changed, 64 insertions, 15 deletions
diff --git a/tools/libxc/xc_core_ia64.c b/tools/libxc/xc_core_ia64.c
index e092d6f69f..443578a0a8 100644
--- a/tools/libxc/xc_core_ia64.c
+++ b/tools/libxc/xc_core_ia64.c
@@ -24,6 +24,16 @@
#include "xc_dom.h"
#include <inttypes.h>
+int
+xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
+ unsigned long pfn)
+{
+ if (arch_ctxt->p2m_table.p2m == NULL)
+ return 1; /* default to trying to map the page */
+
+ return xc_ia64_p2m_present(&arch_ctxt->p2m_table, pfn);
+}
+
static int
xc_memory_map_cmp(const void *lhs__, const void *rhs__)
{
@@ -158,13 +168,18 @@ memory_map_get_old(int xc_handle, xc_dominfo_t *info,
}
int
-xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused,
+xc_core_arch_memory_map_get(int xc_handle,
+ struct xc_core_arch_context *arch_ctxt,
xc_dominfo_t *info, shared_info_t *live_shinfo,
xc_core_memory_map_t **mapp,
unsigned int *nr_entries)
{
int ret = -1;
- xen_ia64_memmap_info_t *memmap_info;
+ unsigned int memmap_info_num_pages;
+ unsigned long memmap_info_pfn;
+
+ xen_ia64_memmap_info_t *memmap_info_live;
+ xen_ia64_memmap_info_t *memmap_info = NULL;
unsigned long map_size;
xc_core_memory_map_t *map;
char *start;
@@ -172,27 +187,46 @@ xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused,
char *p;
efi_memory_desc_t *md;
- if ( live_shinfo == NULL ||
- live_shinfo->arch.memmap_info_num_pages == 0 ||
- live_shinfo->arch.memmap_info_pfn == 0 )
+ if ( live_shinfo == NULL )
+ {
+ ERROR("can't access shared info");
goto old;
+ }
- map_size = PAGE_SIZE * live_shinfo->arch.memmap_info_num_pages;
- memmap_info = xc_map_foreign_range(xc_handle, info->domid,
- map_size, PROT_READ,
- live_shinfo->arch.memmap_info_pfn);
- if ( memmap_info == NULL )
+ /* copy before use in case someone updating them */
+ memmap_info_num_pages = live_shinfo->arch.memmap_info_num_pages;
+ memmap_info_pfn = live_shinfo->arch.memmap_info_pfn;
+ if ( memmap_info_num_pages == 0 || memmap_info_pfn == 0 )
+ {
+ ERROR("memmap_info_num_pages 0x%x memmap_info_pfn 0x%lx",
+ memmap_info_num_pages, memmap_info_pfn);
+ goto old;
+ }
+
+ map_size = PAGE_SIZE * memmap_info_num_pages;
+ memmap_info_live = xc_map_foreign_range(xc_handle, info->domid,
+ map_size, PROT_READ, memmap_info_pfn);
+ if ( memmap_info_live == NULL )
{
PERROR("Could not map memmap info.");
return -1;
}
+ memmap_info = malloc(map_size);
+ if ( memmap_info == NULL )
+ {
+ munmap(memmap_info_live, map_size);
+ return -1;
+ }
+ memcpy(memmap_info, memmap_info_live, map_size); /* copy before use */
+ munmap(memmap_info_live, map_size);
+
if ( memmap_info->efi_memdesc_size != sizeof(*md) ||
(memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size) == 0 ||
memmap_info->efi_memmap_size > map_size - sizeof(memmap_info) ||
memmap_info->efi_memdesc_version != EFI_MEMORY_DESCRIPTOR_VERSION )
{
PERROR("unknown memmap header. defaulting to compat mode.");
- munmap(memmap_info, PAGE_SIZE);
+ free(memmap_info);
goto old;
}
@@ -201,7 +235,8 @@ xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused,
if ( map == NULL )
{
PERROR("Could not allocate memory for memmap.");
- goto out;
+ free(memmap_info);
+ return -1;
}
*mapp = map;
@@ -221,12 +256,16 @@ xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused,
(*nr_entries)++;
}
ret = 0;
-out:
- munmap(memmap_info, map_size);
+
+ xc_ia64_p2m_map(&arch_ctxt->p2m_table, xc_handle, info->domid,
+ memmap_info, 0);
+ if ( memmap_info != NULL )
+ free(memmap_info);
qsort(map, *nr_entries, sizeof(map[0]), &xc_memory_map_cmp);
return ret;
old:
+ DPRINTF("Falling back old method.\n");
return memory_map_get_old(xc_handle, info, live_shinfo, mapp, nr_entries);
}
@@ -253,6 +292,8 @@ xc_core_arch_context_init(struct xc_core_arch_context* arch_ctxt)
arch_ctxt->nr_vcpus = 0;
for ( i = 0; i < MAX_VIRT_CPUS; i++ )
arch_ctxt->mapped_regs[i] = NULL;
+
+ xc_ia64_p2m_init(&arch_ctxt->p2m_table);
}
void
@@ -262,6 +303,7 @@ xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt)
for ( i = 0; i < arch_ctxt->nr_vcpus; i++ )
if ( arch_ctxt->mapped_regs[i] != NULL )
munmap(arch_ctxt->mapped_regs[i], arch_ctxt->mapped_regs_size);
+ xc_ia64_p2m_unmap(&arch_ctxt->p2m_table);
}
int
diff --git a/tools/libxc/xc_core_ia64.h b/tools/libxc/xc_core_ia64.h
index 03cd8e0182..88e7e229e1 100644
--- a/tools/libxc/xc_core_ia64.h
+++ b/tools/libxc/xc_core_ia64.h
@@ -21,6 +21,8 @@
#ifndef XC_CORE_IA64_H
#define XC_CORE_IA64_H
+#include "ia64/xc_ia64.h"
+
#define ELF_ARCH_DATA ELFDATA2LSB
#define ELF_ARCH_MACHINE EM_IA_64
@@ -28,6 +30,8 @@ struct xc_core_arch_context {
size_t mapped_regs_size;
int nr_vcpus;
mapped_regs_t* mapped_regs[MAX_VIRT_CPUS];
+
+ struct xen_ia64_p2m_table p2m_table;
};
void
@@ -46,7 +50,10 @@ xc_core_arch_context_get_shdr(struct xc_core_arch_context* arch_ctxt,
int
xc_core_arch_context_dump(struct xc_core_arch_context* arch_ctxt,
void* args, dumpcore_rtn_t dump_rtn);
-#define xc_core_arch_gpfn_may_present(arch_ctxt, i) (1)
+
+int
+xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
+ unsigned long pfn);
#endif /* XC_CORE_IA64_H */