Commit Graph

168 Commits

Author SHA1 Message Date
dongsheng28849455
e517dbc7b2
XIP adaptation for xtensa platform (#1636)
Add macro WASM_ENABLE_WORD_ALING_READ to enable reading
1/2/4 and n bytes data from vram buffer, which requires 4-byte addr
alignment reading.

Eliminate XIP AOT relocations related to the below ones:
   i32_div_u, f32_min, f32_max, f32_ceil, f32_floor, f32_trunc, f32_rint
2022-10-31 17:25:24 +08:00
Wenyong Huang
0f5b73ae67
Add mutex initializer for wasm-c-api engine operations (#1656)
The host embedder may new/delete wasm-c-api engine simultaneously
in multiple threads, which requires lock for the operations. Since there
isn't one time called global init/destroy APIs provided by wasm-c-api,
we define a global lock and initialize it with thread mutex initializer if
the platform supports that, and use it to lock the operations of engine.

If the platform doesn't support thread mutex initializer, we require
developer to create the lock by himself to ensure the thread-safe of the
engine operations.
2022-10-31 11:48:07 +08:00
Jämes Ménétrey
264fdfafed
linux-sgx: Use non-destructive modes for opening files using SGX IPFS (#1645)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/pull/1645
2022-10-27 12:21:30 +08:00
casaroli
4c61bfd10d
Suppress the warnings when building with GCC11 (#1622)
Add pragma to ignore "-Waddress-of-packed-member"
Adds `void` parameter to the prototype of some functions to make them
have strict declarations
2022-10-20 21:26:57 +08:00
Shengyun Zhou
84b1a6c10e
Remove unnecessary app heap memory clean operations to reduce process RSS (#1608)
With hardware boundary checking enabled, the app heap memory comes from `os_mmap()`.
Clearing the whole heap in the memory allocator causes process RSS to reach maximum
app heap size immediately and wastes lots of memory, so we had better remove the
unnecessary memory clean operations in the memory allocator.
2022-10-18 18:02:48 +08:00
YAMAMOTO Takashi
6f04f115ab
posix_thread.c: Avoid sem_getvalue deprecation warning on macOS (#1596) 2022-10-17 10:18:54 +08:00
Shengyun Zhou
2e77626d0f
wamrc: Support cross building and linking LLVM shared libs (#1578)
1. Support cross building wamrc and installing it
2. Remove PIE flag for Windows to fix compilation error when compiled by clang
3. Support linking LLVM shared libs to help build with system default or custom
   LLVM installation and reduce binary size.
2022-10-13 18:37:34 +08:00
Jämes Ménétrey
78c38d088e
linux-sgx: Implement POSIX calls based on getsockname and set/getbooloption (#1574) 2022-10-12 09:57:01 +08:00
YAMAMOTO Takashi
1e22d1a9e5
Fix the "register native with iwasm" stuff for macOS (#1558)
- core/shared/platform/darwin/platform_internal.h: macOS has dlopen
- samples/native-lib/README.md: Mention macOS
2022-10-07 15:17:36 +08:00
Jämes Ménétrey
e2a3f0f387
linux-sgx: Implement socket API getpeername, recvfrom and sendto (#1556)
Implement some of the popular socket APIs left unimplemented for SGX,
following the merge of dev/socket.
2022-10-06 21:32:33 +08:00
Jämes Ménétrey
a7a9e40fc6
linux-sgx: Fix directional OCALL parameter for getsockname (#1554) 2022-10-04 21:40:37 +08:00
Jämes Ménétrey
4489c3da2b
hash map: Fix a wrongly named parameter and enhance the docs (#1540) 2022-09-30 03:02:22 +08:00
Jämes Ménétrey
dfd16f8e4f
linux-sgx: Implement SGX IPFS as POSIX backend for file interaction (#1489)
This PR integrates an Intel SGX feature called Intel Protection File System Library (IPFS)
into the runtime to create, operate and delete files inside the enclave, while guaranteeing
the confidentiality and integrity of the data persisted. IPFS can be referred to here:
https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-intel-protected-file-system-library-using-software-guard-extensions.html

Introduce a cmake variable `WAMR_BUILD_SGX_IPFS`, when enabled, the files interaction
API of WASI will leverage IPFS, instead of the regular POSIX OCALLs. The implementation
has been written with light changes to sgx platform layer, so all the security aspects
WAMR relies on are conserved.

In addition to this integration, the following changes have been made:
 - The CI workflow has been adapted to test the compilation of the runtime and sample
    with the flag `WAMR_BUILD_SGX_IPFS` set to true
 - Introduction of a new sample that demonstrates the interaction of the files (called `file`),
 - Documentation of this new feature
2022-09-28 13:09:58 +08:00
dongsheng28849455
8436e88a07
Fix link error for ESP-IDF 4.4.2 (#1520)
Fix the issue reported by #1484:
Platform ESP-IDF broken for WAMR 1.0.0 with ESP-IDF 4.4.2
Let the dummy ftruncate only work with ESP-IDF earlier than 4.4.2
2022-09-27 09:00:38 +08:00
YAMAMOTO Takashi
3d56c8133c
Fix NuttX build error after dev/socket was merged (#1517) 2022-09-26 20:06:14 +08:00
Wenyong Huang
78b5c5b484
Merge dev/socket into main (#1393)
Implement more socket APIs, refer to #1336 and below PRs:
- Implement wasi_addr_resolve function (#1319)
- Fix socket-api byte order issue when host/network order are the same (#1327)
- Enhance sock_addr_local syscall (#1320)
- Implement sock_addr_remote syscall (#1360)
- Add support for IPv6 in WAMR (#1411)
- Implement ns lookup allowlist (#1420)
- Implement sock_send_to and sock_recv_from system calls (#1457)
- Added http downloader and multicast socket options (#1467)
- Fix `bind()` calls to receive the correct size of `sockaddr` structure (#1490)
- Assert on correct parameters (#1505)
- Copy only received bytes from socket recv buffer into the app buffer (#1497)

Co-authored-by: Marcin Kolny <mkolny@amazon.com>
Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com>
Co-authored-by: Callum Macmillan <callumimacmillan@gmail.com>
2022-09-22 21:46:14 +08:00
Huang Qi
bbea005db6
Make libc-builtin buffered printf be a common feature (#1483)
Add macros to control whether to use the libc-builtin buffered printf
and the buffer size.
2022-09-15 15:09:01 +08:00
Wenyong Huang
ab929c20a3
Add check for code section size, fix interp float operations (#1480)
And enable classic interpreter instead fast interpreter when llvm jit is enabled,
so as to fix the issue that llvm jit cannot handle opcode drop_64/select_64.
2022-09-14 19:49:18 +08:00
Wenyong Huang
8a2c1a2471
Fix build error on alios platform (#1459)
Add the definition of `korp_sem` in platform_internal.h.
2022-09-07 13:50:11 +08:00
Xu Jun
5722fcc40a
Fix issue in multi-thread sample (#1458)
Set `WAMR_BUILD_LIB_PTHREAD_SEMAPHORE` for the sample,
and update document.
2022-09-07 12:56:50 +08:00
Wenyong Huang
d095876ae6
Enable memory leak check (#1429)
Report the memory leak info when building iwasm with
`cmake .. -DWAMR_BUILD_GC_VERIFY=1`
2022-09-01 16:15:00 +08:00
Huang Qi
77c516ac80
Add a new API to get free memory in memory pool (#1430) 2022-08-31 16:39:25 +08:00
Wenyong Huang
6caa6b1d73
Support get return value for SGX os_printf/os_vprintf (#1387)
Fix the issue reported in #1359, change the implementation of
os_printf/os_vprintf for Intel SGX to get the actual bytes written.
2022-08-16 14:23:34 +08:00
dongheng
071b8c2510
esp-idf: Make esp-idf support Libc WASI (#1356)
esp-idf: Make esp-idf support Libc WASI

1. Support to get WASM APP libs' DIR from upper layer
2. Add SSP support for esp-idf platform
3. Change the errno of readlinkat
2022-08-15 16:17:28 +08:00
Wenyong Huang
e23acfab36
Fix windows thread data issue and enhance windows os_mmap (#1372)
Thread data should not be destroyed when thread exits, or other thread
may not be able to join it. This PR saves the thread data into thread data
list when thread exits, sets thread status and stores the return value, so
that other thread can join it.

Also set MEM_TOP_DOWN flag for Windows VirtualAlloc to yield LLVM
JIT relocation error.

And set opt/size level to 3 for LLVM JIT for future use, currently the flags
are not used by LLVM JIT.
2022-08-11 16:57:32 +08:00
Huang Qi
f3f8d684b3
Implement POSIX semaphore support for linux platform (#1345)
Implement POSIX semaphore support for linux platform
2022-08-08 19:59:46 +08:00
dongheng
b75ae3363d
esp32: Support app management and thread (#1350)
Support app management and thread on esp-idf platform:
- Fix compile issues when app management is enabled
- Add missing thread related APIs
2022-08-02 16:37:55 +08:00
Wenyong Huang
32c94161d1
Clear compilation warnings on Windows (#1307) 2022-07-21 09:32:28 +08:00
Wenyong Huang
daeb7a4265
Don't suppress prev signal handler in hw bound check (#1268)
Enhance the hw bound check reported in #1262:

When registering signal handlers for SIGSEGV & SIGBUS in boundary
check with hardware trap, preserve the previous handlers for signal
SIGSEGV and SIGBUS, and forward the signal to the preserved signal
handlers if it isn't handled by hw bound check.
2022-07-06 16:53:05 +08:00
dongsheng28849455
bc6eda2803
Set nuttx isatty definition according to CONFIG_SERIAL_TERMIOS (#1234)
The isatty definition on nuttx depends on CONFIG_SERIAL_TERMIOS
2022-06-20 11:58:48 +08:00
Xu Jun
4b38205023
Fix some issues reported by klocwork (#1233)
Change memcpy to bh_memcpy_s and add some asserts to
enhance the security.
2022-06-16 19:50:47 +08:00
Wenyong Huang
5b1dcf2fa2
Implement Go language binding (#1196)
Implement Go binding APIs of runtime, module and instance
Add sample, build scripts and update the document

Co-authored-by: venus-taibai <97893654+venus-taibai@users.noreply.github.com>
2022-06-01 11:35:05 +08:00
YAMAMOTO Takashi
da3b519642
core/shared/platform/nuttx: mock several APIs for libc-wasi (#1127) 2022-05-24 12:03:40 +08:00
liang.he
565c1c04db
Fix bh_vector extend_vector not locked issue (#1187)
Fix issue that func `extend_vector` isn't locked in vector insert and append.
2022-05-24 09:10:43 +08:00
YAMAMOTO Takashi
723a808106
nuttx: Use text heap for executable memory (#1181)
Based on nuttx patch "Add up_textheap_heapmember":
  https://github.com/apache/incubator-nuttx/pull/6306
2022-05-23 10:58:09 +08:00
Wenyong Huang
37cc6eac3b
Implement SGX getrandom/getentropy without ocall (#1176)
Implement SGX getrandom with sgx_read_rand and getentropy with `rdseed` instruction
instead of ocall to improve the security.
2022-05-21 12:21:09 +08:00
Namhyeon, Go
0993601d55
Add check for stack_min_addr in bound check with hardware trap (#1166)
Add return value check for os_thread_get_stack_boundary before touch_pages
in the initialization of memory access bound check with hardware trap.
2022-05-12 12:23:35 +08:00
Wenyong Huang
d62543c99c
Enlarge max pool size and fix bh_memcpy_s dest max size check (#1151)
Enlarge max pool size and fix bh_memcpy_s dest max size check to support
large linear memory, e.g. with initial page count 65535.
2022-05-07 16:09:16 +08:00
YAMAMOTO Takashi
2e27d506d8
posix os_socket_inet_network: Use inet_addr instead of inet_network (#1133) 2022-04-28 13:53:01 +08:00
YAMAMOTO Takashi
d9d0777051
Move dlfcn.h availability check to platform_common.h (#1134) 2022-04-28 12:31:28 +08:00
YAMAMOTO Takashi
0f505aafd9
aot_runtime.c: Add static assertions for some offset assumptions (#1103) 2022-04-20 13:58:02 +08:00
Wenyong Huang
d4758d7380
Refine codes and fix several issues (#1094)
Add aot relocation for ".rodata.str" symbol to support more cases
Fix some coding style issues
Fix aot block/value stack destroy issue
Refine classic/fast interpreter codes
Clear compile warning of libc_builtin_wrapper.c in 32-bit platform
2022-04-18 17:33:30 +08:00
Jämes Ménétrey
106974d915
Implement Berkeley Socket API for Intel SGX (#1061)
Implement Berkeley Socket API for Intel SGX
- bring Berkeley socket API in Intel SGX enclaves,
- adapt the documentation of the socket API to mention Intel SGX enclaves,
- adapt _iwasm_ in the mini-product _linux-sgx_ to support the same option as the one for _linux_,
- tested on the socket sample as provided by WAMR (the TCP client/server).
2022-03-25 17:46:29 +08:00
Wenyong Huang
5264ce4118
Fix issues reported by klocwork (#1060)
Fix issues reported by klocwork, fix host_tool compile error,
and update build script of benchmark jetstream
2022-03-24 17:34:22 +08:00
liang.he
86b79cfb93
Enable lock for Vector to protect wasm-c-api read/write/extend operations (#1010) 2022-03-23 11:42:57 +08:00
Wenyong Huang
9c87a1ee17
Implement part of Berkeley Socket API for libc-wasi (#1036)
Refer to [Networking API design](https://github.com/WebAssembly/WASI/issues/370)
and [feat(socket): berkeley socket API v2](https://github.com/WebAssembly/WASI/pull/459):

- Support the socket API of synchronous mode, including `socket/bind/listen/accept/send/recv/close/shutdown`,
    the asynchronous mode isn't supported yet.
- Support adding `--addr-pool=<pool1,pool2,..>` argument for command line to identify the valid ip address range
- Add socket-api sample and update the document
2022-03-10 15:13:38 +08:00
Namhyeon, Go
0d1060b3cc
Fix ‘MADV_HUGEPAGE’ undeclared compilation error (#1012)
In some Linux systems whose kernel version is smaller than 2.6.38, the macro
MADV_HUGEPAGE isn't introduced yet which causes compilation error.
Add macro control to fix the compilation error.
2022-02-18 11:25:06 +08:00
Xu Jun
3fe191b0df
[debugger enhance] don't block gdbserver thread while executing (#989)
Allow to set break point again when all break points are removed and
wasm app starts running.
2022-02-16 17:35:35 +08:00
Karl Fessel
a22a5da40d
Correct RIOT os_mmap size type to size_t (#1002)
Change signature of riot `os_mmap` implementation to match declaration in core/shared/platform/include/platform_api_vmcore.h
2022-02-09 10:21:54 +08:00
lucianoiam
4bdeb909df
Enable Windows MinGW support (#1000)
Allow compilation on Windows MinGW, see build_wamr.md for more details.

Note that WASI and some other smallish details are still not supported, but
we have a starting point. See more discussion at #993
2022-02-06 13:20:38 +08:00