Skip to content

Commit 20e725e

Browse files
blackskyggWei Liu
authored and
Wei Liu
committed
libxc: add xc_domain_add_to_physmap_batch to wrap XENMEM_add_to_physmap_batch
This is a preparation for the proposal "allow setting up shared memory areas between VMs from xl config file". See: V2: https://lists.xen.org/archives/html/xen-devel/2017-06/msg02256.html V1: https://lists.xen.org/archives/html/xen-devel/2017-05/msg01288.html The plan is to use XENMEM_add_to_physmap_batch in xl to map foregin pages from one DomU to another so that the page could be shared. But currently there is no wrapper for XENMEM_add_to_physmap_batch in libxc, so we just add a wrapper for it. Signed-off-by: Zhongze Liu <[email protected]> Acked-by: Wei Liu <[email protected]>
1 parent bda2696 commit 20e725e

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

tools/libxc/include/xenctrl.h

+9
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,15 @@ int xc_domain_add_to_physmap(xc_interface *xch,
13721372
unsigned long idx,
13731373
xen_pfn_t gpfn);
13741374

1375+
int xc_domain_add_to_physmap_batch(xc_interface *xch,
1376+
domid_t domid,
1377+
domid_t foreign_domid,
1378+
unsigned int space,
1379+
unsigned int size,
1380+
xen_ulong_t *idxs,
1381+
xen_pfn_t *gfpns,
1382+
int *errs);
1383+
13751384
int xc_domain_populate_physmap(xc_interface *xch,
13761385
uint32_t domid,
13771386
unsigned long nr_extents,

tools/libxc/xc_domain.c

+45
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,51 @@ int xc_domain_add_to_physmap(xc_interface *xch,
10321032
return do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
10331033
}
10341034

1035+
int xc_domain_add_to_physmap_batch(xc_interface *xch,
1036+
domid_t domid,
1037+
domid_t foreign_domid,
1038+
unsigned int space,
1039+
unsigned int size,
1040+
xen_ulong_t *idxs,
1041+
xen_pfn_t *gpfns,
1042+
int *errs)
1043+
{
1044+
int rc;
1045+
DECLARE_HYPERCALL_BOUNCE(idxs, size * sizeof(*idxs), XC_HYPERCALL_BUFFER_BOUNCE_IN);
1046+
DECLARE_HYPERCALL_BOUNCE(gpfns, size * sizeof(*gpfns), XC_HYPERCALL_BUFFER_BOUNCE_IN);
1047+
DECLARE_HYPERCALL_BOUNCE(errs, size * sizeof(*errs), XC_HYPERCALL_BUFFER_BOUNCE_OUT);
1048+
1049+
struct xen_add_to_physmap_batch xatp_batch = {
1050+
.domid = domid,
1051+
.space = space,
1052+
.size = size,
1053+
.u = { .foreign_domid = foreign_domid }
1054+
};
1055+
1056+
if ( xc_hypercall_bounce_pre(xch, idxs) ||
1057+
xc_hypercall_bounce_pre(xch, gpfns) ||
1058+
xc_hypercall_bounce_pre(xch, errs) )
1059+
{
1060+
PERROR("Could not bounce memory for XENMEM_add_to_physmap_batch");
1061+
rc = -1;
1062+
goto out;
1063+
}
1064+
1065+
set_xen_guest_handle(xatp_batch.idxs, idxs);
1066+
set_xen_guest_handle(xatp_batch.gpfns, gpfns);
1067+
set_xen_guest_handle(xatp_batch.errs, errs);
1068+
1069+
rc = do_memory_op(xch, XENMEM_add_to_physmap_batch,
1070+
&xatp_batch, sizeof(xatp_batch));
1071+
1072+
out:
1073+
xc_hypercall_bounce_post(xch, idxs);
1074+
xc_hypercall_bounce_post(xch, gpfns);
1075+
xc_hypercall_bounce_post(xch, errs);
1076+
1077+
return rc;
1078+
}
1079+
10351080
int xc_domain_claim_pages(xc_interface *xch,
10361081
uint32_t domid,
10371082
unsigned long nr_pages)

0 commit comments

Comments
 (0)