@@ -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;
@@ -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;
@@ -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"
@@ -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
@@ -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(®s, ax)
#define REG_IP(regs) get_user_reg(®s, ip)
#define REG_SYSCALL_NR(regs) get_user_reg(®s, orig_ax)
@@ -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__ */
@@ -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__ */
@@ -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__ */
@@ -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__ */
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@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(-)