Commit e1e23468 authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

cr: Introduce stubs for tls dump/restore

Leave them empty for x86, will be used on ARM.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 3f12d688
...@@ -5,4 +5,7 @@ extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl * ...@@ -5,4 +5,7 @@ extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *
extern int arch_alloc_thread_info(CoreEntry *core); extern int arch_alloc_thread_info(CoreEntry *core);
extern void core_entry_free(CoreEntry *core); extern void core_entry_free(CoreEntry *core);
#define core_put_tls(core, tls)
#endif #endif
#ifndef __ASM_PARASITE_H__
#define __ASM_PARASITE_H__
static inline u32 arch_get_tls()
{
return 0;
}
#endif
...@@ -15,4 +15,6 @@ ...@@ -15,4 +15,6 @@
"g"(task_args) \ "g"(task_args) \
: "rsp", "rdi", "rsi", "rbx", "rax", "memory") : "rsp", "rdi", "rsi", "rbx", "rax", "memory")
#define core_get_tls(pcore, ptls)
#endif #endif
...@@ -134,4 +134,6 @@ int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r); ...@@ -134,4 +134,6 @@ int restore_gpregs(struct rt_sigframe *f, UserX86RegsEntry *r);
int restore_fpu(struct rt_sigframe *sigframe, struct thread_restore_args *args); int restore_fpu(struct rt_sigframe *sigframe, struct thread_restore_args *args);
static inline void restore_tls(u32 tls) { }
#endif #endif
...@@ -790,6 +790,8 @@ static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat, ...@@ -790,6 +790,8 @@ static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
if (ret) if (ret)
goto err_free; goto err_free;
core_put_tls(core, misc->tls);
ret = pb_write_one(fd_core, core, PB_CORE); ret = pb_write_one(fd_core, core, PB_CORE);
if (ret < 0) if (ret < 0)
goto err_free; goto err_free;
...@@ -1156,6 +1158,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1156,6 +1158,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
int ret = -1, fd_core; int ret = -1, fd_core;
unsigned int *taddr; unsigned int *taddr;
pid_t pid = tid->real; pid_t pid = tid->real;
u32 tls;
pr_info("\n"); pr_info("\n");
pr_info("Dumping core for thread (pid: %d)\n", pid); pr_info("Dumping core for thread (pid: %d)\n", pid);
...@@ -1174,12 +1177,15 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1174,12 +1177,15 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
goto err_free; goto err_free;
ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr, ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr,
&tid->virt, &core->thread_core->blk_sigset); &tid->virt, &core->thread_core->blk_sigset,
&tls);
if (ret) { if (ret) {
pr_err("Can't dump thread for pid %d\n", pid); pr_err("Can't dump thread for pid %d\n", pid);
goto err_free; goto err_free;
} }
core->thread_core->has_blk_sigset = true; core->thread_core->has_blk_sigset = true;
core_put_tls(core, tls);
pr_info("%d: virt_pid=%d tid_address=%p sig_blocked=0x%lx\n", pid, pr_info("%d: virt_pid=%d tid_address=%p sig_blocked=0x%lx\n", pid,
tid->virt, taddr, core->thread_core->blk_sigset); tid->virt, taddr, core->thread_core->blk_sigset);
......
...@@ -1897,6 +1897,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core) ...@@ -1897,6 +1897,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
thread_args[i].ta = task_args; thread_args[i].ta = task_args;
thread_args[i].gpregs = *tcore->thread_info->gpregs; thread_args[i].gpregs = *tcore->thread_info->gpregs;
thread_args[i].clear_tid_addr = tcore->thread_info->clear_tid_addr; thread_args[i].clear_tid_addr = tcore->thread_info->clear_tid_addr;
core_get_tls(tcore, &thread_args[i].tls);
if (tcore->thread_core) { if (tcore->thread_core) {
thread_args[i].has_futex = true; thread_args[i].has_futex = true;
......
...@@ -38,7 +38,7 @@ extern int parasite_dump_pages_seized(struct parasite_ctl *ctl, ...@@ -38,7 +38,7 @@ extern int parasite_dump_pages_seized(struct parasite_ctl *ctl,
struct parasite_dump_thread; struct parasite_dump_thread;
extern int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid, extern int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid,
unsigned int **tid_add, pid_t *tid, unsigned int **tid_add, pid_t *tid,
void *blocked); void *blocked, u32 *tls);
struct parasite_drain_fd; struct parasite_drain_fd;
struct fd_opts; struct fd_opts;
......
...@@ -83,6 +83,7 @@ struct parasite_dump_misc { ...@@ -83,6 +83,7 @@ struct parasite_dump_misc {
u32 pid; u32 pid;
u32 sid; u32 sid;
u32 pgid; u32 pgid;
u32 tls;
}; };
#define PARASITE_MAX_GROUPS (PAGE_SIZE / sizeof(unsigned int)) #define PARASITE_MAX_GROUPS (PAGE_SIZE / sizeof(unsigned int))
...@@ -97,6 +98,7 @@ struct parasite_dump_thread { ...@@ -97,6 +98,7 @@ struct parasite_dump_thread {
unsigned int *tid_addr; unsigned int *tid_addr;
pid_t tid; pid_t tid;
k_rtsigset_t blocked; k_rtsigset_t blocked;
u32 tls;
}; };
#define PARASITE_MAX_FDS (PAGE_SIZE / sizeof(int)) #define PARASITE_MAX_FDS (PAGE_SIZE / sizeof(int))
......
...@@ -90,6 +90,8 @@ struct thread_restore_args { ...@@ -90,6 +90,8 @@ struct thread_restore_args {
struct xsave_struct xsave; struct xsave_struct xsave;
unsigned char __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE]; unsigned char __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE];
}; };
u32 tls;
} __aligned(sizeof(long)); } __aligned(sizeof(long));
struct task_restore_core_args { struct task_restore_core_args {
......
#include <unistd.h> #include <unistd.h>
#include <inttypes.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
...@@ -365,7 +366,8 @@ err: ...@@ -365,7 +366,8 @@ err:
int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid, int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid,
unsigned int **tid_addr, pid_t *tid, unsigned int **tid_addr, pid_t *tid,
void *blocked) void *blocked,
u32 *tls)
{ {
struct parasite_dump_thread *args; struct parasite_dump_thread *args;
int ret; int ret;
...@@ -377,6 +379,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid, ...@@ -377,6 +379,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, pid_t pid,
memcpy(blocked, &args->blocked, sizeof(args->blocked)); memcpy(blocked, &args->blocked, sizeof(args->blocked));
*tid_addr = args->tid_addr; *tid_addr = args->tid_addr;
*tid = args->tid; *tid = args->tid;
*tls = args->tls;
return ret; return ret;
} }
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <string.h> #include <string.h>
#include "asm/parasite.h"
#ifndef CONFIG_X86_64 #ifndef CONFIG_X86_64
#error non-x86-64 mode not yet implemented #error non-x86-64 mode not yet implemented
#endif #endif
...@@ -287,6 +289,7 @@ static int dump_misc(struct parasite_dump_misc *args) ...@@ -287,6 +289,7 @@ static int dump_misc(struct parasite_dump_misc *args)
args->pid = sys_getpid(); args->pid = sys_getpid();
args->sid = sys_getsid(); args->sid = sys_getsid();
args->pgid = sys_getpgid(0); args->pgid = sys_getpgid(0);
args->tls = arch_get_tls();
return 0; return 0;
} }
...@@ -372,6 +375,7 @@ static int dump_thread(struct parasite_dump_thread *args) ...@@ -372,6 +375,7 @@ static int dump_thread(struct parasite_dump_thread *args)
args->blocked = s->sig_blocked; args->blocked = s->sig_blocked;
args->tid = tid; args->tid = tid;
args->tls = arch_get_tls();
return 0; return 0;
} }
......
...@@ -162,7 +162,12 @@ static int restore_thread_common(struct rt_sigframe *sigframe, ...@@ -162,7 +162,12 @@ static int restore_thread_common(struct rt_sigframe *sigframe,
if (restore_fpu(sigframe, args)) if (restore_fpu(sigframe, args))
return -1; return -1;
return restore_gpregs(sigframe, &args->gpregs); if (restore_gpregs(sigframe, &args->gpregs))
return -1;
restore_tls(args->tls);
return 0;
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment