aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xg_private.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-04-09 16:31:16 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-04-09 16:31:16 +0100
commit43650c346e2a5be53e83749e0be388697cf9994e (patch)
tree75a365ba8fbb8e43b2464425eed224bc950e32ab /tools/libxc/xg_private.h
parent9e4828ca8b5d6e39023f8cf580b4446a19cc1dcd (diff)
downloadxen-43650c346e2a5be53e83749e0be388697cf9994e.tar.gz
xen-43650c346e2a5be53e83749e0be388697cf9994e.tar.bz2
xen-43650c346e2a5be53e83749e0be388697cf9994e.zip
save/restore: Use page-aligned allocations for hypercall args that are
mlock()ed across other hypercall invocations, to avoid aliasing with other hypercall arguments, causing spurious unlocking. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Diffstat (limited to 'tools/libxc/xg_private.h')
-rw-r--r--tools/libxc/xg_private.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index 2ed3f55849..2b863f7b74 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <malloc.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -176,4 +177,21 @@ int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
domid_t dom);
+/* Grrr portability */
+static inline void *xg_memalign(size_t alignment, size_t size)
+{
+#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
+ int ret;
+ void *ptr;
+ ret = posix_memalign(&ptr, alignment, size);
+ if (ret != 0)
+ return NULL;
+ return ptr;
+#elif defined(_BSD)
+ return valloc(size);
+#else
+ return memalign(alignment, size);
+#endif
+}
+
#endif /* XG_PRIVATE_H */