[CRIU] [PATCH] parasite-syscall: get rid of code_syscall{, size} globals

Dmitry Safonov dsafonov at virtuozzo.com
Wed Mar 16 07:32:22 PDT 2016


I think, we may safetly remove this exports, as:
- code_syscall is used only in one function, which now will have
  it as a parameter;
- code_syscall_size is equall to BUILTIN_SYSCALL_SIZE under
  BUILD_BUG_ON, so BUILTIN_SYSCALL_SIZE may be used instead.

This will reduce arch-depended code coupling a little.

(and I also interested in this because of I need __parasite_execute_syscall
to execute 32-bit syscall code on x86_64, which I prefer to leave without
some CONFIG_X86_64 as it's generic code)

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/arch/aarch64/crtools.c                      | 2 +-
 criu/arch/aarch64/include/asm/parasite-syscall.h | 3 ---
 criu/arch/arm/crtools.c                          | 2 +-
 criu/arch/arm/include/asm/parasite-syscall.h     | 4 ----
 criu/arch/ppc64/crtools.c                        | 2 +-
 criu/arch/ppc64/include/asm/parasite-syscall.h   | 3 ---
 criu/arch/x86/crtools.c                          | 2 +-
 criu/arch/x86/include/asm/parasite-syscall.h     | 3 ---
 criu/include/parasite-syscall.h                  | 2 +-
 criu/parasite-syscall.c                          | 5 +++--
 10 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/criu/arch/aarch64/crtools.c b/criu/arch/aarch64/crtools.c
index 7a25106..f56b864 100644
--- a/criu/arch/aarch64/crtools.c
+++ b/criu/arch/aarch64/crtools.c
@@ -71,7 +71,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.regs[6] = 0;
 	regs.regs[7] = 0;
 
-	err = __parasite_execute_syscall(ctl, &regs);
+	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
 
 	*ret = regs.regs[0];
 	return err;
diff --git a/criu/arch/aarch64/include/asm/parasite-syscall.h b/criu/arch/aarch64/include/asm/parasite-syscall.h
index 0c07121..f992bca 100644
--- a/criu/arch/aarch64/include/asm/parasite-syscall.h
+++ b/criu/arch/aarch64/include/asm/parasite-syscall.h
@@ -6,9 +6,6 @@ struct parasite_ctl;
 #define ARCH_SI_TRAP TRAP_BRKPT
 
 
-extern const char code_syscall[];
-extern const int code_syscall_size;
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 void *mmap_seized(struct parasite_ctl *ctl,
diff --git a/criu/arch/arm/crtools.c b/criu/arch/arm/crtools.c
index 9588990..a82e9ef 100644
--- a/criu/arch/arm/crtools.c
+++ b/criu/arch/arm/crtools.c
@@ -73,7 +73,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.ARM_r4 = arg5;
 	regs.ARM_r5 = arg6;
 
-	err = __parasite_execute_syscall(ctl, &regs);
+	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
 
 	*ret = regs.ARM_r0;
 	return err;
diff --git a/criu/arch/arm/include/asm/parasite-syscall.h b/criu/arch/arm/include/asm/parasite-syscall.h
index 0c66bf9..2d6b85f 100644
--- a/criu/arch/arm/include/asm/parasite-syscall.h
+++ b/criu/arch/arm/include/asm/parasite-syscall.h
@@ -5,10 +5,6 @@
 #define ARCH_SI_TRAP TRAP_BRKPT
 
 
-extern const char code_syscall[];
-extern const int code_syscall_size;
-
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 void *mmap_seized(struct parasite_ctl *ctl,
diff --git a/criu/arch/ppc64/crtools.c b/criu/arch/ppc64/crtools.c
index 14b1e7c..9ed377e 100644
--- a/criu/arch/ppc64/crtools.c
+++ b/criu/arch/ppc64/crtools.c
@@ -80,7 +80,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.gpr[7] = arg5;
 	regs.gpr[8] = arg6;
 
-	err = __parasite_execute_syscall(ctl, &regs);
+	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
 
 	*ret = regs.gpr[3];
 	return err;
diff --git a/criu/arch/ppc64/include/asm/parasite-syscall.h b/criu/arch/ppc64/include/asm/parasite-syscall.h
index 7665e20..1ac6b3b 100644
--- a/criu/arch/ppc64/include/asm/parasite-syscall.h
+++ b/criu/arch/ppc64/include/asm/parasite-syscall.h
@@ -5,9 +5,6 @@ struct parasite_ctl;
 
 #define ARCH_SI_TRAP TRAP_BRKPT
 
-extern const char code_syscall[];
-extern const int code_syscall_size;
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 void *mmap_seized(struct parasite_ctl *ctl,
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 1c43ab1..83d3c8e 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -103,7 +103,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.r8  = arg5;
 	regs.r9  = arg6;
 
-	err = __parasite_execute_syscall(ctl, &regs);
+	err = __parasite_execute_syscall(ctl, &regs, code_syscall);
 
 	*ret = regs.ax;
 	return err;
diff --git a/criu/arch/x86/include/asm/parasite-syscall.h b/criu/arch/x86/include/asm/parasite-syscall.h
index 4d56cb0..e2c7a5a 100644
--- a/criu/arch/x86/include/asm/parasite-syscall.h
+++ b/criu/arch/x86/include/asm/parasite-syscall.h
@@ -8,9 +8,6 @@ struct parasite_ctl;
 #define ARCH_SI_TRAP SI_KERNEL
 
 
-extern const char code_syscall[];
-extern const int code_syscall_size;
-
 void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
 
 void *mmap_seized(struct parasite_ctl *ctl,
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index 5ed8e35..04d2602 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -119,7 +119,7 @@ extern int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 			  unsigned long arg5, unsigned long arg6);
 
 extern int __parasite_execute_syscall(struct parasite_ctl *ctl,
-				user_regs_struct_t *regs);
+		user_regs_struct_t *regs, const char *code_syscall);
 extern bool arch_can_dump_task(pid_t pid);
 
 /*
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index bcdadcb..0a1bdc6 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -44,7 +44,7 @@
 static int can_run_syscall(unsigned long ip, unsigned long start,
 			   unsigned long end, unsigned long pad)
 {
-	return ip >= start && ip < (end - code_syscall_size - pad);
+	return ip >= start && ip < (end - BUILTIN_SYSCALL_SIZE - pad);
 }
 
 static int syscall_fits_vma_area(struct vma_area *vma_area, unsigned long pad)
@@ -210,7 +210,8 @@ err:
 	return ret;
 }
 
-int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *regs)
+int __parasite_execute_syscall(struct parasite_ctl *ctl,
+		user_regs_struct_t *regs, const char *code_syscall)
 {
 	pid_t pid = ctl->pid.real;
 	int err;
-- 
2.7.2



More information about the CRIU mailing list