diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-10-17 16:43:51 +0100 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-10-17 16:43:51 +0100 |
commit | 1ab8784d69076c8bb21cef2f0529e3ebebbc3606 (patch) | |
tree | a225ad19f0adc8819d603d261a1b3a55487499ea /xen/include/asm-arm/guest_access.h | |
parent | 4f3c473d51d1c05bb08fecedfcf257d1a667bc5c (diff) | |
download | xen-1ab8784d69076c8bb21cef2f0529e3ebebbc3606.tar.gz xen-1ab8784d69076c8bb21cef2f0529e3ebebbc3606.tar.bz2 xen-1ab8784d69076c8bb21cef2f0529e3ebebbc3606.zip |
xen: introduce XEN_GUEST_HANDLE_PARAM
XEN_GUEST_HANDLE_PARAM is going to be used to distinguish guest pointers
stored in memory from guest pointers as hypercall parameters.
guest_handle_* macros default to XEN_GUEST_HANDLE_PARAM as return type.
Two new guest_handle_to_param and guest_handle_from_param macros are
introduced to do conversions.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'xen/include/asm-arm/guest_access.h')
-rw-r--r-- | xen/include/asm-arm/guest_access.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xen/include/asm-arm/guest_access.h b/xen/include/asm-arm/guest_access.h index 0fceae6a01..56862178e5 100644 --- a/xen/include/asm-arm/guest_access.h +++ b/xen/include/asm-arm/guest_access.h @@ -27,16 +27,40 @@ unsigned long raw_clear_guest(void *to, unsigned len); #define guest_handle_add_offset(hnd, nr) ((hnd).p += (nr)) #define guest_handle_subtract_offset(hnd, nr) ((hnd).p -= (nr)) -/* Cast a guest handle to the specified type of handle. */ +/* Cast a guest handle (either XEN_GUEST_HANDLE or XEN_GUEST_HANDLE_PARAM) + * to the specified type of XEN_GUEST_HANDLE_PARAM. */ #define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ - (XEN_GUEST_HANDLE(type)) { _x }; \ + (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \ +}) + +/* Cast a XEN_GUEST_HANDLE to XEN_GUEST_HANDLE_PARAM */ +#define guest_handle_to_param(hnd, type) ({ \ + typeof((hnd).p) _x = (hnd).p; \ + XEN_GUEST_HANDLE_PARAM(type) _y = { _x }; \ + /* type checking: make sure that the pointers inside \ + * XEN_GUEST_HANDLE and XEN_GUEST_HANDLE_PARAM are of \ + * the same type, then return hnd */ \ + (void)(&_x == &_y.p); \ + _y; \ +}) + + +/* Cast a XEN_GUEST_HANDLE_PARAM to XEN_GUEST_HANDLE */ +#define guest_handle_from_param(hnd, type) ({ \ + typeof((hnd).p) _x = (hnd).p; \ + XEN_GUEST_HANDLE(type) _y = { _x }; \ + /* type checking: make sure that the pointers inside \ + * XEN_GUEST_HANDLE and XEN_GUEST_HANDLE_PARAM are of \ + * the same type, then return hnd */ \ + (void)(&_x == &_y.p); \ + _y; \ }) #define guest_handle_from_ptr(ptr, type) \ - ((XEN_GUEST_HANDLE(type)) { (type *)ptr }) + ((XEN_GUEST_HANDLE_PARAM(type)) { (type *)ptr }) #define const_guest_handle_from_ptr(ptr, type) \ - ((XEN_GUEST_HANDLE(const_##type)) { (const type *)ptr }) + ((XEN_GUEST_HANDLE_PARAM(const_##type)) { (const type *)ptr }) /* * Copy an array of objects to guest context via a guest handle, |