[CRIU] [PATCH] arch, x86: int80 -- Clobber all rX registers

Cyrill Gorcunov gorcunov at gmail.com
Tue Jan 15 14:07:13 MSK 2019


While vanilla kernel requires only r8-r11 to be saved
by a caller when doing int80 interrupt we've discovered
some buggy kernels which may not follow the rule, thus
to be able to checkpoint programs on such kernels we
mark all rX registers as clobbered to be on a safe side.

CC: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
CC: Andrew Vagin <avagin at virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---

Andrew, ptikhomirov@ has to carry this patch to run our
criu-dev tests on Vz7 kernel. I think it is safe to merge
it upstream.

 compel/arch/x86/src/lib/include/uapi/asm/sigframe.h | 3 ++-
 criu/arch/x86/include/asm/compat.h                  | 2 +-
 criu/arch/x86/include/asm/parasite.h                | 3 ++-
 criu/arch/x86/restorer.c                            | 3 ++-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
index c29de3bd5876..385ff716c5f1 100644
--- a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
+++ b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
@@ -176,7 +176,8 @@ struct rt_sigframe {
 		".code64					\n"	\
 		:							\
 		: "rdi"(new_sp)						\
-		: "eax", "r8", "r9", "r10", "r11", "memory")
+		: "eax", "r8", "r9", "r10", "r11",			\
+			"r12", "r13", "r14", "r15", "memory")
 
 #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe)				\
 do {									\
diff --git a/criu/arch/x86/include/asm/compat.h b/criu/arch/x86/include/asm/compat.h
index cd1ae472d77e..d0a3b3706222 100644
--- a/criu/arch/x86/include/asm/compat.h
+++ b/criu/arch/x86/include/asm/compat.h
@@ -57,7 +57,7 @@ static inline void do_full_int80(struct syscall_args32 *args)
 		      : "+a" (args->nr),
 			"+b" (args->arg0), "+c" (args->arg1), "+d" (args->arg2),
 			"+S" (args->arg3), "+D" (args->arg4), "+g" (args->arg5)
-			: : "r8", "r9", "r10", "r11");
+			: : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15");
 }
 
 #ifndef CR_NOGLIBC
diff --git a/criu/arch/x86/include/asm/parasite.h b/criu/arch/x86/include/asm/parasite.h
index 0ef1d9a867bb..43c005026e79 100644
--- a/criu/arch/x86/include/asm/parasite.h
+++ b/criu/arch/x86/include/asm/parasite.h
@@ -34,7 +34,8 @@ static int arch_get_user_desc(user_desc_t *desc)
 	"	mov %%eax,%0			\n"
 	: "+m"(ret)
 	: "m"(desc)
-	: "rax", "rbx", "r8", "r9", "r10", "r11", "memory");
+	: "rax", "rbx", "r8", "r9", "r10", "r11",
+		"r12", "r13", "r14", "r15", "memory");
 
 	if (ret)
 		pr_err("Failed to dump TLS descriptor #%d: %d\n",
diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
index 2d335d5e1d29..ffee08a82d61 100644
--- a/criu/arch/x86/restorer.c
+++ b/criu/arch/x86/restorer.c
@@ -103,7 +103,8 @@ void restore_tls(tls_t *ptls)
 		"	mov %%eax,%0			\n"
 		: "=g"(ret)
 		: "r"(__NR32_set_thread_area), "r"((uint32_t)(uintptr_t)stack32)
-		: "eax", "ebx", "r8", "r9", "r10", "r11", "memory");
+		: "eax", "ebx", "r8", "r9", "r10", "r11",
+			"r12", "r13", "r14", "r15", "memory");
 
 		if (ret)
 			pr_err("Failed to restore TLS descriptor %u in GDT: %d\n",
-- 
2.20.1



More information about the CRIU mailing list