debuggers.hg

view xen/include/asm-x86/guest_access.h @ 10986:49dcd838b7df

[HVMLOADER] HVM loader initialises hypercall shim and uses
it to interrogate Xen version information. Also add support
for HVM hypercall execution on 64-bit host.

Signed-off-by: Steven Smith <ssmith@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Aug 04 20:30:12 2006 +0100 (2006-08-04)
parents bfe12b4d45d3
children b6ee084892da
line source
1 /******************************************************************************
2 * guest_access.h
3 *
4 * Copyright (c) 2006, K A Fraser
5 */
7 #ifndef __ASM_X86_GUEST_ACCESS_H__
8 #define __ASM_X86_GUEST_ACCESS_H__
10 #include <asm/uaccess.h>
11 #include <asm/hvm/support.h>
12 #include <asm/hvm/guest_access.h>
14 /* Is the guest handle a NULL reference? */
15 #define guest_handle_is_null(hnd) ((hnd).p == NULL)
17 /* Offset the given guest handle into the array it refers to. */
18 #define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr))
20 /* Cast a guest handle to the specified type of handle. */
21 #define guest_handle_cast(hnd, type) ({ \
22 type *_x = (hnd).p; \
23 (XEN_GUEST_HANDLE(type)) { _x }; \
24 })
26 #define guest_handle_from_ptr(ptr, type) \
27 ((XEN_GUEST_HANDLE(type)) { (type *)ptr })
29 /*
30 * Copy an array of objects to guest context via a guest handle,
31 * specifying an offset into the guest array.
32 */
33 #define copy_to_guest_offset(hnd, off, ptr, nr) ({ \
34 const typeof(ptr) _x = (hnd).p; \
35 const typeof(ptr) _y = (ptr); \
36 hvm_guest(current) ? \
37 copy_to_user_hvm(_x+(off), _y, sizeof(*_x)*(nr)) : \
38 copy_to_user(_x+(off), _y, sizeof(*_x)*(nr)); \
39 })
41 /*
42 * Copy an array of objects from guest context via a guest handle,
43 * specifying an offset into the guest array.
44 */
45 #define copy_from_guest_offset(ptr, hnd, off, nr) ({ \
46 const typeof(ptr) _x = (hnd).p; \
47 const typeof(ptr) _y = (ptr); \
48 hvm_guest(current) ? \
49 copy_from_user_hvm(_y, _x+(off), sizeof(*_x)*(nr)) :\
50 copy_from_user(_y, _x+(off), sizeof(*_x)*(nr)); \
51 })
53 /* Copy sub-field of a structure to guest context via a guest handle. */
54 #define copy_field_to_guest(hnd, ptr, field) ({ \
55 const typeof(&(ptr)->field) _x = &(hnd).p->field; \
56 const typeof(&(ptr)->field) _y = &(ptr)->field; \
57 hvm_guest(current) ? \
58 copy_to_user_hvm(_x, _y, sizeof(*_x)) : \
59 copy_to_user(_x, _y, sizeof(*_x)); \
60 })
62 /* Copy sub-field of a structure from guest context via a guest handle. */
63 #define copy_field_from_guest(ptr, hnd, field) ({ \
64 const typeof(&(ptr)->field) _x = &(hnd).p->field; \
65 const typeof(&(ptr)->field) _y = &(ptr)->field; \
66 hvm_guest(current) ? \
67 copy_from_user_hvm(_y, _x, sizeof(*_x)) : \
68 copy_from_user(_y, _x, sizeof(*_x)); \
69 })
71 /*
72 * Pre-validate a guest handle.
73 * Allows use of faster __copy_* functions.
74 */
75 #define guest_handle_okay(hnd, nr) \
76 (hvm_guest(current) || array_access_ok((hnd).p, (nr), sizeof(*(hnd).p)))
78 #define __copy_to_guest_offset(hnd, off, ptr, nr) ({ \
79 const typeof(ptr) _x = (hnd).p; \
80 const typeof(ptr) _y = (ptr); \
81 hvm_guest(current) ? \
82 copy_to_user_hvm(_x+(off), _y, sizeof(*_x)*(nr)) : \
83 __copy_to_user(_x+(off), _y, sizeof(*_x)*(nr)); \
84 })
86 #define __copy_from_guest_offset(ptr, hnd, off, nr) ({ \
87 const typeof(ptr) _x = (hnd).p; \
88 const typeof(ptr) _y = (ptr); \
89 hvm_guest(current) ? \
90 copy_from_user_hvm(_y, _x+(off),sizeof(*_x)*(nr)) : \
91 __copy_from_user(_y, _x+(off), sizeof(*_x)*(nr)); \
92 })
94 #define __copy_field_to_guest(hnd, ptr, field) ({ \
95 const typeof(&(ptr)->field) _x = &(hnd).p->field; \
96 const typeof(&(ptr)->field) _y = &(ptr)->field; \
97 hvm_guest(current) ? \
98 copy_to_user_hvm(_x, _y, sizeof(*_x)) : \
99 __copy_to_user(_x, _y, sizeof(*_x)); \
100 })
102 #define __copy_field_from_guest(ptr, hnd, field) ({ \
103 const typeof(&(ptr)->field) _x = &(hnd).p->field; \
104 const typeof(&(ptr)->field) _y = &(ptr)->field; \
105 hvm_guest(current) ? \
106 copy_from_user_hvm(_x, _y, sizeof(*_x)) : \
107 __copy_from_user(_y, _x, sizeof(*_x)); \
108 })
110 #endif /* __ASM_X86_GUEST_ACCESS_H__ */