Commit 55a04580 authored by Pavel Emelyanov's avatar Pavel Emelyanov

restorer: Compact rst stack evaluation code

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 00dc2660
......@@ -2538,11 +2538,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
task_args->vdso_rt_parked_at = (unsigned long)mem + vdso_rt_delta;
task_args->vdso_sym_rt = vdso_sym_rt;
/*
* Adjust stack.
*/
new_sp = RESTORE_ALIGN_STACK((long)task_args->t->mem_zone.stack,
sizeof(task_args->t->mem_zone.stack));
new_sp = restorer_stack(task_args->t);
/* No longer need it */
core_entry__free_unpacked(core, NULL);
......
......@@ -43,9 +43,6 @@ typedef long (*thread_restore_fcall_t) (struct thread_restore_args *args);
#define RESTORE_STACK_SIGFRAME ALIGN(sizeof(struct rt_sigframe) + SIGFRAME_OFFSET, 64)
#define RESTORE_STACK_SIZE (KILO(32))
#define RESTORE_ALIGN_STACK(start, size) \
(ALIGN((start) + (size) - sizeof(long), sizeof(long)))
struct restore_mem_zone {
u8 redzone[RESTORE_STACK_REDZONE];
u8 stack[RESTORE_STACK_SIZE];
......@@ -154,6 +151,14 @@ struct task_restore_core_args {
#define SHMEMS_SIZE 4096
#define RESTORE_ALIGN_STACK(start, size) \
(ALIGN((start) + (size) - sizeof(long), sizeof(long)))
static inline unsigned long restorer_stack(struct thread_restore_args *a)
{
return RESTORE_ALIGN_STACK((long)a->mem_zone.stack, RESTORE_STACK_SIZE);
}
/*
* pid is a pid of a creater
* start, end are used for open mapping
......
......@@ -824,10 +824,7 @@ long __export_restore_task(struct task_restore_core_args *args)
if (thread_args[i].pid == args->t->pid)
continue;
new_sp =
RESTORE_ALIGN_STACK((long)thread_args[i].mem_zone.stack,
sizeof(thread_args[i].mem_zone.stack));
new_sp = restorer_stack(thread_args + i);
last_pid_len = vprint_num(last_pid_buf, sizeof(last_pid_buf), thread_args[i].pid - 1, &s);
ret = sys_write(fd, s, last_pid_len);
if (ret < 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