Commit Graph

191 Commits

Author SHA1 Message Date
9271990670 Platform: BL_MCU initial support 2023-03-20 10:47:45 +08:00
Wenyong Huang
f279ba84ee
Fix multi-threading issues (#2013)
- Implement atomic.fence to ensure a proper memory synchronization order
- Destroy exec_env_singleton first in wasm/aot deinstantiation
- Change terminate other threads to wait for other threads in
  wasm_exec_env_destroy
- Fix detach thread in thread_manager_start_routine
- Fix duplicated lock cluster->lock in wasm_cluster_cancel_thread
- Add lib-pthread and lib-wasi-threads compilation to Windows CI
2023-03-08 10:57:22 +08:00
Marcin Kolny
7a3d2bfab6
Fix os_socket_addr_resolve() for IPv6 (#2015)
The function always specified IPv4 socklen to sockaddr_to_bh_sockaddr(),
therefore the assertion was failing; however, sockaddr_to_bh_sockaddr()
never actually used socklen parameter, so we deleted it completely.
2023-03-08 07:08:12 +08:00
Gustavo Henrique Nihei
6a3ae689f7
nuttx: Add missing pthread.h header (#2009) 2023-03-07 22:01:16 +08:00
Xu Jun
92c4bbebad
Fix getting port issue in posix os_socket_bind (#1981)
In the previous code, the `*port` is assigned before `getsockname`, so the caller
may be not able to get the actual port number assigned by system.
Move the assigning of `*port` to be after `getsockname` to resolve the issue.
2023-02-22 18:59:13 +08:00
Wenyong Huang
0fa0813a5a
Fix issues reported by Coverity static analysis (#1974) 2023-02-22 11:10:21 +08:00
liang.he
91eafa1ead
Make a workaround for EGO when fstat returns NOT_SUPPORT (#1970)
The problem was found by a `Golang + WAMR (as CGO)` wrapped by EGO
in SGX Enclave.

`fstat()` in EGO returns dummy values:
- EGO uses a `mount` configuration to define the mount points that apply
  the host file system presented to the Encalve.
- EGO has a different programming model: the entire application runs inside
  the enclave. Manual ECALLs/OCALLs by application code are neither
  required nor possible.

Add platform ego and add macro control for the return value checking of
`fd_determine_type_rights` in libc-wasi to resolve the issue.
2023-02-21 11:11:27 +08:00
Patrick Cook
89c11c5361
Fix explicit casts and types in espidf_socket.c (#1945)
In the esp-idf platform, Xtensa GCC 8.4.0 reported incompatible pointer warnings when
building with the lwip component.

Berkeley (POSIX) sockets uses composition in combination with type punning to handle
many protocol families, including IPv4 & IPv6. The type punning just has to be made
explicit with pointer casts from `sockaddr_in` for IPv4 to the generic `sockaddr`.
2023-02-09 09:34:26 +08:00
Jämes Ménétrey
0435acdd43
SGX IPFS: Fix a segfault and support seeking beyond the end of files while using SEEK_CUR/SEEK_END (#1916)
The current implementation throws a segmentation fault when padding
files using a large range, because the writing operation overflows the
source buffer, which was a single char.

IPFS previously assumed that the offset for the seek operation was related
to the start of the file (SEEK_SET). It now correctly checks the parameter
'whence' and computes the offset for SEEK_CUR (middle of the file) and
SEEK_END (end of the file).
2023-01-30 08:24:12 +08:00
Huang Qi
cb7ac8fee3
nuttx: Mock socket APIs if NET is disabled (#1896) 2023-01-18 09:16:13 +08:00
Huang Qi
a1786428e6
nuttx: Remove fdopendir (#1895)
The newer version of nuttx has implemented fdopendir, and the compiler
reports multiple definitions of it.
2023-01-17 11:16:01 +08:00
Wenyong Huang
0c4402293d
Refine Windows thread waiting list operations (#1853)
Add thread_wait_list_end node for thread data and cond for Windows platform
to speedup the thread join and cond wait operations: no need to traverse the
wait list to get the end node to append the wait node.
2023-01-06 14:51:07 +08:00
Huang Qi
41eb938a95
Fix equal check in AOT XIP float cmp intrinsic (#1847) 2022-12-29 18:11:05 +08:00
TianlongLiang
2953614cb8
Port WAMR to the FreeBSD platform and update the document (#1825) 2022-12-24 10:11:10 +08:00
Wenyong Huang
0d9e527fa0
Upgrade version number to 1.1.2 (#1788)
Upgrade version number to 1.1.2, update RELEASE_NOTES.md and
clear several compile warnings.
2022-12-08 12:21:34 +08:00
Marcin Kolny
f8701560df
Fix warnings in the posix socket implementation (#1768) 2022-11-29 20:04:07 +08:00
guangyuhu
8d2aedca77
Compile WAMR on platforms that don't support IPV6 (#1754)
Modify posix_socket.c to support compile WAMR on platforms
that don't support IPV6
2022-11-29 07:45:25 +08:00
Wenyong Huang
ec5ab8274d
Fix zephyr sample build errors (#1757) 2022-11-28 11:23:51 +08:00
Huang Qi
93d3d09aa1
Clear some warnings and enable -Werror for NuttX (#1756) 2022-11-28 09:44:33 +08:00
liang.he
eaedceca2f
Add bh_print_proc_mem() to dump memory info of current process (#1734)
Only support Posix platforms currently, read memory consumption info from
file "/proc/self/status".
2022-11-25 08:33:44 +08:00
Jämes Ménétrey
328fd59f43
linux-sgx: Allow to open files with arbitrary paths in the sandbox using IPFS (#1685)
A limitation of the current implementation of SGX IPFS in WAMR is that
it prevents to open files which are not in the current directory.
This restriction is lifted and can now open files in paths, similarly to the
WASI openat call, which takes into account the sandbox of the file system.
2022-11-07 19:56:16 +08:00
Wenyong Huang
7fd37190e8
Add control for the native stack check with hardware trap (#1682)
Add a new options to control the native stack hw bound check feature:
- Besides the original option `cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1/0`,
  add a new option `cmake -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1/0`
- When the linear memory hw bound check is disabled, the stack hw bound check
   will be disabled automatically, no matter what the input option is
- When the linear memory hw bound check is enabled, the stack hw bound check
  is enabled/disabled according to the value of input option
- Besides the original option `--bounds-checks=1/0`, add a new option
  `--stack-bounds-checks=1/0` for wamrc

Refer to: https://github.com/bytecodealliance/wasm-micro-runtime/issues/1677
2022-11-07 18:26:33 +08:00
dongheng
9ba8c8957d
esp-idf: Add socket support for esp-idf platform (#1364)
Support to get/set recv_buf_size/send_buf_size/reuse_port/reuse_addr for wasm app
Add socket APIs for esp-idf platform
Add setsockopt for linux-sgx platform
2022-11-02 18:02:58 +08:00
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