Skip to content

Commit dd7ee60

Browse files
committed
syscall improvements
1 parent 1c5094d commit dd7ee60

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

arch/wasm/include/asm/thread_info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ struct thread_info {
1717
int preempt_count;
1818
int cpu; // this is for the kernel
1919
atomic_t running_cpu; // negative means unscheduled
20+
unsigned long tp_value;
2021
};
2122

2223
#define INIT_THREAD_INFO(tsk) \
2324
{ \
2425
.flags = 0, .preempt_count = INIT_PREEMPT_COUNT, .cpu = 0, \
25-
.running_cpu = ATOMIC_INIT(0), \
26+
.running_cpu = ATOMIC_INIT(0), .tp_value = U32_MAX, \
2627
}
2728

2829
#define TIF_SYSCALL_TRACE 0 /* syscall trace active */

arch/wasm/include/asm/unistd.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
#define _WASM_UNISTD_H
22
#ifdef _WASM_UNISTD_H
33

4-
#include <uapi/asm/unistd.h>
5-
64
#define sys_mmap2 sys_mmap_pgoff
5+
#define __ARCH_WANT_RENAMEAT
6+
#define __ARCH_WANT_STAT64
7+
#define __ARCH_WANT_SET_GET_RLIMIT
78
#define __ARCH_WANT_SYS_CLONE
9+
#define __ARCH_WANT_SYS_CLONE3
10+
#define __ARCH_WANT_SYS_VFORK
11+
#define __ARCH_WANT_SYS_FORK
12+
#define __ARCH_WANT_TIME32_SYSCALLS
13+
#define __ARCH_WANT_SYNC_FILE_RANGE2
14+
15+
#include <asm-generic/unistd.h>
16+
17+
#define __NR_set_thread_area (__NR_arch_specific_syscall + 0)
18+
__SYSCALL(__NR_set_thread_area, sys_set_thread_area)
819

920
#endif

arch/wasm/kernel/syscall.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,18 @@ wasm_syscall(long nr, unsigned long arg0, unsigned long arg1,
4343
syscall_exit_to_user_mode(regs);
4444

4545
return ret;
46+
}
47+
48+
SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
49+
{
50+
struct thread_info *ti = task_thread_info(current);
51+
ti->tp_value = addr;
52+
return 0;
53+
}
54+
55+
__attribute__((export_name("get_thread_area"))) unsigned long
56+
wasm_get_thread_area(void)
57+
{
58+
struct thread_info *ti = task_thread_info(current);
59+
return ti->tp_value;
4660
}

tools/wasm/src/init2.cpio

-3.4 KB
Binary file not shown.

tools/wasm/src/wasm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Instance extends WebAssembly.Instance {
1212
arg4: number,
1313
arg5: number,
1414
): number;
15+
get_thread_area(): number;
1516
};
1617
}
1718

tools/wasm/src/worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ self.onmessage = (event: MessageEvent<InitMessage>) => {
6262
},
6363
linux: {
6464
syscall: instance.exports.syscall,
65+
get_thread_area: instance.exports.get_thread_area,
6566
},
6667
});
6768

0 commit comments

Comments
 (0)