[CRIU] [PATCH 02/22] x86: parasite -- Add call_daemon_thread and asm_trap helpers

Pavel Emelyanov xemul at parallels.com
Wed May 15 09:04:33 EDT 2013


On 05/08/2013 05:28 PM, Andrey Vagin wrote:
> From: Cyrill Gorcunov <gorcunov at openvz.org>
> 
> call_daemon_thread will be needed to run thread daemon
> with own stack, while asm_trap is just a wrap over trapping
> instruction for portability sake.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  arch/x86/include/asm/parasite.h | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/arch/x86/include/asm/parasite.h b/arch/x86/include/asm/parasite.h
> index 41f4a97..3d55dc5 100644
> --- a/arch/x86/include/asm/parasite.h
> +++ b/arch/x86/include/asm/parasite.h
> @@ -6,4 +6,30 @@ static inline u32 arch_get_tls()
>  	return 0;
>  }
>  
> +/*
> + * Call thread daemon with new stack, the function must
> + * return the original stack pointer passed in argument
> + * argument 3
> + */
> +#define call_daemon_thread(new_sp, args, s, func)	\

For pie/restorer.c we have similar asm codes. Plz, format them
in similar way.

> +do {							\
> +	asm volatile ("movq %0, %%rax		\n"	\
> +		      "movq %1, %%rdi		\n"	\
> +		      "movq %2, %%rsi		\n"	\
> +		      "movq %%rsp, %%rdx	\n"	\
> +		      "movq %%rax, %%rsp	\n"	\
> +		      "call " #func "		\n"	\
> +		      "movq %%rax, %%rsp	\n"	\
> +		      :					\
> +		      : "g"(new_sp), "g"(args), "g"(s)	\
> +		      : "rax", "rdi", "rsi", "rdx",	\
> +		        "rsp", "memory");		\
> +} while (0)
> +
> +#define asm_trap()					\
> +do {							\
> +	asm volatile("int3" ::);			\
> +	while (1) ;					\
> +} while (0)
> +
>  #endif
> 




More information about the CRIU mailing list