mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 18:07:57 +00:00
kerndat: Introduce task_size variable
If we want one CRIU binary to work across all AArch64 kernel configurations, a single task size value cannot be hard coded. Signed-off-by: Christopher Covington <cov@codeaurora.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
f13ec96e58
commit
c0c0546c31
@ -66,6 +66,26 @@ typedef struct user_pt_regs user_regs_struct_t;
|
|||||||
|
|
||||||
#define TASK_SIZE (1ULL << 39)
|
#define TASK_SIZE (1ULL << 39)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Range for task size calculated from the following Linux kernel files:
|
||||||
|
* arch/arm64/include/asm/memory.h
|
||||||
|
* arch/arm64/Kconfig
|
||||||
|
*/
|
||||||
|
#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() {
|
||||||
|
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
|
#define AT_VECTOR_SIZE 40
|
||||||
|
|
||||||
typedef UserAarch64RegsEntry UserRegsEntry;
|
typedef UserAarch64RegsEntry UserRegsEntry;
|
||||||
|
@ -98,6 +98,8 @@ struct user_vfp_exc {
|
|||||||
|
|
||||||
#define TASK_SIZE 0xbf000000
|
#define TASK_SIZE 0xbf000000
|
||||||
|
|
||||||
|
static inline unsigned long task_size() { return TASK_SIZE; }
|
||||||
|
|
||||||
#define AT_VECTOR_SIZE 40
|
#define AT_VECTOR_SIZE 40
|
||||||
|
|
||||||
typedef UserArmRegsEntry UserRegsEntry;
|
typedef UserArmRegsEntry UserRegsEntry;
|
||||||
|
@ -105,6 +105,8 @@ typedef uint64_t tls_t;
|
|||||||
#define TASK_SIZE_USER64 (0x0000400000000000UL)
|
#define TASK_SIZE_USER64 (0x0000400000000000UL)
|
||||||
#define TASK_SIZE TASK_SIZE_USER64
|
#define TASK_SIZE TASK_SIZE_USER64
|
||||||
|
|
||||||
|
static inline unsigned long task_size() { return TASK_SIZE; }
|
||||||
|
|
||||||
static inline void *decode_pointer(uint64_t v) { return (void*)v; }
|
static inline void *decode_pointer(uint64_t v) { return (void*)v; }
|
||||||
static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; }
|
static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; }
|
||||||
|
|
||||||
|
@ -119,6 +119,8 @@ typedef struct {
|
|||||||
# define TASK_SIZE (0xffffe000)
|
# define TASK_SIZE (0xffffe000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline unsigned long task_size() { return TASK_SIZE; }
|
||||||
|
|
||||||
typedef u64 auxv_t;
|
typedef u64 auxv_t;
|
||||||
typedef u32 tls_t;
|
typedef u32 tls_t;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ struct kerndat_s {
|
|||||||
bool has_dirty_track;
|
bool has_dirty_track;
|
||||||
bool has_memfd;
|
bool has_memfd;
|
||||||
bool has_fdinfo_lock;
|
bool has_fdinfo_lock;
|
||||||
|
unsigned long task_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct kerndat_s kdat;
|
extern struct kerndat_s kdat;
|
||||||
|
11
kerndat.c
11
kerndat.c
@ -273,6 +273,13 @@ static bool kerndat_has_memfd_create(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_task_size(void)
|
||||||
|
{
|
||||||
|
kdat.task_size = task_size();
|
||||||
|
pr_debug("Found task size of %lx\n", kdat.task_size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int kerndat_fdinfo_has_lock()
|
int kerndat_fdinfo_has_lock()
|
||||||
{
|
{
|
||||||
int fd, pfd = -1, exit_code = -1, len;
|
int fd, pfd = -1, exit_code = -1, len;
|
||||||
@ -323,6 +330,8 @@ int kerndat_init(void)
|
|||||||
ret = get_last_cap();
|
ret = get_last_cap();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = kerndat_fdinfo_has_lock();
|
ret = kerndat_fdinfo_has_lock();
|
||||||
|
if (!ret)
|
||||||
|
ret = get_task_size();
|
||||||
|
|
||||||
kerndat_lsm();
|
kerndat_lsm();
|
||||||
|
|
||||||
@ -344,6 +353,8 @@ int kerndat_init_rst(void)
|
|||||||
ret = get_last_cap();
|
ret = get_last_cap();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = kerndat_has_memfd_create();
|
ret = kerndat_has_memfd_create();
|
||||||
|
if (!ret)
|
||||||
|
ret = get_task_size();
|
||||||
|
|
||||||
kerndat_lsm();
|
kerndat_lsm();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user