diff --git a/Makefile.config b/Makefile.config index 42b2d94e6..6ff42fe3f 100644 --- a/Makefile.config +++ b/Makefile.config @@ -19,13 +19,15 @@ CONFIG_FILE = $(SRC_DIR)/.config $(CONFIG_FILE): touch $(CONFIG_FILE) -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/compel/Makefile b/compel/Makefile index bfb79237d..4d149a23e 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 000000000..ee0e2185d --- /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 000000000..cdb03ef4c --- /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 000000000..7754721e2 --- /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 744809d07..b22b6d795 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 000000000..e69de29bb diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h index 564d027f2..3296153b3 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 c2ee5757f..216306351 100644 --- a/criu/Makefile +++ b/criu/Makefile @@ -17,6 +17,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.crtools b/criu/Makefile.crtools index eafb8ae5b..cd96cdf17 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 976fca200..17353ac95 100644 --- a/criu/arch/aarch64/include/asm/types.h +++ b/criu/arch/aarch64/include/asm/types.h @@ -10,29 +10,7 @@ #include "bitops.h" #include "asm/int.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; - -#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; +#include "uapi/std/asm/syscall-types.h" #define core_is_compat(core) false diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h index a4a752dad..e4dfd2cf1 100644 --- a/criu/arch/arm/include/asm/types.h +++ b/criu/arch/arm/include/asm/types.h @@ -9,29 +9,7 @@ #include "bitops.h" #include "asm/int.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; - -#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; +#include "uapi/std/asm/syscall-types.h" #define core_is_compat(core) false diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h index 73ab4d270..25e2125b2 100644 --- a/criu/arch/ppc64/include/asm/types.h +++ b/criu/arch/ppc64/include/asm/types.h @@ -9,40 +9,14 @@ #include "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; - -/*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; - -#define core_is_compat(core) false +#include "uapi/std/asm/syscall-types.h" typedef UserPpc64RegsEntry UserRegsEntry; #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__PPC64 +#define core_is_compat(core) false + #define CORE_THREAD_ARCH_INFO(core) core->ti_ppc64 static inline void *decode_pointer(uint64_t v) { return (void*)v; } diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h index fa2cb77f9..84a29ec12 100644 --- a/criu/arch/x86/include/asm/types.h +++ b/criu/arch/x86/include/asm/types.h @@ -8,6 +8,8 @@ #include "bitops.h" #include "asm/int.h" +#include "uapi/std/asm/syscall-types.h" + #include "images/core.pb-c.h" #ifdef CONFIG_X86_64 @@ -26,55 +28,6 @@ static inline int core_is_compat(CoreEntry *c) static inline int core_is_compat(CoreEntry *c) { return 0; } #endif /* CONFIG_X86_64 */ -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; - #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__X86_64 #define CORE_THREAD_ARCH_INFO(core) core->thread_info