[CRIU] [PATCH 2/2] ia32/restorer: move 32-bit pie unmap to x86

Dmitry Safonov dsafonov at virtuozzo.com
Fri Apr 28 11:30:47 PDT 2017


We need compat realization for restorer unmap as after rt_sigreturn()
the task is stopped it 32-bit code and ptrace API doesn't allow
setting x86_64 full registers set to ia32 task.

Generic restorer has now x86-specific __export_unmap_compat()
function, which isn't right.

Clean restorer from x86-related realization.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/arch/x86/restorer_unmap.S | 12 ++++++++++++
 criu/pie/Makefile              |  1 +
 criu/pie/restorer.c            | 25 ++-----------------------
 3 files changed, 15 insertions(+), 23 deletions(-)
 create mode 100644 criu/arch/x86/restorer_unmap.S

diff --git a/criu/arch/x86/restorer_unmap.S b/criu/arch/x86/restorer_unmap.S
new file mode 100644
index 000000000000..09c4c9583da3
--- /dev/null
+++ b/criu/arch/x86/restorer_unmap.S
@@ -0,0 +1,12 @@
+#include "common/asm/linkage.h"
+#include "compel/plugins/std/syscall-codes.h"
+
+	.text
+ENTRY(__export_unmap_compat)
+	.code32
+	mov	bootstrap_start, %ebx
+	mov	bootstrap_len, %ecx
+	movl	$__NR32_munmap, %eax
+	int	$0x80
+	int	$0x03 /* Guard */
+	.code64
diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 6a4fba9c1373..73d95d5f10e4 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -25,6 +25,7 @@ restorer-obj-y	+= ./$(ARCH_DIR)/restorer.o
 ifeq ($(ARCH),x86)
         ifeq ($(CONFIG_COMPAT),y)
                 restorer-obj-y	+= ./$(ARCH_DIR)/call32.o
+                restorer-obj-y	+= ./$(ARCH_DIR)/restorer_unmap.o
                 restorer-obj-y	+= ./$(ARCH_DIR)/sigaction_compat_pie.o
         endif
 endif
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 70ebcdc18a83..030c7ff42a03 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -994,35 +994,14 @@ static unsigned long vdso_rt_size;
 #define vdso_rt_size	(0)
 #endif
 
-static void *bootstrap_start;
-static unsigned int bootstrap_len;
+void *bootstrap_start = NULL;
+unsigned int bootstrap_len = 0;
 
 void __export_unmap(void)
 {
 	sys_munmap(bootstrap_start, bootstrap_len - vdso_rt_size);
 }
 
-#ifdef CONFIG_X86_64
-asm (
-	"	.pushsection .text\n"
-	"	.global	__export_unmap_compat\n"
-	"__export_unmap_compat:\n"
-	"	.code32\n"
-	"	mov bootstrap_start, %ebx\n"
-	"	mov bootstrap_len, %ecx\n"
-	"	sub vdso_rt_size, %ecx\n"
-	"	movl $"__stringify(__NR32_munmap)", %eax\n"
-	"	int	$0x80\n"
-	"	.code64\n"
-	"	.popsection\n"
-);
-extern char __export_unmap_compat;
-#else
-void __export_unmap_compat(void)
-{
-}
-#endif
-
 /*
  * This function unmaps all VMAs, which don't belong to
  * the restored process or the restorer.
-- 
2.12.2



More information about the CRIU mailing list