Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments/questions to the host functions managing module arguments #11

Open
wants to merge 152 commits into
base: wali
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
fff0a87
Added get memory size API
arjunr2 Feb 27, 2023
7e59c24
Added atomics types
arjunr2 Mar 19, 2023
e232ad4
Added uid for tsv
arjunr2 Mar 19, 2023
d091861
Start thread uid from 1
arjunr2 Mar 21, 2023
5152d36
Add instrument module as built-in
arjunr2 Sep 29, 2023
7f556ad
Add AoT global export interface functions
arjunr2 Oct 9, 2023
d547bee
some wali functions and support
arjunr2 Nov 28, 2022
d376789
Moved wali imports to separate file
arjunr2 Nov 28, 2022
a859ca9
Added all wali syscalls; changed format
arjunr2 Nov 28, 2022
544acad
Added mkdir fn, make wali implementation more readable
arjunr2 Nov 28, 2022
8565962
Moved wali to take long (64-bit) args for all syscalls
arjunr2 Jan 12, 2023
8bd78af
Added statx
arjunr2 Jan 14, 2023
e942dde
wali read/open/close working
arjunr2 Jan 15, 2023
b21c51d
added fstat/lstat
arjunr2 Jan 15, 2023
de02d57
added nanosleep and error messages for redundant stats
arjunr2 Jan 15, 2023
8250931
Added all native and impl base defs
arjunr2 Jan 16, 2023
b281189
Fixed mmap/fadvise aliasing
arjunr2 Jan 16, 2023
167079b
Added todo comments
arjunr2 Jan 16, 2023
8b348b6
access, lseek, pipe done
arjunr2 Jan 16, 2023
dd9bf59
tested few more base wali impls
arjunr2 Jan 16, 2023
07d16c3
Added passthrough file permission wali fns
arjunr2 Jan 16, 2023
9dca31a
Added clock gettime/nanosleep
arjunr2 Jan 17, 2023
c892a0f
Finished all passthrough filesystem calls
arjunr2 Jan 17, 2023
1a4369e
socket functions passthrough working
arjunr2 Jan 17, 2023
972b0e7
Added ioctl/writev for printf functionality
arjunr2 Jan 22, 2023
a382b79
Mmap wasm space in interpreter instead of malloc (merged from latest …
arjunr2 Jan 27, 2023
9b8ddd4
Initial mmap support; have to improve
arjunr2 Jan 27, 2023
fbbc4e0
Fixed mmap page alignment address
arjunr2 Jan 27, 2023
106b923
mprotect passthrough works
arjunr2 Jan 27, 2023
9ec5d44
commit brk check
arjunr2 Jan 27, 2023
24b72d6
Fixed mmap to expand wasm memory as well for internal access; still e…
arjunr2 Jan 27, 2023
a86064d
Fixed mmap base enlargement bug
arjunr2 Jan 29, 2023
d3b1d26
WALI Runtime Change: Added base page count
arjunr2 Jan 29, 2023
33af7ec
fix base memsize bug mmap
arjunr2 Jan 29, 2023
ecd8516
Implemented atomics
arjunr2 Jan 29, 2023
1323a50
fix atomic casp return
arjunr2 Jan 29, 2023
e28b9ac
Changed wali implementation to match long64 clang change
arjunr2 Feb 3, 2023
f376bd1
Fixed memory pointer usage with NULL
arjunr2 Feb 3, 2023
93028d8
sigaction/return works when not in syscall
arjunr2 Feb 5, 2023
f39b6c6
alarm and other syscall formatted
arjunr2 Feb 5, 2023
a48b4ef
Added sigprocmask, f/statfs wali
arjunr2 Feb 6, 2023
44697be
Added sigaltstack and sigsuspend
arjunr2 Feb 6, 2023
d11900b
Added execve syscall
arjunr2 Feb 7, 2023
60fe316
Added e/g/uid calls
arjunr2 Feb 16, 2023
48356ab
Fixed 64-bit parameter for 64-bit atomics
arjunr2 Feb 16, 2023
755e00f
Added setpgid; exit, exitgroup impl but not registered
arjunr2 Feb 17, 2023
4aeee02
some rebase fixes for wamr update
arjunr2 Feb 17, 2023
3e67efb
warning fixes for rebase
arjunr2 Feb 17, 2023
616ed21
Added patches to updated wamr for wali (segfault issue)
arjunr2 Feb 17, 2023
be5734b
Fix running mode set
arjunr2 Feb 17, 2023
3067804
fix ERRSC not returning -1
arjunr2 Feb 21, 2023
5300f32
Moved custom functions up
arjunr2 Feb 24, 2023
b7f9655
Added ftruncate and sid; wait4 debug
arjunr2 Mar 29, 2023
f7b35b1
Fixed sigreturn; signals working but no custom handler code
arjunr2 Apr 6, 2023
72cbce9
Removed todos and error out getdents
arjunr2 Apr 6, 2023
92c25a9
Added synchronous signal registration for wali
arjunr2 Apr 9, 2023
6167883
Added interpreter changes for synchronous signals
arjunr2 Apr 9, 2023
c795e49
setitimer syscall added
arjunr2 Apr 9, 2023
f59ad3c
Fixed locking for sigtable
arjunr2 Apr 10, 2023
ee67784
Added wali get cl args
arjunr2 May 12, 2023
27ad163
Remove wasi startup imports
arjunr2 May 17, 2023
1ffe741
meomry bytes/max page set
arjunr2 May 18, 2023
f490feb
sigsetjmp/longjmp support added
arjunr2 May 19, 2023
b1b723d
Added some more syscalls; changed SIG_IGN to -2 for wasm tables
arjunr2 May 19, 2023
cd8cdaa
Added sigaction copy to wasm
arjunr2 May 26, 2023
eb3cbc2
Added signal debug prints
arjunr2 May 26, 2023
ec6b851
Save setjmp to wasm buffer; still errors
arjunr2 May 26, 2023
a692737
Added signal name log
arjunr2 May 30, 2023
84de587
Initial thread spawn support; remove get_tp
arjunr2 Jun 6, 2023
c645f6e
Futex syscall added
arjunr2 Jun 6, 2023
07de3be
Set tid address syscall added
arjunr2 Jun 7, 2023
683dca6
Added pselect syscall
arjunr2 Jun 8, 2023
a8d107f
Fixed pselect6 arg bug
arjunr2 Jun 14, 2023
2607e95
Added getrusage syscall impl
arjunr2 Jun 14, 2023
fa361cf
Added fatal notifications
arjunr2 Jun 14, 2023
5bc31f7
Added fatal log
arjunr2 Jun 16, 2023
d853fd2
Fix mremap last arg
arjunr2 Jun 16, 2023
35d9e70
Moved syscall def to arch specific
arjunr2 Jun 18, 2023
82e0a87
Added aarch64/riscv64 syscall asms
arjunr2 Jun 18, 2023
78c70e2
Added setjmp/signal wali support for all arch
arjunr2 Jun 18, 2023
2cc16a2
One cross arch syscall
arjunr2 Jun 19, 2023
273857d
Placeholder skeletons for most aarch64/riscv64 call patches
arjunr2 Jun 19, 2023
657ef1c
Added syscalls for aarch64/riscv64 portability
arjunr2 Jun 19, 2023
1d9106b
Fix warning/bugs without fstatat
arjunr2 Jun 19, 2023
9fae99a
Added fstatat syscall
arjunr2 Jun 19, 2023
9be8249
Use newfstatat for supported archs
arjunr2 Jun 19, 2023
b32df10
Remove host-based atomics for builtins and libc substitutes
arjunr2 Jun 19, 2023
55775f4
Patched open flags for aarch64 wali
arjunr2 Jun 20, 2023
4ca3c37
Patched stat struct for aarch64/riscv64
arjunr2 Jun 20, 2023
8e37877
Fix ppoll alias bug
arjunr2 Jun 20, 2023
1b0b0b9
Fix riscv64 define
arjunr2 Jun 22, 2023
0b99164
Copy stat struct for riscv
arjunr2 Jun 22, 2023
3159ff3
Fix sendto format bug
arjunr2 Jun 22, 2023
f333e9a
Fix sendto prototype
arjunr2 Jun 22, 2023
6f06e55
Speedup signal handling check in interpreter with wrapper read
arjunr2 Jun 26, 2023
a8a179a
Added mmap edge case fail detection
arjunr2 Jun 26, 2023
cfe6a74
Initial wokring aot support; todo: signals
arjunr2 Jun 27, 2023
3d02216
Fix -9 mmap addr typecast
arjunr2 Jun 27, 2023
f523c2c
Added AOT indirect function handling for signal; todo: signal polling
arjunr2 Jun 27, 2023
9d9cccc
Added signal polling support for AoT
arjunr2 Jun 27, 2023
1b03bb3
Exit siglongjmp with status 1
arjunr2 Jun 27, 2023
d4ca833
Added syscalls for vim
arjunr2 Jun 29, 2023
239937f
Added epoll syscall support
arjunr2 Jun 30, 2023
45198ba
Added Linux thread ID for thread model
arjunr2 Jun 30, 2023
d27a3e6
Fix sendmsg/recvmsg bug with msghdr copy
arjunr2 Jun 30, 2023
85b44db
Added environment var support and fixed verbose warnings
arjunr2 Jul 3, 2023
574151e
Remove env file hardcode
arjunr2 Jul 3, 2023
6f71ffc
Fixed init env execve interaction
arjunr2 Jul 4, 2023
45fd697
Fixed sendmsg iovec bug
arjunr2 Jul 4, 2023
9aff759
Fixed epoll return value bug for non-packed architectures
arjunr2 Jul 4, 2023
3de53a7
Added socketpair syscall and fixed environment args string count
arjunr2 Jul 4, 2023
2fd1f94
Fixed signal to use index instead of pointer in table
arjunr2 Jul 5, 2023
350bac8
Use function index for AoT signal handler
arjunr2 Jul 5, 2023
3ce0474
Increase thread stack size to 128k for all arch and more complex apps
arjunr2 Jul 5, 2023
7ea40f0
Added few syscalls for sshd
arjunr2 Jul 7, 2023
f81cd58
Added syscall return macro
arjunr2 Jul 12, 2023
2593cf9
Added memory profiling
arjunr2 Jul 20, 2023
aefafc8
Added syscall profiling metrics
arjunr2 Jul 24, 2023
1afe51b
Added native syscall profiling as well
arjunr2 Jul 24, 2023
86f532f
Added syscall 0 call
arjunr2 Jul 24, 2023
f937257
Fix profiling dump during exit disable
arjunr2 Jul 26, 2023
245726c
Fixed profile define bug
arjunr2 Jul 31, 2023
2de3bbd
Remove semicolon for native time
arjunr2 Jul 31, 2023
47f09a4
Add compile flags for signal handling granularity
arjunr2 Jul 31, 2023
fd0ee49
Added compile defines to cmake build
arjunr2 Jul 31, 2023
f5e5647
Added vmlib support for wali with WAMR_BUILD_LIBC_WALI cmake flag
arjunr2 Aug 1, 2023
68e6840
Remove old wali comment
arjunr2 Aug 1, 2023
7368875
Added opcode counting through exec_env with WASM_ENABLE_OPCODE_COUNTER=1
arjunr2 Aug 1, 2023
3eff547
Move opcode counter into WasmModuleInstanceExtra
arjunr2 Aug 1, 2023
03dc136
Fix app args support
arjunr2 Aug 1, 2023
7651666
Added mmap bounds check; env working for cl
arjunr2 Aug 2, 2023
26a9210
Added mremap implementation
arjunr2 Aug 3, 2023
381911a
Support func sigpoll
arjunr2 Aug 8, 2023
abf44d1
Added inline signal polling
arjunr2 Aug 9, 2023
60a78d1
Update readability and code reorganization
arjunr2 Aug 16, 2023
37e3840
Fix warnings
arjunr2 Aug 16, 2023
a6c0d31
Add flag to disable wali memory profiling
arjunr2 Sep 8, 2023
1c53eb2
Added support for safe process exit
arjunr2 Sep 10, 2023
c193e5d
Fix post-rebase changes (yet to fix proc_exit with infinite suspend c…
arjunr2 Sep 11, 2023
de7b309
Fix wali proc/thread exit edge cases for suspended threads
arjunr2 Sep 12, 2023
8ad02fa
Fixed wali exported vars
arjunr2 Sep 13, 2023
439aaaa
Fix arch-specific compilation
arjunr2 Sep 13, 2023
03258a5
Fix missing extern for aarch64
arjunr2 Sep 13, 2023
e3fbed0
Don't redefine GNU_SOURCE for wali
arjunr2 Sep 21, 2023
905c3aa
Added api to access max memory
arjunr2 Sep 24, 2023
8fcfb3e
Post-rebase remove wasi proc exit change
arjunr2 Oct 8, 2023
b2168d9
Rework: Syscall name-bindings
arjunr2 Nov 15, 2023
91dd8ff
Added accept4; fix return from last two syscalls
arjunr2 Nov 16, 2023
774ba5a
Fixed wali exit code returns
arjunr2 Nov 17, 2023
6dcfbfc
Add index of indirect call mismatch for interpreter fast
arjunr2 Nov 21, 2023
23e37fc
Add placeholder setjmp implementation for compilation effort
arjunr2 Nov 22, 2023
206be8c
Added comments/questions to the host functions managing module argume…
FedorSmirnov89 Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wali read/open/close working
arjunr2 committed Oct 9, 2023
commit e942dde7310fbdf8a31b87da6bbb297c923c8cd6
74 changes: 43 additions & 31 deletions product-mini/platforms/linux/wali.c
Original file line number Diff line number Diff line change
@@ -72,65 +72,77 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long
#define __syscall6(n, a1, a2, a3, a4, a5, a6) __syscall6(n, (long)a1, (long)a2, (long)a3, (long)a4, (long)a5, (long)a6)


#define PW(f) LOG_WARNING("WALI: " # f);
#define SC(f) LOG_WARNING("WALI: SC | " # f);
#define PW(f) LOG_DEBUG("WALI: " # f);
#define SC(f) LOG_DEBUG("WALI: SC | " # f);

uint32 psize;
typedef uint8_t* Addr;
#define MEM_ADDR(wasm_addr) ({ \
#define MADDR(wasm_addr) ({ \
wasm_runtime_get_memory_ptr(get_module_inst(exec_env), &psize) + wasm_addr; \
})

/***** WALI Methods *******/
// 0
long wali_syscall_read (wasm_exec_env_t exec_env, long a1, long a2, long a3) {
SC(read);
return __syscall3 (SYS_read, a1, MADDR(a2), a3);
}

// 1
long wali_syscall_write (wasm_exec_env_t exec_env, long a1, long a2, long a3) {
Addr addr2 = MEM_ADDR(a2);
return __syscall3(SYS_write, a1, addr2, a3);
SC(write);
return __syscall3 (SYS_write, a1, MADDR(a2), a3);
}

long wali_syscall_getcwd (wasm_exec_env_t exec_env, long a1, long a2) {
SC(getcwd);
Addr addr1 = MEM_ADDR(a1);
return __syscall2(SYS_getcwd, addr1, a2);
// 2
long wali_syscall_open (wasm_exec_env_t exec_env, long a1, long a2, long a3) {
SC(open);
return __syscall3 (SYS_open, MADDR(a1), a2, a3);
}

long wali_syscall_chdir (wasm_exec_env_t exec_env, long a1) {
SC(chdir);
Addr addr1 = MEM_ADDR(a1);
return __syscall1(SYS_chdir, addr1);
// 3
long wali_syscall_close (wasm_exec_env_t exec_env, long a1) {
SC(cloes);
return __syscall1 (SYS_close, a1);
}

long wali_syscall_mkdir (wasm_exec_env_t exec_env, long a1, long a2) {
SC(mkdir);
Addr addr1 = MEM_ADDR(a1);
return __syscall2(SYS_mkdir, addr1, a2);
// 4
long wali_syscall_stat (wasm_exec_env_t exec_env, long a1, long a2) {
SC(stat);
return __syscall2(SYS_stat, MADDR(a1), MADDR(a2));
}

// 57
long wali_syscall_fork (wasm_exec_env_t exec_env) {
SC(fork);
return __syscall0(SYS_fork);
}

long wali_syscall_stat (wasm_exec_env_t exec_env, long a1, long a2) {
SC(stat);
Addr addr1 = MEM_ADDR(a1);
Addr addr2 = MEM_ADDR(a2);
// 79
long wali_syscall_getcwd (wasm_exec_env_t exec_env, long a1, long a2) {
SC(getcwd);
return __syscall2(SYS_getcwd, MADDR(a1), a2);
}

//struct stat sb;
int retval = __syscall2(SYS_stat, addr1, addr2);
for (int i = 0; i < sizeof(struct stat); i++) {
printf("%02x", ((char*)(addr2))[i]);
}
printf("\n");
return retval;
// 80
long wali_syscall_chdir (wasm_exec_env_t exec_env, long a1) {
SC(chdir);
return __syscall1(SYS_chdir, MADDR(a1));
}

// 83
long wali_syscall_mkdir (wasm_exec_env_t exec_env, long a1, long a2) {
SC(mkdir);
return __syscall2(SYS_mkdir, MADDR(a1), a2);
}

// 332
long wali_syscall_statx (wasm_exec_env_t exec_env, long a1, long a2, long a3, long a4, long a5) {
SC(statx);
Addr addr2 = MEM_ADDR(a2);
Addr addr5 = MEM_ADDR(a5);
return __syscall5(SYS_statx, a1, addr2, a3, a4, addr5);
return __syscall5(SYS_statx, a1, MADDR(a2), a3, a4, MADDR(a5));
}


/***** Non-syscall methods *****/
uintptr_t wali__get_tp (wasm_exec_env_t exec_env) {
uintptr_t tp;
7 changes: 5 additions & 2 deletions product-mini/platforms/posix/main.c
Original file line number Diff line number Diff line change
@@ -845,12 +845,15 @@ main(int argc, char *argv[])

static NativeSymbol wali_native_symbols[] = {
// Syscalls
NSYMBOL ( __syscall_SYS_read, wali_syscall_read, "(iii)i" ),
NSYMBOL ( __syscall_SYS_write, wali_syscall_write, "(iii)i" ),
NSYMBOL ( __syscall_SYS_open, wali_syscall_open, "(iii)i" ),
NSYMBOL ( __syscall_SYS_close, wali_syscall_close, "(i)i" ),
NSYMBOL ( __syscall_SYS_stat, wali_syscall_stat, "(ii)i"),
NSYMBOL ( __syscall_SYS_fork, wali_syscall_fork, "()i"),
NSYMBOL ( __syscall_SYS_getcwd, wali_syscall_getcwd, "(ii)i" ),
NSYMBOL ( __syscall_SYS_chdir, wali_syscall_chdir, "(i)i"),
NSYMBOL ( __syscall_SYS_mkdir, wali_syscall_mkdir, "(ii)i"),
NSYMBOL ( __syscall_SYS_fork, wali_syscall_fork, "()i"),
NSYMBOL ( __syscall_SYS_stat, wali_syscall_stat, "(ii)i"),
NSYMBOL ( __syscall_SYS_statx, wali_syscall_statx, "(iiiii)i"),
// Threads
NSYMBOL ( __get_tp, wali__get_tp, "()i" )