2011-09-23 12:00:45 +04:00
|
|
|
#ifndef CR_IMAGE_H
|
|
|
|
#define CR_IMAGE_H
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
|
|
#define FDINFO_MAGIC 0x01010101
|
|
|
|
#define PAGES_MAGIC 0x20202020
|
|
|
|
#define CORE_MAGIC 0xa75b8d43
|
|
|
|
#define SHMEM_MAGIC 0x03300330
|
|
|
|
#define PIPEFS_MAGIC 0x50495045
|
|
|
|
#define PSTREE_MAGIC 0x40044004
|
|
|
|
#define PIPES_MAGIC 0x05055050
|
|
|
|
|
|
|
|
#define FDINFO_FD 1
|
|
|
|
#define FDINFO_MAP 2
|
|
|
|
|
|
|
|
#define PAGE_IMAGE_SIZE 4096
|
|
|
|
#define PAGE_RSS 1
|
|
|
|
|
|
|
|
struct fdinfo_entry {
|
|
|
|
u8 type;
|
|
|
|
u8 len;
|
|
|
|
u16 flags;
|
|
|
|
u32 pos;
|
|
|
|
u64 addr;
|
|
|
|
u8 name[0];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct shmem_entry {
|
|
|
|
u64 start;
|
|
|
|
u64 end;
|
|
|
|
u64 shmid;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct pstree_entry {
|
|
|
|
u32 pid;
|
|
|
|
u32 nr_children;
|
2011-10-20 17:19:26 +04:00
|
|
|
u32 nr_threads;
|
|
|
|
|
2011-09-23 12:00:45 +04:00
|
|
|
u32 children[0];
|
2011-10-20 17:19:26 +04:00
|
|
|
u32 threads[0];
|
2011-09-23 12:00:45 +04:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct pipe_entry {
|
|
|
|
u32 fd;
|
|
|
|
u32 pipeid;
|
|
|
|
u32 flags;
|
|
|
|
u32 bytes;
|
|
|
|
u8 data[0];
|
|
|
|
} __packed;
|
|
|
|
|
2011-09-26 01:26:11 +04:00
|
|
|
#define VMA_AREA_REGULAR (1 << 0) /* Dumpable area */
|
2011-09-23 12:00:45 +04:00
|
|
|
#define VMA_AREA_STACK (1 << 1)
|
|
|
|
#define VMA_AREA_VSYSCALL (1 << 2)
|
|
|
|
#define VMA_AREA_VDSO (1 << 3)
|
2011-09-26 01:26:11 +04:00
|
|
|
#define VMA_FORCE_READ (1 << 4) /* VMA changed to be readable */
|
2011-09-23 12:00:45 +04:00
|
|
|
#define VMA_AREA_HEAP (1 << 5)
|
2011-09-26 01:26:11 +04:00
|
|
|
|
2011-09-23 12:00:45 +04:00
|
|
|
#define VMA_FILE_PRIVATE (1 << 6)
|
|
|
|
#define VMA_FILE_SHARED (1 << 7)
|
|
|
|
#define VMA_ANON_SHARED (1 << 8)
|
|
|
|
#define VMA_ANON_PRIVATE (1 << 9)
|
2011-09-26 01:26:11 +04:00
|
|
|
#define VMA_FORCE_WRITE (1 << 10) /* VMA changed to be writable */
|
|
|
|
|
|
|
|
#define VMA_DUMP_ALL (1 << 11) /* Dump the whole VMA area pages */
|
2011-09-23 12:00:45 +04:00
|
|
|
|
|
|
|
#define vma_entry_has(vma, s) (((vma)->status & (s)) == (s))
|
|
|
|
|
|
|
|
struct vma_entry {
|
|
|
|
u64 start;
|
|
|
|
u64 end;
|
|
|
|
u64 pgoff;
|
|
|
|
u32 prot;
|
|
|
|
u32 flags;
|
|
|
|
u32 status;
|
|
|
|
u32 pid;
|
|
|
|
s64 fd;
|
|
|
|
u64 ino;
|
|
|
|
u32 dev_maj;
|
|
|
|
u32 dev_min;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct page_entry {
|
|
|
|
u64 va;
|
|
|
|
u8 data[PAGE_IMAGE_SIZE];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#define HEADER_VERSION 1
|
|
|
|
#define HEADER_ARCH_X86_64 1
|
|
|
|
|
|
|
|
struct image_header {
|
|
|
|
u16 version;
|
|
|
|
u16 arch;
|
|
|
|
u32 flags;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PTRACE_GETREGS
|
|
|
|
* PTRACE_GETFPREGS
|
|
|
|
* PTRACE_GETFPXREGS dep CONFIG_X86_32
|
|
|
|
* PTRACE_GET_THREAD_AREA dep CONFIG_X86_32 || CONFIG_IA32_EMULATION
|
|
|
|
* PTRACE_GETFDPIC dep CONFIG_BINFMT_ELF_FDPIC
|
|
|
|
*
|
|
|
|
* PTRACE_ARCH_PRCTL dep CONFIG_X86_64
|
|
|
|
* ARCH_SET_GS/ARCH_GET_FS
|
|
|
|
* ARCH_SET_FS/ARCH_GET_GS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
|
|
|
struct user_regs_entry {
|
|
|
|
u64 r15;
|
|
|
|
u64 r14;
|
|
|
|
u64 r13;
|
|
|
|
u64 r12;
|
|
|
|
u64 bp;
|
|
|
|
u64 bx;
|
|
|
|
u64 r11;
|
|
|
|
u64 r10;
|
|
|
|
u64 r9;
|
|
|
|
u64 r8;
|
|
|
|
u64 ax;
|
|
|
|
u64 cx;
|
|
|
|
u64 dx;
|
|
|
|
u64 si;
|
|
|
|
u64 di;
|
|
|
|
u64 orig_ax;
|
|
|
|
u64 ip;
|
|
|
|
u64 cs;
|
|
|
|
u64 flags;
|
|
|
|
u64 sp;
|
|
|
|
u64 ss;
|
|
|
|
u64 fs_base;
|
|
|
|
u64 gs_base;
|
|
|
|
u64 ds;
|
|
|
|
u64 es;
|
|
|
|
u64 fs;
|
|
|
|
u64 gs;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct desc_struct {
|
2011-11-07 16:29:36 +04:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 a;
|
|
|
|
u32 b;
|
|
|
|
} x86_32;
|
|
|
|
u64 base_addr;
|
|
|
|
};
|
2011-09-23 12:00:45 +04:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct user_fpregs_entry {
|
|
|
|
u16 cwd;
|
|
|
|
u16 swd;
|
|
|
|
u16 twd; /* Note this is not the same as
|
|
|
|
the 32bit/x87/FSAVE twd */
|
|
|
|
u16 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];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#define GDT_ENTRY_TLS_ENTRIES 3
|
2011-10-01 13:24:34 +04:00
|
|
|
#define TASK_COMM_LEN 16
|
2011-09-23 12:00:45 +04:00
|
|
|
|
2011-10-10 17:05:12 +04:00
|
|
|
#define TASK_PF_USED_MATH 0x00002000
|
|
|
|
|
2011-10-11 01:32:39 +04:00
|
|
|
struct ckpt_arch_entry {
|
2011-09-23 12:00:45 +04:00
|
|
|
struct user_regs_entry gpregs;
|
|
|
|
struct user_fpregs_entry fpregs;
|
|
|
|
struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
|
2011-10-11 01:32:39 +04:00
|
|
|
};
|
|
|
|
|
2011-10-25 13:53:16 +04:00
|
|
|
#define CKPT_ARCH_SIZE (1 * 4096)
|
|
|
|
#define CKPT_CORE_SIZE (2 * 4096)
|
2011-10-11 10:10:07 +04:00
|
|
|
|
2011-10-11 01:32:39 +04:00
|
|
|
struct core_entry {
|
2011-10-12 09:40:02 +04:00
|
|
|
union {
|
|
|
|
struct {
|
2011-10-11 01:32:39 +04:00
|
|
|
struct image_header header;
|
|
|
|
union {
|
2011-10-12 09:40:02 +04:00
|
|
|
struct ckpt_arch_entry arch; /* per-arch specific */
|
|
|
|
u8 __arch_pad[CKPT_ARCH_SIZE]; /* should be enough for all */
|
2011-10-11 01:32:39 +04:00
|
|
|
} u;
|
|
|
|
u32 task_personality;
|
|
|
|
u8 task_comm[TASK_COMM_LEN];
|
|
|
|
u32 task_flags;
|
2011-10-12 16:02:36 +04:00
|
|
|
u64 mm_start_code;
|
|
|
|
u64 mm_end_code;
|
2011-10-12 18:05:07 +04:00
|
|
|
u64 mm_start_data;
|
|
|
|
u64 mm_end_data;
|
|
|
|
u64 mm_start_stack;
|
|
|
|
u64 mm_start_brk;
|
|
|
|
u64 mm_brk;
|
2011-11-09 00:29:41 +04:00
|
|
|
u64 task_sigset;
|
2011-10-12 09:40:02 +04:00
|
|
|
};
|
|
|
|
u8 __core_pad[CKPT_CORE_SIZE];
|
|
|
|
};
|
2011-09-23 12:00:45 +04:00
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#endif /* CONFIG_X86_64 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There are always 4 magic bytes at the
|
|
|
|
* beginning of the every file.
|
|
|
|
*/
|
|
|
|
#define MAGIC_OFFSET (sizeof(u32))
|
|
|
|
#define GET_FILE_OFF(s, m) (offsetof(s,m) + MAGIC_OFFSET)
|
|
|
|
#define GET_FILE_OFF_AFTER(s) (sizeof(s) + MAGIC_OFFSET)
|
|
|
|
|
|
|
|
#endif /* CR_IMAGE_H */
|