[CRIU] [PATCH 2/3] criu: Use std_ helpers from compel library for builtins

Cyrill Gorcunov gorcunov at openvz.org
Fri Jan 27 09:14:19 PST 2017


Our builtin helpers are scattered over the criu and
compel code, lets rather use compel helpers and zap
criu instances then.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/Makefile                        | 1 +
 criu/arch/ppc64/vdso-pie.c           | 4 ++--
 criu/arch/x86/include/asm/parasite.h | 5 +++--
 criu/arch/x86/restorer.c             | 3 ++-
 criu/arch/x86/sigaction_compat.c     | 4 +++-
 criu/arch/x86/vdso-pie.c             | 3 ++-
 criu/pie/restorer.c                  | 3 ++-
 criu/pie/util-fd.c                   | 3 ++-
 criu/pie/util-vdso.c                 | 8 +++++---
 9 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/criu/Makefile b/criu/Makefile
index 5c19d0af2358..888c344f1720 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -69,6 +69,7 @@ PROGRAM-BUILTINS	+= $(obj)/built-in.o
 PROGRAM-BUILTINS	+= $(ARCH-LIB)
 PROGRAM-BUILTINS	+= soccr/libsoccr.a
 PROGRAM-BUILTINS	+= $(COMPEL_LIBS)
+PROGRAM-BUILTINS	+= compel/plugins/stdstr.built-in.o
 
 $(obj)/built-in.o: pie
 	$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all
diff --git a/criu/arch/ppc64/vdso-pie.c b/criu/arch/ppc64/vdso-pie.c
index 33f3dbd1a32e..781c063fd4d9 100644
--- a/criu/arch/ppc64/vdso-pie.c
+++ b/criu/arch/ppc64/vdso-pie.c
@@ -4,6 +4,7 @@
 #include "asm/types.h"
 
 #include <compel/plugins/std/syscall.h>
+#include <compel/plugins/std/string.h>
 #include "parasite-vdso.h"
 #include "log.h"
 #include "common/bug.h"
@@ -104,8 +105,7 @@ static unsigned long put_trampoline(unsigned long at, struct vdso_symtable *sym)
 
 			pr_debug("Putting vDSO trampoline in %s at %lx\n",
 				 sym->symbols[i].name, trampoline);
-			builtin_memcpy((void *)trampoline, &vdso_trampoline,
-				       size);
+			std_memcpy((void *)trampoline, &vdso_trampoline, size);
 			invalidate_caches(trampoline);
 		}
 	}
diff --git a/criu/arch/x86/include/asm/parasite.h b/criu/arch/x86/include/asm/parasite.h
index 7b259d7a2c8d..64e04861b8fa 100644
--- a/criu/arch/x86/include/asm/parasite.h
+++ b/criu/arch/x86/include/asm/parasite.h
@@ -3,6 +3,7 @@
 
 #include "asm-generic/string.h"
 #include <compel/plugins/std/syscall-codes.h>
+#include <compel/plugins/std/string.h>
 #include "asm/compat.h"
 
 #ifdef CONFIG_X86_32
@@ -68,11 +69,11 @@ static void arch_get_tls(tls_t *ptls)
 	{
 		user_desc_t *d = syscall_mem;
 
-		builtin_memset(d, 0, sizeof(user_desc_t));
+		std_memset(d, 0, sizeof(user_desc_t));
 		d->seg_not_present = 1;
 		d->entry_number = GDT_ENTRY_TLS_MIN + i;
 		arch_get_user_desc(d);
-		builtin_memcpy(&ptls->desc[i], d, sizeof(user_desc_t));
+		std_memcpy(&ptls->desc[i], d, sizeof(user_desc_t));
 	}
 
 	free_compat_syscall_stack(syscall_mem);
diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
index 45107045d670..295cf31b1308 100644
--- a/criu/arch/x86/restorer.c
+++ b/criu/arch/x86/restorer.c
@@ -8,6 +8,7 @@
 #include "asm/string.h"
 
 #include <compel/plugins/std/syscall.h>
+#include <compel/plugins/std/string.h>
 #include "log.h"
 #include "cpu.h"
 
@@ -71,7 +72,7 @@ void restore_tls(tls_t *ptls)
 		if (prepare_stack32(&stack32) < 0)
 			return;
 
-		builtin_memcpy(stack32, desc, sizeof(user_desc_t));
+		std_memcpy(stack32, desc, sizeof(user_desc_t));
 		asm volatile (
 		"       mov %1,%%eax                    \n"
 		"       mov %2,%%ebx                    \n"
diff --git a/criu/arch/x86/sigaction_compat.c b/criu/arch/x86/sigaction_compat.c
index 168d3ddb0200..f8565a70411a 100644
--- a/criu/arch/x86/sigaction_compat.c
+++ b/criu/arch/x86/sigaction_compat.c
@@ -4,6 +4,8 @@
 #include "asm/string.h"
 #include "asm/compat.h"
 
+#include <compel/plugins/std/string.h>
+
 #ifdef CR_NOGLIBC
 # include <compel/plugins/std/syscall.h>
 #else
@@ -38,7 +40,7 @@ int arch_compat_rt_sigaction(void *stack32, int sig, rt_sigaction_t_compat *act)
 	 * To be sure, that sigaction pointer lies under 4G,
 	 * coping it on the bottom of the stack.
 	 */
-	builtin_memcpy(stack32, act, sizeof(rt_sigaction_t_compat));
+	std_memcpy(stack32, act, sizeof(rt_sigaction_t_compat));
 
 	asm volatile ("\t movl %%ebx,%%ebx\n" : :"b"(sig));	/* signum */
 	asm volatile ("\t movl %%ecx,%%ecx\n" : :"c"(stack32));	/* act */
diff --git a/criu/arch/x86/vdso-pie.c b/criu/arch/x86/vdso-pie.c
index 63f8d8d0d8ee..6f454c9153ab 100644
--- a/criu/arch/x86/vdso-pie.c
+++ b/criu/arch/x86/vdso-pie.c
@@ -4,6 +4,7 @@
 #include "asm/types.h"
 
 #include <compel/plugins/std/syscall.h>
+#include <compel/plugins/std/string.h>
 #include "parasite-vdso.h"
 #include "log.h"
 #include "common/bug.h"
@@ -59,7 +60,7 @@ int vdso_redirect_calls(unsigned long base_to, unsigned long base_from,
 			 base_to, to->symbols[i].offset, i);
 
 		IMMEDIATE(jmp) = base_to + to->symbols[i].offset;
-		builtin_memcpy((void *)(base_from + from->symbols[i].offset), &jmp, sizeof(jmp));
+		std_memcpy((void *)(base_from + from->symbols[i].offset), &jmp, sizeof(jmp));
 	}
 
 	return 0;
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index e50dac84cada..d6b76d10b325 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -24,6 +24,7 @@
 #include "common/compiler.h"
 #include "string.h"
 #include <compel/plugins/std/syscall.h>
+#include <compel/plugins/std/string.h>
 #include <compel/plugins/std/log.h>
 #include <compel/ksigset.h>
 #include "signal.h"
@@ -700,7 +701,7 @@ static int restore_aio_ring(struct rst_aio_ring *raio)
 
 populate:
 	i = offsetof(struct aio_ring, io_events);
-	builtin_memcpy((void *)ctx + i, (void *)ring + i, raio->len - i);
+	std_memcpy((void *)ctx + i, (void *)ring + i, raio->len - i);
 
 	/*
 	 * If we failed to get the proper nr_req right and
diff --git a/criu/pie/util-fd.c b/criu/pie/util-fd.c
index 84b8c5e0c0d1..933fa17b1cda 100644
--- a/criu/pie/util-fd.c
+++ b/criu/pie/util-fd.c
@@ -17,7 +17,8 @@
 # define __sys(foo)	foo
 #endif
 
-#define __memcpy builtin_memcpy
+# include <compel/plugins/std/string.h>
+#define __memcpy std_memcpy
 
 #include "util-pie.h"
 #include "fcntl.h"
diff --git a/criu/pie/util-vdso.c b/criu/pie/util-vdso.c
index c02187c366a1..73f66d6c44d4 100644
--- a/criu/pie/util-vdso.c
+++ b/criu/pie/util-vdso.c
@@ -17,6 +17,8 @@
 #include "log.h"
 #include "common/bug.h"
 
+#include <compel/plugins/std/string.h>
+
 #ifdef LOG_PREFIX
 # undef LOG_PREFIX
 #endif
@@ -81,7 +83,7 @@ static int has_elf_identity(Ehdr_t *ehdr)
 
 	BUILD_BUG_ON(sizeof(elf_ident) != sizeof(ehdr->e_ident));
 
-	if (builtin_memcmp(ehdr->e_ident, elf_ident, sizeof(elf_ident)))
+	if (std_memcmp(ehdr->e_ident, elf_ident, sizeof(elf_ident)))
 		return false;
 	return true;
 }
@@ -239,10 +241,10 @@ static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
 				continue;
 			name = (void *)addr;
 
-			if (builtin_strncmp(name, symbol, vdso_symbol_length))
+			if (std_strncmp(name, symbol, vdso_symbol_length))
 				continue;
 
-			builtin_memcpy(t->symbols[i].name, name, vdso_symbol_length);
+			std_memcpy(t->symbols[i].name, name, vdso_symbol_length);
 			t->symbols[i].offset = (unsigned long)sym->st_value - load->p_vaddr;
 			break;
 		}
-- 
2.7.4



More information about the CRIU mailing list