[CRIU] [PATCH 1/6 v3] headers: Move task_size helper into common/page.h

Cyrill Gorcunov gorcunov at gmail.com
Thu Nov 17 23:49:08 PST 2016


It's page based for some arch so looks like a proper
place. In kernel it lives in processor.h fwiw.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 .../aarch64/src/lib/include/uapi/asm/infect-types.h | 21 ---------------------
 .../arm/src/lib/include/uapi/asm/infect-types.h     | 21 ---------------------
 compel/arch/arm/src/lib/infect.c                    |  1 +
 .../ppc64/src/lib/include/uapi/asm/infect-types.h   | 10 ----------
 .../x86/src/lib/include/uapi/asm/infect-types.h     | 13 -------------
 include/common/arch/aarch64/asm/page.h              | 21 +++++++++++++++++++++
 include/common/arch/arm/asm/page.h                  | 21 +++++++++++++++++++++
 include/common/arch/ppc64/asm/page.h                | 10 ++++++++++
 include/common/arch/x86/asm/page.h                  | 12 ++++++++++++
 9 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h b/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h
index 7bc195b14d92..8a3bd87aa280 100644
--- a/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h
+++ b/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h
@@ -5,7 +5,6 @@
 #include <signal.h>
 #include <sys/mman.h>
 #include <asm/ptrace.h>
-#include "common/page.h"
 
 #define SIGMAX			64
 #define SIGMAX_OLD		31
@@ -25,26 +24,6 @@ typedef struct user_fpsimd_state	user_fpregs_struct_t;
 
 #define user_regs_native(pregs)		true
 
-/*
- * 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;
-}
-
 #define AT_VECTOR_SIZE 40
 
 typedef uint64_t auxv_t;
diff --git a/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h b/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h
index 1df9f6836069..79c0b44d6e7d 100644
--- a/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h
+++ b/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h
@@ -3,7 +3,6 @@
 
 #include <stdint.h>
 #include <sys/mman.h>
-#include "common/page.h"
 
 #define SIGMAX			64
 #define SIGMAX_OLD		31
@@ -59,26 +58,6 @@ struct user_vfp_exc {
 
 #define user_regs_native(pregs)	true
 
-/*
- * 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
-
-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 uint32_t auxv_t;
diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c
index b452392113b0..fc323bb1ac51 100644
--- a/compel/arch/arm/src/lib/infect.c
+++ b/compel/arch/arm/src/lib/infect.c
@@ -3,6 +3,7 @@
 #include <compel/plugins/std/syscall-codes.h>
 #include <compel/asm/processor-flags.h>
 #include "uapi/compel/asm/infect-types.h"
+#include "common/page.h"
 #include "log.h"
 #include "errno.h"
 #include "infect.h"
diff --git a/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h b/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h
index 182c1fde7319..39ad12318a2c 100644
--- a/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h
+++ b/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h
@@ -93,16 +93,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; }
-
 #define ARCH_SI_TRAP TRAP_BRKPT
 
 #define __NR(syscall, compat)	__NR_##syscall
diff --git a/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h b/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h
index dc574c304733..6f3093773e16 100644
--- a/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h
+++ b/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h
@@ -4,7 +4,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <signal.h>
-#include "common/page.h"
 #include <compel/plugins/std/asm/syscall-types.h>
 
 #define SIGMAX			64
@@ -109,18 +108,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; }
-
 #define REG_RES(regs)		get_user_reg(&regs, ax)
 #define REG_IP(regs)		get_user_reg(&regs, ip)
 #define REG_SYSCALL_NR(regs)	get_user_reg(&regs, orig_ax)
diff --git a/include/common/arch/aarch64/asm/page.h b/include/common/arch/aarch64/asm/page.h
index de1fe5428c50..aba563ba2cb0 100644
--- a/include/common/arch/aarch64/asm/page.h
+++ b/include/common/arch/aarch64/asm/page.h
@@ -2,6 +2,7 @@
 #define __CR_ASM_PAGE_H__
 
 #include <unistd.h>
+#include <sys/mman.h>
 
 #ifndef PAGE_SHIFT
 # define PAGE_SHIFT	12
@@ -18,4 +19,24 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	sysconf(_SC_PAGESIZE)
 
+/*
+ * 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 /* __CR_ASM_PAGE_H__ */
diff --git a/include/common/arch/arm/asm/page.h b/include/common/arch/arm/asm/page.h
index 134835556c62..8d89415198c3 100644
--- a/include/common/arch/arm/asm/page.h
+++ b/include/common/arch/arm/asm/page.h
@@ -1,6 +1,8 @@
 #ifndef __CR_ASM_PAGE_H__
 #define __CR_ASM_PAGE_H__
 
+#include <sys/mman.h>
+
 #ifndef PAGE_SHIFT
 # define PAGE_SHIFT	12
 #endif
@@ -15,5 +17,24 @@
 
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	PAGE_SIZE
+/*
+ * 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
+
+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 /* __CR_ASM_PAGE_H__ */
diff --git a/include/common/arch/ppc64/asm/page.h b/include/common/arch/ppc64/asm/page.h
index 9d10455f1c47..191135699a32 100644
--- a/include/common/arch/ppc64/asm/page.h
+++ b/include/common/arch/ppc64/asm/page.h
@@ -22,4 +22,14 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	sysconf(_SC_PAGESIZE)
 
+/*
+ * 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 /* __CR_ASM_PAGE_H__ */
diff --git a/include/common/arch/x86/asm/page.h b/include/common/arch/x86/asm/page.h
index 134835556c62..83fb4e75c59c 100644
--- a/include/common/arch/x86/asm/page.h
+++ b/include/common/arch/x86/asm/page.h
@@ -16,4 +16,16 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	PAGE_SIZE
 
+#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 /* __CR_ASM_PAGE_H__ */
-- 
2.7.4



More information about the CRIU mailing list