ia64/xen-unstable

view tools/libxc/xc_core_x86.c @ 15335:be33028fcda5

Fix fully-virtualized core dumps for 32-bit guests.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
author kfraser@localhost.localdomain
date Tue Jun 12 11:39:51 2007 +0100 (2007-06-12)
parents 55d0a5c70986
children 263fc122f62b
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
17 * VA Linux Systems Japan K.K.
18 *
19 */
21 #include "xg_private.h"
22 #include "xc_core.h"
24 static int nr_gpfns(int xc_handle, domid_t domid)
25 {
26 return xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &domid) + 1;
27 }
29 int
30 xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)
31 {
32 return info->hvm;
33 }
35 int
36 xc_core_arch_memory_map_get(int xc_handle, xc_dominfo_t *info,
37 shared_info_t *live_shinfo,
38 xc_core_memory_map_t **mapp,
39 unsigned int *nr_entries)
40 {
41 unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
42 xc_core_memory_map_t *map;
44 map = malloc(sizeof(*map));
45 if ( map == NULL )
46 {
47 PERROR("Could not allocate memory");
48 return -1;
49 }
51 map->addr = 0;
52 map->size = ((uint64_t)p2m_size) << PAGE_SHIFT;
54 *mapp = map;
55 *nr_entries = 1;
56 return 0;
57 }
59 int
60 xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
61 shared_info_t *live_shinfo, xen_pfn_t **live_p2m,
62 unsigned long *pfnp)
63 {
64 /* Double and single indirect references to the live P2M table */
65 xen_pfn_t *live_p2m_frame_list_list = NULL;
66 xen_pfn_t *live_p2m_frame_list = NULL;
67 uint32_t dom = info->domid;
68 unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
69 int ret = -1;
70 int err;
72 if ( p2m_size < info->nr_pages )
73 {
74 ERROR("p2m_size < nr_pages -1 (%lx < %lx", p2m_size, info->nr_pages - 1);
75 goto out;
76 }
78 live_p2m_frame_list_list =
79 xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ,
80 live_shinfo->arch.pfn_to_mfn_frame_list_list);
82 if ( !live_p2m_frame_list_list )
83 {
84 PERROR("Couldn't map p2m_frame_list_list (errno %d)", errno);
85 goto out;
86 }
88 live_p2m_frame_list =
89 xc_map_foreign_batch(xc_handle, dom, PROT_READ,
90 live_p2m_frame_list_list,
91 P2M_FLL_ENTRIES);
93 if ( !live_p2m_frame_list )
94 {
95 PERROR("Couldn't map p2m_frame_list");
96 goto out;
97 }
99 *live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_READ,
100 live_p2m_frame_list,
101 P2M_FL_ENTRIES);
103 if ( !*live_p2m )
104 {
105 PERROR("Couldn't map p2m table");
106 goto out;
107 }
109 *pfnp = p2m_size;
111 ret = 0;
113 out:
114 err = errno;
116 if ( live_p2m_frame_list_list )
117 munmap(live_p2m_frame_list_list, PAGE_SIZE);
119 if ( live_p2m_frame_list )
120 munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
122 errno = err;
123 return ret;
124 }
126 /*
127 * Local variables:
128 * mode: C
129 * c-set-style: "BSD"
130 * c-basic-offset: 4
131 * tab-width: 4
132 * indent-tabs-mode: nil
133 * End:
134 */