[CRIU] [PATCHv2 9/9] criu: wrap compatible code with CONFIG_COMPAT

Andrew Vagin avagin at virtuozzo.com
Thu Aug 4 16:06:21 PDT 2016


On Thu, Aug 04, 2016 at 06:07:49PM +0300, Dmitry Safonov wrote:
> As we will not support *native* 32-bit i386 build, I dropped some
> ifdefs, introducing instead of ifdef(CONFIG_X86_64) --
> ifdef(CONFIG_COMPAT).
> 
> CRIU should build now without ia32 Glibc and gcc-multilib support.
> Maybe I should add some warning that the build is made without
> compatible task support (or criu check should print that),
> will do as compat patches hit master.
> 
> Fixes: #181

It is still impossible to compile criu on Alpine
https://travis-ci.org/avagin/criu/jobs/149899186

> 
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Cc: Andrew Vagin <avagin at virtuozzo.com>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
> ---
>  criu/arch/x86/Makefile               | 6 ++++--
>  criu/arch/x86/Makefile.syscalls      | 8 +++-----
>  criu/arch/x86/include/asm/restorer.h | 7 +++++--
>  criu/arch/x86/restorer.c             | 4 ++--
>  criu/arch/x86/sys-exec-tbl.c         | 8 ++++----
>  criu/parasite-syscall.c              | 4 ++--
>  criu/pie/Makefile                    | 9 ++++++---
>  criu/pie/Makefile.library            | 7 ++++---
>  criu/pie/parasite-blob.h             | 2 +-
>  9 files changed, 31 insertions(+), 24 deletions(-)
> 
> diff --git a/criu/arch/x86/Makefile b/criu/arch/x86/Makefile
> index e214a15be4b1..fb8608211ab5 100644
> --- a/criu/arch/x86/Makefile
> +++ b/criu/arch/x86/Makefile
> @@ -8,5 +8,7 @@ asflags-y		+= -iquote $(obj)/include
>  
>  obj-y			+= cpu.o
>  obj-y			+= crtools.o
> -obj-y			+= sigaction_compat.o
> -obj-y			+= call32.o
> +ifeq ($(CONFIG_COMPAT),y)
> +        obj-y		+= sigaction_compat.o
> +        obj-y		+= call32.o
> +endif
> diff --git a/criu/arch/x86/Makefile.syscalls b/criu/arch/x86/Makefile.syscalls
> index 0506c1f2b117..839f24c1b385 100644
> --- a/criu/arch/x86/Makefile.syscalls
> +++ b/criu/arch/x86/Makefile.syscalls
> @@ -17,11 +17,9 @@ target			:=
>  target_32		:= syscalls-32
>  target_64		:= syscalls-64
>  
> -SYS-BITS		:= 32
> -
> -# native x86_64
> -ifeq ($(ARCH),x86)
> -	SYS-BITS	+= 64
> +SYS-BITS		:= 64
> +ifeq ($(CONFIG_COMPAT),y)
> +        SYS-BITS	+= 32
>  endif
>  
>  # targets
> diff --git a/criu/arch/x86/include/asm/restorer.h b/criu/arch/x86/include/asm/restorer.h
> index a124dd2a6293..6bc5c2b27d54 100644
> --- a/criu/arch/x86/include/asm/restorer.h
> +++ b/criu/arch/x86/include/asm/restorer.h
> @@ -84,7 +84,6 @@ typedef struct {
>  	compat_sigset_word	sig[_COMPAT_NSIG_WORDS];
>  } compat_sigset_t;
>  
> -#ifdef CONFIG_X86_64
>  typedef struct compat_siginfo {
>  	int	si_signo;
>  	int	si_errno;
> @@ -92,6 +91,7 @@ typedef struct compat_siginfo {
>  	int	_pad[128/sizeof(int) - 3];
>  } compat_siginfo_t;
>  
> +#ifdef CONFIG_COMPAT
>  static inline void __always_unused __check_compat_sigset_t(void)
>  {
>  	BUILD_BUG_ON(sizeof(compat_sigset_t) != sizeof(k_rtsigset_t));
> @@ -104,13 +104,16 @@ extern unsigned long call32_from_64(void *stack, void *func);
>  extern int arch_compat_rt_sigaction(void *stack32, int sig,
>  		rt_sigaction_t_compat *act);
>  #else
> -#define rt_sigframe_ia32		rt_sigframe
>  static inline void *alloc_compat_syscall_stack(void) { return NULL; }
>  static inline void free_compat_syscall_stack(void *stack32) { }
>  static inline int
>  arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; }
>  #endif
>  
> +#ifdef CONFIG_X86_32
> +# define rt_sigframe_ia32	rt_sigframe
> +#endif
> +
>  typedef struct compat_sigaltstack {
>  	compat_uptr_t		ss_sp;
>  	int			ss_flags;
> diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
> index f16bdcaa5b68..3de0146e816b 100644
> --- a/criu/arch/x86/restorer.c
> +++ b/criu/arch/x86/restorer.c
> @@ -12,7 +12,6 @@
>  
>  int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
>  {
> -#ifdef CONFIG_X86_64
>  	long ret;
>  	unsigned long fsgs_base;
>  
> @@ -29,10 +28,10 @@ int restore_nonsigframe_gpregs(UserX86RegsEntry *r)
>  		pr_info("SET_GS fail %ld\n", ret);
>  		return -1;
>  	}
> -#endif
>  	return 0;
>  }
>  
> +#ifdef CONFIG_COMPAT
>  asm (	"	.pushsection .text				\n"
>  	"	.global restore_set_thread_area			\n"
>  	"	.code32						\n"
> @@ -89,3 +88,4 @@ void restore_tls(tls_t *ptls)
>  	if (stack32)
>  		free_compat_syscall_stack(stack32);
>  }
> +#endif
> diff --git a/criu/arch/x86/sys-exec-tbl.c b/criu/arch/x86/sys-exec-tbl.c
> index ca45ef0d3126..f52578736f29 100644
> --- a/criu/arch/x86/sys-exec-tbl.c
> +++ b/criu/arch/x86/sys-exec-tbl.c
> @@ -1,15 +1,15 @@
>  
> -#ifdef CONFIG_X86_64
>  static struct syscall_exec_desc sc_exec_table_64[] = {
>  #include "sys-exec-tbl-64.c"
>  	{ }, /* terminator */
>  };
> -#endif
>  
> +#ifdef CONFIG_COMPAT
>  static struct syscall_exec_desc sc_exec_table_32[] = {
>  #include "sys-exec-tbl-32.c"
>  	{ }, /* terminator */
>  };
> +#endif
>  
>  struct syscall_exec_desc;
>  
> @@ -26,7 +26,7 @@ find_syscall_table(char *name, struct syscall_exec_desc *tbl)
>  
>  #define ARCH_HAS_FIND_SYSCALL
>  /* overwrite default to search in two tables above */
> -#ifdef CONFIG_X86_64
> +#ifdef CONFIG_COMPAT
>  struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
>  {
>  	if (seized_native(ctl))
> @@ -38,6 +38,6 @@ struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
>  struct syscall_exec_desc *
>  find_syscall(char *name, __always_unused struct parasite_ctl *ctl)
>  {
> -	return find_syscall_table(name, sc_exec_table_32);
> +	return find_syscall_table(name, sc_exec_table_64);
>  }
>  #endif
> diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
> index b6d283e2a793..f16b38de1e6d 100644
> --- a/criu/parasite-syscall.c
> +++ b/criu/parasite-syscall.c
> @@ -1499,7 +1499,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
>  
>  	if (seized_native(ctl))
>  		parasite_size = pie_size(parasite_native);
> -#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
> +#ifdef CONFIG_COMPAT
>  	else
>  		parasite_size = pie_size(parasite_compat);
>  #endif
> @@ -1523,7 +1523,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
>  
>  	if (seized_native(ctl))
>  		init_parasite_ctl(ctl, native);
> -#ifdef CONFIG_X86_64 /* compat blob isn't defined for other archs */
> +#ifdef CONFIG_COMPAT
>  	else
>  		init_parasite_ctl(ctl, compat);
>  #endif
> diff --git a/criu/pie/Makefile b/criu/pie/Makefile
> index 57c71fb2ab68..12ce3e5462c8 100644
> --- a/criu/pie/Makefile
> +++ b/criu/pie/Makefile
> @@ -2,7 +2,7 @@
>  # restorer is always native (64-bit)
>  parasite_target		:= native
>  
> -ifeq ($(ARCH),x86)
> +ifeq ($(CONFIG_COMPAT),y)
>          parasite_target	+= compat
>  endif
>  
> @@ -14,8 +14,11 @@ restorer-obj-y		+= ./$(ARCH_DIR)/restorer.o
>  
>  ifeq ($(ARCH),x86)
>          restorer-obj-e		+= ./$(ARCH_DIR)/syscalls-64.built-in.o
> -        restorer-obj-y		+= ./$(ARCH_DIR)/call32.o
> -        restorer-obj-y		+= ./$(ARCH_DIR)/sigaction_compat_pie.o
> +
> +        ifeq ($(CONFIG_COMPAT),y)
> +                restorer-obj-y	+= ./$(ARCH_DIR)/call32.o
> +                restorer-obj-y	+= ./$(ARCH_DIR)/sigaction_compat_pie.o
> +        endif
>  
>          native-obj-y		+= ./$(ARCH_DIR)/parasite-head-64.o
>          native-obj-e		+= ./$(ARCH_DIR)/syscalls-64.built-in.o
> diff --git a/criu/pie/Makefile.library b/criu/pie/Makefile.library
> index b5825e069a62..331eecd82778 100644
> --- a/criu/pie/Makefile.library
> +++ b/criu/pie/Makefile.library
> @@ -6,11 +6,12 @@ CFLAGS			+= -Wa,--noexecstack -fno-stack-protector -DCR_NOGLIBC
>  CFLAGS_native		+= -fpie
>  
>  ifeq ($(ARCH),x86)
> -        target		+= compat
> +        ifeq ($(CONFIG_COMPAT),y)
> +                target	+= compat
> +                native-lib-y	+= util-vdso-elf32.o
> +        endif
>          CFLAGS_native	+= -DCONFIG_X86_64
>          CFLAGS_compat	+= -fno-pic -m32 -DCONFIG_X86_32
> -
> -        native-lib-y	+= util-vdso-elf32.o
>          CFLAGS_util-vdso-elf32.o	+= -DCONFIG_X86_32
>  endif
>  
> diff --git a/criu/pie/parasite-blob.h b/criu/pie/parasite-blob.h
> index 796d36ed23e6..ddafd05f50ed 100644
> --- a/criu/pie/parasite-blob.h
> +++ b/criu/pie/parasite-blob.h
> @@ -1,5 +1,5 @@
>  #include "parasite-native-blob.h"
>  
> -#ifdef CONFIG_X86_64
> +#ifdef CONFIG_COMPAT
>  # include "parasite-compat-blob.h"
>  #endif
> -- 
> 2.9.0
> 


More information about the CRIU mailing list