[CRIU] [PATCH 2/2] headers: Move in task-size.h
Cyrill Gorcunov
gorcunov at openvz.org
Tue Oct 25 12:15:43 PDT 2016
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/arch/aarch64/include/asm/types.h | 23 +--------------------
criu/arch/arm/include/asm/types.h | 23 +--------------------
criu/arch/ppc64/include/asm/types.h | 11 +---------
criu/arch/x86/include/asm/types.h | 13 +-----------
criu/include/task-size.h | 4 ++++
include/common/arch/aarch64/asm/task-size.h | 30 ++++++++++++++++++++++++++++
include/common/arch/arm/asm/task-size.h | 31 +++++++++++++++++++++++++++++
include/common/arch/ppc64/asm/task-size.h | 14 +++++++++++++
include/common/arch/x86/asm/task-size.h | 18 +++++++++++++++++
include/common/task-size.h | 4 ++++
10 files changed, 105 insertions(+), 66 deletions(-)
create mode 100644 criu/include/task-size.h
create mode 100644 include/common/arch/aarch64/asm/task-size.h
create mode 100644 include/common/arch/arm/asm/task-size.h
create mode 100644 include/common/arch/ppc64/asm/task-size.h
create mode 100644 include/common/arch/x86/asm/task-size.h
create mode 100644 include/common/task-size.h
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index d26baf4aa54f..82aecde128aa 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -8,6 +8,7 @@
#include "page.h"
#include "bitops.h"
+#include "task-size.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
@@ -32,28 +33,6 @@ typedef struct user_fpsimd_state user_fpregs_struct_t;
#define user_regs_native(pregs) true
#define core_is_compat(core) false
-/*
- * Range for task size calculated from the following Linux kernel files:
- * arch/arm64/include/asm/memory.h
- * arch/arm64/Kconfig
- *
- * TODO: handle 32 bit tasks
- */
-#define TASK_SIZE_MIN (1UL << 39)
-#define TASK_SIZE_MAX (1UL << 48)
-
-int munmap(void *addr, size_t length);
-
-static inline unsigned long task_size(void) {
- unsigned long task_size;
-
- for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
- if (munmap((void *)task_size, page_size()))
- break;
-
- return task_size;
-}
-
#define AT_VECTOR_SIZE 40
typedef UserAarch64RegsEntry UserRegsEntry;
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 806c980a02dd..09743675db68 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -7,6 +7,7 @@
#include "page.h"
#include "bitops.h"
+#include "task-size.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
@@ -69,28 +70,6 @@ struct user_vfp_exc {
#define user_regs_native(pregs) true
#define core_is_compat(core) false
-/*
- * Range for task size calculated from the following Linux kernel files:
- * arch/arm/include/asm/memory.h
- * arch/arm/Kconfig (PAGE_OFFSET values in Memory split section)
- */
-#define TASK_SIZE_MIN 0x3f000000
-#define TASK_SIZE_MAX 0xbf000000
-#define SZ_1G 0x40000000
-
-int munmap(void *addr, size_t length);
-
-static inline unsigned long task_size(void)
-{
- unsigned long task_size;
-
- for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size += SZ_1G)
- if (munmap((void *)task_size, page_size()))
- break;
-
- return task_size;
-}
-
#define AT_VECTOR_SIZE 40
typedef UserArmRegsEntry UserRegsEntry;
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index 34661bab70a8..0ada83f707f1 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -7,6 +7,7 @@
#include "page.h"
#include "bitops.h"
+#include "task-size.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
@@ -89,16 +90,6 @@ typedef uint64_t auxv_t;
/* Not used but the structure parasite_dump_thread needs a tls_t field */
typedef uint64_t tls_t;
-/*
- * Copied for the Linux kernel arch/powerpc/include/asm/processor.h
- *
- * NOTE: 32bit tasks are not supported.
- */
-#define TASK_SIZE_USER64 (0x0000400000000000UL)
-#define TASK_SIZE TASK_SIZE_USER64
-
-static inline unsigned long task_size(void) { return TASK_SIZE; }
-
static inline void *decode_pointer(uint64_t v) { return (void*)v; }
static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; }
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index 41d3b647a558..094d81e62873 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -6,6 +6,7 @@
#include "page.h"
#include "bitops.h"
+#include "task-size.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
@@ -140,18 +141,6 @@ typedef struct {
typedef struct xsave_struct user_fpregs_struct_t;
-#ifdef CONFIG_X86_64
-# define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
-#else
-/*
- * Task size may be limited to 3G but we need a
- * higher limit, because it's backward compatible.
- */
-# define TASK_SIZE (0xffffe000)
-#endif
-
-static inline unsigned long task_size(void) { return TASK_SIZE; }
-
typedef u64 auxv_t;
/*
diff --git a/criu/include/task-size.h b/criu/include/task-size.h
new file mode 100644
index 000000000000..44bea93b7711
--- /dev/null
+++ b/criu/include/task-size.h
@@ -0,0 +1,4 @@
+#ifndef __CR_INC_TASK_SIZE_H__
+#define __CR_INC_TASK_SIZE_H__
+#include "common/task-size.h"
+#endif
diff --git a/include/common/arch/aarch64/asm/task-size.h b/include/common/arch/aarch64/asm/task-size.h
new file mode 100644
index 000000000000..12808c9931c4
--- /dev/null
+++ b/include/common/arch/aarch64/asm/task-size.h
@@ -0,0 +1,30 @@
+#ifndef COMMON_ASM_TASK_SIZE_H__
+#define COMMON_ASM_TASK_SIZE_H__
+
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "common/page.h"
+
+/*
+ * Range for task size calculated from the following Linux kernel files:
+ * arch/arm64/include/asm/memory.h
+ * arch/arm64/Kconfig
+ *
+ * TODO: handle 32 bit tasks
+ */
+#define TASK_SIZE_MIN (1UL << 39)
+#define TASK_SIZE_MAX (1UL << 48)
+
+static inline unsigned long task_size(void)
+{
+ unsigned long task_size;
+
+ for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
+ if (munmap((void *)task_size, page_size()))
+ break;
+
+ return task_size;
+}
+
+#endif /* COMMON_ASM_TASK_SIZE_H__ */
diff --git a/include/common/arch/arm/asm/task-size.h b/include/common/arch/arm/asm/task-size.h
new file mode 100644
index 000000000000..eabcda0e3d75
--- /dev/null
+++ b/include/common/arch/arm/asm/task-size.h
@@ -0,0 +1,31 @@
+#ifndef COMMON_ASM_TASK_SIZE_H__
+#define COMMON_ASM_TASK_SIZE_H__
+
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "common/page.h"
+
+/*
+ * Range for task size calculated from the following Linux kernel files:
+ * arch/arm/include/asm/memory.h
+ * arch/arm/Kconfig (PAGE_OFFSET values in Memory split section)
+ */
+#define TASK_SIZE_MIN 0x3f000000
+#define TASK_SIZE_MAX 0xbf000000
+#define SZ_1G 0x40000000
+
+int munmap(void *addr, size_t length);
+
+static inline unsigned long task_size(void)
+{
+ unsigned long task_size;
+
+ for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size += SZ_1G)
+ if (munmap((void *)task_size, page_size()))
+ break;
+
+ return task_size;
+}
+
+#endif /* COMMON_ASM_TASK_SIZE_H__ */
diff --git a/include/common/arch/ppc64/asm/task-size.h b/include/common/arch/ppc64/asm/task-size.h
new file mode 100644
index 000000000000..9508f38404fe
--- /dev/null
+++ b/include/common/arch/ppc64/asm/task-size.h
@@ -0,0 +1,14 @@
+#ifndef COMMON_ASM_TASK_SIZE_H__
+#define COMMON_ASM_TASK_SIZE_H__
+
+/*
+ * Copied for the Linux kernel arch/powerpc/include/asm/processor.h
+ *
+ * NOTE: 32bit tasks are not supported.
+ */
+#define TASK_SIZE_USER64 (0x0000400000000000UL)
+#define TASK_SIZE TASK_SIZE_USER64
+
+static inline unsigned long task_size(void) { return TASK_SIZE; }
+
+#endif /* COMMON_ASM_TASK_SIZE_H__ */
diff --git a/include/common/arch/x86/asm/task-size.h b/include/common/arch/x86/asm/task-size.h
new file mode 100644
index 000000000000..5ce17544649f
--- /dev/null
+++ b/include/common/arch/x86/asm/task-size.h
@@ -0,0 +1,18 @@
+#ifndef COMMON_ASM_TASK_SIZE_H__
+#define COMMON_ASM_TASK_SIZE_H__
+
+#include "common/page.h"
+
+#ifdef CONFIG_X86_64
+# define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
+#else
+/*
+ * Task size may be limited to 3G but we need a
+ * higher limit, because it's backward compatible.
+ */
+# define TASK_SIZE (0xffffe000)
+#endif
+
+static inline unsigned long task_size(void) { return TASK_SIZE; }
+
+#endif /* COMMON_ASM_TASK_SIZE_H__ */
diff --git a/include/common/task-size.h b/include/common/task-size.h
new file mode 100644
index 000000000000..0d1565d4cc4c
--- /dev/null
+++ b/include/common/task-size.h
@@ -0,0 +1,4 @@
+#ifndef COMMON_TASK_SIZE_H__
+#define COMMON_TASK_SIZE_H__
+#include "common/asm/task-size.h"
+#endif
--
2.7.4
More information about the CRIU
mailing list