[CRIU] [PATCH 04/22] compel: Shuffle source code for new directory structure

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 19 12:21:19 PDT 2016


The overall idea of compel structure is the following (I've
changed it a bit in compare with previous code  shuffling):

 - the files needed for uapi are sitting in uapi/compel
   directory, so when we start shipping the headers into
   system we should move the complete uapi/compel into
   say /usr/include/compel.

   The callers should include compel headers as

	#include <compel/***.h>

   in turn the compel itself should open them as

	#include "uapi/compel/***.h"

   Same time if some uapi header refers to another
   uapi header the inclusion of course should be
   done via natural <compel/***.h>

 - same applies to plugins: external reference

	#include <compel/plugins/***.h>

   and internal as

	#include "uapi/compel/plugins/***.h"

The requirement of inclusion via system wide path forces
us to export types needed, so we move CRIU's per-arch page.h,
fpu.h and parts of types.h into appropriate compel's arch
and then copy them into compel/include/uapi/compel directory
during building procedure. The CRIU itself start including
appropriate headers.

Of course makefiles are had to be lifed up as well
and piegen now exports external header inclusion.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Makefile.compel                                    |  17 ++-
 compel/Makefile                                    |  34 ++++-
 compel/arch/aarch64/src/lib/handle-elf.c           |   2 +-
 .../arch/aarch64/src/lib/include/compel/asm/fpu.h  |   4 +
 .../aarch64/src/lib/include/compel}/asm/page.h     |   6 +-
 .../aarch64/src/lib/include/compel/asm/types.h     |  60 ++++++++
 .../src/lib/include/{ => compel}/handle-elf.h      |   0
 .../arm/plugins/std/syscalls/Makefile.syscalls     |  22 +--
 .../arch/arm/plugins/std/syscalls/gen-syscalls.pl  |  16 +--
 compel/arch/arm/src/lib/handle-elf.c               |   2 +-
 compel/arch/arm/src/lib/include/compel/asm/fpu.h   |   4 +
 .../arch/arm/src/lib/include/compel}/asm/page.h    |   6 +-
 compel/arch/arm/src/lib/include/compel/asm/types.h |  94 ++++++++++++
 .../arm/src/lib/include/{ => compel}/handle-elf.h  |   0
 .../ppc64/plugins/std/syscalls/Makefile.syscalls   |  16 +--
 compel/arch/ppc64/src/lib/handle-elf.c             |   2 +-
 compel/arch/ppc64/src/lib/include/compel/asm/fpu.h |   4 +
 .../arch/ppc64/src/lib/include/compel}/asm/page.h  |   6 +-
 .../arch/ppc64/src/lib/include/compel/asm/types.h  | 114 +++++++++++++++
 .../src/lib/include/{ => compel}/handle-elf.h      |   0
 compel/arch/x86/plugins/std/prologue.S             |   2 +-
 .../x86/plugins/std/syscalls/Makefile.syscalls     |  26 ++--
 compel/arch/x86/src/lib/handle-elf.c               |   2 +-
 compel/arch/x86/src/lib/include/compel/asm/fpu.h   |  98 +++++++++++++
 .../arch/x86/src/lib/include/compel}/asm/page.h    |   6 +-
 compel/arch/x86/src/lib/include/compel/asm/types.h | 158 +++++++++++++++++++++
 .../x86/src/lib/include/{ => compel}/handle-elf.h  |   0
 compel/include/compel/asm-generic/int.h            |   1 +
 compel/include/compel/compiler.h                   |   1 +
 compel/include/{ => compel}/elf32-types.h          |   0
 compel/include/{ => compel}/elf64-types.h          |   0
 compel/include/{ => compel}/piegen.h               |   0
 compel/include/{ => compel}/shmem.h                |   0
 compel/include/compiler.h                          |   1 -
 compel/include/int.h                               |   1 -
 .../std => include/uapi/compel}/asm/.gitignore     |   0
 compel/include/uapi/{ => compel}/compel.h          |   0
 compel/include/uapi/{ => compel}/plugins.h         |   0
 compel/plugins/Makefile                            |   8 ++
 compel/plugins/fds/fds.c                           |   8 +-
 .../include/uapi/{ => compel/plugins}/plugin-fds.h |   0
 .../uapi/{ => compel/plugins}/plugin-shmem.h       |   0
 .../include/uapi/{ => compel/plugins}/plugin-std.h |   4 +-
 .../include/uapi/compel/plugins/std/asm/.gitignore |   0
 .../include/uapi/{ => compel/plugins}/std/string.h |   0
 .../uapi/{ => compel/plugins}/std/syscall-types.h  |   4 +-
 compel/plugins/shmem/shmem.c                       |   8 +-
 compel/plugins/std/std.c                           |   6 +-
 compel/plugins/std/string.c                        |   4 +-
 compel/src/lib/handle-elf.c                        |   4 +-
 criu/Makefile                                      |   6 +-
 criu/Makefile.crtools                              |   6 +-
 criu/arch/aarch64/Makefile                         |   2 -
 criu/arch/aarch64/include/asm/fpu.h                |   4 -
 criu/arch/aarch64/include/asm/parasite-syscall.h   |   4 -
 criu/arch/aarch64/include/asm/types.h              |  52 +------
 criu/arch/aarch64/infect.c                         |   4 +-
 criu/arch/aarch64/restorer.c                       |   5 +-
 criu/arch/aarch64/vdso-pie.c                       |   3 +-
 criu/arch/arm/Makefile                             |   2 -
 criu/arch/arm/include/asm/fpu.h                    |   4 -
 criu/arch/arm/include/asm/parasite-syscall.h       |   5 -
 criu/arch/arm/include/asm/types.h                  |  91 +-----------
 criu/arch/arm/infect.c                             |   4 +-
 criu/arch/arm/restorer.c                           |   5 +-
 criu/arch/ppc64/Makefile                           |   2 -
 criu/arch/ppc64/crtools.c                          |  13 +-
 criu/arch/ppc64/include/asm/fpu.h                  |   4 -
 criu/arch/ppc64/include/asm/parasite-syscall.h     |   4 -
 criu/arch/ppc64/include/asm/types.h                |  85 +----------
 criu/arch/ppc64/infect.c                           |   4 +-
 criu/arch/ppc64/restorer.c                         |   5 +-
 criu/arch/ppc64/vdso-pie.c                         |   3 +-
 criu/arch/x86/Makefile                             |   2 -
 criu/arch/x86/cpu.c                                |   1 -
 criu/arch/x86/crtools.c                            |   4 +-
 criu/arch/x86/include/asm/fpu.h                    | 102 -------------
 criu/arch/x86/include/asm/parasite-syscall.h       |  13 --
 criu/arch/x86/include/asm/restorer.h               |   4 +-
 criu/arch/x86/include/asm/types.h                  | 151 +-------------------
 criu/arch/x86/infect.c                             |   5 +-
 criu/arch/x86/restorer.c                           |   5 +-
 criu/arch/x86/sigaction_compat.c                   |   5 +-
 criu/arch/x86/vdso-pie.c                           |   3 +-
 criu/bfd.c                                         |   3 +-
 criu/cgroup.c                                      |   3 +-
 criu/cr-restore.c                                  |   3 +-
 criu/fsnotify.c                                    |   3 +-
 criu/include/lock.h                                |   2 +-
 criu/include/pagemap-cache.h                       |   4 +-
 criu/include/restorer.h                            |   3 +-
 criu/include/syscall-types.h                       |  57 --------
 criu/kerndat.c                                     |   3 +-
 criu/parasite-syscall.c                            |   3 +-
 criu/pie/Makefile                                  |   7 +-
 criu/pie/Makefile.library                          |   5 +-
 criu/pie/log-simple.c                              |   3 +-
 criu/pie/parasite-vdso.c                           |   4 +-
 criu/pie/parasite.c                                |   3 +-
 criu/pie/pie-relocs.c                              |   3 +-
 criu/pie/pie-relocs.h                              |   2 +-
 criu/pie/restorer.c                                |   3 +-
 criu/pie/util-fd.c                                 |   2 +-
 criu/pie/util.c                                    |   2 +-
 criu/shmem.c                                       |   3 +-
 criu/uffd.c                                        |   5 +-
 106 files changed, 771 insertions(+), 718 deletions(-)
 create mode 100644 compel/arch/aarch64/src/lib/include/compel/asm/fpu.h
 rename {criu/arch/aarch64/include => compel/arch/aarch64/src/lib/include/compel}/asm/page.h (72%)
 create mode 100644 compel/arch/aarch64/src/lib/include/compel/asm/types.h
 rename compel/arch/aarch64/src/lib/include/{ => compel}/handle-elf.h (100%)
 create mode 100644 compel/arch/arm/src/lib/include/compel/asm/fpu.h
 rename {criu/arch/arm/include => compel/arch/arm/src/lib/include/compel}/asm/page.h (71%)
 create mode 100644 compel/arch/arm/src/lib/include/compel/asm/types.h
 rename compel/arch/arm/src/lib/include/{ => compel}/handle-elf.h (100%)
 create mode 100644 compel/arch/ppc64/src/lib/include/compel/asm/fpu.h
 rename {criu/arch/ppc64/include => compel/arch/ppc64/src/lib/include/compel}/asm/page.h (79%)
 create mode 100644 compel/arch/ppc64/src/lib/include/compel/asm/types.h
 rename compel/arch/ppc64/src/lib/include/{ => compel}/handle-elf.h (100%)
 create mode 100644 compel/arch/x86/src/lib/include/compel/asm/fpu.h
 rename {criu/arch/x86/include => compel/arch/x86/src/lib/include/compel}/asm/page.h (71%)
 create mode 100644 compel/arch/x86/src/lib/include/compel/asm/types.h
 rename compel/arch/x86/src/lib/include/{ => compel}/handle-elf.h (100%)
 create mode 120000 compel/include/compel/asm-generic/int.h
 create mode 120000 compel/include/compel/compiler.h
 rename compel/include/{ => compel}/elf32-types.h (100%)
 rename compel/include/{ => compel}/elf64-types.h (100%)
 rename compel/include/{ => compel}/piegen.h (100%)
 rename compel/include/{ => compel}/shmem.h (100%)
 delete mode 120000 compel/include/compiler.h
 delete mode 120000 compel/include/int.h
 rename compel/{plugins/include/uapi/std => include/uapi/compel}/asm/.gitignore (100%)
 rename compel/include/uapi/{ => compel}/compel.h (100%)
 rename compel/include/uapi/{ => compel}/plugins.h (100%)
 rename compel/plugins/include/uapi/{ => compel/plugins}/plugin-fds.h (100%)
 rename compel/plugins/include/uapi/{ => compel/plugins}/plugin-shmem.h (100%)
 rename compel/plugins/include/uapi/{ => compel/plugins}/plugin-std.h (61%)
 create mode 100644 compel/plugins/include/uapi/compel/plugins/std/asm/.gitignore
 rename compel/plugins/include/uapi/{ => compel/plugins}/std/string.h (100%)
 rename compel/plugins/include/uapi/{ => compel/plugins}/std/syscall-types.h (91%)
 delete mode 100644 criu/arch/aarch64/include/asm/fpu.h
 delete mode 100644 criu/arch/arm/include/asm/fpu.h
 delete mode 100644 criu/arch/ppc64/include/asm/fpu.h
 delete mode 100644 criu/arch/x86/include/asm/fpu.h
 delete mode 100644 criu/include/syscall-types.h

diff --git a/Makefile.compel b/Makefile.compel
index e3edd558d762..b76aa44f7c27 100644
--- a/Makefile.compel
+++ b/Makefile.compel
@@ -11,30 +11,35 @@ $(COMPEL_VERSION_HEADER): $(SRC_DIR)/Makefile.versions
 	$(Q) echo "#define COMPEL_SO_VERSION_SUBLEVEL " $(COMPEL_SO_VERSION_SUBLEVEL)	>> $(COMPEL_VERSION_HEADER)
 	$(Q) echo "#endif /* COMPEL_SO_VERSION_H__ */"					>> $(COMPEL_VERSION_HEADER)
 
+build-headers-y:
+	$(Q) $(MAKE) $(build)=compel $@
+.PHONY: build-headers-y
+
+compel-prereq	+= build-headers-y
 #
 # Compel itself.
-compel/%: $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
+compel/%: $(compel-prereq)  $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel $@
 
 #
 # Plugins
-compel/plugins/%: $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
+compel/plugins/%: $(compel-prereq)  $(COMPEL_VERSION_HEADER) $(CONFIG_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel/plugins $@
 
 #
 # GNU make 4.x supports targets matching via wide
 # match targeting, where GNU make 3.x series (used on
 # Travis) is not, so we have to write them here explicitly.
-compel/plugins/std.built-in.o: $(COMPEL_VERSION_HEADER) .FORCE
+compel/plugins/std.built-in.o: $(compel-prereq)  $(COMPEL_VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel/plugins $@
 
-compel/plugins/shmem.built-in.o: $(COMPEL_VERSION_HEADER) .FORCE
+compel/plugins/shmem.built-in.o: $(compel-prereq)  $(COMPEL_VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel/plugins $@
 
-compel/plugins/fds.built-in.o: $(COMPEL_VERSION_HEADER) .FORCE
+compel/plugins/fds.built-in.o: $(compel-prereq)  $(COMPEL_VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=compel/plugins $@
 
-compel/compel: compel/built-in.o compel/lib.a $(COMPEL_VERSION_HEADER)
+compel/compel: compel/built-in.o compel/lib.a $(COMPEL_VERSION_HEADER) | $(compel-prereq)
 	$(call msg-link, $@)
 	$(Q) $(CC) $(CFLAGS) $^ $(WRAPFLAGS) $(LDFLAGS) -rdynamic -o $@
 
diff --git a/compel/Makefile b/compel/Makefile
index bfb79237dbb2..2464d614b117 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -4,17 +4,44 @@ include $(SRC_DIR)/Makefile.versions
 
 COMPEL_SO_VERSION	:= $(COMPEL_SO_VERSION_MAJOR)$(if $(COMPEL_SO_VERSION_MINOR),.$(COMPEL_SO_VERSION_MINOR))$(if $(COMPEL_SO_VERSION_SUBLEVEL),.$(COMPEL_SO_VERSION_SUBLEVEL))
 COMPEL_SO_VERSION_CODE	:= $(shell expr $(COMPEL_SO_VERSION_MAJOR) \* 65536 \+ $(COMPEL_SO_VERSION_MINOR) \* 256 \+ $(COMPEL_SO_VERSION_SUBLEVEL))
+ccflags-y		+= -iquote compel/arch/$(ARCH)/src/lib/include/compel
 ccflags-y		+= -iquote compel/arch/$(ARCH)/src/lib/include
-ccflags-y		+= -iquote compel/include
+ccflags-y		+= -iquote compel/include/
+ccflags-y		+= -iquote compel/include/compel
 ccflags-y		+= -iquote compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/criu/include
 ccflags-y		+= -fPIC
 
+#
+# UAPI inclusion, referred as <compel/...>
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
+
 lib-y			+= arch/$(ARCH)/src/lib/handle-elf.o
 host-lib-y		+= arch/$(ARCH)/src/lib/handle-elf.o
 lib-y			+= src/lib/handle-elf.o
 host-lib-y		+= src/lib/handle-elf.o
 
+#
+# This requires arch specific header to
+# be generated into uapi
+$(obj)/include/uapi/compel/asm/page.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/page.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+cleanup-y		+= $(obj)/include/uapi/compel/asm/page.h
+headers-y		+= $(obj)/include/uapi/compel/asm/page.h
+
+$(obj)/include/uapi/compel/asm/fpu.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/fpu.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+cleanup-y		+= $(obj)/include/uapi/compel/asm/fpu.h
+headers-y		+= $(obj)/include/uapi/compel/asm/fpu.h
+
+$(obj)/include/uapi/compel/asm/types.h: $(obj)/arch/$(ARCH)/src/lib/include/compel/asm/types.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+cleanup-y		+= $(obj)/include/uapi/compel/asm/types.h
+headers-y		+= $(obj)/include/uapi/compel/asm/types.h
+
 ifeq ($(ARCH),x86)
 lib-y			+= src/lib/handle-elf-32.o
 host-lib-y		+= src/lib/handle-elf-32.o
@@ -40,3 +67,6 @@ endif
 cleanup-y		+= compel/compel
 cleanup-y		+= compel/compel-host
 cleanup-y		+= compel/libcompel.so
+
+build-headers-y: $(headers-y)
+	@true
diff --git a/compel/arch/aarch64/src/lib/handle-elf.c b/compel/arch/aarch64/src/lib/handle-elf.c
index 633a382cc2da..22ae01c501fc 100644
--- a/compel/arch/aarch64/src/lib/handle-elf.c
+++ b/compel/arch/aarch64/src/lib/handle-elf.c
@@ -1,6 +1,6 @@
 #include <string.h>
 
-#include "uapi/compel.h"
+#include "uapi/compel/compel.h"
 
 #include "handle-elf.h"
 #include "piegen.h"
diff --git a/compel/arch/aarch64/src/lib/include/compel/asm/fpu.h b/compel/arch/aarch64/src/lib/include/compel/asm/fpu.h
new file mode 100644
index 000000000000..1c7c648edad5
--- /dev/null
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/fpu.h
@@ -0,0 +1,4 @@
+#ifndef UAPI_COMPEL_ASM__FPU_H__
+#define UAPI_COMPEL_ASM__FPU_H__
+
+#endif /* UAPI_COMPEL_ASM__FPU_H__ */
diff --git a/criu/arch/aarch64/include/asm/page.h b/compel/arch/aarch64/src/lib/include/compel/asm/page.h
similarity index 72%
rename from criu/arch/aarch64/include/asm/page.h
rename to compel/arch/aarch64/src/lib/include/compel/asm/page.h
index de1fe5428c50..7e29634cfd56 100644
--- a/criu/arch/aarch64/include/asm/page.h
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/page.h
@@ -1,5 +1,5 @@
-#ifndef __CR_ASM_PAGE_H__
-#define __CR_ASM_PAGE_H__
+#ifndef UAPI_COMPEL_ASM__PAGE_H__
+#define UAPI_COMPEL_ASM__PAGE_H__
 
 #include <unistd.h>
 
@@ -18,4 +18,4 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	sysconf(_SC_PAGESIZE)
 
-#endif /* __CR_ASM_PAGE_H__ */
+#endif /* UAPI_COMPEL_ASM__PAGE_H__ */
diff --git a/compel/arch/aarch64/src/lib/include/compel/asm/types.h b/compel/arch/aarch64/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..f6f66ebf7478
--- /dev/null
+++ b/compel/arch/aarch64/src/lib/include/compel/asm/types.h
@@ -0,0 +1,60 @@
+#ifndef UAPI_COMPEL_ASM_TYPES_H__
+#define UAPI_COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <asm/ptrace.h>
+
+#include <compel/plugins/std/syscall-types.h>
+#include <compel/asm/page.h>
+#include <compel/asm/fpu.h>
+
+#define SIGMAX			64
+#define SIGMAX_OLD		31
+
+/*
+ * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
+ *
+ * A thread ARM CPU context
+ */
+
+typedef struct user_pt_regs		user_regs_struct_t;
+typedef struct user_fpsimd_state	user_fpregs_struct_t;
+
+#define REG_RES(r)			((uint64_t)(r).regs[0])
+#define REG_IP(r)			((uint64_t)(r).pc)
+#define REG_SYSCALL_NR(r)		((uint64_t)(r).regs[8])
+
+#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;
+}
+
+#define AT_VECTOR_SIZE 40
+
+typedef uint64_t auxv_t;
+typedef uint64_t tls_t;
+
+#define ARCH_SI_TRAP		TRAP_BRKPT
+
+#define __NR(syscall, compat)	__NR_##syscall
+
+#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/aarch64/src/lib/include/handle-elf.h b/compel/arch/aarch64/src/lib/include/compel/handle-elf.h
similarity index 100%
rename from compel/arch/aarch64/src/lib/include/handle-elf.h
rename to compel/arch/aarch64/src/lib/include/compel/handle-elf.h
diff --git a/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls b/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
index 6be8cacbdcc4..9dc232bb93b1 100644
--- a/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
+++ b/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
@@ -1,14 +1,14 @@
 ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
 asflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
 
-sys-types		:= $(obj)/include/uapi/std/syscall-types.h
-sys-codes		:= $(obj)/include/uapi/std/syscall-codes.h
-sys-proto		:= $(obj)/include/uapi/std/syscall.h
+sys-types		:= $(obj)/include/uapi/compel/plugins/std/syscall-types.h
+sys-codes		:= $(obj)/include/uapi/compel/plugins/std/syscall-codes.h
+sys-proto		:= $(obj)/include/uapi/compel/plugins/std/syscall.h
 
 sys-def			:= $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
 sys-asm-common-name	:= std/syscalls/syscall-common.S
 sys-asm-common		:= $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
-sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-asm-types		:= $(obj)/include/uapi/compel/plugins/std/asm/syscall-types.h
 sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
 
 sys-gen			:= $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
@@ -49,11 +49,15 @@ $(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
 
 $(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
 	$(call msg-gen, $@)
-	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
-	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
-	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h
+	$(Q) cp $^ $@
+$(obj)/include/uapi/compel/plugins/std/syscall-aux.S: $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
+$(obj)/include/uapi/compel/plugins/std/syscall-aux.h: $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h
+	$(call msg-gen, $@)
+	$(Q) cp $^ $@
 
 std-headers-deps	+= $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
+std-headers-deps	+= $(obj)/include/uapi/compel/plugins/std/syscall-aux.S
+std-headers-deps	+= $(obj)/include/uapi/compel/plugins/std/syscall-aux.h
 mrproper-y		+= $(std-headers-deps)
-mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.S
-mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.h
diff --git a/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl b/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
index c683e4998b1a..c79a70dea661 100755
--- a/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
+++ b/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
@@ -6,14 +6,14 @@ use warnings;
 my $in         = $ARGV[0];
 my $codesout   = $ARGV[1];
 my $codes      = $ARGV[1];
-$codes         =~ s/.*include\///g;
+$codes         =~ s/.*include\/uapi\///g;
 my $protosout  = $ARGV[2];
 my $protos     = $ARGV[2];
-$protos        =~ s/.*include\///g;
+$protos        =~ s/.*include\/uapi\///g;
 my $asmout     = $ARGV[3];
 my $asmcommon  = $ARGV[4];
 my $prototypes = $ARGV[5];
-$prototypes    =~ s/.*include\///g;
+$prototypes    =~ s/.*include\/uapi\///g;
 my $bits       = $ARGV[6];
 
 my $codesdef   = $codes;
@@ -42,13 +42,13 @@ print PROTOSOUT <<"END";
 /* Autogenerated, don't edit */
 #ifndef $protosdef
 #define $protosdef
-#include "$prototypes"
-#include "$codes"
+#include <$prototypes>
+#include <$codes>
 END
 
 print ASMOUT <<"END";
 /* Autogenerated, don't edit */
-#include "$codes"
+#include <$codes>
 #include "$asmcommon"
 END
 
@@ -91,8 +91,8 @@ for (<IN>) {
 }
 
 if ($need_aux == 1) {
-	print ASMOUT   "#include \"uapi/std/syscall-aux.S\"\n";
-	print CODESOUT "#include \"uapi/std/syscall-aux.h\"\n";
+	print ASMOUT   "#include \<compel/plugins/std/syscall-aux.S\>\n";
+	print CODESOUT "#include \<compel/plugins/std/syscall-aux.h\>\n";
 }
 
 print CODESOUT  "#endif /* $codesdef */";
diff --git a/compel/arch/arm/src/lib/handle-elf.c b/compel/arch/arm/src/lib/handle-elf.c
index e2df0f90ddf5..4998688a0ad9 100644
--- a/compel/arch/arm/src/lib/handle-elf.c
+++ b/compel/arch/arm/src/lib/handle-elf.c
@@ -1,6 +1,6 @@
 #include <string.h>
 
-#include "uapi/compel.h"
+#include "uapi/compel/compel.h"
 
 #include "handle-elf.h"
 #include "piegen.h"
diff --git a/compel/arch/arm/src/lib/include/compel/asm/fpu.h b/compel/arch/arm/src/lib/include/compel/asm/fpu.h
new file mode 100644
index 000000000000..27dd71b3497e
--- /dev/null
+++ b/compel/arch/arm/src/lib/include/compel/asm/fpu.h
@@ -0,0 +1,4 @@
+#ifndef UAPI_COMPEL_ASM_FPU_H__
+#define UAPI_COMPEL_ASM_FPU_H__
+
+#endif /* UAPI_COMPEL_ASM_FPU_H__ */
diff --git a/criu/arch/arm/include/asm/page.h b/compel/arch/arm/src/lib/include/compel/asm/page.h
similarity index 71%
rename from criu/arch/arm/include/asm/page.h
rename to compel/arch/arm/src/lib/include/compel/asm/page.h
index 134835556c62..bd99cacb0b0d 100644
--- a/criu/arch/arm/include/asm/page.h
+++ b/compel/arch/arm/src/lib/include/compel/asm/page.h
@@ -1,5 +1,5 @@
-#ifndef __CR_ASM_PAGE_H__
-#define __CR_ASM_PAGE_H__
+#ifndef UAPI_COMPEL_ASM_PAGE_H__
+#define UAPI_COMPEL_ASM_PAGE_H__
 
 #ifndef PAGE_SHIFT
 # define PAGE_SHIFT	12
@@ -16,4 +16,4 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	PAGE_SIZE
 
-#endif /* __CR_ASM_PAGE_H__ */
+#endif /* UAPI_COMPEL_ASM_PAGE_H__ */
diff --git a/compel/arch/arm/src/lib/include/compel/asm/types.h b/compel/arch/arm/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..5937d3861210
--- /dev/null
+++ b/compel/arch/arm/src/lib/include/compel/asm/types.h
@@ -0,0 +1,94 @@
+#ifndef UAPI_COMPEL_ASM_TYPES_H__
+#define UAPI_COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <sys/mman.h>
+
+#include <compel/plugins/std/syscall-types.h>
+#include <compel/asm/page.h>
+#include <compel/asm/fpu.h>
+
+#define SIGMAX			64
+#define SIGMAX_OLD		31
+
+/*
+ * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
+ *
+ * A thread ARM CPU context
+ */
+
+typedef struct {
+	long			uregs[18];
+} user_regs_struct_t;
+
+typedef struct user_vfp		user_fpregs_struct_t;
+
+#define ARM_cpsr		uregs[16]
+#define ARM_pc			uregs[15]
+#define ARM_lr			uregs[14]
+#define ARM_sp			uregs[13]
+#define ARM_ip			uregs[12]
+#define ARM_fp			uregs[11]
+#define ARM_r10			uregs[10]
+#define ARM_r9			uregs[9]
+#define ARM_r8			uregs[8]
+#define ARM_r7			uregs[7]
+#define ARM_r6			uregs[6]
+#define ARM_r5			uregs[5]
+#define ARM_r4			uregs[4]
+#define ARM_r3			uregs[3]
+#define ARM_r2			uregs[2]
+#define ARM_r1			uregs[1]
+#define ARM_r0			uregs[0]
+#define ARM_ORIG_r0		uregs[17]
+
+
+/* Copied from arch/arm/include/asm/user.h */
+
+struct user_vfp {
+	unsigned long long	fpregs[32];
+	unsigned long		fpscr;
+};
+
+struct user_vfp_exc {
+	unsigned long		fpexc;
+	unsigned long		fpinst;
+	unsigned long		fpinst2;
+};
+
+#define REG_RES(regs)		((regs).ARM_r0)
+#define REG_IP(regs)		((regs).ARM_pc)
+#define REG_SYSCALL_NR(regs)	((regs).ARM_r7)
+
+#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;
+}
+
+#define AT_VECTOR_SIZE		40
+
+typedef uint32_t auxv_t;
+typedef uint32_t tls_t;
+
+#define ARCH_SI_TRAP		TRAP_BRKPT
+
+#define __NR(syscall, compat)	__NR_##syscall
+
+#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/arm/src/lib/include/handle-elf.h b/compel/arch/arm/src/lib/include/compel/handle-elf.h
similarity index 100%
rename from compel/arch/arm/src/lib/include/handle-elf.h
rename to compel/arch/arm/src/lib/include/compel/handle-elf.h
diff --git a/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls b/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
index 894e9dea2f31..c3855115d5da 100644
--- a/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
+++ b/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
@@ -1,14 +1,14 @@
 ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
 asflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
 
-sys-types		:= $(obj)/include/uapi/std/syscall-types.h
-sys-codes		:= $(obj)/include/uapi/std/syscall-codes.h
-sys-proto		:= $(obj)/include/uapi/std/syscall.h
+sys-types		:= $(obj)/include/uapi/compel/plugins/std/syscall-types.h
+sys-codes		:= $(obj)/include/uapi/compel/plugins/std/syscall-codes.h
+sys-proto		:= $(obj)/include/uapi/compel/plugins/std/syscall.h
 
 sys-def			:= $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-ppc64.tbl
 sys-asm-common-name	:= std/syscalls/syscall-common-ppc64.S
 sys-asm-common		:= $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
-sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-asm-types		:= $(obj)/include/uapi/compel/plugins/std/asm/syscall-types.h
 sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
 
 sys-asm			:= ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
@@ -29,15 +29,15 @@ $(sys-proto): $(sys-def)
 	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
 	$(Q) echo "#ifndef UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H__"					>> $@
 	$(Q) echo "#define UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H__"					>> $@
-	$(Q) echo "#include \"uapi/std/syscall-codes.h\""						>> $@
-	$(Q) echo "#include \"uapi/std/syscall-types.h\""						>> $@
+	$(Q) echo "#include <compel/plugins/std/syscall-codes.h>"					>> $@
+	$(Q) echo "#include <compel/plugins/std/syscall-types.h>"					>> $@
 	$(Q) cat $< | awk  '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}'	>> $@
 	$(Q) echo "#endif /* UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H__ */"				>> $@
 
 $(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
 	$(E) "  GEN     " $@
 	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
-	$(Q) echo "#include \"uapi/std/syscall-codes.h\""						>> $@
+	$(Q) echo "#include <compel/plugins/std/syscall-codes.h>"					>> $@
 	$(Q) echo "#include \"$(sys-asm-common-name)\""							>> $@
 	$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}'				>> $@
 
@@ -51,7 +51,7 @@ $(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
 
 $(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
 	$(call msg-gen, $@)
-	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
+	$(Q) cp $^ $@
 
 std-headers-deps	+= $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
 mrproper-y		+= $(std-headers-deps)
diff --git a/compel/arch/ppc64/src/lib/handle-elf.c b/compel/arch/ppc64/src/lib/handle-elf.c
index 6491f20850ad..78703bc1d9a6 100644
--- a/compel/arch/ppc64/src/lib/handle-elf.c
+++ b/compel/arch/ppc64/src/lib/handle-elf.c
@@ -1,6 +1,6 @@
 #include <string.h>
 
-#include "uapi/compel.h"
+#include "uapi/compel/compel.h"
 
 #include "handle-elf.h"
 #include "piegen.h"
diff --git a/compel/arch/ppc64/src/lib/include/compel/asm/fpu.h b/compel/arch/ppc64/src/lib/include/compel/asm/fpu.h
new file mode 100644
index 000000000000..27dd71b3497e
--- /dev/null
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/fpu.h
@@ -0,0 +1,4 @@
+#ifndef UAPI_COMPEL_ASM_FPU_H__
+#define UAPI_COMPEL_ASM_FPU_H__
+
+#endif /* UAPI_COMPEL_ASM_FPU_H__ */
diff --git a/criu/arch/ppc64/include/asm/page.h b/compel/arch/ppc64/src/lib/include/compel/asm/page.h
similarity index 79%
rename from criu/arch/ppc64/include/asm/page.h
rename to compel/arch/ppc64/src/lib/include/compel/asm/page.h
index 9d10455f1c47..3b85418eb547 100644
--- a/criu/arch/ppc64/include/asm/page.h
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/page.h
@@ -1,5 +1,5 @@
-#ifndef __CR_ASM_PAGE_H__
-#define __CR_ASM_PAGE_H__
+#ifndef UAPI_COMPEL_ASM_PAGE_H__
+#define UAPI_COMPEL_ASM_PAGE_H__
 
 #include <unistd.h>
 
@@ -22,4 +22,4 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	sysconf(_SC_PAGESIZE)
 
-#endif /* __CR_ASM_PAGE_H__ */
+#endif /* UAPI_COMPEL_ASM_PAGE_H__ */
diff --git a/compel/arch/ppc64/src/lib/include/compel/asm/types.h b/compel/arch/ppc64/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..4b83320cd6b8
--- /dev/null
+++ b/compel/arch/ppc64/src/lib/include/compel/asm/types.h
@@ -0,0 +1,114 @@
+#ifndef UAPI_COMPEL_ASM_TYPES_H__
+#define UAPI_COMPEL_ASM_TYPES_H__
+
+#include <stdbool.h>
+#include <signal.h>
+#include <stdint.h>
+
+#include <compel/plugins/std/syscall-types.h>
+#include <compel/asm/page.h>
+#include <compel/asm/fpu.h>
+
+#define SIGMAX_OLD	31
+#define SIGMAX		64
+
+/*
+ * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
+ */
+typedef struct {
+	unsigned long gpr[32];
+	unsigned long nip;
+	unsigned long msr;
+	unsigned long orig_gpr3;	/* Used for restarting system calls */
+	unsigned long ctr;
+	unsigned long link;
+	unsigned long xer;
+	unsigned long ccr;
+	unsigned long softe;		/* Soft enabled/disabled */
+	unsigned long trap;		/* Reason for being here */
+	/*
+	 * N.B. for critical exceptions on 4xx, the dar and dsisr
+	 * fields are overloaded to hold srr0 and srr1.
+	 */
+	unsigned long dar;		/* Fault registers */
+	unsigned long dsisr;		/* on 4xx/Book-E used for ESR */
+	unsigned long result;		/* Result of a system call */
+} user_regs_struct_t;
+
+#define NVSXREG	32
+
+#define USER_FPREGS_FL_FP	0x00001
+#define USER_FPREGS_FL_ALTIVEC	0x00002
+#define USER_FPREGS_FL_VSX	0x00004
+#define USER_FPREGS_FL_TM	0x00010
+
+#ifndef NT_PPC_TM_SPR
+# define NT_PPC_TM_CGPR		0x108		/* TM checkpointed GPR Registers */
+# define NT_PPC_TM_CFPR		0x109		/* TM checkpointed FPR Registers */
+# define NT_PPC_TM_CVMX		0x10a		/* TM checkpointed VMX Registers */
+# define NT_PPC_TM_CVSX		0x10b		/* TM checkpointed VSX Registers */
+# define NT_PPC_TM_SPR		0x10c		/* TM Special Purpose Registers */
+#endif
+
+#define MSR_TMA			(1UL<<34)	/* bit 29 Trans Mem state: Transactional */
+#define MSR_TMS			(1UL<<33)	/* bit 30 Trans Mem state: Suspended */
+#define MSR_TM			(1UL<<32)	/* bit 31 Trans Mem Available */
+#define MSR_VEC			(1UL<<25)
+#define MSR_VSX			(1UL<<23)
+
+#define MSR_TM_ACTIVE(x) ((((x) & MSR_TM) && ((x)&(MSR_TMA|MSR_TMS))) != 0)
+
+typedef struct {
+	uint64_t fpregs[NFPREG];
+	__vector128 vrregs[NVRREG];
+	uint64_t vsxregs[NVSXREG];
+
+	int flags;
+	struct tm_regs {
+		int flags;
+		struct {
+			uint64_t tfhar, texasr, tfiar;
+		} tm_spr_regs;
+		user_regs_struct_t regs;
+		uint64_t fpregs[NFPREG];
+		__vector128 vrregs[NVRREG];
+		uint64_t vsxregs[NVSXREG];
+	} tm;
+} user_fpregs_struct_t;
+
+#define REG_RES(regs)		((uint64_t)(regs).gpr[3])
+#define REG_IP(regs)		((uint64_t)(regs).nip)
+#define REG_SYSCALL_NR(regs)	((uint64_t)(regs).gpr[0])
+
+#define user_regs_native(pregs)	true
+
+/*
+ * Copied from the following kernel header files :
+ * 	include/linux/auxvec.h
+ *	arch/powerpc/include/uapi/asm/auxvec.h
+ *	include/linux/mm_types.h
+ */
+#define AT_VECTOR_SIZE_BASE	20
+#define AT_VECTOR_SIZE_ARCH	6
+#define AT_VECTOR_SIZE		(2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
+
+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; }
+
+#define ARCH_SI_TRAP TRAP_BRKPT
+
+#define __NR(syscall, compat)	__NR_##syscall
+
+#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/ppc64/src/lib/include/handle-elf.h b/compel/arch/ppc64/src/lib/include/compel/handle-elf.h
similarity index 100%
rename from compel/arch/ppc64/src/lib/include/handle-elf.h
rename to compel/arch/ppc64/src/lib/include/compel/handle-elf.h
diff --git a/compel/arch/x86/plugins/std/prologue.S b/compel/arch/x86/plugins/std/prologue.S
index 62e51c64dc43..fac8afa27458 100644
--- a/compel/arch/x86/plugins/std/prologue.S
+++ b/compel/arch/x86/plugins/std/prologue.S
@@ -1,7 +1,7 @@
 #include "asm/linkage.h"
 #include "asm/prologue.h"
 
-#include "uapi/std/syscall-codes.h"
+#include "uapi/compel/plugins/std/syscall-codes.h"
 
 	.section .compel.prologue.text, "ax"
 ENTRY(__export_std_prologue_start)
diff --git a/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls b/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
index a82e08e94c59..37be7237545c 100644
--- a/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
+++ b/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
@@ -1,15 +1,15 @@
 std-obj-y		+= ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
 
-sys-proto-types		:= $(obj)/include/uapi/std/syscall-types.h
-sys-proto-generic	:= $(obj)/include/uapi/std/syscall.h
-sys-codes-generic	:= $(obj)/include/uapi/std/syscall-codes.h
-sys-codes		 = $(obj)/include/uapi/std/syscall-codes-$(1).h
-sys-proto		 = $(obj)/include/uapi/std/syscall-$(1).h
+sys-proto-types		:= $(obj)/include/uapi/compel/plugins/std/syscall-types.h
+sys-proto-generic	:= $(obj)/include/uapi/compel/plugins/std/syscall.h
+sys-codes-generic	:= $(obj)/include/uapi/compel/plugins/std/syscall-codes.h
+sys-codes		 = $(obj)/include/uapi/compel/plugins/std/syscall-codes-$(1).h
+sys-proto		 = $(obj)/include/uapi/compel/plugins/std/syscall-$(1).h
 sys-def			 = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
 sys-asm			 = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
 sys-asm-common-name	 = std/syscalls/syscall-common-x86-$(1).S
 sys-asm-common		 = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
-sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-asm-types		:= $(obj)/include/uapi/compel/plugins/std/asm/syscall-types.h
 sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
 
 sys-bits		:= 64
@@ -39,8 +39,8 @@ $(sys-proto): $(sys-def) $(sys-proto-types)
 	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
 	$(Q) echo "#ifndef UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H_$(1)__"		>> $$@
 	$(Q) echo "#define UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H_$(1)__"		>> $$@
-	$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"'				>> $$@
-	$(Q) echo '#include "uapi/std/syscall-types.h"'					>> $$@
+	$(Q) echo '#include <compel/plugins/std/syscall-codes-$(1).h>'			>> $$@
+	$(Q) echo '#include <compel/plugins/std/syscall-types.h>'			>> $$@
 ifeq ($(1),32)
 	$(Q) echo '#include "asm/syscall32.h"'						>> $$@
 endif
@@ -53,7 +53,7 @@ define gen-rule-sys-asm
 $(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
 	$(call msg-gen, $$@)
 	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
-	$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"'				>> $$@
+	$(Q) echo '#include <compel/plugins/std/syscall-codes-$(1).h>'			>> $$@
 	$(Q) echo '#include "$(sys-asm-common-name)"'					>> $$@
 	$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}'	>> $$@
 endef
@@ -71,7 +71,7 @@ $(sys-codes-generic): $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_32.tbl $(sys-proto
 	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
 	$(Q) echo "#ifndef UAPI_COMPEL_PLUGIN_STD_SYSCALL_CODES_H__"			>> $@
 	$(Q) echo "#define UAPI_COMPEL_PLUGIN_STD_SYSCALL_CODES_H__"			>> $@
-	$(Q) echo '#include "uapi/std/syscall-codes-64.h"'		>> $@
+	$(Q) echo '#include <compel/plugins/std/syscall-codes-64.h>'			>> $@
 	$(Q) cat $< | awk '/^__NR/{NR32=$$1;				\
 		sub("^__NR", "__NR32", NR32);				\
 		print "\n#ifndef ", NR32;				\
@@ -87,9 +87,9 @@ $(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-typ
 	$(Q) echo "#define UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H__"			>> $@
 	$(Q) echo ""							>> $@
 	$(Q) echo "#ifdef CONFIG_X86_32"				>> $@
-	$(Q) echo '#include "uapi/std/syscall-32.h"'			>> $@
+	$(Q) echo '#include <compel/plugins/std/syscall-32.h>'				>> $@
 	$(Q) echo "#else"						>> $@
-	$(Q) echo '#include "uapi/std/syscall-64.h"'			>> $@
+	$(Q) echo '#include <compel/plugins/std/syscall-64.h>'				>> $@
 	$(Q) echo "#endif /* CONFIG_X86_32 */"				>> $@
 	$(Q) echo ""							>> $@
 	$(Q) echo "#endif /* UAPI_COMPEL_PLUGIN_STD_SYSCALL_PROTO_H__ */"		>> $@
@@ -110,7 +110,7 @@ $(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
 
 $(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
 	$(call msg-gen, $@)
-	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
+	$(Q) cp $^ $@
 
 std-headers-deps	+= $(call sys-codes,$(sys-bits))
 std-headers-deps	+= $(call sys-proto,$(sys-bits))
diff --git a/compel/arch/x86/src/lib/handle-elf.c b/compel/arch/x86/src/lib/handle-elf.c
index 7cfbaa1dd026..26b15ec7ac13 100644
--- a/compel/arch/x86/src/lib/handle-elf.c
+++ b/compel/arch/x86/src/lib/handle-elf.c
@@ -1,6 +1,6 @@
 #include <string.h>
 
-#include "uapi/compel.h"
+#include "uapi/compel/compel.h"
 
 #include "handle-elf.h"
 #include "piegen.h"
diff --git a/compel/arch/x86/src/lib/include/compel/asm/fpu.h b/compel/arch/x86/src/lib/include/compel/asm/fpu.h
new file mode 100644
index 000000000000..1d0f43c74f48
--- /dev/null
+++ b/compel/arch/x86/src/lib/include/compel/asm/fpu.h
@@ -0,0 +1,98 @@
+#ifndef UAPI_COMPEL_ASM_FPU_H__
+#define UAPI_COMPEL_ASM_FPU_H__
+
+#include <stdint.h>
+
+#define FP_MIN_ALIGN_BYTES		64
+
+#define FP_XSTATE_MAGIC1		0x46505853U
+#define FP_XSTATE_MAGIC2		0x46505845U
+#define FP_XSTATE_MAGIC2_SIZE		sizeof(FP_XSTATE_MAGIC2)
+
+#define XSTATE_FP			0x1
+#define XSTATE_SSE			0x2
+#define XSTATE_YMM			0x4
+
+#define FXSAVE_SIZE			512
+#define XSAVE_SIZE			832
+
+struct fpx_sw_bytes {
+	uint32_t			magic1;
+	uint32_t			extended_size;
+	uint64_t			xstate_bv;
+	uint32_t			xstate_size;
+	uint32_t			padding[7];
+};
+
+struct i387_fxsave_struct {
+	uint16_t			cwd; /* Control Word			*/
+	uint16_t			swd; /* Status Word			*/
+	uint16_t			twd; /* Tag Word			*/
+	uint16_t			fop; /* Last Instruction Opcode		*/
+	union {
+		struct {
+			uint64_t	rip; /* Instruction Pointer		*/
+			uint64_t	rdp; /* Data Pointer			*/
+		};
+		struct {
+			uint32_t	fip; /* FPU IP Offset			*/
+			uint32_t	fcs; /* FPU IP Selector			*/
+			uint32_t	foo; /* FPU Operand Offset		*/
+			uint32_t	fos; /* FPU Operand Selector		*/
+		};
+	};
+	uint32_t			mxcsr;		/* MXCSR Register State */
+	uint32_t			mxcsr_mask;	/* MXCSR Mask		*/
+
+	/* 8*16 bytes for each FP-reg = 128 bytes				*/
+	uint32_t			st_space[32];
+
+	/* 16*16 bytes for each XMM-reg = 256 bytes				*/
+	uint32_t			xmm_space[64];
+
+	uint32_t			padding[12];
+
+	union {
+		uint32_t		padding1[12];
+		uint32_t		sw_reserved[12];
+	};
+
+} __attribute__((aligned(16)));
+
+struct xsave_hdr_struct {
+	uint64_t			xstate_bv;
+	uint64_t			reserved1[2];
+	uint64_t			reserved2[5];
+} __attribute__((__packed__));
+
+struct ymmh_struct {
+	uint32_t			ymmh_space[64];
+} __attribute__((__packed__));
+
+/*
+ * cpu requires it to be 64 byte aligned
+ */
+struct xsave_struct {
+	struct i387_fxsave_struct	i387;
+	struct xsave_hdr_struct		xsave_hdr;
+	struct ymmh_struct		ymmh;
+} __attribute__((aligned(FP_MIN_ALIGN_BYTES))) __attribute__((__packed__));
+
+/*
+ * This one is used in restorer.
+ */
+typedef struct {
+	/*
+	 * The FPU xsave area must be continious and FP_MIN_ALIGN_BYTES
+	 * aligned, thus make sure the compiler won't insert any hole here.
+	 */
+
+	union {
+		struct xsave_struct	xsave;
+		uint8_t			__pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE];
+	};
+
+	uint8_t				has_fpu;
+} fpu_state_t;
+
+#endif /* UAPI_COMPEL_ASM_FPU_H__ */
diff --git a/criu/arch/x86/include/asm/page.h b/compel/arch/x86/src/lib/include/compel/asm/page.h
similarity index 71%
rename from criu/arch/x86/include/asm/page.h
rename to compel/arch/x86/src/lib/include/compel/asm/page.h
index 134835556c62..bd99cacb0b0d 100644
--- a/criu/arch/x86/include/asm/page.h
+++ b/compel/arch/x86/src/lib/include/compel/asm/page.h
@@ -1,5 +1,5 @@
-#ifndef __CR_ASM_PAGE_H__
-#define __CR_ASM_PAGE_H__
+#ifndef UAPI_COMPEL_ASM_PAGE_H__
+#define UAPI_COMPEL_ASM_PAGE_H__
 
 #ifndef PAGE_SHIFT
 # define PAGE_SHIFT	12
@@ -16,4 +16,4 @@
 #define PAGE_PFN(addr)	((addr) / PAGE_SIZE)
 #define page_size()	PAGE_SIZE
 
-#endif /* __CR_ASM_PAGE_H__ */
+#endif /* UAPI_COMPEL_ASM_PAGE_H__ */
diff --git a/compel/arch/x86/src/lib/include/compel/asm/types.h b/compel/arch/x86/src/lib/include/compel/asm/types.h
new file mode 100644
index 000000000000..1abdf8938d5b
--- /dev/null
+++ b/compel/arch/x86/src/lib/include/compel/asm/types.h
@@ -0,0 +1,158 @@
+#ifndef UAPI_COMPEL_ASM_TYPES_H__
+#define UAPI_COMPEL_ASM_TYPES_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <compel/plugins/std/syscall-types.h>
+#include <compel/asm/page.h>
+#include <compel/asm/fpu.h>
+
+#define SIGMAX			64
+#define SIGMAX_OLD		31
+
+typedef struct {
+	uint64_t	r15;
+	uint64_t	r14;
+	uint64_t	r13;
+	uint64_t	r12;
+	uint64_t	bp;
+	uint64_t	bx;
+	uint64_t	r11;
+	uint64_t	r10;
+	uint64_t	r9;
+	uint64_t	r8;
+	uint64_t	ax;
+	uint64_t	cx;
+	uint64_t	dx;
+	uint64_t	si;
+	uint64_t	di;
+	uint64_t	orig_ax;
+	uint64_t	ip;
+	uint64_t	cs;
+	uint64_t	flags;
+	uint64_t	sp;
+	uint64_t	ss;
+	uint64_t	fs_base;
+	uint64_t	gs_base;
+	uint64_t	ds;
+	uint64_t	es;
+	uint64_t	fs;
+	uint64_t	gs;
+} user_regs_struct64;
+
+typedef struct {
+	uint32_t	bx;
+	uint32_t	cx;
+	uint32_t	dx;
+	uint32_t	si;
+	uint32_t	di;
+	uint32_t	bp;
+	uint32_t	ax;
+	uint32_t	ds;
+	uint32_t	es;
+	uint32_t	fs;
+	uint32_t	gs;
+	uint32_t	orig_ax;
+	uint32_t	ip;
+	uint32_t	cs;
+	uint32_t	flags;
+	uint32_t	sp;
+	uint32_t	ss;
+} user_regs_struct32;
+
+#ifdef CONFIG_X86_64
+/*
+ * To be sure that we rely on inited reg->__is_native, this member
+ * is (short int) instead of initial (bool). The right way to
+ * check if regs are native or compat is to use user_regs_native() macro.
+ * This should cost nothing, as *usually* sizeof(bool) == sizeof(short)
+ */
+typedef struct {
+	union {
+		user_regs_struct64 native;
+		user_regs_struct32 compat;
+	};
+	short __is_native; /* use user_regs_native macro to check it */
+} user_regs_struct_t;
+
+#define NATIVE_MAGIC	0x0A
+#define COMPAT_MAGIC	0x0C
+
+static inline bool user_regs_native(user_regs_struct_t *pregs)
+{
+	return pregs->__is_native == NATIVE_MAGIC;
+}
+
+#define get_user_reg(pregs, name)			\
+	((user_regs_native(pregs))		?	\
+	 ((pregs)->native.name)			:	\
+	 ((pregs)->compat.name))
+
+#define set_user_reg(pregs, name, val)			\
+	((user_regs_native(pregs))		?	\
+	 ((pregs)->native.name = (val))		:	\
+	 ((pregs)->compat.name = (val)))
+
+#else /* CONFIG_X86_64 */
+
+typedef struct {
+	union {
+		user_regs_struct32 native;
+	};
+} user_regs_struct_t;
+
+#define user_regs_native(pregs)		true
+#define get_user_reg(pregs, name)	((pregs)->native.name)
+#define set_user_reg(pregs, name, val)	((pregs)->native.name = val)
+
+#endif /* CONFIG_X86_64 */
+
+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; }
+
+#define REG_RES(regs)		get_user_reg(&regs, ax)
+#define REG_IP(regs)		get_user_reg(&regs, ip)
+#define REG_SYSCALL_NR(regs)	get_user_reg(&regs, orig_ax)
+
+typedef uint64_t auxv_t;
+
+/*
+ * Linux preserves three TLS segments in GDT.
+ * Offsets in GDT differ between 32-bit and 64-bit machines.
+ * For 64-bit x86 those GDT offsets are the same
+ * for native and compat tasks.
+ */
+#define GDT_ENTRY_TLS_MIN		12
+#define GDT_ENTRY_TLS_MAX		14
+#define GDT_ENTRY_TLS_NUM		3
+typedef struct {
+	user_desc_t		desc[GDT_ENTRY_TLS_NUM];
+} tls_t;
+
+#define AT_VECTOR_SIZE 44
+
+#define __NR(syscall, compat)	((compat) ? __NR32_##syscall : __NR_##syscall)
+
+/*
+ * For x86_32 __NR_mmap inside the kernel represents old_mmap system
+ * call, but since we didn't use it yet lets go further and simply
+ * define own alias for __NR_mmap2 which would allow us to unify code
+ * between 32 and 64 bits version.
+ */
+#define __NR32_mmap __NR32_mmap2
+
+#define ARCH_SI_TRAP SI_KERNEL
+
+#endif /* UAPI_COMPEL_ASM_TYPES_H__ */
diff --git a/compel/arch/x86/src/lib/include/handle-elf.h b/compel/arch/x86/src/lib/include/compel/handle-elf.h
similarity index 100%
rename from compel/arch/x86/src/lib/include/handle-elf.h
rename to compel/arch/x86/src/lib/include/compel/handle-elf.h
diff --git a/compel/include/compel/asm-generic/int.h b/compel/include/compel/asm-generic/int.h
new file mode 120000
index 000000000000..cd5176e289e2
--- /dev/null
+++ b/compel/include/compel/asm-generic/int.h
@@ -0,0 +1 @@
+../../../../criu/include/asm-generic/int.h
\ No newline at end of file
diff --git a/compel/include/compel/compiler.h b/compel/include/compel/compiler.h
new file mode 120000
index 000000000000..ab14103d453a
--- /dev/null
+++ b/compel/include/compel/compiler.h
@@ -0,0 +1 @@
+../../../criu/include/compiler.h
\ No newline at end of file
diff --git a/compel/include/elf32-types.h b/compel/include/compel/elf32-types.h
similarity index 100%
rename from compel/include/elf32-types.h
rename to compel/include/compel/elf32-types.h
diff --git a/compel/include/elf64-types.h b/compel/include/compel/elf64-types.h
similarity index 100%
rename from compel/include/elf64-types.h
rename to compel/include/compel/elf64-types.h
diff --git a/compel/include/piegen.h b/compel/include/compel/piegen.h
similarity index 100%
rename from compel/include/piegen.h
rename to compel/include/compel/piegen.h
diff --git a/compel/include/shmem.h b/compel/include/compel/shmem.h
similarity index 100%
rename from compel/include/shmem.h
rename to compel/include/compel/shmem.h
diff --git a/compel/include/compiler.h b/compel/include/compiler.h
deleted file mode 120000
index ef56d20f668e..000000000000
--- a/compel/include/compiler.h
+++ /dev/null
@@ -1 +0,0 @@
-../../criu/include/compiler.h
\ No newline at end of file
diff --git a/compel/include/int.h b/compel/include/int.h
deleted file mode 120000
index 5c118d596759..000000000000
--- a/compel/include/int.h
+++ /dev/null
@@ -1 +0,0 @@
-../../criu/include/asm-generic/int.h
\ No newline at end of file
diff --git a/compel/plugins/include/uapi/std/asm/.gitignore b/compel/include/uapi/compel/asm/.gitignore
similarity index 100%
rename from compel/plugins/include/uapi/std/asm/.gitignore
rename to compel/include/uapi/compel/asm/.gitignore
diff --git a/compel/include/uapi/compel.h b/compel/include/uapi/compel/compel.h
similarity index 100%
rename from compel/include/uapi/compel.h
rename to compel/include/uapi/compel/compel.h
diff --git a/compel/include/uapi/plugins.h b/compel/include/uapi/compel/plugins.h
similarity index 100%
rename from compel/include/uapi/plugins.h
rename to compel/include/uapi/compel/plugins.h
diff --git a/compel/plugins/Makefile b/compel/plugins/Makefile
index ac54f7c2ec8a..b65f8b5ed1fa 100644
--- a/compel/plugins/Makefile
+++ b/compel/plugins/Makefile
@@ -6,8 +6,14 @@ PLUGIN_ARCH_DIR		:= compel/arch/$(ARCH)/plugins
 #
 # CFLAGS, ASFLAGS, LDFLAGS
 
+#
+# UAPI inclusion, referred as <compel/...>
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
+
 # General compel includes
 ccflags-y		+= -iquote $(SRC_DIR)/compel/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include/compel
 ccflags-y		+= -fno-stack-protector
 
 # General compel/plugins includes
@@ -15,6 +21,8 @@ ccflags-y		+= -iquote $(obj)/include
 ccflags-y		+= -iquote $(obj)/include/uapi
 asflags-y		+= -iquote $(obj)/include
 asflags-y		+= -iquote $(obj)/include/uapi
+asflags-y		+= -I compel/include/uapi
+asflags-y		+= -I compel/plugins/include/uapi
 
 # Arch compel/plugins includes
 ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/include
diff --git a/compel/plugins/fds/fds.c b/compel/plugins/fds/fds.c
index fa739058f5d6..5ea5148a2ef4 100644
--- a/compel/plugins/fds/fds.c
+++ b/compel/plugins/fds/fds.c
@@ -1,8 +1,8 @@
-#include "uapi/plugins.h"
+#include "uapi/compel/plugins.h"
 
-#include "uapi/std/syscall.h"
-#include "uapi/std/string.h"
-#include "uapi/plugin-fds.h"
+#include "uapi/compel/plugins/std/syscall.h"
+#include "uapi/compel/plugins/std/string.h"
+#include "uapi/compel/plugins/plugin-fds.h"
 
 #include "std-priv.h"
 
diff --git a/compel/plugins/include/uapi/plugin-fds.h b/compel/plugins/include/uapi/compel/plugins/plugin-fds.h
similarity index 100%
rename from compel/plugins/include/uapi/plugin-fds.h
rename to compel/plugins/include/uapi/compel/plugins/plugin-fds.h
diff --git a/compel/plugins/include/uapi/plugin-shmem.h b/compel/plugins/include/uapi/compel/plugins/plugin-shmem.h
similarity index 100%
rename from compel/plugins/include/uapi/plugin-shmem.h
rename to compel/plugins/include/uapi/compel/plugins/plugin-shmem.h
diff --git a/compel/plugins/include/uapi/plugin-std.h b/compel/plugins/include/uapi/compel/plugins/plugin-std.h
similarity index 61%
rename from compel/plugins/include/uapi/plugin-std.h
rename to compel/plugins/include/uapi/compel/plugins/plugin-std.h
index b77a7b44975b..97a13388ab59 100644
--- a/compel/plugins/include/uapi/plugin-std.h
+++ b/compel/plugins/include/uapi/compel/plugins/plugin-std.h
@@ -1,7 +1,7 @@
 #ifndef COMPEL_PLUGIN_STD_STD_H__
 #define COMPEL_PLUGIN_STD_STD_H__
 
-#include "uapi/plugins.h"
-#include "uapi/std/syscall.h"
+#include <compel/plugins.h>
+#include <compel/plugins/std/syscall.h>
 
 #endif /* COMPEL_PLUGIN_STD_STD_H__ */
diff --git a/compel/plugins/include/uapi/compel/plugins/std/asm/.gitignore b/compel/plugins/include/uapi/compel/plugins/std/asm/.gitignore
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/compel/plugins/include/uapi/std/string.h b/compel/plugins/include/uapi/compel/plugins/std/string.h
similarity index 100%
rename from compel/plugins/include/uapi/std/string.h
rename to compel/plugins/include/uapi/compel/plugins/std/string.h
diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
similarity index 91%
rename from compel/plugins/include/uapi/std/syscall-types.h
rename to compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
index 3296153b39a0..4a907765b8be 100644
--- a/compel/plugins/include/uapi/std/syscall-types.h
+++ b/compel/plugins/include/uapi/compel/plugins/std/syscall-types.h
@@ -14,7 +14,7 @@
 #include <fcntl.h>
 #include <time.h>
 
-#include "int.h"
+#include "asm-generic/int.h"
 
 struct cap_header {
 	u32 version;
@@ -52,6 +52,6 @@ struct krlimit {
 /* Type of timers in the kernel.  */
 typedef int kernel_timer_t;
 
-#include "uapi/std/asm/syscall-types.h"
+#include <compel/plugins/std/asm/syscall-types.h>
 
 #endif /* COMPEL_SYSCALL_TYPES_H__ */
diff --git a/compel/plugins/shmem/shmem.c b/compel/plugins/shmem/shmem.c
index 9ded93fb3e3d..cf499393ff70 100644
--- a/compel/plugins/shmem/shmem.c
+++ b/compel/plugins/shmem/shmem.c
@@ -1,9 +1,9 @@
 #include <sys/mman.h>
 
-#include "uapi/plugins.h"
-#include "uapi/plugin-shmem.h"
-#include "uapi/std/syscall.h"
-#include "shmem.h"
+#include "uapi/compel/plugins.h"
+#include "uapi/compel/plugins/plugin-shmem.h"
+#include "uapi/compel/plugins/std/syscall.h"
+
 #include "std-priv.h"
 
 void *shmem_create(unsigned long size)
diff --git a/compel/plugins/std/std.c b/compel/plugins/std/std.c
index ada3f09d21a3..493f47efc905 100644
--- a/compel/plugins/std/std.c
+++ b/compel/plugins/std/std.c
@@ -1,8 +1,8 @@
 #include <sys/types.h>
 
-#include "int.h"
-#include "uapi/plugins.h"
-#include "uapi/plugin-std.h"
+#include "asm-generic/int.h"
+#include "uapi/compel/plugins.h"
+#include "uapi/compel/plugins/plugin-std.h"
 
 #include "asm/prologue.h"
 
diff --git a/compel/plugins/std/string.c b/compel/plugins/std/string.c
index 6e5d42ed1ea7..6f4ade7c5d92 100644
--- a/compel/plugins/std/string.c
+++ b/compel/plugins/std/string.c
@@ -2,8 +2,8 @@
 #include <stdbool.h>
 #include <stdarg.h>
 
-#include "uapi/std/syscall.h"
-#include "uapi/std/string.h"
+#include "uapi/compel/plugins/std/syscall.h"
+#include "uapi/compel/plugins/std/string.h"
 
 static const char conv_tab[] = "0123456789abcdefghijklmnopqrstuvwxyz";
 
diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index 32759fe0f714..8fa89135e268 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -11,7 +11,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
-#include "uapi/compel.h"
+#include "uapi/compel/compel.h"
 
 #include "asm-generic/int.h"
 
@@ -222,7 +222,7 @@ int __handle_elf(void *mem, size_t size)
 	}
 
 	pr_out("/* Autogenerated from %s */\n", opts.input_filename);
-	pr_out("#include \"%s/compel.h\"\n", opts.uapi_dir);
+	pr_out("#include <%s/compel.h>\n", opts.uapi_dir);
 
 	for (i = 0; i < symtab_hdr->sh_size / symtab_hdr->sh_entsize; i++) {
 		Elf_Sym *sym = &symbols[i];
diff --git a/criu/Makefile b/criu/Makefile
index cf962d4ef4ef..e9cc9fd626b7 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -16,9 +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
+
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
 
 export ccflags-y
 
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index 8b6535c26679..3563de727063 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -1,7 +1,7 @@
 ccflags-y		+= -iquote criu/$(ARCH)
-ccflags-y		+= -iquote compel/plugins/include
-ccflags-y		+= -iquote compel/include
-ccflags-y		+= -iquote compel/arch/$(ARCH)/plugins/std
+
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
 
 obj-y			+= infect.o
 obj-y			+= infect-rpc.o
diff --git a/criu/arch/aarch64/Makefile b/criu/arch/aarch64/Makefile
index 8d4759421b25..6ae255a8aad9 100644
--- a/criu/arch/aarch64/Makefile
+++ b/criu/arch/aarch64/Makefile
@@ -2,8 +2,6 @@ builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR)
 ccflags-y		+= -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/aarch64/include/asm/fpu.h b/criu/arch/aarch64/include/asm/fpu.h
deleted file mode 100644
index 7f476d541a7d..000000000000
--- a/criu/arch/aarch64/include/asm/fpu.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef __CR_ASM_FPU_H__
-#define __CR_ASM_FPU_H__
-
-#endif /* __CR_ASM_FPU_H__ */
diff --git a/criu/arch/aarch64/include/asm/parasite-syscall.h b/criu/arch/aarch64/include/asm/parasite-syscall.h
index e420ccbdc625..4a370f605f57 100644
--- a/criu/arch/aarch64/include/asm/parasite-syscall.h
+++ b/criu/arch/aarch64/include/asm/parasite-syscall.h
@@ -3,10 +3,6 @@
 
 struct parasite_ctl;
 
-#define ARCH_SI_TRAP TRAP_BRKPT
-
-#define __NR(syscall, compat)	__NR_##syscall
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 #endif
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 0fd5972ae543..c1020a5eefa5 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -4,58 +4,17 @@
 #include <stdbool.h>
 #include <signal.h>
 #include <asm/ptrace.h>
+
+#include <compel/plugins/std/asm/syscall-types.h>
+#include <compel/asm/types.h>
+
 #include "images/core.pb-c.h"
 
-#include "asm/page.h"
 #include "asm/bitops.h"
 #include "asm/int.h"
 
-#include "uapi/std/asm/syscall-types.h"
-
-#define SIGMAX			64
-#define SIGMAX_OLD		31
-
-/*
- * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
- *
- * A thread ARM CPU context
- */
-
-typedef struct user_pt_regs user_regs_struct_t;
-typedef struct user_fpsimd_state user_fpregs_struct_t;
-
-
-#define REG_RES(r)		((u64)(r).regs[0])
-#define REG_IP(r)		((u64)(r).pc)
-#define REG_SYSCALL_NR(r)	((u64)(r).regs[8])
-
-#define user_regs_native(pregs)			true
 #define core_is_compat(core)			false
 
-/*
- * 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)
-
-int munmap(void *addr, size_t length);
-
-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;
-}
-
-#define AT_VECTOR_SIZE 40
-
 typedef UserAarch64RegsEntry UserRegsEntry;
 
 #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__AARCH64
@@ -64,9 +23,6 @@ typedef UserAarch64RegsEntry UserRegsEntry;
 
 #define TI_SP(core) ((core)->ti_aarch64->gpregs->sp)
 
-typedef uint64_t auxv_t;
-typedef uint64_t tls_t;
-
 static inline void *decode_pointer(uint64_t v) { return (void*)v; }
 static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; }
 
diff --git a/criu/arch/aarch64/infect.c b/criu/arch/aarch64/infect.c
index bcf4724c3e5d..aaa91b8c162a 100644
--- a/criu/arch/aarch64/infect.c
+++ b/criu/arch/aarch64/infect.c
@@ -1,7 +1,9 @@
 #include <sys/ptrace.h>
 #include <sys/types.h>
+
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/parasite-syscall.h"
-#include "uapi/std/syscall-codes.h"
 #include "asm/types.h"
 #include "criu-log.h"
 #include "kerndat.h"
diff --git a/criu/arch/aarch64/restorer.c b/criu/arch/aarch64/restorer.c
index 8a206315ddc0..e0bc2cd59382 100644
--- a/criu/arch/aarch64/restorer.c
+++ b/criu/arch/aarch64/restorer.c
@@ -1,12 +1,13 @@
 #include <unistd.h>
 
+#include <compel/plugins/std/syscall.h>
+#include <compel/asm/fpu.h>
+
 #include "restorer.h"
 #include "asm/restorer.h"
 #include "asm/string.h"
 
-#include "uapi/std/syscall.h"
 #include "log.h"
-#include "asm/fpu.h"
 #include "cpu.h"
 
 int restore_nonsigframe_gpregs(UserRegsEntry *r)
diff --git a/criu/arch/aarch64/vdso-pie.c b/criu/arch/aarch64/vdso-pie.c
index 6967b5cf644c..172f13d4485b 100644
--- a/criu/arch/aarch64/vdso-pie.c
+++ b/criu/arch/aarch64/vdso-pie.c
@@ -1,9 +1,10 @@
 #include <unistd.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/arch/arm/Makefile b/criu/arch/arm/Makefile
index 87c6fd67d9b3..69de18e49585 100644
--- a/criu/arch/arm/Makefile
+++ b/criu/arch/arm/Makefile
@@ -1,8 +1,6 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/arm/include/asm/fpu.h b/criu/arch/arm/include/asm/fpu.h
deleted file mode 100644
index 7f476d541a7d..000000000000
--- a/criu/arch/arm/include/asm/fpu.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef __CR_ASM_FPU_H__
-#define __CR_ASM_FPU_H__
-
-#endif /* __CR_ASM_FPU_H__ */
diff --git a/criu/arch/arm/include/asm/parasite-syscall.h b/criu/arch/arm/include/asm/parasite-syscall.h
index 7beec792fccc..5c880fdaa9d5 100644
--- a/criu/arch/arm/include/asm/parasite-syscall.h
+++ b/criu/arch/arm/include/asm/parasite-syscall.h
@@ -1,11 +1,6 @@
 #ifndef __CR_ASM_PARASITE_SYSCALL_H__
 #define __CR_ASM_PARASITE_SYSCALL_H__
 
-
-#define ARCH_SI_TRAP TRAP_BRKPT
-
-#define __NR(syscall, compat)	__NR_##syscall
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 #endif
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index 4f3b7cf52d3b..77c081dc4f60 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -3,96 +3,18 @@
 
 #include <stdbool.h>
 #include <signal.h>
+
+#include <compel/plugins/std/asm/syscall-types.h>
+#include <compel/asm/types.h>
+#include <compel/asm/page.h>
+
 #include "images/core.pb-c.h"
 
-#include "asm/page.h"
 #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)
-
-/*
- * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
- *
- * A thread ARM CPU context
- */
-
-typedef struct {
-        long uregs[18];
-} user_regs_struct_t;
-
-typedef struct user_vfp user_fpregs_struct_t;
-
-#define ARM_cpsr        uregs[16]
-#define ARM_pc          uregs[15]
-#define ARM_lr          uregs[14]
-#define ARM_sp          uregs[13]
-#define ARM_ip          uregs[12]
-#define ARM_fp          uregs[11]
-#define ARM_r10         uregs[10]
-#define ARM_r9          uregs[9]
-#define ARM_r8          uregs[8]
-#define ARM_r7          uregs[7]
-#define ARM_r6          uregs[6]
-#define ARM_r5          uregs[5]
-#define ARM_r4          uregs[4]
-#define ARM_r3          uregs[3]
-#define ARM_r2          uregs[2]
-#define ARM_r1          uregs[1]
-#define ARM_r0          uregs[0]
-#define ARM_ORIG_r0     uregs[17]
-
-
-/* Copied from arch/arm/include/asm/user.h */
-
-struct user_vfp {
-	unsigned long long fpregs[32];
-	unsigned long fpscr;
-};
-
-struct user_vfp_exc {
-        unsigned long   fpexc;
-	unsigned long   fpinst;
-	unsigned long   fpinst2;
-};
-
-#define REG_RES(regs) ((regs).ARM_r0)
-#define REG_IP(regs)  ((regs).ARM_pc)
-#define REG_SYSCALL_NR(regs) ((regs).ARM_r7)
-
-#define user_regs_native(pregs)			true
 #define core_is_compat(core)			false
 
-/*
- * 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
-
-int munmap(void *addr, size_t length);
-
-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;
-}
-
-#define AT_VECTOR_SIZE 40
-
 typedef UserArmRegsEntry UserRegsEntry;
 
 #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__ARM
@@ -101,9 +23,6 @@ typedef UserArmRegsEntry UserRegsEntry;
 
 #define TI_SP(core) ((core)->ti_arm->gpregs->sp)
 
-typedef u32 auxv_t;
-typedef u32 tls_t;
-
 static inline void *decode_pointer(u64 v) { return (void*)(u32)v; }
 static inline u64 encode_pointer(void *p) { return (u32)p; }
 
diff --git a/criu/arch/arm/infect.c b/criu/arch/arm/infect.c
index ec84c20aabb5..6f87a33d23d8 100644
--- a/criu/arch/arm/infect.c
+++ b/criu/arch/arm/infect.c
@@ -1,7 +1,9 @@
 #include <sys/ptrace.h>
 #include <sys/types.h>
+
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/parasite-syscall.h"
-#include "uapi/std/syscall-codes.h"
 #include "asm/types.h"
 #include "criu-log.h"
 #include "kerndat.h"
diff --git a/criu/arch/arm/restorer.c b/criu/arch/arm/restorer.c
index ea9ae680547a..729e404a7e26 100644
--- a/criu/arch/arm/restorer.c
+++ b/criu/arch/arm/restorer.c
@@ -4,9 +4,10 @@
 #include "asm/restorer.h"
 #include "asm/string.h"
 
-#include "uapi/std/syscall.h"
+#include <compel/plugins/std/syscall.h>
+#include <compel/asm/fpu.h>
+
 #include "log.h"
-#include "asm/fpu.h"
 #include "cpu.h"
 
 int restore_nonsigframe_gpregs(UserArmRegsEntry *r)
diff --git a/criu/arch/ppc64/Makefile b/criu/arch/ppc64/Makefile
index 87c6fd67d9b3..69de18e49585 100644
--- a/criu/arch/ppc64/Makefile
+++ b/criu/arch/ppc64/Makefile
@@ -1,8 +1,6 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c
index e2baa7e3e715..33134b1abc2a 100644
--- a/criu/arch/ppc64/crtools.c
+++ b/criu/arch/ppc64/crtools.c
@@ -5,8 +5,9 @@
 #include <asm/unistd.h>
 #include <sys/uio.h>
 
+#include <compel/asm/fpu.h>
+
 #include "asm/types.h"
-#include "asm/fpu.h"
 #include "asm/restorer.h"
 #include "asm/dump.h"
 
@@ -24,16 +25,6 @@
 #include "images/core.pb-c.h"
 #include "images/creds.pb-c.h"
 
-/* FIXME -- copied between crtools.c and infect.c */
-#define MSR_TMA (1UL<<34)	/* bit 29 Trans Mem state: Transactional */
-#define MSR_TMS (1UL<<33)	/* bit 30 Trans Mem state: Suspended */
-#define MSR_TM  (1UL<<32)	/* bit 31 Trans Mem Available */
-#define MSR_VEC (1UL<<25)
-#define MSR_VSX (1UL<<23)
-
-#define MSR_TM_ACTIVE(x) ((((x) & MSR_TM) && ((x)&(MSR_TMA|MSR_TMS))) != 0)
-
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
 {
 	/*
diff --git a/criu/arch/ppc64/include/asm/fpu.h b/criu/arch/ppc64/include/asm/fpu.h
deleted file mode 100644
index 7f476d541a7d..000000000000
--- a/criu/arch/ppc64/include/asm/fpu.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef __CR_ASM_FPU_H__
-#define __CR_ASM_FPU_H__
-
-#endif /* __CR_ASM_FPU_H__ */
diff --git a/criu/arch/ppc64/include/asm/parasite-syscall.h b/criu/arch/ppc64/include/asm/parasite-syscall.h
index e420ccbdc625..4a370f605f57 100644
--- a/criu/arch/ppc64/include/asm/parasite-syscall.h
+++ b/criu/arch/ppc64/include/asm/parasite-syscall.h
@@ -3,10 +3,6 @@
 
 struct parasite_ctl;
 
-#define ARCH_SI_TRAP TRAP_BRKPT
-
-#define __NR(syscall, compat)	__NR_##syscall
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 #endif
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index cc4699bdae39..f74af930470e 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -5,100 +5,21 @@
 #include <signal.h>
 #include "images/core.pb-c.h"
 
-#include "asm/page.h"
 #include "asm/bitops.h"
 #include "asm/int.h"
 
-#include "uapi/std/asm/syscall-types.h"
-
-#define SIGMAX_OLD	31
-#define SIGMAX		64
-
-/*
- * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
- */
-typedef struct {
-        unsigned long gpr[32];
-        unsigned long nip;
-        unsigned long msr;
-        unsigned long orig_gpr3;        /* Used for restarting system calls */
-        unsigned long ctr;
-        unsigned long link;
-        unsigned long xer;
-        unsigned long ccr;
-        unsigned long softe;            /* Soft enabled/disabled */
-        unsigned long trap;             /* Reason for being here */
-        /* N.B. for critical exceptions on 4xx, the dar and dsisr
-           fields are overloaded to hold srr0 and srr1. */
-        unsigned long dar;              /* Fault registers */
-        unsigned long dsisr;            /* on 4xx/Book-E used for ESR */
-        unsigned long result;           /* Result of a system call */
-} user_regs_struct_t;
-
-#define NVSXREG	32
-
-#define USER_FPREGS_FL_FP	0x00001
-#define USER_FPREGS_FL_ALTIVEC	0x00002
-#define USER_FPREGS_FL_VSX	0x00004
-#define USER_FPREGS_FL_TM	0x00010
-
-typedef struct {
-	uint64_t fpregs[NFPREG];
-	__vector128 vrregs[NVRREG];
-	uint64_t vsxregs[NVSXREG];
-
-	int flags;
-	struct tm_regs {
-		int flags;
-		struct {
-			uint64_t tfhar, texasr, tfiar;
-		} tm_spr_regs;
-		user_regs_struct_t regs;
-		uint64_t fpregs[NFPREG];
-		__vector128 vrregs[NVRREG];
-		uint64_t vsxregs[NVSXREG];
-	} tm;
-} user_fpregs_struct_t;
-
+#include <compel/plugins/std/asm/syscall-types.h>
+#include <compel/asm/types.h>
+#include <compel/asm/page.h>
 
 typedef UserPpc64RegsEntry UserRegsEntry;
 
 #define CORE_ENTRY__MARCH	CORE_ENTRY__MARCH__PPC64
 
-#define REG_RES(regs)           ((u64)(regs).gpr[3])
-#define REG_IP(regs)            ((u64)(regs).nip)
-#define REG_SYSCALL_NR(regs)    ((u64)(regs).gpr[0])
-
-#define user_regs_native(pregs)			true
 #define core_is_compat(core)			false
 
 #define CORE_THREAD_ARCH_INFO(core) core->ti_ppc64
 
-/*
- * Copied from the following kernel header files :
- * 	include/linux/auxvec.h
- *	arch/powerpc/include/uapi/asm/auxvec.h
- *	include/linux/mm_types.h
- */
-#define AT_VECTOR_SIZE_BASE 20
-#define AT_VECTOR_SIZE_ARCH 6
-#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
-
-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; }
-
 static inline void *decode_pointer(uint64_t v) { return (void*)v; }
 static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; }
 
diff --git a/criu/arch/ppc64/infect.c b/criu/arch/ppc64/infect.c
index 9479bc6063fa..201307be1705 100644
--- a/criu/arch/ppc64/infect.c
+++ b/criu/arch/ppc64/infect.c
@@ -2,7 +2,9 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <errno.h>
-#include "uapi/std/syscall-codes.h"
+
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/types.h"
 #include "ptrace.h"
 #include "parasite-syscall.h"
diff --git a/criu/arch/ppc64/restorer.c b/criu/arch/ppc64/restorer.c
index 3f0aff87a5d4..9cf3e6d0b84c 100644
--- a/criu/arch/ppc64/restorer.c
+++ b/criu/arch/ppc64/restorer.c
@@ -2,9 +2,10 @@
 
 #include "restorer.h"
 #include "asm/restorer.h"
-#include "asm/fpu.h"
 
-#include "uapi/std/syscall.h"
+#include <compel/plugins/std/syscall.h>
+#include <compel/asm/fpu.h>
+
 #include "log.h"
 
 int restore_nonsigframe_gpregs(UserPpc64RegsEntry *r)
diff --git a/criu/arch/ppc64/vdso-pie.c b/criu/arch/ppc64/vdso-pie.c
index b3994f11e0d0..ac2e176b2fd0 100644
--- a/criu/arch/ppc64/vdso-pie.c
+++ b/criu/arch/ppc64/vdso-pie.c
@@ -1,9 +1,10 @@
 #include <unistd.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/arch/x86/Makefile b/criu/arch/x86/Makefile
index 6c77e5f80745..c088b2dd47e4 100644
--- a/criu/arch/x86/Makefile
+++ b/criu/arch/x86/Makefile
@@ -1,8 +1,6 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 asflags-y		+= -Wstrict-prototypes -Wa,--noexecstack
 asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
diff --git a/criu/arch/x86/cpu.c b/criu/arch/x86/cpu.c
index c60d3c2581c0..97d76f20527c 100644
--- a/criu/arch/x86/cpu.c
+++ b/criu/arch/x86/cpu.c
@@ -9,7 +9,6 @@
 #include "asm/bitops.h"
 #include "asm/types.h"
 #include "asm/cpu.h"
-#include "asm/fpu.h"
 
 #include "compiler.h"
 
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index bc9382046881..49fe9f6c77bd 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -6,11 +6,12 @@
 #include <sys/syscall.h>
 #include <sys/auxv.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/processor-flags.h"
 #include "asm/parasite-syscall.h"
 #include "asm/restorer.h"
 #include "asm/types.h"
-#include "asm/fpu.h"
 #include "asm/dump.h"
 
 #include "cr_options.h"
@@ -22,7 +23,6 @@
 #include "util.h"
 #include "cpu.h"
 #include "errno.h"
-#include "uapi/std/syscall-codes.h"
 #include "kerndat.h"
 #include "infect.h"
 
diff --git a/criu/arch/x86/include/asm/fpu.h b/criu/arch/x86/include/asm/fpu.h
deleted file mode 100644
index 6362ebe47f79..000000000000
--- a/criu/arch/x86/include/asm/fpu.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef __CR_ASM_FPU_H__
-#define __CR_ASM_FPU_H__
-
-#include <sys/types.h>
-#include <stdbool.h>
-
-#include "compiler.h"
-#include "asm/int.h"
-
-#define FP_MIN_ALIGN_BYTES		64
-
-#define FP_XSTATE_MAGIC1		0x46505853U
-#define FP_XSTATE_MAGIC2		0x46505845U
-#define FP_XSTATE_MAGIC2_SIZE		sizeof(FP_XSTATE_MAGIC2)
-
-#define XSTATE_FP			0x1
-#define XSTATE_SSE			0x2
-#define XSTATE_YMM			0x4
-
-#define FXSAVE_SIZE			512
-#define XSAVE_SIZE			832
-
-struct fpx_sw_bytes {
-	u32				magic1;
-	u32				extended_size;
-	u64				xstate_bv;
-	u32				xstate_size;
-	u32				padding[7];
-};
-
-struct i387_fxsave_struct {
-	u16				cwd; /* Control Word			*/
-	u16				swd; /* Status Word			*/
-	u16				twd; /* Tag Word			*/
-	u16				fop; /* Last Instruction Opcode		*/
-	union {
-		struct {
-			u64		rip; /* Instruction Pointer		*/
-			u64		rdp; /* Data Pointer			*/
-		};
-		struct {
-			u32		fip; /* FPU IP Offset			*/
-			u32		fcs; /* FPU IP Selector			*/
-			u32		foo; /* FPU Operand Offset		*/
-			u32		fos; /* FPU Operand Selector		*/
-		};
-	};
-	u32				mxcsr;		/* MXCSR Register State */
-	u32				mxcsr_mask;	/* MXCSR Mask		*/
-
-	/* 8*16 bytes for each FP-reg = 128 bytes				*/
-	u32				st_space[32];
-
-	/* 16*16 bytes for each XMM-reg = 256 bytes				*/
-	u32				xmm_space[64];
-
-	u32				padding[12];
-
-	union {
-		u32			padding1[12];
-		u32			sw_reserved[12];
-	};
-
-} __aligned(16);
-
-struct xsave_hdr_struct {
-	u64				xstate_bv;
-	u64				reserved1[2];
-	u64				reserved2[5];
-} __packed;
-
-struct ymmh_struct {
-	u32				ymmh_space[64];
-} __packed;
-
-/*
- * cpu requires it to be 64 byte aligned
- */
-struct xsave_struct {
-	struct i387_fxsave_struct	i387;
-	struct xsave_hdr_struct		xsave_hdr;
-	struct ymmh_struct		ymmh;
-} __aligned(FP_MIN_ALIGN_BYTES) __packed;
-
-/*
- * This one is used in restorer.
- */
-typedef struct {
-	/*
-	 * The FPU xsave area must be continious and FP_MIN_ALIGN_BYTES
-	 * aligned, thus make sure the compiler won't insert any hole here.
-	 */
-
-	union {
-		struct xsave_struct	xsave;
-		u8		__pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE];
-	};
-
-	u8 has_fpu;
-} fpu_state_t;
-
-#endif /* __CR_ASM_FPU_H__ */
diff --git a/criu/arch/x86/include/asm/parasite-syscall.h b/criu/arch/x86/include/asm/parasite-syscall.h
index 18c746f6fc59..769367d70a78 100644
--- a/criu/arch/x86/include/asm/parasite-syscall.h
+++ b/criu/arch/x86/include/asm/parasite-syscall.h
@@ -5,19 +5,6 @@
 
 struct parasite_ctl;
 
-#define ARCH_SI_TRAP SI_KERNEL
-
-#define __NR(syscall, compat)	((compat) ? __NR32_##syscall : __NR_##syscall)
-
-/*
- * For x86_32 __NR_mmap inside the kernel represents old_mmap system
- * call, but since we didn't use it yet lets go further and simply
- * define own alias for __NR_mmap2 which would allow us to unify code
- * between 32 and 64 bits version.
- */
-#define __NR32_mmap __NR32_mmap2
-
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 #endif
diff --git a/criu/arch/x86/include/asm/restorer.h b/criu/arch/x86/include/asm/restorer.h
index a10f3c9d9c88..d7971c58194c 100644
--- a/criu/arch/x86/include/asm/restorer.h
+++ b/criu/arch/x86/include/asm/restorer.h
@@ -1,10 +1,10 @@
 #ifndef __CR_ASM_RESTORER_H__
 #define __CR_ASM_RESTORER_H__
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/types.h"
-#include "asm/fpu.h"
 #include "images/core.pb-c.h"
-#include "uapi/std/syscall-codes.h"
 
 struct rt_sigcontext {
 	unsigned long			r8;
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index fef94f3c1855..1f04b12b9c11 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -4,99 +4,16 @@
 #include <stdbool.h>
 #include <signal.h>
 
-#include "asm/page.h"
+#include <compel/plugins/std/asm/syscall-types.h>
+#include <compel/asm/types.h>
+
 #include "asm/bitops.h"
 #include "asm/int.h"
 
-#include "uapi/std/asm/syscall-types.h"
-
 #include "bug.h"
 #include "images/core.pb-c.h"
 
-#define SIGMAX			64
-#define SIGMAX_OLD		31
-
-#define MAJOR(dev)		((dev)>>8)
-#define MINOR(dev)		((dev) & 0xff)
-
-typedef struct {
-	uint64_t	r15;
-	uint64_t	r14;
-	uint64_t	r13;
-	uint64_t	r12;
-	uint64_t	bp;
-	uint64_t	bx;
-	uint64_t	r11;
-	uint64_t	r10;
-	uint64_t	r9;
-	uint64_t	r8;
-	uint64_t	ax;
-	uint64_t	cx;
-	uint64_t	dx;
-	uint64_t	si;
-	uint64_t	di;
-	uint64_t	orig_ax;
-	uint64_t	ip;
-	uint64_t	cs;
-	uint64_t	flags;
-	uint64_t	sp;
-	uint64_t	ss;
-	uint64_t	fs_base;
-	uint64_t	gs_base;
-	uint64_t	ds;
-	uint64_t	es;
-	uint64_t	fs;
-	uint64_t	gs;
-} user_regs_struct64;
-
-typedef struct {
-	uint32_t	bx;
-	uint32_t	cx;
-	uint32_t	dx;
-	uint32_t	si;
-	uint32_t	di;
-	uint32_t	bp;
-	uint32_t	ax;
-	uint32_t	ds;
-	uint32_t	es;
-	uint32_t	fs;
-	uint32_t	gs;
-	uint32_t	orig_ax;
-	uint32_t	ip;
-	uint32_t	cs;
-	uint32_t	flags;
-	uint32_t	sp;
-	uint32_t	ss;
-} user_regs_struct32;
-
 #ifdef CONFIG_X86_64
-/*
- * To be sure that we rely on inited reg->__is_native, this member
- * is (short int) instead of initial (bool). The right way to
- * check if regs are native or compat is to use user_regs_native() macro.
- * This should cost nothing, as *usually* sizeof(bool) == sizeof(short)
- */
-typedef struct {
-	union {
-		user_regs_struct64 native;
-		user_regs_struct32 compat;
-	};
-	short __is_native; /* use user_regs_native macro to check it */
-} user_regs_struct_t;
-
-#define NATIVE_MAGIC	0x0A
-#define COMPAT_MAGIC	0x0C
-static inline bool user_regs_native(user_regs_struct_t *pregs)
-{
-	BUG_ON(pregs->__is_native != NATIVE_MAGIC &&
-		pregs->__is_native != COMPAT_MAGIC);
-	return pregs->__is_native == NATIVE_MAGIC;
-}
-
-#define get_user_reg(pregs, name) ((user_regs_native(pregs)) ?		\
-		((pregs)->native.name) : ((pregs)->compat.name))
-#define set_user_reg(pregs, name, val) ((user_regs_native(pregs)) ?	\
-		((pregs)->native.name = (val)) : ((pregs)->compat.name = (val)))
 static inline int core_is_compat(CoreEntry *c)
 {
 	switch (c->thread_info->gpregs->mode) {
@@ -108,72 +25,12 @@ static inline int core_is_compat(CoreEntry *c)
 			return -1;
 	}
 }
-#else /* !CONFIG_X86_64 */
-typedef struct {
-	union {
-		user_regs_struct32 native;
-	};
-} user_regs_struct_t;
-#define user_regs_native(pregs)		true
-#define get_user_reg(pregs, name)	((pregs)->native.name)
-#define set_user_reg(pregs, name, val)	((pregs)->native.name = val)
-static inline int core_is_compat(CoreEntry *c) { return 0; }
-#endif /* !CONFIG_X86_64 */
-
-#if 0
-typedef struct {
-	unsigned short	cwd;
-	unsigned short	swd;
-	unsigned short	twd;	/* Note this is not the same as
-				   the 32bit/x87/FSAVE twd */
-	unsigned short	fop;
-	u64		rip;
-	u64		rdp;
-	u32		mxcsr;
-	u32		mxcsr_mask;
-	u32		st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
-	u32		xmm_space[64];	/* 16*16 bytes for each XMM-reg = 256 bytes */
-	u32		padding[24];
-} user_fpregs_struct_t;
-#endif
-
-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)
+static inline int core_is_compat(CoreEntry *c) { return 0; }
 #endif
 
-static inline unsigned long task_size(void) { return TASK_SIZE; }
-
-typedef u64 auxv_t;
-
-/*
- * Linux preserves three TLS segments in GDT.
- * Offsets in GDT differ between 32-bit and 64-bit machines.
- * For 64-bit x86 those GDT offsets are the same
- * for native and compat tasks.
- */
-#define GDT_ENTRY_TLS_MIN		12
-#define GDT_ENTRY_TLS_MAX		14
-#define GDT_ENTRY_TLS_NUM		3
-typedef struct {
-	user_desc_t desc[GDT_ENTRY_TLS_NUM];
-} tls_t;
-
-#define REG_RES(regs)		get_user_reg(&regs, ax)
-#define REG_IP(regs)		get_user_reg(&regs, ip)
-#define REG_SYSCALL_NR(regs)	get_user_reg(&regs, orig_ax)
-
 #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__X86_64
 
-#define AT_VECTOR_SIZE 44
-
 #define CORE_THREAD_ARCH_INFO(core) core->thread_info
 
 typedef UserX86RegsEntry UserRegsEntry;
diff --git a/criu/arch/x86/infect.c b/criu/arch/x86/infect.c
index ad3ce267958d..fa07698068a8 100644
--- a/criu/arch/x86/infect.c
+++ b/criu/arch/x86/infect.c
@@ -3,10 +3,11 @@
 #include <sys/uio.h>
 #include <sys/auxv.h>
 #include <sys/mman.h>
+
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "asm/parasite-syscall.h"
-#include "uapi/std/syscall-codes.h"
 #include "err.h"
-#include "asm/fpu.h"
 #include "asm/types.h"
 #include "errno.h"
 #include "asm/cpu.h"
diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
index 0c0725147250..0709c2dbd1e3 100644
--- a/criu/arch/x86/restorer.c
+++ b/criu/arch/x86/restorer.c
@@ -1,12 +1,13 @@
 #include <asm/prctl.h>
 #include <unistd.h>
 
+#include <compel/plugins/std/syscall.h>
+#include <compel/asm/types.h>
+
 #include "restorer.h"
 #include "asm/restorer.h"
-#include "asm/fpu.h"
 #include "asm/string.h"
 
-#include "uapi/std/syscall.h"
 #include "log.h"
 #include "cpu.h"
 
diff --git a/criu/arch/x86/sigaction_compat.c b/criu/arch/x86/sigaction_compat.c
index 214b2058bf63..316d07cc519c 100644
--- a/criu/arch/x86/sigaction_compat.c
+++ b/criu/arch/x86/sigaction_compat.c
@@ -1,11 +1,12 @@
+#include <compel/asm/types.h>
+
 #include "asm/restorer.h"
-#include "asm/fpu.h"
 #include "asm/string.h"
 
 #include <sys/mman.h>
 
 #ifdef CR_NOGLIBC
-# include "uapi/std/syscall.h"
+# include <compel/plugins/std/syscall.h>
 #else
 # define sys_mmap mmap
 # define sys_munmap munmap
diff --git a/criu/arch/x86/vdso-pie.c b/criu/arch/x86/vdso-pie.c
index 1d27716c4da3..c1e9e2a30725 100644
--- a/criu/arch/x86/vdso-pie.c
+++ b/criu/arch/x86/vdso-pie.c
@@ -1,9 +1,10 @@
 #include <unistd.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/bfd.c b/criu/bfd.c
index 66c318c6ee5b..c79c879ae8d8 100644
--- a/criu/bfd.c
+++ b/criu/bfd.c
@@ -7,13 +7,14 @@
 #include <sys/uio.h>
 #include <errno.h>
 
+#include <compel/asm/page.h>
+
 #include "bug.h"
 #include "log.h"
 #include "bfd.h"
 #include "list.h"
 #include "util.h"
 #include "xmalloc.h"
-#include "asm/page.h"
 
 #undef	LOG_PREFIX
 #define LOG_PREFIX "bfd: "
diff --git a/criu/cgroup.c b/criu/cgroup.c
index 3a0f81f16078..c3a76e59a1db 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -18,12 +18,13 @@
 #include "util-pie.h"
 #include "namespaces.h"
 #include "seize.h"
-#include "syscall-types.h"
 #include "parasite.h"
 #include "protobuf.h"
 #include "images/core.pb-c.h"
 #include "images/cgroup.pb-c.h"
 
+#include <compel/plugins/std/asm/syscall-types.h>
+
 /*
  * This structure describes set of controller groups
  * a task lives in. The cg_ctl entries are stored in
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 0b072239bd82..8e097245a145 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -24,6 +24,8 @@
 
 #include <sys/sendfile.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "ptrace.h"
 #include "compiler.h"
 #include "asm/types.h"
@@ -81,7 +83,6 @@
 
 #include "parasite-syscall.h"
 #include "files-reg.h"
-#include "uapi/std/syscall-codes.h"
 
 #include "protobuf.h"
 #include "images/sa.pb-c.h"
diff --git a/criu/fsnotify.c b/criu/fsnotify.c
index 87c47d5036a9..862189458fe2 100644
--- a/criu/fsnotify.c
+++ b/criu/fsnotify.c
@@ -22,6 +22,8 @@
 
 #include <sys/fanotify.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "compiler.h"
 #include "asm/types.h"
 #include "imgset.h"
@@ -42,7 +44,6 @@
 #include "namespaces.h"
 #include "pstree.h"
 #include "fault-injection.h"
-#include "uapi/std/syscall-codes.h"
 
 #include "protobuf.h"
 #include "images/fsnotify.pb-c.h"
diff --git a/criu/include/lock.h b/criu/include/lock.h
index 1d2cab00eb7e..a1cf08cc8de4 100644
--- a/criu/include/lock.h
+++ b/criu/include/lock.h
@@ -11,7 +11,7 @@
 #include "bug.h"
 
 #ifdef CR_NOGLIBC
-# include "uapi/std/syscall.h"
+# include <compel/plugins/std/syscall-codes.h>
 #else
 # include <unistd.h>
 # include <sys/syscall.h>
diff --git a/criu/include/pagemap-cache.h b/criu/include/pagemap-cache.h
index e0880906d74f..6d07b801ef0f 100644
--- a/criu/include/pagemap-cache.h
+++ b/criu/include/pagemap-cache.h
@@ -2,7 +2,9 @@
 #define __CR_PAGEMAP_H__
 
 #include <sys/types.h>
-#include "asm/page.h"
+
+#include <compel/asm/page.h>
+
 #include "asm/int.h"
 
 #include "list.h"
diff --git a/criu/include/restorer.h b/criu/include/restorer.h
index bfa3e8fec513..c318a44b974c 100644
--- a/criu/include/restorer.h
+++ b/criu/include/restorer.h
@@ -5,9 +5,10 @@
 #include <limits.h>
 #include <sys/resource.h>
 
+#include <compel/asm/fpu.h>
+
 #include "compiler.h"
 #include "asm/types.h"
-#include "asm/fpu.h"
 #include "lock.h"
 #include "util.h"
 #include "asm/restorer.h"
diff --git a/criu/include/syscall-types.h b/criu/include/syscall-types.h
deleted file mode 100644
index db0dbc09ba04..000000000000
--- a/criu/include/syscall-types.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Please add here type definitions if
- * syscall prototypes need them.
- *
- * Anything else should go to plain type.h
- */
-
-#ifndef __CR_SYSCALL_TYPES_H__
-#define __CR_SYSCALL_TYPES_H__
-
-#include <sys/time.h>
-#include <arpa/inet.h>
-#include <sched.h>
-#include <time.h>
-#include <fcntl.h>
-
-#include "asm/types.h"
-
-struct cap_header {
-	u32 version;
-	int pid;
-};
-
-struct cap_data {
-	u32 eff;
-	u32 prm;
-	u32 inh;
-};
-
-struct sockaddr;
-struct msghdr;
-struct rusage;
-struct file_handle;
-struct robust_list_head;
-struct io_event;
-struct iocb;
-struct timespec;
-
-typedef unsigned long aio_context_t;
-
-struct itimerspec;
-
-#ifndef F_GETFD
-#define F_GETFD 1
-#endif
-
-struct krlimit {
-	unsigned long rlim_cur;
-	unsigned long rlim_max;
-};
-
-struct siginfo;
-
-/* Type of timers in the kernel.  */
-typedef int kernel_timer_t;
-
-#endif /* __CR_SYSCALL_TYPES_H__ */
diff --git a/criu/kerndat.c b/criu/kerndat.c
index a4ec2f778c90..292c777d6cb5 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -8,6 +8,8 @@
 #include <errno.h>
 #include <sys/syscall.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "log.h"
 #include "bug.h"
 #include "kerndat.h"
@@ -22,7 +24,6 @@
 #include "lsm.h"
 #include "proc_parse.h"
 #include "config.h"
-#include "uapi/std/syscall-codes.h"
 
 struct kerndat_s kdat = {
 };
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 0c48a6d22642..b831a7834f2b 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -5,6 +5,8 @@
 #include <sys/wait.h>
 #include <sys/mman.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "protobuf.h"
 #include "images/sa.pb-c.h"
 #include "images/timer.pb-c.h"
@@ -28,7 +30,6 @@
 #include "proc_parse.h"
 #include "aio.h"
 #include "fault-injection.h"
-#include "uapi/std/syscall-codes.h"
 #include "signal.h"
 
 #include <string.h>
diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 420bb42e21ae..e354d64fd905 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -51,8 +51,9 @@ CFLAGS			+= -iquote $(SRC_DIR)/criu/arch/$(ARCH)/include
 CFLAGS			+= -iquote $(SRC_DIR)/criu/include
 CFLAGS			+= -iquote $(SRC_DIR)
 
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
+
 ccflags-y		+= -DCR_NOGLIBC
 ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
 NATIVE_CFLAGS		:= $(shell $(SRC_DIR)/compel/compel-host --arch=$(ARCH) cflags)
@@ -162,7 +163,7 @@ $(obj)/%-blob.h: $(obj)/%.built-in.bin.o $(SRC_DIR)/compel/compel-host
 		-p $(call target-name,$@)_blob_offset__			\
 		-s $(call target-name,$@)_blob				\
 		-r $(call target-name,$@)_nr_gotpcrel			\
-		-u $(SRC_DIR)/compel/include/uapi			\
+		-u compel						\
 		-o $@ $(piegen_stdout)
 
 else # !piegen-y
diff --git a/criu/pie/Makefile.library b/criu/pie/Makefile.library
index ea72c28b147a..cdf77322e157 100644
--- a/criu/pie/Makefile.library
+++ b/criu/pie/Makefile.library
@@ -61,8 +61,9 @@ iquotes			+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
 iquotes			+= -iquote $(SRC_DIR) -iquote $(SRC_DIR)/criu/include
 CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS)) $(iquotes)
 asflags-y		:= -D__ASSEMBLY__ $(iquotes)
-ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
-ccflags-y		+= -iquote $(SRC_DIR)/compel/include
+
+ccflags-y		+= -I compel/include/uapi
+ccflags-y		+= -I compel/plugins/include/uapi
 
 ifeq ($(SRCARCH),arm)
 	ccflags-y	+= -marm
diff --git a/criu/pie/log-simple.c b/criu/pie/log-simple.c
index 39b95b94d631..88f4c7c2d86f 100644
--- a/criu/pie/log-simple.c
+++ b/criu/pie/log-simple.c
@@ -1,8 +1,9 @@
 #include <stdarg.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "asm/bitsperlong.h"
 
-#include "uapi/std/syscall.h"
 #include "log.h"
 
 struct simple_buf {
diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index ea8a1f2b1d75..ce049e114392 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -9,11 +9,11 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "asm/string.h"
 #include "asm/types.h"
-#include "asm/page.h"
 
-#include "uapi/std/syscall.h"
 #include "image.h"
 #include "parasite-vdso.h"
 #include "vma.h"
diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
index dfbccf4c9221..48ce705b9d49 100644
--- a/criu/pie/parasite.c
+++ b/criu/pie/parasite.c
@@ -7,7 +7,8 @@
 #include <stdarg.h>
 #include <sys/ioctl.h>
 
-#include "uapi/std/syscall.h"
+#include <compel/plugins/std/syscall.h>
+
 #include "parasite.h"
 #include "config.h"
 #include "fcntl.h"
diff --git a/criu/pie/pie-relocs.c b/criu/pie/pie-relocs.c
index 3a178ce79437..f3d5ca9ed3f9 100644
--- a/criu/pie/pie-relocs.c
+++ b/criu/pie/pie-relocs.c
@@ -12,10 +12,11 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
+#include <compel/compel.h>
+
 #include "asm-generic/int.h"
 
 #include "compiler.h"
-#include "compel/include/uapi/compel.h"
 #include "bug.h"
 
 __maybe_unused void elf_relocs_apply(void *mem, void *vbase, size_t size, compel_reloc_t *elf_relocs, size_t nr_relocs)
diff --git a/criu/pie/pie-relocs.h b/criu/pie/pie-relocs.h
index e2141dcdf0e9..8c4e9451cfb1 100644
--- a/criu/pie/pie-relocs.h
+++ b/criu/pie/pie-relocs.h
@@ -1,7 +1,7 @@
 #ifndef __PIE_RELOCS_H__
 #define __PIE_RELOCS_H__
 
-#include "compel/include/uapi/compel.h"
+#include <compel/compel.h>
 
 #include "compiler.h"
 #include "config.h"
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 3fcdc8b4586b..824a2fabaada 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -17,12 +17,13 @@
 #include <sys/resource.h>
 #include <signal.h>
 
+#include <compel/plugins/std/syscall.h>
+
 #include "linux/userfaultfd.h"
 
 #include "compiler.h"
 #include "asm/string.h"
 #include "asm/types.h"
-#include "uapi/std/syscall.h"
 #include "signal.h"
 #include "config.h"
 #include "prctl.h"
diff --git a/criu/pie/util-fd.c b/criu/pie/util-fd.c
index 78252cd22241..4b8c926302c2 100644
--- a/criu/pie/util-fd.c
+++ b/criu/pie/util-fd.c
@@ -10,7 +10,7 @@
 #include "asm/types.h"
 
 #ifdef CR_NOGLIBC
-# include "uapi/std/syscall.h"
+# include <compel/plugins/std/syscall.h>
 # define __sys(foo)	sys_##foo
 #else
 # define __sys(foo)	foo
diff --git a/criu/pie/util.c b/criu/pie/util.c
index 4dace66b03b6..33f63a9afbfb 100644
--- a/criu/pie/util.c
+++ b/criu/pie/util.c
@@ -12,7 +12,7 @@
 #include "util-pie.h"
 
 #ifdef CR_NOGLIBC
-# include "uapi/std/syscall.h"
+# include <compel/plugins/std/syscall.h>
 # define __sys(foo)     sys_##foo
 #else
 # define __sys(foo)     foo
diff --git a/criu/shmem.c b/criu/shmem.c
index ebd22ecb3b72..9ba25c9d1406 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -4,6 +4,8 @@
 #include <fcntl.h>
 #include <stdbool.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+
 #include "list.h"
 #include "pid.h"
 #include "shmem.h"
@@ -16,7 +18,6 @@
 #include "vma.h"
 #include "mem.h"
 #include "config.h"
-#include "uapi/std/syscall-codes.h"
 #include "asm/bitops.h"
 #include "criu-log.h"
 
diff --git a/criu/uffd.c b/criu/uffd.c
index f3ee0f84e896..4ef149af7383 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -16,9 +16,11 @@
 #include <sys/socket.h>
 #include <sys/epoll.h>
 
+#include <compel/plugins/std/syscall-codes.h>
+#include <compel/asm/page.h>
+
 #include "linux/userfaultfd.h"
 
-#include "asm/page.h"
 #include "log.h"
 #include "criu-plugin.h"
 #include "pagemap.h"
@@ -32,7 +34,6 @@
 #include "crtools.h"
 #include "cr_options.h"
 #include "xmalloc.h"
-#include "uapi/std/syscall-codes.h"
 #include "restorer.h"
 #include "page-xfer.h"
 #include "lock.h"
-- 
2.7.4



More information about the CRIU mailing list