return set_s3_state(dm, 0, "s3 awaken");
}
+int xendevicemodel_populate_ram(xendevicemodel_handle *dm,
+ xen_pfn_t start_gpfn, size_t nr_pages)
+{
+ xen_memory_reservation_t *arg = NULL;
+ xen_pfn_t *pfns = NULL;
+ size_t i, ret = -1;
+
+ arg = xencall_alloc_buffer(dm->call, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ LOGE(ERROR, "unable to allocate memory for populate ram hypercall");
+ goto err;
+ }
+
+ pfns = xencall_alloc_buffer(dm->call, sizeof(*pfns) * nr_pages);
+ if ( pfns == NULL )
+ {
+ LOGE(ERROR, "unable to allocate memory for populate ram hypercall pfns");
+ goto err;
+ }
+
+ for (i = 0; i < nr_pages; i++)
+ pfns[i] = start_gpfn + i;
+
+ arg->domid = dm->domid;
+ arg->nr_extents = nr_pages;
+ arg->extent_order = 0;
+ arg->mem_flags = 0;
+ set_xen_guest_handle(arg->extent_start, pfns);
+
+ ret = xencall2(dm->call, __HYPERVISOR_memory_op,
+ XENMEM_populate_physmap,
+ (uintptr_t)arg);
+
+ if ( ret == nr_pages )
+ ret = 0; /* success */
+ else if ( ret >= 0 )
+ {
+ LOG(ERROR, "populate ram partial success %zd/%zd pages", ret, nr_pages);
+ ret = -1;
+ errno = -EBUSY;
+ }
+ else
+ {
+ LOGE(ERROR, "populate ram hypercall failed");
+ ret = -1;
+ }
+
+ err:
+ xencall_free_buffer(dm->call, pfns);
+ xencall_free_buffer(dm->call, arg);
+
+ return ret;
+}
/*
* Local variables:
int xendevicemodel_set_isa_irq_level(xendevicemodel_handle *dm,
uint8_t isa_irq, bool assert);
+/*
+ * Memory handling
+ * ===============
+ */
+
+/*
+ * Populate a region of guest physical address space with normal
+ * RAM. On success the entire region will have been populated and zero
+ * is returned.
+ *
+ * On failure -1 is returned and errno is set. The contents of the
+ * memory region is undefined and may contain partial success.
+ *
+ * Always logs on failure.
+ *
+ * XXX on partial failure xc_domain_populate_physmap_exact would
+ * return -1/EBUSY without undoing the partial success. This seems
+ * like a poor model to follow, note however that options for undoing
+ * are limited to de-populating the underlying area, which may not
+ * have been the initial state.
+ */
+int xendevicemodel_populate_ram(xendevicemodel_handle *dm,
+ xen_pfn_t start_gpfn, size_t nr_pages);
+
#endif
/*
* Local variables: