[CRIU] [PATCH 05/44] parasite-syscall.c: moved the syscall instructions into the file arch/x86/crtools.c.
Alexander Kartashov
alekskartashov at parallels.com
Mon Jan 7 10:04:34 EST 2013
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
Makefile | 1 +
arch/x86/crtools.c | 18 ++++++++++++++++++
arch/x86/include/asm/parasite-syscall.h | 7 +++++++
parasite-syscall.c | 7 +------
4 files changed, 27 insertions(+), 6 deletions(-)
create mode 100644 arch/x86/crtools.c
create mode 100644 arch/x86/include/asm/parasite-syscall.h
diff --git a/Makefile b/Makefile
index 60770cd..1e4c851 100644
--- a/Makefile
+++ b/Makefile
@@ -121,6 +121,7 @@ OBJS += protobuf.o
OBJS += tty.o
OBJS += cr-exec.o
OBJS += cpu.o
+OBJS += $(ARCH_DIR)/crtools.o
DEPS := $(patsubst %.o,%.d,$(OBJS))
diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c
new file mode 100644
index 0000000..1f6fd14
--- /dev/null
+++ b/arch/x86/crtools.c
@@ -0,0 +1,18 @@
+#include "asm/types.h"
+#include "compiler.h"
+#include "parasite-syscall.h"
+
+/*
+ * Injected syscall instruction
+ */
+const char code_syscall[] = {
+ 0x0f, 0x05, /* syscall */
+ 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc /* int 3, ... */
+};
+
+const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
+
+static inline void __check_code_syscall(void) {
+ BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
+ BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
+}
diff --git a/arch/x86/include/asm/parasite-syscall.h b/arch/x86/include/asm/parasite-syscall.h
new file mode 100644
index 0000000..df7f6ef
--- /dev/null
+++ b/arch/x86/include/asm/parasite-syscall.h
@@ -0,0 +1,7 @@
+#ifndef __CR_ASM_PARASITE_SYSCALL_H__
+#define __CR_ASM_PARASITE_SYSCALL_H__
+
+extern const char code_syscall[];
+extern const int code_syscall_size;
+
+#endif
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 6249196..88e2ce7 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -22,10 +22,8 @@
#include <string.h>
#include <stdlib.h>
-static const char code_syscall[] = {0x0f, 0x05, 0xcc, 0xcc,
- 0xcc, 0xcc, 0xcc, 0xcc};
+#include "asm/parasite-syscall.h"
-#define code_syscall_size (round_up(sizeof(code_syscall), sizeof(long)))
#define parasite_size (round_up(sizeof(parasite_blob), sizeof(long)))
static int can_run_syscall(unsigned long ip, unsigned long start, unsigned long end)
@@ -793,9 +791,6 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct list_head *vma_area_lis
* Inject syscall instruction and remember original code,
* we will need it to restore original program content.
*/
- BUILD_BUG_ON(sizeof(code_syscall) != sizeof(ctl->code_orig));
- BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
-
memcpy(ctl->code_orig, code_syscall, sizeof(ctl->code_orig));
if (ptrace_swap_area(ctl->pid, (void *)ctl->syscall_ip,
(void *)ctl->code_orig, sizeof(ctl->code_orig))) {
--
1.7.10.4
More information about the CRIU
mailing list