diff --git a/compel/arch/x86/plugins/std/parasite-head.S b/compel/arch/x86/plugins/std/parasite-head.S index 2225568b9..4fb38d1f1 100644 --- a/compel/arch/x86/plugins/std/parasite-head.S +++ b/compel/arch/x86/plugins/std/parasite-head.S @@ -6,14 +6,6 @@ # error 64-bit parasite should compile with CONFIG_X86_64 #endif -.macro PARASITE_ENTRY num - subq $16, %rsp - andq $~15, %rsp - pushq $\num - movq %rsp, %rbp - call parasite_service -.endm - #ifdef CONFIG_COMPAT .code32 ENTRY(__export_parasite_head_start_compat) @@ -21,7 +13,7 @@ ENTRY(__export_parasite_head_start_compat) jmp $__USER_CS,$1f 1: .code64 - PARASITE_ENTRY 0 + call parasite_service pushq $__USER32_CS xor %r11, %r11 movl $2f, %r11d @@ -43,6 +35,6 @@ END(__export_parasite_head_start_compat) #endif ENTRY(__export_parasite_head_start) - PARASITE_ENTRY 0 + call parasite_service int $0x03 END(__export_parasite_head_start) diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c index 78fe1f1a6..da02d1744 100644 --- a/compel/src/lib/infect.c +++ b/compel/src/lib/infect.c @@ -948,6 +948,17 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l p += PARASITE_STACK_SIZE; ctl->rstack = ctl->remote_map + p; + /* + * x86-64 ABI requires a 16 bytes aligned stack. + * It is already the case as RESTORE_STACK_SIGFRAME is a multiple of + * 64, and PARASITE_STACK_SIZE is 0x4000. + */ + if ((unsigned long)ctl->rstack & (16-1)) { + pr_err("BUG: stack is not 16 bytes aligned: %p\n", ctl->rstack); + ctl->rstack = (void *)round_down((unsigned long)ctl->rstack, 16); + } + + if (nr_threads > 1) { p += PARASITE_STACK_SIZE; ctl->r_thread_stack = ctl->remote_map + p;