Skip to content

Commit

Permalink
Merge pull request torvalds#246 from tavip/no-syscall-threads
Browse files Browse the repository at this point in the history
Direct host calls - v2
  • Loading branch information
tavip authored Oct 30, 2016
2 parents 8f15f09 + e3b23ec commit 9b3d507
Show file tree
Hide file tree
Showing 26 changed files with 635 additions and 503 deletions.
14 changes: 14 additions & 0 deletions arch/lkl/include/asm/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _ASM_LKL_CPU_H
#define _ASM_LKL_CPU_H

int lkl_cpu_get(void);
void lkl_cpu_put(void);
int lkl_cpu_try_run_irq(int irq);
int lkl_cpu_init(void);
void lkl_cpu_shutdown(void);
void lkl_cpu_wait_shutdown(void);
void lkl_cpu_wakeup(void);
void lkl_cpu_change_owner(lkl_thread_t owner);
void lkl_cpu_set_irqs_pending(void);

#endif /* _ASM_LKL_CPU_H */
5 changes: 4 additions & 1 deletion arch/lkl/include/asm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#define _ASM_LKL_IRQ_H

#define IRQ_STATUS_BITS (sizeof(long) * 8)
#define NR_IRQS ((int)IRQ_STATUS_BITS * IRQ_STATUS_BITS)
#define NR_IRQS ((int)(IRQ_STATUS_BITS * IRQ_STATUS_BITS))

void run_irqs(void);
void set_irq_pending(int irq);

#include <uapi/asm/irq.h>

Expand Down
4 changes: 0 additions & 4 deletions arch/lkl/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@

#define COMMAND_LINE_SIZE 4096

#ifndef __ASSEMBLY__
void wakeup_cpu(void);
#endif

#endif
4 changes: 2 additions & 2 deletions arch/lkl/include/asm/syscalls.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _ASM_LKL_SYSCALLS_H
#define _ASM_LKL_SYSCALLS_H

int initial_syscall_thread(void *);
void free_initial_syscall_thread(void);
int syscalls_init(void);
void syscalls_cleanup(void);
long lkl_syscall(long no, long *params);

#define sys_mmap sys_mmap_pgoff
Expand Down
21 changes: 20 additions & 1 deletion arch/lkl/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct thread_info {
int preempt_count;
mm_segment_t addr_limit;
struct lkl_sem *sched_sem;
struct lkl_jmp_buf sched_jb;
bool dead;
lkl_thread_t tid;
struct task_struct *prev_sched;
Expand Down Expand Up @@ -46,7 +47,7 @@ static inline struct thread_info *current_thread_info(void)
unsigned long *alloc_thread_stack_node(struct task_struct *, int node);
void free_thread_stack(unsigned long *);

int threads_init(void);
void threads_init(void);
void threads_cleanup(void);

#define TIF_SYSCALL_TRACE 0
Expand All @@ -56,6 +57,24 @@ void threads_cleanup(void);
#define TIF_RESTORE_SIGMASK 4
#define TIF_MEMDIE 5
#define TIF_NOHZ 6
#define TIF_SCHED_JB 7
#define TIF_SCHED_EXIT 8
#define TIF_HOST_THREAD 9

static inline void set_ti_thread_flag(struct thread_info *ti, int flag);

static inline int thread_set_sched_jmp(void)
{
set_ti_thread_flag(current_thread_info(), TIF_SCHED_JB);
return lkl_ops->jmp_buf_set(&current_thread_info()->sched_jb);
}

static inline void thread_set_sched_exit(void)
{
set_ti_thread_flag(current_thread_info(), TIF_SCHED_EXIT);
}

void switch_to_host_task(struct task_struct *);

#define __HAVE_THREAD_FUNCTIONS

Expand Down
1 change: 0 additions & 1 deletion arch/lkl/include/asm/unistd.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <uapi/asm/unistd.h>

__SYSCALL(__NR_create_syscall_thread, sys_create_syscall_thread)
__SYSCALL(__NR_virtio_mmio_device_add, sys_virtio_mmio_device_add)

#define __SC_ASCII(t, a) #t "," #a
Expand Down
16 changes: 14 additions & 2 deletions arch/lkl/include/uapi/asm/host_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
struct lkl_mutex;
struct lkl_sem;
typedef unsigned long lkl_thread_t;
struct lkl_jmp_buf {
unsigned long buf[32];
};

/**
* lkl_host_operations - host operations used by the Linux kernel
Expand All @@ -25,7 +28,8 @@ typedef unsigned long lkl_thread_t;
* @sem_up - perform an up operation on the semaphore
* @sem_down - perform a down operation on the semaphore
*
* @mutex_alloc - allocate and initialize a host mutex
* @mutex_alloc - allocate and initialize a host mutex; the recursive parameter
* determines if the mutex is recursive or not
* @mutex_free - free a host mutex
* @mutex_lock - acquire the mutex
* @mutex_unlock - release the mutex
Expand Down Expand Up @@ -77,7 +81,7 @@ struct lkl_host_operations {
void (*sem_up)(struct lkl_sem *sem);
void (*sem_down)(struct lkl_sem *sem);

struct lkl_mutex *(*mutex_alloc)(void);
struct lkl_mutex *(*mutex_alloc)(int recursive);
void (*mutex_free)(struct lkl_mutex *mutex);
void (*mutex_lock)(struct lkl_mutex *mutex);
void (*mutex_unlock)(struct lkl_mutex *mutex);
Expand All @@ -86,6 +90,8 @@ struct lkl_host_operations {
void (*thread_detach)(void);
void (*thread_exit)(void);
int (*thread_join)(lkl_thread_t tid);
lkl_thread_t (*thread_self)(void);
int (*thread_equal)(lkl_thread_t a, lkl_thread_t b);

int (*tls_alloc)(unsigned int *key, void (*destructor)(void *));
int (*tls_free)(unsigned int key);
Expand All @@ -106,6 +112,9 @@ struct lkl_host_operations {
int write);

long (*gettid)(void);

int (*jmp_buf_set)(struct lkl_jmp_buf *jmpb);
void (*jmp_buf_longjmp)(struct lkl_jmp_buf *jmpb, int val);
};

/**
Expand All @@ -127,4 +136,7 @@ int lkl_start_kernel(struct lkl_host_operations *lkl_ops,
*/
int lkl_is_running(void);

int lkl_printf(const char *, ...);
void lkl_bug(const char *, ...);

#endif
3 changes: 1 addition & 2 deletions arch/lkl/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@

#include <asm-generic/unistd.h>

#define __NR_create_syscall_thread (__NR_arch_specific_syscall + 0)
#define __NR_virtio_mmio_device_add (__NR_arch_specific_syscall + 1)
#define __NR_virtio_mmio_device_add (__NR_arch_specific_syscall + 0)
3 changes: 2 additions & 1 deletion arch/lkl/kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extra-y := vmlinux.lds

obj-y = setup.o threads.o irq.o time.o syscalls.o misc.o console.o syscalls_32.o
obj-y = setup.o threads.o irq.o time.o syscalls.o misc.o console.o \
syscalls_32.o cpu.o
Loading

0 comments on commit 9b3d507

Please sign in to comment.