1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
/*
* vmx_hyparcall.c: handling hypercall from domain
* Copyright (c) 2005, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Xuefei Xu (Anthony Xu) (Anthony.xu@intel.com)
*/
#include <xen/config.h>
#include <xen/errno.h>
#include <asm/vmx_vcpu.h>
#include <xen/guest_access.h>
#include <public/event_channel.h>
#include <asm/vmmu.h>
#include <asm/tlb.h>
#include <asm/regionreg.h>
#include <asm/page.h>
#include <xen/mm.h>
#include <xen/multicall.h>
#include <xen/hypercall.h>
#include <public/version.h>
#include <asm/dom_fw.h>
#include <xen/domain.h>
#include <asm/vmx.h>
long
do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
{
long rc = 0;
switch (op) {
case HVMOP_set_param:
case HVMOP_get_param:
{
struct xen_hvm_param a;
struct domain *d;
if (copy_from_guest(&a, arg, 1))
return -EFAULT;
if (a.index > HVM_NR_PARAMS)
return -EINVAL;
if (a.domid == DOMID_SELF) {
get_knownalive_domain(current->domain);
d = current->domain;
}
else if (IS_PRIV(current->domain)) {
d = find_domain_by_id(a.domid);
if (d == NULL)
return -ESRCH;
}
else
return -EPERM;
if (op == HVMOP_set_param) {
d->arch.hvm_domain.params[a.index] = a.value;
rc = 0;
}
else {
a.value = d->arch.hvm_domain.params[a.index];
rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
}
put_domain(d);
break;
}
case HVMOP_set_irq_level:
{
struct xen_hvm_set_irq_level op;
struct domain *d;
if (copy_from_guest(&op, arg, 1))
return -EFAULT;
if (!IS_PRIV(current->domain))
return -EPERM;
d = find_domain_by_id(op.domid);
if (d == NULL)
return -ESRCH;
rc = -EINVAL;
if (is_hvm_domain(d)) {
vmx_vioapic_set_irq(d, op.irq, op.level);
rc = 0;
}
put_domain(d);
break;
}
default:
gdprintk(XENLOG_INFO, "Bad HVM op %ld.\n", op);
rc = -ENOSYS;
}
return rc;
}
|