1
/******************************************************************************
5
* Interface to low-level memory sharing functionality.
7
* Copyright (c) 2009 Citrix Systems, Inc. (Grzegorz Milos)
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "xc_private.h"
25
#include <xen/memory.h>
26
#include <xen/grant_table.h>
28
int xc_memshr_control(int xc_handle,
33
struct xen_domctl_mem_sharing_op *op;
35
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
36
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
37
domctl.domain = (domid_t)domid;
38
op = &(domctl.u.mem_sharing_op);
39
op->op = XEN_DOMCTL_MEM_SHARING_OP_CONTROL;
40
op->u.enable = enable;
42
return do_domctl(xc_handle, &domctl);
45
int xc_memshr_nominate_gfn(int xc_handle,
51
struct xen_domctl_mem_sharing_op *op;
54
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
55
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
56
domctl.domain = (domid_t)domid;
57
op = &(domctl.u.mem_sharing_op);
58
op->op = XEN_DOMCTL_MEM_SHARING_OP_NOMINATE_GFN;
59
op->u.nominate.u.gfn = gfn;
61
ret = do_domctl(xc_handle, &domctl);
62
if(!ret) *handle = op->u.nominate.handle;
67
int xc_memshr_nominate_gref(int xc_handle,
73
struct xen_domctl_mem_sharing_op *op;
76
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
77
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
78
domctl.domain = (domid_t)domid;
79
op = &(domctl.u.mem_sharing_op);
80
op->op = XEN_DOMCTL_MEM_SHARING_OP_NOMINATE_GREF;
81
op->u.nominate.u.grant_ref = gref;
83
ret = do_domctl(xc_handle, &domctl);
84
if(!ret) *handle = op->u.nominate.handle;
89
int xc_memshr_share(int xc_handle,
90
uint64_t source_handle,
91
uint64_t client_handle)
94
struct xen_domctl_mem_sharing_op *op;
96
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
97
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
99
op = &(domctl.u.mem_sharing_op);
100
op->op = XEN_DOMCTL_MEM_SHARING_OP_SHARE;
101
op->u.share.source_handle = source_handle;
102
op->u.share.client_handle = client_handle;
104
return do_domctl(xc_handle, &domctl);
107
int xc_memshr_domain_resume(int xc_handle,
111
struct xen_domctl_mem_sharing_op *op;
113
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
114
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
115
domctl.domain = (domid_t)domid;
116
op = &(domctl.u.mem_sharing_op);
117
op->op = XEN_DOMCTL_MEM_SHARING_OP_RESUME;
119
return do_domctl(xc_handle, &domctl);
122
int xc_memshr_debug_gfn(int xc_handle,
127
struct xen_domctl_mem_sharing_op *op;
129
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
130
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
131
domctl.domain = (domid_t)domid;
132
op = &(domctl.u.mem_sharing_op);
133
op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_GFN;
134
op->u.debug.u.gfn = gfn;
136
return do_domctl(xc_handle, &domctl);
139
int xc_memshr_debug_mfn(int xc_handle,
144
struct xen_domctl_mem_sharing_op *op;
146
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
147
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
148
domctl.domain = (domid_t)domid;
149
op = &(domctl.u.mem_sharing_op);
150
op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_MFN;
151
op->u.debug.u.mfn = mfn;
153
return do_domctl(xc_handle, &domctl);
156
int xc_memshr_debug_gref(int xc_handle,
161
struct xen_domctl_mem_sharing_op *op;
163
domctl.cmd = XEN_DOMCTL_mem_sharing_op;
164
domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
165
domctl.domain = (domid_t)domid;
166
op = &(domctl.u.mem_sharing_op);
167
op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_GREF;
168
op->u.debug.u.gref = gref;
170
return do_domctl(xc_handle, &domctl);