ia64/xen-unstable

view xen/arch/ia64/vmx/vmx_hypercall.c @ 14196:9d36026b1b43

xen: Cleanups and bug fixes after the rcu_lock_domain patch.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Mar 01 11:38:55 2007 +0000 (2007-03-01)
parents 271ffb1c12eb
children cc83df4c96d6
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
2 /*
3 * vmx_hyparcall.c: handling hypercall from domain
4 * Copyright (c) 2005, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 *
19 * Xuefei Xu (Anthony Xu) (Anthony.xu@intel.com)
20 */
22 #include <xen/config.h>
23 #include <xen/errno.h>
24 #include <asm/vmx_vcpu.h>
25 #include <xen/guest_access.h>
26 #include <public/event_channel.h>
27 #include <asm/vmmu.h>
28 #include <asm/tlb.h>
29 #include <asm/regionreg.h>
30 #include <asm/page.h>
31 #include <xen/mm.h>
32 #include <xen/multicall.h>
33 #include <xen/hypercall.h>
34 #include <public/version.h>
35 #include <asm/dom_fw.h>
36 #include <xen/domain.h>
37 #include <asm/vmx.h>
38 #include <asm/viosapic.h>
40 static int hvmop_set_isa_irq_level(
41 XEN_GUEST_HANDLE(xen_hvm_set_isa_irq_level_t) uop)
42 {
43 struct xen_hvm_set_isa_irq_level op;
44 struct domain *d;
45 int rc;
47 if ( copy_from_guest(&op, uop, 1) )
48 return -EFAULT;
50 if ( !IS_PRIV(current->domain) )
51 return -EPERM;
53 if ( op.isa_irq > 15 )
54 return -EINVAL;
56 d = get_domain_by_id(op.domid);
57 if ( d == NULL )
58 return -ESRCH;
60 rc = -EINVAL;
61 if ( !is_hvm_domain(d) )
62 goto out;
64 rc = 0;
65 viosapic_set_irq(d, op.isa_irq, op.level);
67 out:
68 put_domain(d);
69 return rc;
70 }
72 static int hvmop_set_pci_intx_level(
73 XEN_GUEST_HANDLE(xen_hvm_set_pci_intx_level_t) uop)
74 {
75 struct xen_hvm_set_pci_intx_level op;
76 struct domain *d;
77 int rc;
79 if ( copy_from_guest(&op, uop, 1) )
80 return -EFAULT;
82 if ( !IS_PRIV(current->domain) )
83 return -EPERM;
85 if ( (op.domain > 0) || (op.bus > 0) || (op.device > 31) || (op.intx > 3) )
86 return -EINVAL;
88 d = get_domain_by_id(op.domid);
89 if ( d == NULL )
90 return -ESRCH;
92 rc = -EINVAL;
93 if ( !is_hvm_domain(d) )
94 goto out;
96 rc = 0;
97 viosapic_set_pci_irq(d, op.device, op.intx, op.level);
99 out:
100 put_domain(d);
101 return rc;
102 }
106 long
107 do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
108 {
109 long rc = 0;
111 switch (op) {
112 case HVMOP_set_param:
113 case HVMOP_get_param:
114 {
115 struct xen_hvm_param a;
116 struct domain *d;
118 if (copy_from_guest(&a, arg, 1))
119 return -EFAULT;
121 if (a.index > HVM_NR_PARAMS)
122 return -EINVAL;
124 if (a.domid == DOMID_SELF) {
125 d = get_current_domain();
126 }
127 else if (IS_PRIV(current->domain)) {
128 d = get_domain_by_id(a.domid);
129 if (d == NULL)
130 return -ESRCH;
131 }
132 else
133 return -EPERM;
135 if (op == HVMOP_set_param) {
136 d->arch.hvm_domain.params[a.index] = a.value;
137 rc = 0;
138 }
139 else {
140 a.value = d->arch.hvm_domain.params[a.index];
141 rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
142 }
144 put_domain(d);
145 break;
146 }
148 case HVMOP_set_pci_intx_level:
149 rc = hvmop_set_pci_intx_level(
150 guest_handle_cast(arg, xen_hvm_set_pci_intx_level_t));
151 break;
153 case HVMOP_set_isa_irq_level:
154 rc = hvmop_set_isa_irq_level(
155 guest_handle_cast(arg, xen_hvm_set_isa_irq_level_t));
156 break;
158 case HVMOP_set_pci_link_route:
159 rc = 0;
160 break;
162 default:
163 gdprintk(XENLOG_INFO, "Bad HVM op %ld.\n", op);
164 rc = -ENOSYS;
165 }
166 return rc;
167 }