[CRIU] [PATCH 3/7] compel/x86: hang in 32-bit mode on sw-break for compat tasks

Dmitry Safonov dsafonov at virtuozzo.com
Mon Jan 9 09:19:08 PST 2017


Otherwise we'll try to set 32-bit register set to 64-bit task,
which is not possible with ptrace - it uses register set size,
according to processes mode. So we should set 32-bit regset
only to tasks those are in 32-bit mode already.
Please, see inline comment in the patch for more info.

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 compel/arch/x86/plugins/std/parasite-head.S | 36 ++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/compel/arch/x86/plugins/std/parasite-head.S b/compel/arch/x86/plugins/std/parasite-head.S
index 2757828cf1bd..bdb56c877c37 100644
--- a/compel/arch/x86/plugins/std/parasite-head.S
+++ b/compel/arch/x86/plugins/std/parasite-head.S
@@ -6,24 +6,44 @@
 # error 64-bit parasite should compile with CONFIG_X86_64
 #endif
 
+.macro PARASITE_ENTRY
+	subq	$16, %rsp
+	andq	$~15, %rsp
+	pushq	$0
+	movq	%rsp, %rbp
+	movl	__export_parasite_cmd(%rip), %edi
+	leaq	__export_parasite_args(%rip), %rsi
+	call	parasite_service
+.endm
+
 #ifdef CONFIG_COMPAT
 .code32
 ENTRY(__export_parasite_head_start_compat)
 	/* A long jump to 64-bit parasite. */
-	jmp $__USER_CS,$__export_parasite_head_start
+	jmp	$__USER_CS,$1f
+1:
+.code64
+	PARASITE_ENTRY
+	pushq	$__USER32_CS
+	pushq	$2f
+	lretq
+2:
+.code32
+	/*
+	 * parasite_service() can run commands in non-daemon mode
+	 * with parasite_trap_cmd(): it waits that after return there
+	 * is a software break.
+	 * compel_run_in_thread() uses this and after hitting the break,
+	 * it restores register set - that's the reason, why we should
+	 * stop in 32-bit mode for compat tasks here.
+	 */
 	int	$0x03
 END(__export_parasite_head_start_compat)
 .code64
 #endif
 
 ENTRY(__export_parasite_head_start)
-	subq	$16, %rsp
-	andq	$~15, %rsp
-	pushq	$0
-	movq	%rsp, %rbp
-	movl	__export_parasite_cmd(%rip), %edi
-	leaq	__export_parasite_args(%rip), %rsi
-	call	parasite_service
+	PARASITE_ENTRY
 	int	$0x03
 END(__export_parasite_head_start)
 
-- 
2.11.0



More information about the CRIU mailing list