* In this function, we will allocate memory and build P2M/M2P table for VTI
* guest. Frist, a pfn list will be initialized discontiguous, normal memory
* begins with 0, GFW memory and other five pages at their place defined in
- * xen/include/public/arch-ia64.h xc_domain_memory_populate_physmap() called
+ * xen/include/public/arch-ia64.h xc_domain_populate_physmap_exact() called
* five times, to set parameter 'extent_order' to different value, this is
* convenient to allocate discontiguous memory with different size.
*/
pfn++)
pfn_list[i++] = pfn;
- rc = xc_domain_memory_populate_physmap(xch, dom, nr_pages, 0, 0,
+ rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages, 0, 0,
&pfn_list[0]);
if (rc != 0) {
PERROR("Could not allocate normal memory for Vti guest.");
for (i = 0; i < GFW_PAGES; i++)
pfn_list[i] = (GFW_START >> PAGE_SHIFT) + i;
- rc = xc_domain_memory_populate_physmap(xch, dom, GFW_PAGES,
+ rc = xc_domain_populate_physmap_exact(xch, dom, GFW_PAGES,
0, 0, &pfn_list[0]);
if (rc != 0) {
PERROR("Could not allocate GFW memory for Vti guest.");
pfn_list[nr_special_pages] = memmap_info_pfn;
nr_special_pages++;
- rc = xc_domain_memory_populate_physmap(xch, dom, nr_special_pages,
+ rc = xc_domain_populate_physmap_exact(xch, dom, nr_special_pages,
0, 0, &pfn_list[0]);
if (rc != 0) {
PERROR("Could not allocate IO page or store page or buffer io page.");
if (xc_ia64_p2m_present(p2m_table, gmfn))
return 0;
- return xc_domain_memory_populate_physmap(xch, dom, 1, 0, 0, &gmfn);
+ return xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &gmfn);
}
static int
}
}
if (nr_frees > 0) {
- if (xc_domain_memory_decrease_reservation(xch, dom, nr_frees,
+ if (xc_domain_decrease_reservation_exact(xch, dom, nr_frees,
0, pfntab) < 0) {
PERROR("Could not decrease reservation");
goto out;
};
unsigned long nr_pages = sizeof(pfn_list) / sizeof(pfn_list[0]);
- rc = xc_domain_memory_populate_physmap(xch, dom, nr_pages,
+ rc = xc_domain_populate_physmap_exact(xch, dom, nr_pages,
0, 0, &pfn_list[0]);
if (rc != 0)
PERROR("Could not allocate IO page or buffer io page.");
dom->p2m_host[pfn] = start + pfn;
/* allocate guest memory */
- rc = xc_domain_memory_populate_physmap(dom->xch, dom->guest_domid,
+ rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid,
nbr, 0, 0,
dom->p2m_host);
return rc;
DOMPRINTF("Populating memory with %d superpages", count);
for ( pfn = 0; pfn < count; pfn++ )
extents[pfn] = pfn << SUPERPAGE_PFN_SHIFT;
- rc = xc_domain_memory_populate_physmap(dom->xch, dom->guest_domid,
+ rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid,
count, SUPERPAGE_PFN_SHIFT, 0,
extents);
if ( rc )
allocsz = dom->total_pages - i;
if ( allocsz > 1024*1024 )
allocsz = 1024*1024;
- rc = xc_domain_memory_populate_physmap(
+ rc = xc_domain_populate_physmap_exact(
dom->xch, dom->guest_domid, allocsz,
0, 0, &dom->p2m_host[i]);
}
}
-int xc_domain_memory_increase_reservation(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- unsigned int mem_flags,
- xen_pfn_t *extent_start)
+int xc_domain_increase_reservation(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start)
{
int err;
struct xen_memory_reservation reservation = {
set_xen_guest_handle(reservation.extent_start, extent_start);
err = xc_memory_op(xch, XENMEM_increase_reservation, &reservation);
+
+ return err;
+}
+
+int xc_domain_increase_reservation_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start)
+{
+ int err;
+
+ err = xc_domain_increase_reservation(xch, domid, nr_extents,
+ extent_order, mem_flags, extent_start);
+
if ( err == nr_extents )
return 0;
return err;
}
-int xc_domain_memory_decrease_reservation(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- xen_pfn_t *extent_start)
+int xc_domain_decrease_reservation(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ xen_pfn_t *extent_start)
{
int err;
struct xen_memory_reservation reservation = {
}
err = xc_memory_op(xch, XENMEM_decrease_reservation, &reservation);
+
+ return err;
+}
+
+int xc_domain_decrease_reservation_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ xen_pfn_t *extent_start)
+{
+ int err;
+
+ err = xc_domain_decrease_reservation(xch, domid, nr_extents,
+ extent_order, extent_start);
+
if ( err == nr_extents )
return 0;
return err;
}
-int xc_domain_memory_populate_physmap(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- unsigned int mem_flags,
- xen_pfn_t *extent_start)
+int xc_domain_populate_physmap(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start)
{
int err;
struct xen_memory_reservation reservation = {
set_xen_guest_handle(reservation.extent_start, extent_start);
err = xc_memory_op(xch, XENMEM_populate_physmap, &reservation);
+
+ return err;
+}
+
+int xc_domain_populate_physmap_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start)
+{
+ int err;
+
+ err = xc_domain_populate_physmap(xch, domid, nr_extents,
+ extent_order, mem_flags, extent_start);
if ( err == nr_extents )
return 0;
return err;
}
-static int xc_domain_memory_pod_target(xc_interface *xch,
- int op,
- uint32_t domid,
- uint64_t target_pages,
- uint64_t *tot_pages,
- uint64_t *pod_cache_pages,
- uint64_t *pod_entries)
+static int xc_domain_pod_target(xc_interface *xch,
+ int op,
+ uint32_t domid,
+ uint64_t target_pages,
+ uint64_t *tot_pages,
+ uint64_t *pod_cache_pages,
+ uint64_t *pod_entries)
{
int err;
if ( err < 0 )
{
- DPRINTF("Failed %s_memory_target dom %d\n",
+ DPRINTF("Failed %s_pod_target dom %d\n",
(op==XENMEM_set_pod_target)?"set":"get",
domid);
errno = -err;
return err;
}
-
-
-int xc_domain_memory_set_pod_target(xc_interface *xch,
- uint32_t domid,
- uint64_t target_pages,
- uint64_t *tot_pages,
- uint64_t *pod_cache_pages,
- uint64_t *pod_entries)
+
+
+int xc_domain_set_pod_target(xc_interface *xch,
+ uint32_t domid,
+ uint64_t target_pages,
+ uint64_t *tot_pages,
+ uint64_t *pod_cache_pages,
+ uint64_t *pod_entries)
{
- return xc_domain_memory_pod_target(xch,
- XENMEM_set_pod_target,
- domid,
- target_pages,
- tot_pages,
- pod_cache_pages,
- pod_entries);
+ return xc_domain_pod_target(xch,
+ XENMEM_set_pod_target,
+ domid,
+ target_pages,
+ tot_pages,
+ pod_cache_pages,
+ pod_entries);
}
-int xc_domain_memory_get_pod_target(xc_interface *xch,
- uint32_t domid,
- uint64_t *tot_pages,
- uint64_t *pod_cache_pages,
- uint64_t *pod_entries)
+int xc_domain_get_pod_target(xc_interface *xch,
+ uint32_t domid,
+ uint64_t *tot_pages,
+ uint64_t *pod_cache_pages,
+ uint64_t *pod_entries)
{
- return xc_domain_memory_pod_target(xch,
- XENMEM_get_pod_target,
- domid,
- -1,
- tot_pages,
- pod_cache_pages,
- pod_entries);
+ return xc_domain_pod_target(xch,
+ XENMEM_get_pod_target,
+ domid,
+ -1,
+ tot_pages,
+ pod_cache_pages,
+ pod_entries);
}
int xc_domain_max_vcpus(xc_interface *xch, uint32_t domid, unsigned int max)
/* Allocate the requisite number of mfns. */
if ( nr_mfns &&
- (xc_domain_memory_populate_physmap(xch, dom, nr_mfns, 0, 0,
+ (xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0, 0,
ctx->p2m_batch) != 0) )
{
ERROR("Failed to allocate memory for batch.!\n");
/* Now allocate a bunch of mfns for this batch */
if ( nr_mfns &&
- (xc_domain_memory_populate_physmap(xch, dom, nr_mfns, 0,
+ (xc_domain_populate_physmap_exact(xch, dom, nr_mfns, 0,
0, ctx->p2m_batch) != 0) )
{
ERROR("Failed to allocate memory for batch.!\n");
if ( nr_frees > 0 )
{
- struct xen_memory_reservation reservation = {
- .nr_extents = nr_frees,
- .extent_order = 0,
- .domid = dom
- };
- set_xen_guest_handle(reservation.extent_start, tailbuf.u.pv.pfntab);
-
- if ( (frc = xc_memory_op(xch, XENMEM_decrease_reservation,
- &reservation)) != nr_frees )
+ if ( (frc = xc_domain_decrease_reservation(xch, dom, nr_frees, 0, tailbuf.u.pv.pfntab)) != nr_frees )
{
PERROR("Could not decrease reservation : %d", frc);
goto out;
* Under 2MB mode, we allocate pages in batches of no more than 8MB to
* ensure that we can be preempted and hence dom0 remains responsive.
*/
- rc = xc_domain_memory_populate_physmap(
+ rc = xc_domain_populate_physmap_exact(
xch, dom, 0xa0, 0, 0, &page_array[0x00]);
cur_pages = 0xc0;
stat_normal_pages = 0xc0;
SUPERPAGE_1GB_NR_PFNS << PAGE_SHIFT) )
{
long done;
- xen_pfn_t sp_extents[count >> SUPERPAGE_1GB_SHIFT];
- struct xen_memory_reservation sp_req = {
- .nr_extents = count >> SUPERPAGE_1GB_SHIFT,
- .extent_order = SUPERPAGE_1GB_SHIFT,
- .domid = dom
- };
-
- if ( pod_mode )
- sp_req.mem_flags = XENMEMF_populate_on_demand;
-
- set_xen_guest_handle(sp_req.extent_start, sp_extents);
- for ( i = 0; i < sp_req.nr_extents; i++ )
+ unsigned long nr_extents = count >> SUPERPAGE_1GB_SHIFT;
+ xen_pfn_t sp_extents[nr_extents];
+
+ for ( i = 0; i < nr_extents; i++ )
sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_1GB_SHIFT)];
- done = xc_memory_op(xch, XENMEM_populate_physmap, &sp_req);
+
+ done = xc_domain_populate_physmap(xch, dom, nr_extents, SUPERPAGE_1GB_SHIFT,
+ pod_mode ? XENMEMF_populate_on_demand : 0,
+ sp_extents);
+
if ( done > 0 )
{
stat_1gb_pages += done;
if ( ((count | cur_pages) & (SUPERPAGE_2MB_NR_PFNS - 1)) == 0 )
{
long done;
- xen_pfn_t sp_extents[count >> SUPERPAGE_2MB_SHIFT];
- struct xen_memory_reservation sp_req = {
- .nr_extents = count >> SUPERPAGE_2MB_SHIFT,
- .extent_order = SUPERPAGE_2MB_SHIFT,
- .domid = dom
- };
-
- if ( pod_mode )
- sp_req.mem_flags = XENMEMF_populate_on_demand;
-
- set_xen_guest_handle(sp_req.extent_start, sp_extents);
- for ( i = 0; i < sp_req.nr_extents; i++ )
+ unsigned long nr_extents = count >> SUPERPAGE_2MB_SHIFT;
+ xen_pfn_t sp_extents[nr_extents];
+
+ for ( i = 0; i < nr_extents; i++ )
sp_extents[i] = page_array[cur_pages+(i<<SUPERPAGE_2MB_SHIFT)];
- done = xc_memory_op(xch, XENMEM_populate_physmap, &sp_req);
+
+ done = xc_domain_populate_physmap(xch, dom, nr_extents, SUPERPAGE_2MB_SHIFT,
+ pod_mode ? XENMEMF_populate_on_demand : 0,
+ sp_extents);
+
if ( done > 0 )
{
stat_2mb_pages += done;
/* Fall back to 4kB extents. */
if ( count != 0 )
{
- rc = xc_domain_memory_populate_physmap(
+ rc = xc_domain_populate_physmap_exact(
xch, dom, count, 0, 0, &page_array[cur_pages]);
cur_pages += count;
stat_normal_pages += count;
* adjust the PoD cache size so that domain tot_pages will be
* target_pages - 0x20 after this call. */
if ( pod_mode )
- rc = xc_domain_memory_set_pod_target(xch,
- dom,
- target_pages - 0x20,
- NULL, NULL, NULL);
+ rc = xc_domain_set_pod_target(xch, dom, target_pages - 0x20,
+ NULL, NULL, NULL);
if ( rc != 0 )
{
for ( i = 0; i < NR_SPECIAL_PAGES; i++ )
{
xen_pfn_t pfn = special_pfn(i);
- rc = xc_domain_memory_populate_physmap(xch, dom, 1, 0, 0, &pfn);
+ rc = xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &pfn);
if ( rc != 0 )
{
PERROR("Could not allocate %d'th special page.", i);
xen_pfn_t old_mfn = mfn;
xen_pfn_t new_mfn;
- if ( xc_domain_memory_decrease_reservation(
+ if ( xc_domain_decrease_reservation_exact(
xch, domid, 1, 0, &old_mfn) != 0 )
{
DPRINTF("xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
return 0;
}
- if ( xc_domain_memory_increase_reservation(
+ if ( xc_domain_increase_reservation_exact(
xch, domid, 1, 0, XENMEMF_address_bits(32), &new_mfn) != 0 )
{
DPRINTF("xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
-int xc_domain_memory_increase_reservation(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- unsigned int mem_flags,
- xen_pfn_t *extent_start);
-
-int xc_domain_memory_decrease_reservation(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- xen_pfn_t *extent_start);
-
-int xc_domain_memory_populate_physmap(xc_interface *xch,
- uint32_t domid,
- unsigned long nr_extents,
- unsigned int extent_order,
- unsigned int mem_flags,
- xen_pfn_t *extent_start);
+int xc_domain_increase_reservation(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start);
+
+int xc_domain_increase_reservation_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start);
+
+int xc_domain_decrease_reservation(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ xen_pfn_t *extent_start);
-int xc_domain_memory_set_pod_target(xc_interface *xch,
- uint32_t domid,
- uint64_t target_pages,
- uint64_t *tot_pages,
- uint64_t *pod_cache_pages,
- uint64_t *pod_entries);
+int xc_domain_decrease_reservation_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ xen_pfn_t *extent_start);
-int xc_domain_memory_get_pod_target(xc_interface *xch,
- uint32_t domid,
- uint64_t *tot_pages,
- uint64_t *pod_cache_pages,
- uint64_t *pod_entries);
+int xc_domain_populate_physmap(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start);
+
+int xc_domain_populate_physmap_exact(xc_interface *xch,
+ uint32_t domid,
+ unsigned long nr_extents,
+ unsigned int extent_order,
+ unsigned int mem_flags,
+ xen_pfn_t *extent_start);
+
+/* Temporary for compatibility */
+#define xc_domain_memory_populate_physmap(x, d, nr, eo, mf, es) \
+ xc_domain_populate_physmap_exact(x, d, nr, eo, mf, es)
+
+int xc_domain_set_pod_target(xc_interface *xch,
+ uint32_t domid,
+ uint64_t target_pages,
+ uint64_t *tot_pages,
+ uint64_t *pod_cache_pages,
+ uint64_t *pod_entries);
+
+int xc_domain_get_pod_target(xc_interface *xch,
+ uint32_t domid,
+ uint64_t *tot_pages,
+ uint64_t *pod_cache_pages,
+ uint64_t *pod_entries);
int xc_domain_ioport_permission(xc_interface *xch,
uint32_t domid,
}
new_target_memkb -= videoram;
- rc = xc_domain_memory_set_pod_target(ctx->xch, domid,
+ rc = xc_domain_set_pod_target(ctx->xch, domid,
new_target_memkb / 4, NULL, NULL, NULL);
if (rc != 0) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "xc_domain_memory_set_pod_target domid=%d, memkb=%d "
+ "xc_domain_set_pod_target domid=%d, memkb=%d "
"failed rc=%d\n", domid, new_target_memkb / 4,
rc);
abort = 1;
mem_pages = mem_kb / 4;
- if (xc_domain_memory_set_pod_target(self->xc_handle, dom, mem_pages,
- NULL, NULL, NULL) != 0)
+ if (xc_domain_set_pod_target(self->xc_handle, dom, mem_pages,
+ NULL, NULL, NULL) != 0)
return pyxc_error_to_exception(self->xc_handle);
Py_INCREF(zero);