1 /*
2 * Copyright (c) 2016 Citrix Systems Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include <xen/dm.h>
18 #include <xen/guest_access.h>
19 #include <xen/hypercall.h>
20 #include <xen/nospec.h>
21
do_dm_op(domid_t domid,unsigned int nr_bufs,XEN_GUEST_HANDLE_PARAM (xen_dm_op_buf_t)bufs)22 long do_dm_op(
23 domid_t domid, unsigned int nr_bufs,
24 XEN_GUEST_HANDLE_PARAM(xen_dm_op_buf_t) bufs)
25 {
26 struct dmop_args args;
27 int rc;
28
29 if ( nr_bufs > ARRAY_SIZE(args.buf) )
30 return -E2BIG;
31
32 args.domid = domid;
33 args.nr_bufs = array_index_nospec(nr_bufs, ARRAY_SIZE(args.buf) + 1);
34
35 if ( copy_from_guest_offset(&args.buf[0], bufs, 0, args.nr_bufs) )
36 return -EFAULT;
37
38 rc = dm_op(&args);
39
40 if ( rc == -ERESTART )
41 rc = hypercall_create_continuation(__HYPERVISOR_dm_op, "iih",
42 domid, nr_bufs, bufs);
43
44 return rc;
45 }
46
47 /*
48 * Local variables:
49 * mode: C
50 * c-file-style: "BSD"
51 * c-basic-offset: 4
52 * tab-width: 4
53 * indent-tabs-mode: nil
54 * End:
55 */
56