[CRIU] [PATCH v3] parasite-syscall: get rid of code_syscall{, size} globals

Andrew Vagin avagin at virtuozzo.com
Mon Mar 21 13:47:09 PDT 2016


https://ci.openvz.org/view/CRIU/job/CRIU-dump-only/1476/console

arch/ppc64/crtools.c: In function ‘syscall_seized’:
arch/ppc64/crtools.c:81:47: error: passing argument 3 of ‘__parasite_execute_syscall’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  err = __parasite_execute_syscall(ctl, &regs, code_syscall);
                                               ^
In file included from arch/ppc64/crtools.c:14:0:
/var/lib/jenkins/workspace/CRIU-dump-only/criu/include/parasite-syscall.h:121:12: note: expected ‘const char *’ but argument is of type ‘const u32 * {aka const unsigned int *}’
 extern int __parasite_execute_syscall(struct parasite_ctl *ctl,
            ^

On Thu, Mar 17, 2016 at 08:17:45PM +0300, Dmitry Safonov wrote:
> I think, we may safely remove this exports, as:
> - code_syscall is used only in one function, which now will have
>   it as a parameter;
> - code_syscall_size must be equall to BUILTIN_SYSCALL_SIZE under
>   BUILD_BUG_ON, so BUILTIN_SYSCALL_SIZE may be used instead.
>   (see ptrace(2) - align restriction to PTRACE_PEEKUSER).
> 
> This will reduce arch-depended code coupling a little.
> 
> (and I also interested in this because of I need __parasite_execute_syscall
> to execute 32-bit syscall code on x86_64, which I prefer to leave without
> some CONFIG_X86_64 as it's generic code)
> 
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
> ---
> v3: renamed code_syscall_size -> code_syscall_aligned which is equall to
>     BUILTIN_SYSCALL_SIZE under BUILD_BUG_ON
> v2: left code_syscall_size global
> 
>  criu/arch/aarch64/crtools.c                      | 7 ++++---
>  criu/arch/aarch64/include/asm/parasite-syscall.h | 3 ---
>  criu/arch/arm/crtools.c                          | 7 ++++---
>  criu/arch/arm/include/asm/parasite-syscall.h     | 4 ----
>  criu/arch/ppc64/crtools.c                        | 4 +---
>  criu/arch/ppc64/include/asm/parasite-syscall.h   | 3 ---
>  criu/arch/x86/crtools.c                          | 7 ++++---
>  criu/arch/x86/include/asm/parasite-syscall.h     | 3 ---
>  criu/include/parasite-syscall.h                  | 2 +-
>  criu/parasite-syscall.c                          | 5 +++--
>  10 files changed, 17 insertions(+), 28 deletions(-)
> 
> diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c
> index 7a25106..15345ec 100644
> --- a/criu/arch/aarch64/crtools.c
> +++ b/criu/arch/aarch64/crtools.c
> @@ -27,11 +27,12 @@ const char code_syscall[] = {
>  	0x00, 0x00, 0x20, 0xd4		/* BRK #0 */
>  };
>  
> -const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
> +static const int
> +code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
>  
>  static inline void __always_unused __check_code_syscall(void)
>  {
> -	BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
> +	BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
>  	BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
>  }
>  
> @@ -71,7 +72,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  	regs.regs[6] = 0;
>  	regs.regs[7] = 0;
>  
> -	err = __parasite_execute_syscall(ctl, &regs);
> +	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
>  
>  	*ret = regs.regs[0];
>  	return err;
> diff --git a/criu/arch/aarch64/include/asm/parasite-syscall.h b/criu/arch/aarch64/include/asm/parasite-syscall.h
> index 0c07121..f992bca 100644
> --- a/criu/arch/aarch64/include/asm/parasite-syscall.h
> +++ b/criu/arch/aarch64/include/asm/parasite-syscall.h
> @@ -6,9 +6,6 @@ struct parasite_ctl;
>  #define ARCH_SI_TRAP TRAP_BRKPT
>  
>  
> -extern const char code_syscall[];
> -extern const int code_syscall_size;
> -
>  void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
>  
>  void *mmap_seized(struct parasite_ctl *ctl,
> diff --git a/criu/arch/arm/crtools.c b/criu/arch/arm/crtools.c
> index 9588990..8887262 100644
> --- a/criu/arch/arm/crtools.c
> +++ b/criu/arch/arm/crtools.c
> @@ -28,11 +28,12 @@ const char code_syscall[] = {
>  	0xf0, 0x01, 0xf0, 0xe7          /* UDF #32 */
>  };
>  
> -const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
> +static const int
> +code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
>  
>  static inline __always_unused void __check_code_syscall(void)
>  {
> -	BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
> +	BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
>  	BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
>  }
>  
> @@ -73,7 +74,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  	regs.ARM_r4 = arg5;
>  	regs.ARM_r5 = arg6;
>  
> -	err = __parasite_execute_syscall(ctl, &regs);
> +	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
>  
>  	*ret = regs.ARM_r0;
>  	return err;
> diff --git a/criu/arch/arm/include/asm/parasite-syscall.h b/criu/arch/arm/include/asm/parasite-syscall.h
> index 0c66bf9..2d6b85f 100644
> --- a/criu/arch/arm/include/asm/parasite-syscall.h
> +++ b/criu/arch/arm/include/asm/parasite-syscall.h
> @@ -5,10 +5,6 @@
>  #define ARCH_SI_TRAP TRAP_BRKPT
>  
>  
> -extern const char code_syscall[];
> -extern const int code_syscall_size;
> -
> -
>  void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
>  
>  void *mmap_seized(struct parasite_ctl *ctl,
> diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c
> index 14b1e7c..7d039a0 100644
> --- a/criu/arch/ppc64/crtools.c
> +++ b/criu/arch/ppc64/crtools.c
> @@ -32,8 +32,6 @@ const u32 code_syscall[] = {
>  	0x0fe00000		/* twi 31,0,0	*/
>  };
>  
> -const int code_syscall_size = sizeof(code_syscall);
> -
>  static inline void __check_code_syscall(void)
>  {
>  	BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
> @@ -80,7 +78,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  	regs.gpr[7] = arg5;
>  	regs.gpr[8] = arg6;
>  
> -	err = __parasite_execute_syscall(ctl, &regs);
> +	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
>  
>  	*ret = regs.gpr[3];
>  	return err;
> diff --git a/criu/arch/ppc64/include/asm/parasite-syscall.h b/criu/arch/ppc64/include/asm/parasite-syscall.h
> index 7665e20..1ac6b3b 100644
> --- a/criu/arch/ppc64/include/asm/parasite-syscall.h
> +++ b/criu/arch/ppc64/include/asm/parasite-syscall.h
> @@ -5,9 +5,6 @@ struct parasite_ctl;
>  
>  #define ARCH_SI_TRAP TRAP_BRKPT
>  
> -extern const char code_syscall[];
> -extern const int code_syscall_size;
> -
>  void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
>  
>  void *mmap_seized(struct parasite_ctl *ctl,
> diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
> index 1c43ab1..51eab13 100644
> --- a/criu/arch/x86/crtools.c
> +++ b/criu/arch/x86/crtools.c
> @@ -31,11 +31,12 @@ const char code_syscall[] = {
>  	0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc	/* int 3, ... */
>  };
>  
> -const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
> +static const int
> +code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
>  
>  static inline __always_unused void __check_code_syscall(void)
>  {
> -	BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
> +	BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
>  	BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
>  }
>  
> @@ -103,7 +104,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  	regs.r8  = arg5;
>  	regs.r9  = arg6;
>  
> -	err = __parasite_execute_syscall(ctl, &regs);
> +	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
>  
>  	*ret = regs.ax;
>  	return err;
> diff --git a/criu/arch/x86/include/asm/parasite-syscall.h b/criu/arch/x86/include/asm/parasite-syscall.h
> index 4d56cb0..e2c7a5a 100644
> --- a/criu/arch/x86/include/asm/parasite-syscall.h
> +++ b/criu/arch/x86/include/asm/parasite-syscall.h
> @@ -8,9 +8,6 @@ struct parasite_ctl;
>  #define ARCH_SI_TRAP SI_KERNEL
>  
>  
> -extern const char code_syscall[];
> -extern const int code_syscall_size;
> -
>  void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
>  
>  void *mmap_seized(struct parasite_ctl *ctl,
> diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
> index 5ed8e35..04d2602 100644
> --- a/criu/include/parasite-syscall.h
> +++ b/criu/include/parasite-syscall.h
> @@ -119,7 +119,7 @@ extern int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
>  			  unsigned long arg5, unsigned long arg6);
>  
>  extern int __parasite_execute_syscall(struct parasite_ctl *ctl,
> -				user_regs_struct_t *regs);
> +		user_regs_struct_t *regs, const char *code_syscall);
>  extern bool arch_can_dump_task(pid_t pid);
>  
>  /*
> diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
> index bcdadcb..0a1bdc6 100644
> --- a/criu/parasite-syscall.c
> +++ b/criu/parasite-syscall.c
> @@ -44,7 +44,7 @@
>  static int can_run_syscall(unsigned long ip, unsigned long start,
>  			   unsigned long end, unsigned long pad)
>  {
> -	return ip >= start && ip < (end - code_syscall_size - pad);
> +	return ip >= start && ip < (end - BUILTIN_SYSCALL_SIZE - pad);
>  }
>  
>  static int syscall_fits_vma_area(struct vma_area *vma_area, unsigned long pad)
> @@ -210,7 +210,8 @@ err:
>  	return ret;
>  }
>  
> -int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *regs)
> +int __parasite_execute_syscall(struct parasite_ctl *ctl,
> +		user_regs_struct_t *regs, const char *code_syscall)
>  {
>  	pid_t pid = ctl->pid.real;
>  	int err;
> -- 
> 2.7.2
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list