Commit Graph

162 Commits

Author SHA1 Message Date
tonibofarull
1614ce12fa
wasi-nn: Enable GPU support (#1922)
- Split logic in several dockers
  - runtime: wasi-nn-cpu and wasi-nn- Nvidia-gpu.
  - compilation: wasi-nn-compile. Prepare the testing wasm and generates the TFLites.
- Implement GPU support for TFLite with Opencl.
2023-02-02 08:09:46 +08:00
Huang Qi
58316635d4
ci: Enable libc-wasi compilation test on NuttX (#1918) 2023-01-28 12:39:14 +08:00
tonibofarull
9eed6686df
Refactor WASI-NN to simplify the support for multiple frameworks (#1834)
- Reorganize the library structure
- Use the latest version of `wasi-nn` wit (Oct 25, 2022):
    0f77c48ec1/wasi-nn.wit.md
- Split logic that converts WASM structs to native structs in a separate file
- Simplify addition of new frameworks
2023-01-25 18:32:40 +08:00
Xu Jun
cadf9d0ad3
Main thread spread exception when thread-mgr is enabled (#1889)
And refactor clear_wasi_proc_exit_exception, refer to
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1869
2023-01-20 08:54:27 +08:00
Xu Jun
e696ac36d7
Fix potential block issue in source debugger (#1887)
Fix issue reported in #1860
2023-01-17 08:45:29 +08:00
YAMAMOTO Takashi
d04f3988c3
libc-wasi: Fix spurious poll timeout (#1824)
This reverts the "Fix libc-wasi poll_oneoff hang issue" change.
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1300
2022-12-21 17:29:29 +08:00
Wenyong Huang
fb8727ba68
Update release notes and fix issues reported by Coverity (#1813) 2022-12-16 14:16:58 +08:00
Callum Macmillan
c3d66f916e
Add memory watchpoint support for source debugger (#1762)
Allow to add watchpoints to variables for source debugging. For instance:
`breakpoint set variable var`
will pause WAMR execution when the address at var is written to.
Can also set read/write watchpoints by passing r/w flags. This will pause
execution when the address at var is read:
`watchpoint set variable -w read var`

Add two linked lists for read/write watchpoints. When the debug message
handler receives a watchpoint request, it adds/removes to one/both of these
lists. In the interpreter, when an address is read or stored to, check whether
the address is in these lists. If so, throw a sigtrap and suspend the process.
2022-12-07 17:18:28 +08:00
Wenyong Huang
1652f22a77
Fix issues reported by Coverity (#1775)
Fix some issues reported by Coverity and fix windows exception
check with guard page issue
2022-12-01 19:24:13 +08:00
TianlongLiang
be7a4abee2
Fix source debugger error handling: continue executing when detached (#1725)
Change main thread hangs when encounter debugger encounters error to
main thread exits when debugger encounters error
Change main thread blocks when debugger detaches to
main thread continues executing when debugger detaches, and main thread
exits normally when finishing executing
2022-11-28 22:12:46 +08:00
Huang Qi
93d3d09aa1
Clear some warnings and enable -Werror for NuttX (#1756) 2022-11-28 09:44:33 +08:00
Wenyong Huang
29b76dd275
Create module hash for each module in SGX lib-rats (#1745)
Current SGX lib-rats wasm module hash is stored in a global buffer,
which may be overwritten if there are multiple wasm module loadings.
We move the module hash into the enclave module to resolve the issue.

And rename the SGX_IPFS macro/variable in Makefile and Enclave.edl to
make the code more consistent.

And refine the sgx-ra sample document.
2022-11-24 21:48:50 +08:00
YAMAMOTO Takashi
1032aac60b
Add wasm_runtime_get_wasi_exit_code (#1748)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/1738
2022-11-24 20:26:18 +08:00
dependabot[bot]
2c5e7bc650
Bump tensorflow from 2.10.0 to 2.10.1 in /core/iwasm/libraries/wasi-nn/test (#1735)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.10.0 to 2.10.1.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.10.0...v2.10.1)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-22 16:21:06 +08:00
Zeuson
656a8427e6
linux-sgx: Improve the remote attestation (#1695)
The current implementation of remote attestation does not take into
account the integrity of the wasm module. The SHA256 of the wasm
module has been put into user_data to generate the quote, and more
parameters are exposed for further verification.
2022-11-22 14:45:03 +08:00
Xu Jun
e278861206
Avoid raising exception when debugging with VSCode (#1686) 2022-11-07 11:57:53 +08:00
dongsheng28849455
52ebd98ff4
Fix a build failure error on nuttx (#1675)
NuttX doesn't have SO_REUSEPORT.
2022-11-03 16:29:58 +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
TianlongLiang
3b4033aceb
Allow source debugger reconnection (#1667)
Allow to wait for a new debugger connection once the previous one
is disconnected:
- when receiving a detach command
- when the client socket is closed (for example, lldb process is killed)
2022-11-02 17:12:34 +08:00
Blaine Bublitz
101ea0ea3c
Update libuv version number (#1666)
Update the libuv version to work around a mingw64 bug, refer to:
  https://github.com/libuv/libuv/pull/3345
2022-11-01 11:07:35 +08:00
Wenyong Huang
a182926a73
Refactor interpreter/AOT module instance layout (#1559)
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
  WASMMemoryInstance/WASMTableInstance data structures for both interpreter
  and AOT
- Make the offset of most fields the same in module instance for both interpreter
  and AOT, append memory instance structure, global data and table instances to
  the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
  create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
  module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
  and LLVM JIT can access the same data structures, and make it possible to
  implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
  related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1384
2022-10-18 10:59:28 +08:00
Wenyong Huang
7cc7b56f88
Fix build socket api error (#1610)
Fix build socket api error introduced by #1590
2022-10-17 15:54:03 +08:00
Xu Jun
a75295ec14
Minor fix in assembly script library (#1597)
And fix a code format issue introduced by last commit.
2022-10-14 12:54:25 +08:00
dzobbe
84e88e4f85
Small change to make init of vars buildable in clang and clang++ (#1590) 2022-10-14 10:22:25 +08:00
Hanged Fish
f28a15bf2f
Wrap wasi_socket_ext api with extern "C" (#1575)
Fix wasi_socket_ext library failed to link with cxx project
2022-10-12 15:51:07 +08:00
tonibofarull
e53ab91439
Integrate WASI-NN into WAMR (#1521)
Initial integration of WASI-NN based on #1225:
- Implement the library core/iwasm/libraries/wasi-nn
- Support TensorFlow, CPU, F32 at the first stage
- Add cmake variable `-DWAMR_BUILD_WASI_NN`
- Add test case based on Docker image and update document

Refer to #1573
2022-10-12 12:09:29 +08:00
Callum Macmillan
5ddc335a7f
Add timeout send/recv and multicast client/server socket examples (#1519)
Add a couple of socket examples that can be used with WAMR:
- The `timeout_client` and `timeout_server` examples demonstrate socket
  send and receive timeouts using the socket options
- The `multicast_client` and `multicast_server` examples demonstrate receiving
  multicast packets in WASM

And add several macro controls for `socket_opts` example.
2022-10-07 10:31:21 +08:00
Jämes Ménétrey
5b10d4e630
socket: Explicit narrowing type cast and add missing static keywords (#1539)
While compiling the file wasi_socket_ext.c with pedantic options (typically
`-Wimplicit-int-conversion` and `-Wmissing-prototypes`), some warnings are raised.

This PR addresses those warnings by adding missing static statements before
functions and explicitly casting a narrowing conversion.

And fix the error handling after calling getpeername.
2022-09-29 22:44:57 +08:00
dzobbe
3fad613ea2
Enable build wasi_socket_ext.c with both clang and clang++ (#1527)
Enable to run WolfSSL into wasm and need some features from C++:
https://github.com/JamesMenetrey/wolfssl-examples/tree/wasm/Wasm
2022-09-29 20:52:11 +08:00
Marcin Kolny
c505da7464
Update __wasi_sock_accept signature to match wasi_snapshot_preview1 (#1531)
The function was introduced to WASI about half a year ago after it already
existed in WAMR.

It caused problems with compiling `wasi_socket_ext.c` with the wasi-sdk
that already had this hostcall exported (wasi-sdk >= 15).

The approach we take is the following:
- we update WASI interface to be compatible with the wasi_snapshot_preview1
- compilation with `wasi_socket_ext.c` supports both wasi_sdk >= 15 and wasi_sdk < 15
  (although we intend to drop support for < 15 at one point of time)
- we override `accept()` from wasi-libc - we do that because `accept()` in `wasi-libc`
  doesn't support returning address (as it doesn't have `getpeername()` implemented),
  so `wasi_socket_ext.c` offers more functionality right now

Resolves #1167 and #1528.

[1] https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/witx/wasi_snapshot_preview1.witx
2022-09-29 09:29:54 +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
Shengyun Zhou
edaff3c6ec
thread-mgr: Prevent an already detached thread from being detached again (#1487)
If WASM app has called pthread_detach() to detach a thread, it will be detached again
when thread exits. Attempting to detach an already detached thread may result in crash
in musl-libc. This patch fixes it.
2022-09-15 17:13:33 +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
Qiang
6820af6212
Fix a potential memory leak issue in wasm_native_init (#1465)
Should call `wasm_native_destroy` to destroy the registered native libs
when registering native lib failed in `wasm_native_init`.
2022-09-08 14:22:34 +08:00
Zeuson
729c4aeeaa
Enable remote attestation by librats in SGX mode (#1445)
Add library librats, update SGX build scripts, add sample and update document.
2022-09-06 14:29:58 +08:00
YAMAMOTO Takashi
0ca271873d
debug-engine: Handle wasm_debug_instance_get_current_object_name failure (#1453)
Use an empty string instead of stack garbage.
2022-09-05 19:45:20 +08:00
YAMAMOTO Takashi
6b073af3b0
debug-engine: Reduce the default MAX_PACKET_SIZE (#1425) 2022-08-30 17:00:32 +08:00
YAMAMOTO Takashi
fba12e9969
debug-engine: constify several global variables (#1427) 2022-08-30 15:43:47 +08:00
YAMAMOTO Takashi
1985a251cd
debug-engine: Use default stack size for control thread (#1424) 2022-08-26 21:13:30 +08:00
YAMAMOTO Takashi
04c1eb30cf
debug-engine: allocate "tmpbuf" dynamically (#1423)
Some configurations (eg. esp32/nuttx) have limited space for BSS,
0x20000 byte buffer is huge on embedded systems, change to
allocate the buffer dynamically.
2022-08-26 19:49:57 +08:00
YAMAMOTO Takashi
3875c6649a
wasm_runtime_start_debug_instance: Allow to override port (#1421)
Allow the embedder to manage port number for this purpose by itself.
2022-08-26 16:33:47 +08:00
YAMAMOTO Takashi
ee98b583d5
debug-engine: Fix process_port handling (#1415)
process_port=1 means "use port 1"
2022-08-25 20:03:44 +08:00
YAMAMOTO Takashi
7c75f6cf63
wasm_debug_engine_create: Remove unused comment (#1416) 2022-08-25 19:29:26 +08:00
YAMAMOTO Takashi
5586f7b82d
source debug: Remove unused platform_port (#1403) 2022-08-24 16:39:32 +08:00
YAMAMOTO Takashi
f5283399ec
debug: Retire wasm_debug_(get|set)_engine_active mechanism (#1404)
They are no longer necessary because we no longer create
debug instances automatically for exec env at this layer.
2022-08-24 12:15:37 +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
6798637891
Remove some unused codes (#1379)
Remove some unused fields in module instance and the related codes,
which are introduced by emsdk some special mode (-DSIDE_MODULE=1),
and are not required now.
2022-08-15 10:13:37 +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
Wenyong Huang
d955aa1bcc
Fix libc-wasi/uvwasi poll/environ_get issues (#1300)
Fix libc-wasi poll_oneoff hang issue
Fix libc-uvwasi environ_get sanity check issue
2022-07-20 20:02:26 +08:00
Marcin Kolny
d08e13c5ad
Fix socket api verification of addresses in the address pool (#1270)
The existing validation didn't work as expected; e.g. for address
pool: 8.8.8.8/24 the application had access to the 127.0.0.1 address (which
should not).
2022-07-12 16:21:49 +08:00