[CRIU] [PATCH 10/24] dump: update task registers if a signal is started handling

Andrey Vagin avagin at openvz.org
Wed May 22 16:08:11 EDT 2013


When we try to execute a parasite code, a signal can be started
handling, so we need to update a task registers, which will be saved in
a core file.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/arm/crtools.c         | 3 ++-
 arch/x86/crtools.c         | 3 ++-
 include/parasite-syscall.h | 4 +++-
 parasite-syscall.c         | 8 +++++---
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/crtools.c b/arch/arm/crtools.c
index a64a86c..162566b 100644
--- a/arch/arm/crtools.c
+++ b/arch/arm/crtools.c
@@ -74,7 +74,8 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.ARM_r5 = arg6;
 
 	parasite_setup_regs(ctl->syscall_ip, &regs);
-	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs);
+	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs,
+					&ctl->threads[0].regs_orig);
 	if (err)
 		return err;
 
diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c
index 1fc0b63..8683851 100644
--- a/arch/x86/crtools.c
+++ b/arch/x86/crtools.c
@@ -98,7 +98,8 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.r9  = arg6;
 
 	parasite_setup_regs(ctl->syscall_ip, &regs);
-	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs);
+	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs,
+					&ctl->threads[0].regs_orig);
 	if (err)
 		return err;
 
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 19ccc79..cce5680 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -99,6 +99,8 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 		unsigned long arg6);
 
 extern bool arch_can_dump_task(pid_t pid);
-extern int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs);
+extern int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
+					user_regs_struct_t *regs,
+					user_regs_struct_t *regs_orig);
 
 #endif /* __CR_PARASITE_SYSCALL_H__ */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 70f993e..9dca5c6 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -61,7 +61,9 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned
 }
 
 /* we run at @regs->ip */
-int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs)
+int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid,
+				user_regs_struct_t *regs,
+				user_regs_struct_t *regs_orig)
 {
 	siginfo_t siginfo;
 	int status;
@@ -169,7 +171,7 @@ retry_signal:
 				pr_perror("Can't obtain registers (pid: %d)", pid);
 				goto err;
 			}
-			ctl->threads[0].regs_orig = r;
+			*regs_orig = r;
 		}
 
 		goto again;
@@ -206,7 +208,7 @@ static int parasite_execute_trap_by_pid(unsigned int cmd, struct parasite_ctl *c
 
 	parasite_setup_regs(ctl->parasite_ip, &regs);
 
-	ret = __parasite_execute_trap(ctl, pid, &regs);
+	ret = __parasite_execute_trap(ctl, pid, &regs, &thread->regs_orig);
 	if (ret == 0)
 		ret = (int)REG_RES(regs);
 
-- 
1.8.2



More information about the CRIU mailing list