[CRIU] [PATCHv2] pie: fix clobber registers for int 0x80

Andrei Vagin avagin at virtuozzo.com
Wed Dec 14 10:40:33 PST 2016


On Wed, Dec 14, 2016 at 07:40:23PM +0300, Dmitry Safonov wrote:
> I managed to forgot that kernel erases R8...R11 regitster
> prior returning to userspace from `int 0x80`:
> https://lkml.org/lkml/2009/10/1/164
> 
> That was the reason for hang on gcc v6.1 on Jenkins/elsewhere:
> https://ci.openvz.org/job/CRIU/job/CRIU-x86_64/branch/criu-dev/
> 
> Tested on gcc v6.1 locally, on Travis-CI:
> https://travis-ci.org/0x7f454c46/criu/builds/183976899
> 
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>

Tested-by: Andrei Vagin <avagin at virtuozzo.com>

> ---
> v2: add r8..r11 clobbers to all int80 callers
> 
>  compel/arch/x86/src/lib/include/uapi/asm/sigframe.h | 2 +-
>  criu/arch/x86/include/asm/parasite.h                | 6 +-----
>  criu/arch/x86/restorer.c                            | 2 +-
>  3 files changed, 3 insertions(+), 7 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 75eb76eda34a..e9357002c18a 100644
> --- a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
> +++ b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
> @@ -185,7 +185,7 @@ struct rt_sigframe {
>  		".code64					\n"	\
>  		:							\
>  		: "rdi"(new_sp)						\
> -		: "eax","esp","memory")
> +		: "eax","esp", "r8", "r9", "r10", "r11", "memory")
>  
>  #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe)				\
>  do {									\
> diff --git a/criu/arch/x86/include/asm/parasite.h b/criu/arch/x86/include/asm/parasite.h
> index 2385ec16d061..7b259d7a2c8d 100644
> --- a/criu/arch/x86/include/asm/parasite.h
> +++ b/criu/arch/x86/include/asm/parasite.h
> @@ -38,12 +38,8 @@ static int arch_get_user_desc(user_desc_t *desc)
>  	"	mov %%eax,%0			\n"
>  	: "+m"(ret)
>  	: "m"(desc)
> -	: "eax", "rbx", "memory");
> +	: "rax", "rbx", "r8", "r9", "r10", "r11", "memory");
>  
> -	/*
> -	 * Fixup for Travis: on missing GDT entry get_thread_area()
> -	 * retruns -EINTR then descriptor with seg_not_preset = 1
> -	 */
>  	if (ret)
>  		pr_err("Failed to dump TLS descriptor #%d: %d\n",
>  				desc->entry_number, ret);
> diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
> index 9cc76fe17c50..377a9186e928 100644
> --- a/criu/arch/x86/restorer.c
> +++ b/criu/arch/x86/restorer.c
> @@ -79,7 +79,7 @@ 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", "memory");
> +		: "eax", "ebx", "r8", "r9", "r10", "r11", "memory");
>  
>  		if (ret)
>  			pr_err("Failed to restore TLS descriptor %u in GDT: %d\n",
> -- 
> 2.10.2
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list