[CRIU] [PATCH 2/4] compel: Drop off common/page from uapi
Pavel Emelyanov
xemul at virtuozzo.com
Tue Nov 15 22:48:56 PST 2016
On 11/15/2016 09:01 PM, Cyrill Gorcunov wrote:
> From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
>
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> .../aarch64/src/lib/include/uapi/asm/infect-types.h | 20 +-------------------
> compel/arch/aarch64/src/lib/infect.c | 21 +++++++++++++++++++++
> .../arm/src/lib/include/uapi/asm/infect-types.h | 20 +-------------------
> compel/arch/arm/src/lib/infect.c | 21 +++++++++++++++++++++
> .../ppc64/src/lib/include/uapi/asm/infect-types.h | 10 +---------
> compel/arch/ppc64/src/lib/infect.c | 13 +++++++++++++
> .../x86/src/lib/include/uapi/asm/infect-types.h | 13 +------------
> compel/arch/x86/src/lib/infect.c | 16 ++++++++++++++++
> 8 files changed, 75 insertions(+), 59 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..a188b470df83 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
> @@ -25,25 +25,7 @@ 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;
> -}
> +extern unsigned long task_size(void);
Plz, move to include/uapi/infect.h and rename to compel_get_task_size();
> #define AT_VECTOR_SIZE 40
>
> diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c
> index fceea2816bf4..927cd9e6ebe0 100644
> --- a/compel/arch/aarch64/src/lib/infect.c
> +++ b/compel/arch/aarch64/src/lib/infect.c
> @@ -4,6 +4,7 @@
> #include <linux/elf.h>
> #include <compel/plugins/std/syscall-codes.h>
> #include "uapi/compel/asm/infect-types.h"
> +#include "common/page.h"
> #include "log.h"
> #include "errno.h"
> #include "infect.h"
> @@ -109,3 +110,23 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
> */
> return 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)
> +
> +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;
> +}
> 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..c0bbbe83f378 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
> @@ -59,25 +59,7 @@ 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;
> -}
> +extern unsigned long task_size(void);
>
> #define AT_VECTOR_SIZE 40
>
> diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c
> index b440ff73622a..10396a45f467 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"
> @@ -120,3 +121,23 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
> */
> return 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
> +
> +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;
> +}
> 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..5578313bb15d 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,15 +93,7 @@ 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; }
> +extern unsigned long task_size(void);
>
> #define ARCH_SI_TRAP TRAP_BRKPT
>
> diff --git a/compel/arch/ppc64/src/lib/infect.c b/compel/arch/ppc64/src/lib/infect.c
> index 959098b8c61e..54ec1d885096 100644
> --- a/compel/arch/ppc64/src/lib/infect.c
> +++ b/compel/arch/ppc64/src/lib/infect.c
> @@ -316,3 +316,16 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
> */
> return true;
> }
> +
> +/*
> + * 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
> +
> +unsigned long task_size(void)
> +{
> + return TASK_SIZE;
> +}
> 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..0348f9bdb449 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,17 +108,7 @@ 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; }
> +extern unsigned long task_size(void);
>
> #define REG_RES(regs) get_user_reg(®s, ax)
> #define REG_IP(regs) get_user_reg(®s, ip)
> diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
> index 3ac45c2d52c1..693d0f0d7ee9 100644
> --- a/compel/arch/x86/src/lib/infect.c
> +++ b/compel/arch/x86/src/lib/infect.c
> @@ -16,6 +16,7 @@
> #include <compel/plugins/std/syscall.h>
> #include "asm/ptrace.h"
> #include "common/err.h"
> +#include "common/page.h"
> #include "asm/infect-types.h"
> #include "uapi/compel/ptrace.h"
> #include "infect.h"
> @@ -349,3 +350,18 @@ int ptrace_set_regs(pid_t pid, user_regs_struct_t *regs)
> }
> return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
> }
> +
> +#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
> +
> +unsigned long task_size(void)
> +{
> + return TASK_SIZE;
> +}
>
More information about the CRIU
mailing list