[CRIU] [PATCH 4/7] compel: plugins, std -- Add syscall-types.h header

Cyrill Gorcunov gorcunov at openvz.org
Mon Sep 26 12:36:36 PDT 2016


Both std and criu will use it for syscalls sake.
Note I've to disable x86 compat mode for a while:
we have to provide native types there thus will
back once everything else is complete.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 compel/Makefile                                    | 10 +++++
 .../aarch64/plugins/include/asm/syscall-types.h    | 28 ++++++++++++
 .../arch/arm/plugins/include/asm/syscall-types.h   | 28 ++++++++++++
 .../arch/ppc64/plugins/include/asm/syscall-types.h | 28 ++++++++++++
 .../arch/x86/plugins/include/asm/syscall-types.h   | 21 ++++++---
 compel/plugins/include/uapi/std/asm/.gitignore     |  0
 compel/plugins/include/uapi/std/syscall-types.h    |  2 +-
 criu/Makefile                                      |  3 ++
 criu/Makefile.config                               | 16 ++++---
 criu/Makefile.crtools                              |  4 ++
 criu/arch/aarch64/include/asm/types.h              | 25 +----------
 criu/arch/arm/include/asm/types.h                  | 26 +----------
 criu/arch/ppc64/include/asm/types.h                | 28 +-----------
 criu/arch/x86/include/asm/types.h                  | 51 +---------------------
 14 files changed, 131 insertions(+), 139 deletions(-)
 create mode 100644 compel/arch/aarch64/plugins/include/asm/syscall-types.h
 create mode 100644 compel/arch/arm/plugins/include/asm/syscall-types.h
 create mode 100644 compel/arch/ppc64/plugins/include/asm/syscall-types.h
 create mode 100644 compel/plugins/include/uapi/std/asm/.gitignore

diff --git a/compel/Makefile b/compel/Makefile
index bfb79237dbb2..4d149a23ee58 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -40,3 +40,13 @@ endif
 cleanup-y		+= compel/compel
 cleanup-y		+= compel/compel-host
 cleanup-y		+= compel/libcompel.so
+
+#
+# FIXME Fake target for syscalls headers generation,
+# drop after syscalls generation.
+$(obj)/plugins/include/uapi/std/asm/syscall-types.h: $(obj)/arch/$(ARCH)/plugins/include/asm/syscall-types.h
+	$(call msg-gen,$@)
+	$(Q) ln -s ../../../../../arch/$(ARCH)/plugins/include/asm/syscall-types.h $@
+
+cleanup-y		+= $(obj)/plugins/include/uapi/std/asm/syscall-types.h
+$(obj)/compel-host: $(obj)/plugins/include/uapi/std/asm/syscall-types.h
diff --git a/compel/arch/aarch64/plugins/include/asm/syscall-types.h b/compel/arch/aarch64/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..ee0e2185ddb0
--- /dev/null
+++ b/compel/arch/aarch64/plugins/include/asm/syscall-types.h
@@ -0,0 +1,28 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+#define SA_RESTORER   0x04000000
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	64
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/arm/plugins/include/asm/syscall-types.h b/compel/arch/arm/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..cdb03ef4c5fd
--- /dev/null
+++ b/compel/arch/arm/plugins/include/asm/syscall-types.h
@@ -0,0 +1,28 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+#define SA_RESTORER   0x04000000
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	32
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/ppc64/plugins/include/asm/syscall-types.h b/compel/arch/ppc64/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..7754721e2423
--- /dev/null
+++ b/compel/arch/ppc64/plugins/include/asm/syscall-types.h
@@ -0,0 +1,28 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+#define SA_RESTORER     0x04000000U
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	64
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long	sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/x86/plugins/include/asm/syscall-types.h b/compel/arch/x86/plugins/include/asm/syscall-types.h
index 744809d07894..b22b6d795c74 100644
--- a/compel/arch/x86/plugins/include/asm/syscall-types.h
+++ b/compel/arch/x86/plugins/include/asm/syscall-types.h
@@ -8,13 +8,20 @@ typedef rt_signalfn_t *rt_sighandler_t;
 typedef void rt_restorefn_t(void);
 typedef rt_restorefn_t *rt_sigrestore_t;
 
-#define _KNSIG           64
-# define _NSIG_BPW      64
+#define SA_RESTORER	0x04000000
 
-#define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
+#define _KNSIG		64
+
+#ifndef CONFIG_COMPAT
+#define _NSIG_BPW	64
+#else
+#define _NSIG_BPW	32
+#endif
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
 
 typedef struct {
-	u64 sig[_KNSIG_WORDS];
+	unsigned long	sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
 typedef struct {
@@ -30,9 +37,9 @@ typedef struct {
  * with unaligned rt_sa_mask.
  */
 typedef struct __attribute__((packed)) {
-	u32	rt_sa_handler;
-	u32	rt_sa_flags;
-	u32	rt_sa_restorer;
+	unsigned int	rt_sa_handler;
+	unsigned int	rt_sa_flags;
+	unsigned int	rt_sa_restorer;
 	k_rtsigset_t	rt_sa_mask;
 } rt_sigaction_t_compat;
 
diff --git a/compel/plugins/include/uapi/std/asm/.gitignore b/compel/plugins/include/uapi/std/asm/.gitignore
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h
index 564d027f206d..3296153b39a0 100644
--- a/compel/plugins/include/uapi/std/syscall-types.h
+++ b/compel/plugins/include/uapi/std/syscall-types.h
@@ -52,6 +52,6 @@ struct krlimit {
 /* Type of timers in the kernel.  */
 typedef int kernel_timer_t;
 
-#include "asm/syscall-types.h"
+#include "uapi/std/asm/syscall-types.h"
 
 #endif /* COMPEL_SYSCALL_TYPES_H__ */
diff --git a/criu/Makefile b/criu/Makefile
index f7a25ab4c893..d8b9bf90ff13 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -16,6 +16,9 @@ ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)
 ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
 ccflags-y		+= -iquote $(SRC_DIR)/
 ccflags-y		+= -I/usr/include/libnl3
+ccflags-y		+= -iquote compel/plugins/include
+ccflags-y		+= -iquote compel/include
+ccflags-y		+= -iquote compel/arch/$(ARCH)/plugins/std
 
 export ccflags-y
 
diff --git a/criu/Makefile.config b/criu/Makefile.config
index 7bcecb380e7a..148bc2c4b9fb 100644
--- a/criu/Makefile.config
+++ b/criu/Makefile.config
@@ -12,13 +12,15 @@ ifeq ($(call pkg-config-check,libselinux),y)
         FEATURE_DEFINES	+= -DCONFIG_HAS_SELINUX
 endif
 
-ifeq ($(SRCARCH),x86)
-# CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
-ifeq ($(call try-cc,$(FEATURE_TEST_X86_COMPAT),-m32),true)
-        export CONFIG_COMPAT := y
-        FEATURE_DEFINES	+= -DCONFIG_COMPAT
-endif
-endif
+#
+# FIXME Bring back once libcompel complete
+#ifeq ($(SRCARCH),x86)
+## CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
+#ifeq ($(call try-cc,$(FEATURE_TEST_X86_COMPAT),-m32),true)
+#        export CONFIG_COMPAT := y
+#        FEATURE_DEFINES	+= -DCONFIG_COMPAT
+#endif
+#endif
 
 export DEFINES += $(FEATURE_DEFINES)
 export CFLAGS += $(FEATURE_DEFINES)
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index 9ef23992d69a..a8c0ac319495 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -1,4 +1,8 @@
 ccflags-y		+= -iquote criu/$(ARCH)
+ccflags-y		+= -iquote compel/plugins/include
+ccflags-y		+= -iquote compel/include
+ccflags-y		+= -iquote compel/arch/$(ARCH)/plugins/std
+
 obj-y			+= action-scripts.o
 obj-y			+= external.o
 obj-y			+= aio.o
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 078a8f2fb3c3..dfd289820950 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -10,34 +10,11 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
 
 #define SIGMAX			64
 #define SIGMAX_OLD		31
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG		64
-#define _NSIG_BPW	64
-
-#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	unsigned long sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
-#define SA_RESTORER	0x00000000
-
-typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
 /*
  * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
  *
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index aafc4bb5362b..bc12006448aa 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -9,36 +9,14 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
+
 #define SIGMAX			64
 #define SIGMAX_OLD		31
 
 #define MAJOR(dev)		((dev)>>8)
 #define MINOR(dev)		((dev) & 0xff)
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG		64
-#define _NSIG_BPW	32
-
-#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	unsigned long sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
-#define SA_RESTORER	0x04000000
-
-typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
 /*
  * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
  *
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index 82a09e051c88..c583d68c4ad8 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -9,37 +9,11 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
-/*
- * Copied from kernel header include/uapi/asm-generic/signal-defs.h
- */
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
+#include "uapi/std/asm/syscall-types.h"
 
 #define SIGMAX_OLD	31
 #define SIGMAX		64
 
-/*Copied from the Linux kernel arch/powerpc/include/uapi/asm/signal.h */
-#define _KNSIG		64
-#define _NSIG_BPW       64
-#define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
-
-typedef struct {
-        uint64_t sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
-/* Copied from the Linux kernel arch/powerpc/include/uapi/asm/signal.h */
-#define SA_RESTORER     0x04000000U
-
-typedef struct {
-        rt_sighandler_t rt_sa_handler;
-        unsigned long rt_sa_flags;
-        rt_sigrestore_t rt_sa_restorer;
-        k_rtsigset_t rt_sa_mask;               /* mask last for extensibility */
-} rt_sigaction_t;
-
 /*
  * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
  */
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index 7b38c509f87a..58bc59919593 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -8,6 +8,8 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
+
 #include "bug.h"
 #include "images/core.pb-c.h"
 
@@ -17,55 +19,6 @@
 #define MAJOR(dev)		((dev)>>8)
 #define MINOR(dev)		((dev) & 0xff)
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG           64
-# define _NSIG_BPW      64
-
-#define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	u64 sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
-#define SA_RESTORER	0x04000000
-
-typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
-/*
- * Note: there is unaligned access on x86_64 and it's fine.
- * However, when porting this code -- keep in mind about possible issues
- * with unaligned rt_sa_mask.
- */
-typedef struct __attribute__((packed)) {
-	u32	rt_sa_handler;
-	u32	rt_sa_flags;
-	u32	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t_compat;
-
-typedef struct {
-	unsigned int	entry_number;
-	unsigned int	base_addr;
-	unsigned int	limit;
-	unsigned int	seg_32bit:1;
-	unsigned int	contents:2;
-	unsigned int	read_exec_only:1;
-	unsigned int	limit_in_pages:1;
-	unsigned int	seg_not_present:1;
-	unsigned int	useable:1;
-	unsigned int	lm:1;
-} user_desc_t;
-
 typedef struct {
 	uint64_t	r15;
 	uint64_t	r14;
-- 
2.7.4



More information about the CRIU mailing list