[CRIU] [PATCH 32/38] compel: Wire in types.h
Cyrill Gorcunov
gorcunov at openvz.org
Tue Oct 11 09:04:22 PDT 2016
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
.../aarch64/src/lib/include/compel/asm/types.h | 55 ++++++++
compel/arch/arm/src/lib/include/compel/asm/types.h | 88 ++++++++++++
.../arch/ppc64/src/lib/include/compel/asm/types.h | 95 +++++++++++++
compel/arch/x86/src/lib/include/compel/asm/types.h | 149 +++++++++++++++++++++
criu/arch/aarch64/include/asm/types.h | 47 +------
criu/arch/arm/include/asm/types.h | 85 +-----------
criu/arch/ppc64/include/asm/types.h | 83 +-----------
criu/arch/x86/include/asm/types.h | 148 +-------------------
8 files changed, 392 insertions(+), 358 deletions(-)
create mode 100644 compel/arch/aarch64/src/lib/include/compel/asm/types.h
create mode 100644 compel/arch/arm/src/lib/include/compel/asm/types.h
create mode 100644 compel/arch/ppc64/src/lib/include/compel/asm/types.h
create mode 100644 compel/arch/x86/src/lib/include/compel/asm/types.h
diff --git a/compel/arch/aarch64/src/lib/include/compel/asm/types.h b/compel/arch/aarch64/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..31011f26187d
--- /dev/null
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/types.h
@@ -0,0 +1,55 @@
+#ifndef COMPEL_ASM_TYPES_H__
+#define COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <asm/ptrace.h>
+
+#include "compel/asm/page.h"
+#include "compel/asm/fpu.h"
+
+#define SIGMAX 64
+#define SIGMAX_OLD 31
+
+/*
+ * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
+ *
+ * A thread ARM CPU context
+ */
+
+typedef struct user_pt_regs user_regs_struct_t;
+typedef struct user_fpsimd_state user_fpregs_struct_t;
+
+#define REG_RES(r) ((uint64_t)(r).regs[0])
+#define REG_IP(r) ((uint64_t)(r).pc)
+#define REG_SYSCALL_NR(r) ((uint64_t)(r).regs[8])
+
+#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;
+typedef uint64_t tls_t;
+
+#endif /* COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/arm/src/lib/include/compel/asm/types.h b/compel/arch/arm/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..e02cd89f20ff
--- /dev/null
+++ b/compel/arch/arm/src/lib/include/compel/asm/types.h
@@ -0,0 +1,88 @@
+#ifndef COMPEL_ASM_TYPES_H__
+#define COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <sys/mman.h>
+
+#include "compel/asm/page.h"
+
+#define SIGMAX 64
+#define SIGMAX_OLD 31
+
+/*
+ * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
+ *
+ * A thread ARM CPU context
+ */
+
+typedef struct {
+ long uregs[18];
+} user_regs_struct_t;
+
+typedef struct user_vfp user_fpregs_struct_t;
+
+#define ARM_cpsr uregs[16]
+#define ARM_pc uregs[15]
+#define ARM_lr uregs[14]
+#define ARM_sp uregs[13]
+#define ARM_ip uregs[12]
+#define ARM_fp uregs[11]
+#define ARM_r10 uregs[10]
+#define ARM_r9 uregs[9]
+#define ARM_r8 uregs[8]
+#define ARM_r7 uregs[7]
+#define ARM_r6 uregs[6]
+#define ARM_r5 uregs[5]
+#define ARM_r4 uregs[4]
+#define ARM_r3 uregs[3]
+#define ARM_r2 uregs[2]
+#define ARM_r1 uregs[1]
+#define ARM_r0 uregs[0]
+#define ARM_ORIG_r0 uregs[17]
+
+
+/* Copied from arch/arm/include/asm/user.h */
+
+struct user_vfp {
+ unsigned long long fpregs[32];
+ unsigned long fpscr;
+};
+
+struct user_vfp_exc {
+ unsigned long fpexc;
+ unsigned long fpinst;
+ unsigned long fpinst2;
+};
+
+#define REG_RES(regs) ((regs).ARM_r0)
+#define REG_IP(regs) ((regs).ARM_pc)
+#define REG_SYSCALL_NR(regs) ((regs).ARM_r7)
+
+#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;
+typedef uint32_t tls_t;
+
+#endif /* COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/ppc64/src/lib/include/compel/asm/types.h b/compel/arch/ppc64/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..ae8e0b440aae
--- /dev/null
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/types.h
@@ -0,0 +1,95 @@
+#ifndef COMPEL_ASM_TYPES_H__
+#define COMPEL_ASM_TYPES_H__
+
+#include <stdbool.h>
+#include <signal.h>
+#include <stdint.h>
+
+#include "compel/asm/page.h"
+
+#define SIGMAX_OLD 31
+#define SIGMAX 64
+
+/*
+ * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
+ */
+typedef struct {
+ unsigned long gpr[32];
+ unsigned long nip;
+ unsigned long msr;
+ unsigned long orig_gpr3; /* Used for restarting system calls */
+ unsigned long ctr;
+ unsigned long link;
+ unsigned long xer;
+ unsigned long ccr;
+ unsigned long softe; /* Soft enabled/disabled */
+ unsigned long trap; /* Reason for being here */
+ /*
+ * N.B. for critical exceptions on 4xx, the dar and dsisr
+ * fields are overloaded to hold srr0 and srr1.
+ */
+ unsigned long dar; /* Fault registers */
+ unsigned long dsisr; /* on 4xx/Book-E used for ESR */
+ unsigned long result; /* Result of a system call */
+} user_regs_struct_t;
+
+#define NVSXREG 32
+
+typedef struct {
+ uint64_t fpregs[NFPREG];
+ /*
+ * The kernel returns :
+ * 32 Vector registers (128bit)
+ * VSCR (32bit) stored in a 128bit entry (odd)
+ * VRSAVE (32bit) store at the end.
+ *
+ * Kernel setup_sigcontext's comment mentions:
+ * "Userland shall check AT_HWCAP to know whether it can rely on the
+ * v_regs pointer or not"
+ */
+ unsigned char vrregs[(NVRREG-1) * 16 + 4];
+ uint64_t vsregs[NVSXREG];
+
+ int flags;
+ struct tm_regs {
+ struct {
+ uint64_t tfhar, texasr, tfiar;
+ } tm_spr_regs;
+ user_regs_struct_t regs;
+ uint64_t fpregs[NFPREG], vmxregs[34][2], vsxregs[32];
+ } tm;
+} user_fpregs_struct_t;
+
+
+#define REG_RES(regs) ((u64)(regs).gpr[3])
+#define REG_IP(regs) ((u64)(regs).nip)
+#define REG_SYSCALL_NR(regs) ((u64)(regs).gpr[0])
+
+#define user_regs_native(pregs) true
+
+/*
+ * Copied from the following kernel header files :
+ * include/linux/auxvec.h
+ * arch/powerpc/include/uapi/asm/auxvec.h
+ * include/linux/mm_types.h
+ */
+#define AT_VECTOR_SIZE_BASE 20
+#define AT_VECTOR_SIZE_ARCH 6
+#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
+
+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; }
+
+#endif /* COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/x86/src/lib/include/compel/asm/types.h b/compel/arch/x86/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..2d25eef1ae2d
--- /dev/null
+++ b/compel/arch/x86/src/lib/include/compel/asm/types.h
@@ -0,0 +1,149 @@
+#ifndef COMPEL_ASM_TYPES_H__
+#define COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "compel/asm/page.h"
+#include "compel/asm/fpu.h"
+
+#include "bug.h"
+
+#define SIGMAX 64
+#define SIGMAX_OLD 31
+
+typedef struct {
+ uint64_t r15;
+ uint64_t r14;
+ uint64_t r13;
+ uint64_t r12;
+ uint64_t bp;
+ uint64_t bx;
+ uint64_t r11;
+ uint64_t r10;
+ uint64_t r9;
+ uint64_t r8;
+ uint64_t ax;
+ uint64_t cx;
+ uint64_t dx;
+ uint64_t si;
+ uint64_t di;
+ uint64_t orig_ax;
+ uint64_t ip;
+ uint64_t cs;
+ uint64_t flags;
+ uint64_t sp;
+ uint64_t ss;
+ uint64_t fs_base;
+ uint64_t gs_base;
+ uint64_t ds;
+ uint64_t es;
+ uint64_t fs;
+ uint64_t gs;
+} user_regs_struct64;
+
+typedef struct {
+ uint32_t bx;
+ uint32_t cx;
+ uint32_t dx;
+ uint32_t si;
+ uint32_t di;
+ uint32_t bp;
+ uint32_t ax;
+ uint32_t ds;
+ uint32_t es;
+ uint32_t fs;
+ uint32_t gs;
+ uint32_t orig_ax;
+ uint32_t ip;
+ uint32_t cs;
+ uint32_t flags;
+ uint32_t sp;
+ uint32_t ss;
+} user_regs_struct32;
+
+#ifdef CONFIG_X86_64
+/*
+ * To be sure that we rely on inited reg->__is_native, this member
+ * is (short int) instead of initial (bool). The right way to
+ * check if regs are native or compat is to use user_regs_native() macro.
+ * This should cost nothing, as *usually* sizeof(bool) == sizeof(short)
+ */
+typedef struct {
+ union {
+ user_regs_struct64 native;
+ user_regs_struct32 compat;
+ };
+ short __is_native; /* use user_regs_native macro to check it */
+} user_regs_struct_t;
+
+#define NATIVE_MAGIC 0x0A
+#define COMPAT_MAGIC 0x0C
+
+static inline bool user_regs_native(user_regs_struct_t *pregs)
+{
+ BUG_ON(pregs->__is_native != NATIVE_MAGIC &&
+ pregs->__is_native != COMPAT_MAGIC);
+ return pregs->__is_native == NATIVE_MAGIC;
+}
+
+#define get_user_reg(pregs, name) \
+ ((user_regs_native(pregs)) ? \
+ ((pregs)->native.name) : \
+ ((pregs)->compat.name))
+
+#define set_user_reg(pregs, name, val) \
+ ((user_regs_native(pregs)) ? \
+ ((pregs)->native.name = (val)) : \
+ ((pregs)->compat.name = (val)))
+
+#else /* CONFIG_X86_64 */
+
+typedef struct {
+ union {
+ user_regs_struct32 native;
+ };
+} user_regs_struct_t;
+
+#define user_regs_native(pregs) true
+#define get_user_reg(pregs, name) ((pregs)->native.name)
+#define set_user_reg(pregs, name, val) ((pregs)->native.name = val)
+
+#endif /* CONFIG_X86_64 */
+
+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)
+
+typedef uint64_t auxv_t;
+
+/*
+ * Linux preserves three TLS segments in GDT.
+ * Offsets in GDT differ between 32-bit and 64-bit machines.
+ * For 64-bit x86 those GDT offsets are the same
+ * for native and compat tasks.
+ */
+#define GDT_ENTRY_TLS_MIN 12
+#define GDT_ENTRY_TLS_MAX 14
+#define GDT_ENTRY_TLS_NUM 3
+typedef struct {
+ user_desc_t desc[GDT_ENTRY_TLS_NUM];
+} tls_t;
+
+#define AT_VECTOR_SIZE 44
+
+#endif /* COMPEL_ASM_TYPES_H__ */
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index d0823dde8d9d..65b675f6996f 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -6,56 +6,14 @@
#include <asm/ptrace.h>
#include "images/core.pb-c.h"
-#include "compel/asm/page.h"
#include "asm/bitops.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
+#include "compel/asm/types.h"
-#define SIGMAX 64
-#define SIGMAX_OLD 31
-
-/*
- * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
- *
- * A thread ARM CPU context
- */
-
-typedef struct user_pt_regs user_regs_struct_t;
-typedef struct user_fpsimd_state user_fpregs_struct_t;
-
-
-#define REG_RES(r) ((u64)(r).regs[0])
-#define REG_IP(r) ((u64)(r).pc)
-#define REG_SYSCALL_NR(r) ((u64)(r).regs[8])
-
-#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;
#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__AARCH64
@@ -64,9 +22,6 @@ typedef UserAarch64RegsEntry UserRegsEntry;
#define TI_SP(core) ((core)->ti_aarch64->gpregs->sp)
-typedef uint64_t auxv_t;
-typedef uint64_t tls_t;
-
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/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 6ca09ff5b1a9..3aeb25f544c3 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -5,94 +5,14 @@
#include <signal.h>
#include "images/core.pb-c.h"
-#include "compel/asm/page.h"
#include "asm/bitops.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
+#include "compel/asm/types.h"
-#define SIGMAX 64
-#define SIGMAX_OLD 31
-
-#define MAJOR(dev) ((dev)>>8)
-#define MINOR(dev) ((dev) & 0xff)
-
-/*
- * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
- *
- * A thread ARM CPU context
- */
-
-typedef struct {
- long uregs[18];
-} user_regs_struct_t;
-
-typedef struct user_vfp user_fpregs_struct_t;
-
-#define ARM_cpsr uregs[16]
-#define ARM_pc uregs[15]
-#define ARM_lr uregs[14]
-#define ARM_sp uregs[13]
-#define ARM_ip uregs[12]
-#define ARM_fp uregs[11]
-#define ARM_r10 uregs[10]
-#define ARM_r9 uregs[9]
-#define ARM_r8 uregs[8]
-#define ARM_r7 uregs[7]
-#define ARM_r6 uregs[6]
-#define ARM_r5 uregs[5]
-#define ARM_r4 uregs[4]
-#define ARM_r3 uregs[3]
-#define ARM_r2 uregs[2]
-#define ARM_r1 uregs[1]
-#define ARM_r0 uregs[0]
-#define ARM_ORIG_r0 uregs[17]
-
-
-/* Copied from arch/arm/include/asm/user.h */
-
-struct user_vfp {
- unsigned long long fpregs[32];
- unsigned long fpscr;
-};
-
-struct user_vfp_exc {
- unsigned long fpexc;
- unsigned long fpinst;
- unsigned long fpinst2;
-};
-
-#define REG_RES(regs) ((regs).ARM_r0)
-#define REG_IP(regs) ((regs).ARM_pc)
-#define REG_SYSCALL_NR(regs) ((regs).ARM_r7)
-
-#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;
#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__ARM
@@ -101,9 +21,6 @@ typedef UserArmRegsEntry UserRegsEntry;
#define TI_SP(core) ((core)->ti_arm->gpregs->sp)
-typedef u32 auxv_t;
-typedef u32 tls_t;
-
static inline void *decode_pointer(u64 v) { return (void*)(u32)v; }
static inline u64 encode_pointer(void *p) { return (u32)p; }
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index b8dc6658682f..68175f97d5d0 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -5,101 +5,20 @@
#include <signal.h>
#include "images/core.pb-c.h"
-#include "compel/asm/page.h"
#include "asm/bitops.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
-
-#define SIGMAX_OLD 31
-#define SIGMAX 64
-
-/*
- * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
- */
-typedef struct {
- unsigned long gpr[32];
- unsigned long nip;
- unsigned long msr;
- unsigned long orig_gpr3; /* Used for restarting system calls */
- unsigned long ctr;
- unsigned long link;
- unsigned long xer;
- unsigned long ccr;
- unsigned long softe; /* Soft enabled/disabled */
- unsigned long trap; /* Reason for being here */
- /* N.B. for critical exceptions on 4xx, the dar and dsisr
- fields are overloaded to hold srr0 and srr1. */
- unsigned long dar; /* Fault registers */
- unsigned long dsisr; /* on 4xx/Book-E used for ESR */
- unsigned long result; /* Result of a system call */
-} user_regs_struct_t;
-
-#define NVSXREG 32
-
-typedef struct {
- uint64_t fpregs[NFPREG];
- /* The kernel returns :
- * 32 Vector registers (128bit)
- * VSCR (32bit) stored in a 128bit entry (odd)
- * VRSAVE (32bit) store at the end.
- *
- * Kernel setup_sigcontext's comment mentions:
- * "Userland shall check AT_HWCAP to know whether it can rely on the
- * v_regs pointer or not"
- */
- unsigned char vrregs[(NVRREG-1) * 16 + 4];
- uint64_t vsregs[NVSXREG];
-
- int flags;
- struct tm_regs {
- struct {
- uint64_t tfhar, texasr, tfiar;
- } tm_spr_regs;
- user_regs_struct_t regs;
- uint64_t fpregs[NFPREG], vmxregs[34][2], vsxregs[32];
- } tm;
-} user_fpregs_struct_t;
-
+#include "compel/asm/types.h"
typedef UserPpc64RegsEntry UserRegsEntry;
#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__PPC64
-#define REG_RES(regs) ((u64)(regs).gpr[3])
-#define REG_IP(regs) ((u64)(regs).nip)
-#define REG_SYSCALL_NR(regs) ((u64)(regs).gpr[0])
-
-#define user_regs_native(pregs) true
#define core_is_compat(core) false
#define CORE_THREAD_ARCH_INFO(core) core->ti_ppc64
-/*
- * Copied from the following kernel header files :
- * include/linux/auxvec.h
- * arch/powerpc/include/uapi/asm/auxvec.h
- * include/linux/mm_types.h
- */
-#define AT_VECTOR_SIZE_BASE 20
-#define AT_VECTOR_SIZE_ARCH 6
-#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
-
-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 72e35da3d0b0..14b0146a9ca4 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -4,99 +4,15 @@
#include <stdbool.h>
#include <signal.h>
-#include "compel/asm/page.h"
#include "asm/bitops.h"
#include "asm/int.h"
#include "uapi/std/asm/syscall-types.h"
+#include "compel/asm/types.h"
-#include "bug.h"
#include "images/core.pb-c.h"
-#define SIGMAX 64
-#define SIGMAX_OLD 31
-
-#define MAJOR(dev) ((dev)>>8)
-#define MINOR(dev) ((dev) & 0xff)
-
-typedef struct {
- uint64_t r15;
- uint64_t r14;
- uint64_t r13;
- uint64_t r12;
- uint64_t bp;
- uint64_t bx;
- uint64_t r11;
- uint64_t r10;
- uint64_t r9;
- uint64_t r8;
- uint64_t ax;
- uint64_t cx;
- uint64_t dx;
- uint64_t si;
- uint64_t di;
- uint64_t orig_ax;
- uint64_t ip;
- uint64_t cs;
- uint64_t flags;
- uint64_t sp;
- uint64_t ss;
- uint64_t fs_base;
- uint64_t gs_base;
- uint64_t ds;
- uint64_t es;
- uint64_t fs;
- uint64_t gs;
-} user_regs_struct64;
-
-typedef struct {
- uint32_t bx;
- uint32_t cx;
- uint32_t dx;
- uint32_t si;
- uint32_t di;
- uint32_t bp;
- uint32_t ax;
- uint32_t ds;
- uint32_t es;
- uint32_t fs;
- uint32_t gs;
- uint32_t orig_ax;
- uint32_t ip;
- uint32_t cs;
- uint32_t flags;
- uint32_t sp;
- uint32_t ss;
-} user_regs_struct32;
-
#ifdef CONFIG_X86_64
-/*
- * To be sure that we rely on inited reg->__is_native, this member
- * is (short int) instead of initial (bool). The right way to
- * check if regs are native or compat is to use user_regs_native() macro.
- * This should cost nothing, as *usually* sizeof(bool) == sizeof(short)
- */
-typedef struct {
- union {
- user_regs_struct64 native;
- user_regs_struct32 compat;
- };
- short __is_native; /* use user_regs_native macro to check it */
-} user_regs_struct_t;
-
-#define NATIVE_MAGIC 0x0A
-#define COMPAT_MAGIC 0x0C
-static inline bool user_regs_native(user_regs_struct_t *pregs)
-{
- BUG_ON(pregs->__is_native != NATIVE_MAGIC &&
- pregs->__is_native != COMPAT_MAGIC);
- return pregs->__is_native == NATIVE_MAGIC;
-}
-
-#define get_user_reg(pregs, name) ((user_regs_native(pregs)) ? \
- ((pregs)->native.name) : ((pregs)->compat.name))
-#define set_user_reg(pregs, name, val) ((user_regs_native(pregs)) ? \
- ((pregs)->native.name = (val)) : ((pregs)->compat.name = (val)))
static inline int core_is_compat(CoreEntry *c)
{
switch (c->thread_info->gpregs->mode) {
@@ -108,72 +24,12 @@ static inline int core_is_compat(CoreEntry *c)
return -1;
}
}
-#else /* !CONFIG_X86_64 */
-typedef struct {
- union {
- user_regs_struct32 native;
- };
-} user_regs_struct_t;
-#define user_regs_native(pregs) true
-#define get_user_reg(pregs, name) ((pregs)->native.name)
-#define set_user_reg(pregs, name, val) ((pregs)->native.name = val)
-static inline int core_is_compat(CoreEntry *c) { return 0; }
-#endif /* !CONFIG_X86_64 */
-
-#if 0
-typedef struct {
- unsigned short cwd;
- unsigned short swd;
- unsigned short twd; /* Note this is not the same as
- the 32bit/x87/FSAVE twd */
- unsigned short fop;
- u64 rip;
- u64 rdp;
- u32 mxcsr;
- u32 mxcsr_mask;
- u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
- u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
- u32 padding[24];
-} user_fpregs_struct_t;
-#endif
-
-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)
+static inline int core_is_compat(CoreEntry *c) { return 0; }
#endif
-static inline unsigned long task_size(void) { return TASK_SIZE; }
-
-typedef u64 auxv_t;
-
-/*
- * Linux preserves three TLS segments in GDT.
- * Offsets in GDT differ between 32-bit and 64-bit machines.
- * For 64-bit x86 those GDT offsets are the same
- * for native and compat tasks.
- */
-#define GDT_ENTRY_TLS_MIN 12
-#define GDT_ENTRY_TLS_MAX 14
-#define GDT_ENTRY_TLS_NUM 3
-typedef struct {
- user_desc_t desc[GDT_ENTRY_TLS_NUM];
-} tls_t;
-
-#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)
-
#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__X86_64
-#define AT_VECTOR_SIZE 44
-
#define CORE_THREAD_ARCH_INFO(core) core->thread_info
typedef UserX86RegsEntry UserRegsEntry;
--
2.7.4
More information about the CRIU
mailing list