[CRIU] [PATCH 2/8] cr: generalize the type to store the value of the TLS register

Cyrill Gorcunov gorcunov at gmail.com
Tue Mar 11 01:53:27 PDT 2014


On Mon, Mar 10, 2014 at 12:51:22PM +0400, Alexander Kartashov wrote:
> Supported machine architectures provide TLS stogares of different sizes:
> the size of the TLS storage in x86-64 is 24 bytes, ARM --- 4 bytes
> and upcoming AArch64 --- 8 bytes. This means every supported architecture
> needs a specific type to store the value of the TLS register.
> 
> This patch reworks the insterface of the routines arch_get_tls()
> and restore_tls() passing them the TLS storage by pointer
> rather than by value to simplify the TLS stub for x86.
> 
> Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
> ---
> --- a/arch/x86/include/asm/types.h
> +++ b/arch/x86/include/asm/types.h
> @@ -112,6 +112,7 @@ typedef struct {
>  #define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
>  
>  typedef u64 auxv_t;
> +typedef char tls_t[24];
>  
>  #define REG_RES(regs) ((regs).ax)
>  #define REG_IP(regs)  ((regs).ip)
> diff --git a/include/parasite.h b/include/parasite.h
> index d53242e..502d575 100644
> --- a/include/parasite.h
> +++ b/include/parasite.h
> @@ -138,7 +138,7 @@ static inline int posix_timers_dump_size(int timer_n)
>  struct parasite_dump_thread {
>  	unsigned int		*tid_addr;
>  	pid_t			tid;
> -	u32			tls;
> +	tls_t			tls;
>  	stack_t			sas;
>  };

No, left it as

	typedef u32 tls_t;

on x86-64 the thread local storage is identified by %fs register (which is
saved as a part of general registers set), so this tls entry will be needed
for compat mode (once we implement it). Meanwhile don't bring holes into
parasite_dump_thread structure.


More information about the CRIU mailing list