Skip to content

Commit

Permalink
lkl: Fix lkl_sys_halt
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Liu <liuyuan@google.com>
  • Loading branch information
liuyuan10 committed Nov 11, 2016
1 parent c329658 commit 8e4ddea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/lkl/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void free_thread_stack(unsigned long *);

void threads_init(void);
void threads_cleanup(void);
void threads_cnt_dec(void);

#define TIF_SYSCALL_TRACE 0
#define TIF_NOTIFY_RESUME 1
Expand Down
4 changes: 3 additions & 1 deletion arch/lkl/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ void machine_restart(char *unused)
long lkl_sys_halt(void)
{
long err;
long params[6] = { 0, };
long params[6] = {LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART, };

err = lkl_syscall(__NR_reboot, params);
if (err < 0)
Expand Down Expand Up @@ -158,6 +159,7 @@ static int lkl_run_init(struct linux_binprm *bprm)
init_pid_ns.child_reaper = 0;

syscalls_init();
threads_cnt_dec();

lkl_ops->sem_up(init_sem);
lkl_ops->thread_exit();
Expand Down
7 changes: 7 additions & 0 deletions arch/lkl/kernel/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ long lkl_syscall(long no, long *params)

ret = run_syscall(no, params);

if (no == __NR_reboot) {
set_current_state(TASK_UNINTERRUPTIBLE);
if (!thread_set_sched_jmp())
schedule();
return ret;
}

out:
lkl_cpu_put();

Expand Down
5 changes: 5 additions & 0 deletions arch/lkl/kernel/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ void threads_init(void)
ti->tid = lkl_ops->thread_self();
}

void threads_cnt_dec(void)
{
__sync_fetch_and_sub(&threads_counter, 1);
}

void threads_cleanup(void)
{
struct task_struct *p;
Expand Down
5 changes: 4 additions & 1 deletion tools/lkl/lib/hijack/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ hijack_fini(void)
{
int i;
char *dump = getenv("LKL_HIJACK_DUMP");
int err;

/* The following pauses the kernel before exiting allowing one
* to debug or collect stattistics/diagnosis info from it.
Expand All @@ -453,5 +454,7 @@ hijack_fini(void)
if (nd)
lkl_netdev_free(nd);

lkl_sys_halt();
err = lkl_sys_halt();
if (err)
fprintf(stderr, "lkl_sys_halt: %s\n", lkl_strerror(err));
}

0 comments on commit 8e4ddea

Please sign in to comment.