ia64/xen-unstable

view linux-2.6-xen-sparse/include/asm-ia64/hypercall.h @ 12794:9787cb7262e8

[IA64] changed foreign domain page mapping semantic.

x86 foreign HVM domain page mapping semantic was changed to use gmfn
instead mfn. It applies to domains with auto_translated_mode enabled,
and all ia64 domains enable auto_translated_mode. This patch changes
ia64 foreign domain page mapping to use gmfn and fixes ia64 domU buidler.
However this patch breaks domain save/restore/dump-core.
They should also be fixed-up

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Tue Dec 05 10:59:32 2006 -0700 (2006-12-05)
parents 52e6bf6dc744
children 01ea554f1c5e
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 #ifndef __HYPERVISOR_H__
37 # error "please don't include this file directly"
38 #endif
40 #include <asm/xen/xcom_hcall.h>
41 struct xencomm_handle;
43 /*
44 * Assembler stubs for hyper-calls.
45 */
47 #define _hypercall0(type, name) \
48 ({ \
49 long __res; \
50 __asm__ __volatile__ (";;\n" \
51 "mov r2=%1\n" \
52 "break 0x1000 ;;\n" \
53 "mov %0=r8 ;;\n" \
54 : "=r" (__res) \
55 : "J" (__HYPERVISOR_##name) \
56 : "r2","r8", \
57 "memory" ); \
58 (type)__res; \
59 })
61 #define _hypercall1(type, name, a1) \
62 ({ \
63 long __res; \
64 __asm__ __volatile__ (";;\n" \
65 "mov r14=%2\n" \
66 "mov r2=%1\n" \
67 "break 0x1000 ;;\n" \
68 "mov %0=r8 ;;\n" \
69 : "=r" (__res) \
70 : "J" (__HYPERVISOR_##name), \
71 "rI" ((unsigned long)(a1)) \
72 : "r14","r2","r8", \
73 "memory" ); \
74 (type)__res; \
75 })
77 #define _hypercall2(type, name, a1, a2) \
78 ({ \
79 long __res; \
80 __asm__ __volatile__ (";;\n" \
81 "mov r14=%2\n" \
82 "mov r15=%3\n" \
83 "mov r2=%1\n" \
84 "break 0x1000 ;;\n" \
85 "mov %0=r8 ;;\n" \
86 : "=r" (__res) \
87 : "J" (__HYPERVISOR_##name), \
88 "rI" ((unsigned long)(a1)), \
89 "rI" ((unsigned long)(a2)) \
90 : "r14","r15","r2","r8", \
91 "memory" ); \
92 (type)__res; \
93 })
95 #define _hypercall3(type, name, a1, a2, a3) \
96 ({ \
97 long __res; \
98 __asm__ __volatile__ (";;\n" \
99 "mov r14=%2\n" \
100 "mov r15=%3\n" \
101 "mov r16=%4\n" \
102 "mov r2=%1\n" \
103 "break 0x1000 ;;\n" \
104 "mov %0=r8 ;;\n" \
105 : "=r" (__res) \
106 : "J" (__HYPERVISOR_##name), \
107 "rI" ((unsigned long)(a1)), \
108 "rI" ((unsigned long)(a2)), \
109 "rI" ((unsigned long)(a3)) \
110 : "r14","r15","r16","r2","r8", \
111 "memory" ); \
112 (type)__res; \
113 })
115 #define _hypercall4(type, name, a1, a2, a3, a4) \
116 ({ \
117 long __res; \
118 __asm__ __volatile__ (";;\n" \
119 "mov r14=%2\n" \
120 "mov r15=%3\n" \
121 "mov r16=%4\n" \
122 "mov r17=%5\n" \
123 "mov r2=%1\n" \
124 "break 0x1000 ;;\n" \
125 "mov %0=r8 ;;\n" \
126 : "=r" (__res) \
127 : "J" (__HYPERVISOR_##name), \
128 "rI" ((unsigned long)(a1)), \
129 "rI" ((unsigned long)(a2)), \
130 "rI" ((unsigned long)(a3)), \
131 "rI" ((unsigned long)(a4)) \
132 : "r14","r15","r16","r2","r8", \
133 "r17","memory" ); \
134 (type)__res; \
135 })
137 #define _hypercall5(type, name, a1, a2, a3, a4, a5) \
138 ({ \
139 long __res; \
140 __asm__ __volatile__ (";;\n" \
141 "mov r14=%2\n" \
142 "mov r15=%3\n" \
143 "mov r16=%4\n" \
144 "mov r17=%5\n" \
145 "mov r18=%6\n" \
146 "mov r2=%1\n" \
147 "break 0x1000 ;;\n" \
148 "mov %0=r8 ;;\n" \
149 : "=r" (__res) \
150 : "J" (__HYPERVISOR_##name), \
151 "rI" ((unsigned long)(a1)), \
152 "rI" ((unsigned long)(a2)), \
153 "rI" ((unsigned long)(a3)), \
154 "rI" ((unsigned long)(a4)), \
155 "rI" ((unsigned long)(a5)) \
156 : "r14","r15","r16","r2","r8", \
157 "r17","r18","memory" ); \
158 (type)__res; \
159 })
162 static inline int
163 xencomm_arch_hypercall_sched_op(int cmd, struct xencomm_handle *arg)
164 {
165 return _hypercall2(int, sched_op, cmd, arg);
166 }
168 static inline long
169 HYPERVISOR_set_timer_op(u64 timeout)
170 {
171 unsigned long timeout_hi = (unsigned long)(timeout >> 32);
172 unsigned long timeout_lo = (unsigned long)timeout;
173 return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
174 }
176 static inline int
177 xencomm_arch_hypercall_dom0_op(struct xencomm_handle *op)
178 {
179 return _hypercall1(int, dom0_op, op);
180 }
182 static inline int
183 xencomm_arch_hypercall_sysctl(struct xencomm_handle *op)
184 {
185 return _hypercall1(int, sysctl, op);
186 }
188 static inline int
189 xencomm_arch_hypercall_domctl(struct xencomm_handle *op)
190 {
191 return _hypercall1(int, domctl, op);
192 }
194 static inline int
195 xencomm_arch_hypercall_multicall(struct xencomm_handle *call_list,
196 int nr_calls)
197 {
198 return _hypercall2(int, multicall, call_list, nr_calls);
199 }
201 static inline int
202 xencomm_arch_hypercall_memory_op(unsigned int cmd, struct xencomm_handle *arg)
203 {
204 return _hypercall2(int, memory_op, cmd, arg);
205 }
207 static inline int
208 xencomm_arch_hypercall_event_channel_op(int cmd, struct xencomm_handle *arg)
209 {
210 return _hypercall2(int, event_channel_op, cmd, arg);
211 }
213 static inline int
214 xencomm_arch_hypercall_acm_op(unsigned int cmd, struct xencomm_handle *arg)
215 {
216 return _hypercall2(int, acm_op, cmd, arg);
217 }
219 static inline int
220 xencomm_arch_hypercall_xen_version(int cmd, struct xencomm_handle *arg)
221 {
222 return _hypercall2(int, xen_version, cmd, arg);
223 }
225 static inline int
226 xencomm_arch_hypercall_console_io(int cmd, int count,
227 struct xencomm_handle *str)
228 {
229 return _hypercall3(int, console_io, cmd, count, str);
230 }
232 static inline int
233 xencomm_arch_hypercall_physdev_op(int cmd, struct xencomm_handle *arg)
234 {
235 return _hypercall2(int, physdev_op, cmd, arg);
236 }
238 static inline int
239 xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
240 struct xencomm_handle *uop,
241 unsigned int count)
242 {
243 return _hypercall3(int, grant_table_op, cmd, uop, count);
244 }
246 int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
248 extern int xencomm_arch_hypercall_suspend(struct xencomm_handle *arg);
250 static inline int
251 xencomm_arch_hypercall_callback_op(int cmd, struct xencomm_handle *arg)
252 {
253 return _hypercall2(int, callback_op, cmd, arg);
254 }
256 static inline unsigned long
257 xencomm_arch_hypercall_hvm_op(int cmd, void *arg)
258 {
259 return _hypercall2(unsigned long, hvm_op, cmd, arg);
260 }
262 static inline int
263 HYPERVISOR_physdev_op(int cmd, void *arg)
264 {
265 switch (cmd) {
266 case PHYSDEVOP_eoi:
267 return _hypercall1(int, ia64_fast_eoi,
268 ((struct physdev_eoi *)arg)->irq);
269 default:
270 return xencomm_hypercall_physdev_op(cmd, arg);
271 }
272 }
274 static inline int
275 xencomm_arch_hypercall_xenoprof_op(int op, struct xencomm_handle *arg)
276 {
277 return _hypercall2(int, xenoprof_op, op, arg);
278 }
280 extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
281 static inline void exit_idle(void) {}
282 #define do_IRQ(irq, regs) ({ \
283 irq_enter(); \
284 __do_IRQ((irq), (regs)); \
285 irq_exit(); \
286 })
288 #include <linux/err.h>
289 #ifdef CONFIG_XEN
290 #include <asm/xen/privop.h>
291 #endif /* CONFIG_XEN */
292 #ifdef HAVE_XEN_PLATFORM_COMPAT_H
293 #include <xen/platform-compat.h>
294 #endif
296 static inline unsigned long
297 __HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
298 {
299 return _hypercall3(unsigned long, ia64_dom0vp_op,
300 IA64_DOM0VP_ioremap, ioaddr, size);
301 }
303 static inline unsigned long
304 HYPERVISOR_ioremap(unsigned long ioaddr, unsigned long size)
305 {
306 unsigned long ret = ioaddr;
307 if (is_running_on_xen()) {
308 ret = __HYPERVISOR_ioremap(ioaddr, size);
309 if (unlikely(ret == -ENOSYS))
310 panic("hypercall %s failed with %ld. "
311 "Please check Xen and Linux config mismatch\n",
312 __func__, -ret);
313 else if (unlikely(IS_ERR_VALUE(ret)))
314 ret = ioaddr;
315 }
316 return ret;
317 }
319 static inline unsigned long
320 __HYPERVISOR_phystomach(unsigned long gpfn)
321 {
322 return _hypercall2(unsigned long, ia64_dom0vp_op,
323 IA64_DOM0VP_phystomach, gpfn);
324 }
326 static inline unsigned long
327 HYPERVISOR_phystomach(unsigned long gpfn)
328 {
329 unsigned long ret = gpfn;
330 if (is_running_on_xen()) {
331 ret = __HYPERVISOR_phystomach(gpfn);
332 }
333 return ret;
334 }
336 static inline unsigned long
337 __HYPERVISOR_machtophys(unsigned long mfn)
338 {
339 return _hypercall2(unsigned long, ia64_dom0vp_op,
340 IA64_DOM0VP_machtophys, mfn);
341 }
343 static inline unsigned long
344 HYPERVISOR_machtophys(unsigned long mfn)
345 {
346 unsigned long ret = mfn;
347 if (is_running_on_xen()) {
348 ret = __HYPERVISOR_machtophys(mfn);
349 }
350 return ret;
351 }
353 static inline unsigned long
354 __HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
355 {
356 return _hypercall3(unsigned long, ia64_dom0vp_op,
357 IA64_DOM0VP_zap_physmap, gpfn, extent_order);
358 }
360 static inline unsigned long
361 HYPERVISOR_zap_physmap(unsigned long gpfn, unsigned int extent_order)
362 {
363 unsigned long ret = 0;
364 if (is_running_on_xen()) {
365 ret = __HYPERVISOR_zap_physmap(gpfn, extent_order);
366 }
367 return ret;
368 }
370 static inline unsigned long
371 __HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
372 unsigned long flags, domid_t domid)
373 {
374 return _hypercall5(unsigned long, ia64_dom0vp_op,
375 IA64_DOM0VP_add_physmap, gpfn, mfn, flags, domid);
376 }
378 static inline unsigned long
379 HYPERVISOR_add_physmap(unsigned long gpfn, unsigned long mfn,
380 unsigned long flags, domid_t domid)
381 {
382 unsigned long ret = 0;
383 BUG_ON(!is_running_on_xen());//XXX
384 if (is_running_on_xen()) {
385 ret = __HYPERVISOR_add_physmap(gpfn, mfn, flags, domid);
386 }
387 return ret;
388 }
390 static inline unsigned long
391 __HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
392 unsigned long flags, domid_t domid)
393 {
394 return _hypercall5(unsigned long, ia64_dom0vp_op,
395 IA64_DOM0VP_add_physmap_with_gmfn,
396 gpfn, gmfn, flags, domid);
397 }
399 static inline unsigned long
400 HYPERVISOR_add_physmap_with_gmfn(unsigned long gpfn, unsigned long gmfn,
401 unsigned long flags, domid_t domid)
402 {
403 unsigned long ret = 0;
404 BUG_ON(!is_running_on_xen());//XXX
405 if (is_running_on_xen()) {
406 ret = __HYPERVISOR_add_physmap_with_gmfn(gpfn, gmfn,
407 flags, domid);
408 }
409 return ret;
410 }
412 #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
413 static inline unsigned long
414 HYPERVISOR_expose_p2m(unsigned long conv_start_gpfn,
415 unsigned long assign_start_gpfn,
416 unsigned long expose_size, unsigned long granule_pfn)
417 {
418 return _hypercall5(unsigned long, ia64_dom0vp_op,
419 IA64_DOM0VP_expose_p2m, conv_start_gpfn,
420 assign_start_gpfn, expose_size, granule_pfn);
421 }
422 #endif
424 static inline int
425 xencomm_arch_hypercall_perfmon_op(unsigned long cmd,
426 struct xencomm_handle *arg,
427 unsigned long count)
428 {
429 return _hypercall4(int, ia64_dom0vp_op,
430 IA64_DOM0VP_perfmon, cmd, arg, count);
431 }
433 // for balloon driver
434 #define HYPERVISOR_update_va_mapping(va, new_val, flags) (0)
436 /* Use xencomm to do hypercalls. */
437 #ifdef MODULE
438 #define HYPERVISOR_sched_op xencomm_mini_hypercall_sched_op
439 #define HYPERVISOR_event_channel_op xencomm_mini_hypercall_event_channel_op
440 #define HYPERVISOR_callback_op xencomm_mini_hypercall_callback_op
441 #define HYPERVISOR_multicall xencomm_mini_hypercall_multicall
442 #define HYPERVISOR_xen_version xencomm_mini_hypercall_xen_version
443 #define HYPERVISOR_console_io xencomm_mini_hypercall_console_io
444 #define HYPERVISOR_hvm_op xencomm_mini_hypercall_hvm_op
445 #define HYPERVISOR_memory_op xencomm_mini_hypercall_memory_op
446 #define HYPERVISOR_xenoprof_op xencomm_mini_hypercall_xenoprof_op
447 #define HYPERVISOR_perfmon_op xencomm_mini_hypercall_perfmon_op
448 #else
449 #define HYPERVISOR_sched_op xencomm_hypercall_sched_op
450 #define HYPERVISOR_event_channel_op xencomm_hypercall_event_channel_op
451 #define HYPERVISOR_callback_op xencomm_hypercall_callback_op
452 #define HYPERVISOR_multicall xencomm_hypercall_multicall
453 #define HYPERVISOR_xen_version xencomm_hypercall_xen_version
454 #define HYPERVISOR_console_io xencomm_hypercall_console_io
455 #define HYPERVISOR_hvm_op xencomm_hypercall_hvm_op
456 #define HYPERVISOR_memory_op xencomm_hypercall_memory_op
457 #define HYPERVISOR_xenoprof_op xencomm_hypercall_xenoprof_op
458 #define HYPERVISOR_perfmon_op xencomm_hypercall_perfmon_op
459 #endif
461 #define HYPERVISOR_suspend xencomm_hypercall_suspend
463 #endif /* __HYPERCALL_H__ */