[CRIU] [PATCH] Wire up AArch64 TLS dump and restore
Alexander Kartashov
alekskartashov at parallels.com
Sun Feb 16 22:48:04 PST 2014
On 02/15/2014 03:18 AM, Christopher Covington wrote:
> I wonder why ptrace isn't being used by existing architecture
> ports for TLS registers, but since the hooks already exist for
> non-ptrace style, implement that for now.
>
> Signed-off-by: Christopher Covington <cov at codeaurora.org>
Acked-by: Alexander Kartashov <alekskartashov at parallels.com>
Thanks!
> ---
> arch/aarch64/include/asm/dump.h | 5 ++++-
> arch/aarch64/include/asm/parasite.h | 6 +++++-
> arch/aarch64/include/asm/restore.h | 5 ++++-
> arch/aarch64/include/asm/restorer.h | 4 +++-
> protobuf/core-aarch64.proto | 5 +++--
> 5 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/arch/aarch64/include/asm/dump.h b/arch/aarch64/include/asm/dump.h
> index 396c97e..2665166 100644
> --- a/arch/aarch64/include/asm/dump.h
> +++ b/arch/aarch64/include/asm/dump.h
> @@ -6,6 +6,9 @@ extern int arch_alloc_thread_info(CoreEntry *core);
> extern void arch_free_thread_info(CoreEntry *core);
>
>
> -static inline void core_put_tls(CoreEntry *core, u32 tls) { }
> +static inline void core_put_tls(CoreEntry *core, u32 tls)
> +{
> + core->ti_aarch64->tls = tls;
> +}
>
> #endif
> diff --git a/arch/aarch64/include/asm/parasite.h b/arch/aarch64/include/asm/parasite.h
> index 19959b7..8f3644d 100644
> --- a/arch/aarch64/include/asm/parasite.h
> +++ b/arch/aarch64/include/asm/parasite.h
> @@ -1,6 +1,10 @@
> #ifndef __ASM_PARASITE_H__
> #define __ASM_PARASITE_H__
>
> -static inline u32 arch_get_tls(void) { return 0; }
> +static inline u32 arch_get_tls(void) {
> + u32 ret;
> + asm("mrs %0, tpidr_el0" : "=r" (ret));
> + return ret;
> +}
>
> #endif
> diff --git a/arch/aarch64/include/asm/restore.h b/arch/aarch64/include/asm/restore.h
> index 8aae682..7724843 100644
> --- a/arch/aarch64/include/asm/restore.h
> +++ b/arch/aarch64/include/asm/restore.h
> @@ -20,7 +20,10 @@
> "r"(task_args) \
> : "sp", "x0", "x1", "memory")
>
> -static inline void core_get_tls(CoreEntry *pcore, uint32_t *ptls) { }
> +static inline void core_get_tls(CoreEntry *pcore, uint32_t *ptls)
> +{
> + *ptls = pcore->ti_aarch64->tls;
> +}
>
>
> int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core);
> diff --git a/arch/aarch64/include/asm/restorer.h b/arch/aarch64/include/asm/restorer.h
> index 5fa929e..91bc912 100644
> --- a/arch/aarch64/include/asm/restorer.h
> +++ b/arch/aarch64/include/asm/restorer.h
> @@ -135,6 +135,8 @@ int restore_nonsigframe_gpregs(UserAarch64RegsEntry *r);
>
> static inline int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, fpu_state_t *fpu_state) { return 0; }
>
> -static inline void restore_tls(u32 tls) { }
> +static inline void restore_tls(u32 tls) {
> + asm("msr tpidr_el0, %0" : : "r" (tls));
> +}
>
> #endif
> diff --git a/protobuf/core-aarch64.proto b/protobuf/core-aarch64.proto
> index b29425e..b0fd352 100644
> --- a/protobuf/core-aarch64.proto
> +++ b/protobuf/core-aarch64.proto
> @@ -13,6 +13,7 @@ message user_aarch64_fpsimd_context_entry {
>
> message thread_info_aarch64 {
> required uint64 clear_tid_addr = 1;
> - required user_aarch64_regs_entry gpregs = 2;
> - required user_aarch64_fpsimd_context_entry fpsimd = 3;
> + required uint32 tls = 2;
> + required user_aarch64_regs_entry gpregs = 3;
> + required user_aarch64_fpsimd_context_entry fpsimd = 4;
> }
--
Sincerely yours,
Alexander Kartashov
Intern
Core team
www.parallels.com
Skype: aleksandr.kartashov
Email: alekskartashov at parallels.com
More information about the CRIU
mailing list