direct-io.hg

view linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h @ 11509:2e6c10dc7c0b

[POWERPC][XEN] make sure put_domain() is called in case of allocate_rma() failuer

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Sep 12 10:53:46 2006 -0400 (2006-09-12)
parents 2b78726766d1
children 6f3865b4d3d3
line source
1 /******************************************************************************
2 * hypercall.h
3 *
4 * Linux-specific hypervisor handling.
5 *
6 * Copyright (c) 2002-2004, K A Fraser
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 */
33 #ifndef __HYPERCALL_H__
34 #define __HYPERCALL_H__
36 #include <linux/string.h> /* memcpy() */
38 #ifndef __HYPERVISOR_H__
39 # error "please don't include this file directly"
40 #endif
42 #define __STR(x) #x
43 #define STR(x) __STR(x)
45 #ifdef CONFIG_XEN
46 #define HYPERCALL_STR(name) \
47 "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
48 #else
49 #define HYPERCALL_STR(name) \
50 "mov hypercall_stubs,%%eax; " \
51 "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; " \
52 "call *%%eax"
53 #endif
55 #define _hypercall0(type, name) \
56 ({ \
57 long __res; \
58 asm volatile ( \
59 HYPERCALL_STR(name) \
60 : "=a" (__res) \
61 : \
62 : "memory" ); \
63 (type)__res; \
64 })
66 #define _hypercall1(type, name, a1) \
67 ({ \
68 long __res, __ign1; \
69 asm volatile ( \
70 HYPERCALL_STR(name) \
71 : "=a" (__res), "=b" (__ign1) \
72 : "1" ((long)(a1)) \
73 : "memory" ); \
74 (type)__res; \
75 })
77 #define _hypercall2(type, name, a1, a2) \
78 ({ \
79 long __res, __ign1, __ign2; \
80 asm volatile ( \
81 HYPERCALL_STR(name) \
82 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
83 : "1" ((long)(a1)), "2" ((long)(a2)) \
84 : "memory" ); \
85 (type)__res; \
86 })
88 #define _hypercall3(type, name, a1, a2, a3) \
89 ({ \
90 long __res, __ign1, __ign2, __ign3; \
91 asm volatile ( \
92 HYPERCALL_STR(name) \
93 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
94 "=d" (__ign3) \
95 : "1" ((long)(a1)), "2" ((long)(a2)), \
96 "3" ((long)(a3)) \
97 : "memory" ); \
98 (type)__res; \
99 })
101 #define _hypercall4(type, name, a1, a2, a3, a4) \
102 ({ \
103 long __res, __ign1, __ign2, __ign3, __ign4; \
104 asm volatile ( \
105 HYPERCALL_STR(name) \
106 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
107 "=d" (__ign3), "=S" (__ign4) \
108 : "1" ((long)(a1)), "2" ((long)(a2)), \
109 "3" ((long)(a3)), "4" ((long)(a4)) \
110 : "memory" ); \
111 (type)__res; \
112 })
114 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
115 ({ \
116 long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
117 asm volatile ( \
118 HYPERCALL_STR(name) \
119 : "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
120 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
121 : "1" ((long)(a1)), "2" ((long)(a2)), \
122 "3" ((long)(a3)), "4" ((long)(a4)), \
123 "5" ((long)(a5)) \
124 : "memory" ); \
125 (type)__res; \
126 })
128 static inline int
129 HYPERVISOR_set_trap_table(
130 trap_info_t *table)
131 {
132 return _hypercall1(int, set_trap_table, table);
133 }
135 static inline int
136 HYPERVISOR_mmu_update(
137 mmu_update_t *req, int count, int *success_count, domid_t domid)
138 {
139 return _hypercall4(int, mmu_update, req, count, success_count, domid);
140 }
142 static inline int
143 HYPERVISOR_mmuext_op(
144 struct mmuext_op *op, int count, int *success_count, domid_t domid)
145 {
146 return _hypercall4(int, mmuext_op, op, count, success_count, domid);
147 }
149 static inline int
150 HYPERVISOR_set_gdt(
151 unsigned long *frame_list, int entries)
152 {
153 return _hypercall2(int, set_gdt, frame_list, entries);
154 }
156 static inline int
157 HYPERVISOR_stack_switch(
158 unsigned long ss, unsigned long esp)
159 {
160 return _hypercall2(int, stack_switch, ss, esp);
161 }
163 static inline int
164 HYPERVISOR_set_callbacks(
165 unsigned long event_selector, unsigned long event_address,
166 unsigned long failsafe_selector, unsigned long failsafe_address)
167 {
168 return _hypercall4(int, set_callbacks,
169 event_selector, event_address,
170 failsafe_selector, failsafe_address);
171 }
173 static inline int
174 HYPERVISOR_fpu_taskswitch(
175 int set)
176 {
177 return _hypercall1(int, fpu_taskswitch, set);
178 }
180 static inline int
181 HYPERVISOR_sched_op_compat(
182 int cmd, unsigned long arg)
183 {
184 return _hypercall2(int, sched_op_compat, cmd, arg);
185 }
187 static inline int
188 HYPERVISOR_sched_op(
189 int cmd, void *arg)
190 {
191 return _hypercall2(int, sched_op, cmd, arg);
192 }
194 static inline long
195 HYPERVISOR_set_timer_op(
196 u64 timeout)
197 {
198 unsigned long timeout_hi = (unsigned long)(timeout>>32);
199 unsigned long timeout_lo = (unsigned long)timeout;
200 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
201 }
203 static inline int
204 HYPERVISOR_dom0_op(
205 dom0_op_t *dom0_op)
206 {
207 dom0_op->interface_version = DOM0_INTERFACE_VERSION;
208 return _hypercall1(int, dom0_op, dom0_op);
209 }
211 static inline int
212 HYPERVISOR_set_debugreg(
213 int reg, unsigned long value)
214 {
215 return _hypercall2(int, set_debugreg, reg, value);
216 }
218 static inline unsigned long
219 HYPERVISOR_get_debugreg(
220 int reg)
221 {
222 return _hypercall1(unsigned long, get_debugreg, reg);
223 }
225 static inline int
226 HYPERVISOR_update_descriptor(
227 u64 ma, u64 desc)
228 {
229 return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
230 }
232 static inline int
233 HYPERVISOR_memory_op(
234 unsigned int cmd, void *arg)
235 {
236 return _hypercall2(int, memory_op, cmd, arg);
237 }
239 static inline int
240 HYPERVISOR_multicall(
241 void *call_list, int nr_calls)
242 {
243 return _hypercall2(int, multicall, call_list, nr_calls);
244 }
246 static inline int
247 HYPERVISOR_update_va_mapping(
248 unsigned long va, pte_t new_val, unsigned long flags)
249 {
250 unsigned long pte_hi = 0;
251 #ifdef CONFIG_X86_PAE
252 pte_hi = new_val.pte_high;
253 #endif
254 return _hypercall4(int, update_va_mapping, va,
255 new_val.pte_low, pte_hi, flags);
256 }
258 static inline int
259 HYPERVISOR_event_channel_op(
260 int cmd, void *arg)
261 {
262 int rc = _hypercall2(int, event_channel_op, cmd, arg);
263 if (unlikely(rc == -ENOSYS)) {
264 struct evtchn_op op;
265 op.cmd = cmd;
266 memcpy(&op.u, arg, sizeof(op.u));
267 rc = _hypercall1(int, event_channel_op_compat, &op);
268 memcpy(arg, &op.u, sizeof(op.u));
269 }
270 return rc;
271 }
273 static inline int
274 HYPERVISOR_acm_op(
275 int cmd, void *arg)
276 {
277 return _hypercall2(int, acm_op, cmd, arg);
278 }
280 static inline int
281 HYPERVISOR_xen_version(
282 int cmd, void *arg)
283 {
284 return _hypercall2(int, xen_version, cmd, arg);
285 }
287 static inline int
288 HYPERVISOR_console_io(
289 int cmd, int count, char *str)
290 {
291 return _hypercall3(int, console_io, cmd, count, str);
292 }
294 static inline int
295 HYPERVISOR_physdev_op(
296 int cmd, void *arg)
297 {
298 int rc = _hypercall2(int, physdev_op, cmd, arg);
299 if (unlikely(rc == -ENOSYS)) {
300 struct physdev_op op;
301 op.cmd = cmd;
302 memcpy(&op.u, arg, sizeof(op.u));
303 rc = _hypercall1(int, physdev_op_compat, &op);
304 memcpy(arg, &op.u, sizeof(op.u));
305 }
306 return rc;
307 }
309 static inline int
310 HYPERVISOR_grant_table_op(
311 unsigned int cmd, void *uop, unsigned int count)
312 {
313 return _hypercall3(int, grant_table_op, cmd, uop, count);
314 }
316 static inline int
317 HYPERVISOR_update_va_mapping_otherdomain(
318 unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
319 {
320 unsigned long pte_hi = 0;
321 #ifdef CONFIG_X86_PAE
322 pte_hi = new_val.pte_high;
323 #endif
324 return _hypercall5(int, update_va_mapping_otherdomain, va,
325 new_val.pte_low, pte_hi, flags, domid);
326 }
328 static inline int
329 HYPERVISOR_vm_assist(
330 unsigned int cmd, unsigned int type)
331 {
332 return _hypercall2(int, vm_assist, cmd, type);
333 }
335 static inline int
336 HYPERVISOR_vcpu_op(
337 int cmd, int vcpuid, void *extra_args)
338 {
339 return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
340 }
342 static inline int
343 HYPERVISOR_suspend(
344 unsigned long srec)
345 {
346 struct sched_shutdown sched_shutdown = {
347 .reason = SHUTDOWN_suspend
348 };
350 int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
351 &sched_shutdown, srec);
353 if (rc == -ENOSYS)
354 rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
355 SHUTDOWN_suspend, srec);
357 return rc;
358 }
360 static inline int
361 HYPERVISOR_nmi_op(
362 unsigned long op, void *arg)
363 {
364 return _hypercall2(int, nmi_op, op, arg);
365 }
367 static inline unsigned long
368 HYPERVISOR_hvm_op(
369 int op, void *arg)
370 {
371 return _hypercall2(unsigned long, hvm_op, op, arg);
372 }
374 static inline int
375 HYPERVISOR_callback_op(
376 int cmd, void *arg)
377 {
378 return _hypercall2(int, callback_op, cmd, arg);
379 }
381 static inline int
382 HYPERVISOR_xenoprof_op(
383 int op, void *arg)
384 {
385 return _hypercall2(int, xenoprof_op, op, arg);
386 }
389 #endif /* __HYPERCALL_H__ */