Commit Graph

150 Commits

Author SHA1 Message Date
liang.he
30ee992762
Add wasm_module_obtain() to clone wasm_module_t (#1660)
Also add support for wasm_shared_module_t, and add lock for
wasm_module_t related operations.

And add wasm-c-api sample threads, update sample clone.
2022-11-09 12:50:58 +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
Jämes Ménétrey
aba267afc7
linux-sgx: Improve the documentation of SGX-RA sample (#1679)
Improve the documentation for setting up SGX-RA using WAMR, based on
the feedback in #1670.

This notably highlights the dependency on Intel PCS and PCCS and how to
install/configure them.
2022-11-04 14:14:18 +08:00
YAMAMOTO Takashi
825544ddab
samples/native-lib: use the same shared lib name as product-mini (#1669)
Use the shared lib name `libiwasm` instead of static lib name `vmlib`
2022-11-01 21:55:43 +08:00
liang.he
a1f7832625
Remove an improper assumption when creating wasm_trap (#1657)
Allow to have multiple stores in an engine and multiple instances
in a store. Letting a wasm_function_t pass its wasm_store_t to make
it more efficient.
2022-11-01 11:56:28 +08:00
YAMAMOTO Takashi
960b613d10
samples/native-lib: Add an example to use wamr API from native lib (#1649)
Real world native libs likely need to access the wasm_runtime_xxx API.
This example demonstrates it.

Build vmlib as a shared lib to make it straightforward to share a
single runtime instance between iwasm and native libs.
2022-10-28 19:31:21 +08:00
Wenyong Huang
84161fe084
Add CIs to release new version and publish binary files (#1648)
Add CIs to enable the release process of a new version of WAMR,
and build and publish the binary files when a version is released,
including iwasm, wamrc, lldb, vscode-extension and wamr-ide for
Ubuntu-20.04, Ubuntu-22.04 and MacOS.

And refine the CIs to test spec cases.
2022-10-28 13:55:41 +08:00
YAMAMOTO Takashi
bc58778c34
samples/native-lib: Add a bit more complicated example (#1643)
Add test_hello sample and update the document
2022-10-27 15:06:14 +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
Wenyong Huang
ef21f0c951
Implement Fast JIT dump call stack and perf profiling (#1633)
Implement dump call stack and perf profiling features for Fast JIT,
and refine some code.
2022-10-27 09:28:32 +08:00
YAMAMOTO Takashi
654ac5feca
Use cmake POSITION_INDEPENDENT_CODE instead of hardcoding -pie -fPIE (#1598)
This fixes unused option warnings on -pie for macOS.
(On macOS cmake produces "-fPIE -Xlinker -pie")

Bump required cmake version to 3.14 for CheckPIESupported.

References:
https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html
https://cmake.org/cmake/help/latest/module/CheckPIESupported.html#module:CheckPIESupported
2022-10-19 01:51:18 +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
ace05b182d
Fix possible non null-terminated string issue in socket sample (#1612) 2022-10-17 22:45:10 +08:00
YAMAMOTO Takashi
9ba8c80850
samples/multi-module: Examine module registration a bit (#1595) 2022-10-14 16:37:57 +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
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
YAMAMOTO Takashi
3094b20bd8
samples/native-lib: Fix exec_env type (#1557)
Change `wasm_exec_env_t *exec_env` to `wasm_exec_env_t exec_env`
2022-10-06 20:21:21 +08:00
Wenyong Huang
0cea769b71
Fix sample sgx-ra build error (#1544) 2022-09-30 15:57:04 +08:00
Marcin Kolny
dc2c6c75f5
Update socket API samples doc to cover UDP client/server and addr_resolve samples (#1538)
Also fix installing `addr_resolve.wasm` example.

Resolves #1534
2022-09-29 18:16:16 +08:00
liang.he
1effda4cb5
Fix isssues detected by coverity (#1529)
Add return value checks
Append string terminator
2022-09-29 13:28:18 +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
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
TianlongLiang
ee210d019f
Dockerfile lint errors fix (#1493)
Fix the Dockerfile linter errors and most warnings
2022-09-22 13:06: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
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
Wenyong Huang
a9cb9206d6
Fix build issue of the meshoptimizer workload (#1452)
meshoptimizer repo had changed, change the patch accordingly.
2022-09-05 21:56:23 +08:00
Wenyong Huang
22c235b5ec
Fix multi-module and some other issues (#1435)
Fix multi-module issue:
  don't call the sub module's function with "$sub_module_name$func_name"
Fix the aot_call_function free argv1 issue
Modify some API comments in wasm_export.h
Fix the wamrc help info
2022-08-31 17:38:38 +08:00
YAMAMOTO Takashi
d41543f829
cmake: Use CMAKE_BINARY_DIR instead of ${CMAKE_CURRENT_SOURCE_DIR}/build (#1410) 2022-08-24 15:57:03 +08:00
Wenyong Huang
a517bb249a
Fix socket sample issue reported by coverity (#1397) 2022-08-19 18:06:26 +08:00
Wenyong Huang
9cf7b88bad
Enhance cmake makefiles (#1390)
Upgrade `cmake_minimum_required` from `(VERSION 2.8)` to `(VERSION 2.9)` to
yield the warning:
"Compatibility with CMake < 2.8.12 will be removed from a future version of CMake"

Add "-Wno-unused" for CMAKE_CXX_FLAGS to yield the compilation warnings
when build LLVM JIT.

Fix the link error when code coverage is enabled.
2022-08-18 16:27:01 +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
liang.he
1ee0d90d81
Add import subtyping validation (#1308)
According to import subtyping validation:
  https://webassembly.github.io/spec/core/valid/types.html#import-subtyping
wasm-c-api needs to check types when linking.
2022-07-20 18:31:19 +08:00
Cengizhan Pasaoglu
2746d29751
Make robust on choosing target assumption for X86_32 support (#1241)
When WAMR_BUILD_TARGET isn't set, choosing right target is decided
by checking `CMAKE_SIZEOF_VOID_P` variable. However, choosing `X86_32`
target is not doing specifically checking size of void pointer. It is kind
a fallback target for others.

This patch explicitly checks the size of void pointer before setting the target
to `X86_32` to fix the issue.
2022-06-27 20:30:31 +08:00
liang.he
ceaf7dc660
Fix invalid calculation of total size of bytes to send and recv (#1162)
The total size of bytes to send and recv should be set to 0 before calculation,
but not including the size of iovec_app_t structure.
2022-05-10 10:43:34 +08:00
liang.he
3ba2d7e7de
Fix socket-api send/recv issue and c-api sample callback_chain issue (#1158)
Re-implement socket api send/recv in an atomic-like way, fix the return value
check in posix.c.
And fix wasm-c-api sample callback_chain calling malloc issue.
2022-05-09 16:52:43 +08:00
Xu Jun
474f081f56
Fix return value not checked issue reported by Coverity (#1156)
Fix return value not checked issue in function init_wasm_timer,
reported by Coverity
2022-05-07 19:22:00 +08:00
liang.he
ed512c6867
Fix issues detected by Coverity (#1154)
wasm_c_api.c: add more checks, fix LOG_WARNING invalid specifier
aot_emit_aot_file: fix strncpy max size length to copy
posix.c: fix potential socket not close issue
wasm-c-api samples: add return value checks for fseek/ftell
cJSON.c: remove dead code
2022-05-07 18:53:02 +08:00
Wenyong Huang
2bac6a42a7
Fix some issues reported by Coverity (#1150)
module_wasm_app.c: add return value check for wasm_runtime_call_wasm
aot_runtime.c: add return value check for aot_get_default_memory
aot_runtime.c: add return value check before calling wasm app malloc/free func
wasm_runtime_common.c: fix dead code warning in wasm_runtime_load_from_sections
aot_emit_memory.c: fix potential integer overflow issue
wasm_runtime.c: remove dead code in memory_instantiate, add assertion for globals
samples simple/gui/littlevgl: fix fields of struct sigaction initialization issue
host-tool: add return value check for sendto
2022-05-07 16:51:43 +08:00
Xu Jun
a7f4c3c15c
Fix app manager/framework issues reported by Coverity (#1155)
runtime_sensor.c: add return value check for os_mutex_init
                             fix find_sensor_client
sensor_mgr_ref.c: add return value check for init_sensor_framework
app_manager_host.c: add return value check for app_manager_host_init
module_wasm_app.c: add bh_assert for m_data
                                   fix mkdir potential issue
sample littlevgl/gui/simple: add return value check for init_sensor_framework
host_tool: add more check for g_conn_fd
2022-05-07 15:43:34 +08:00
Wenyong Huang
2007ba38cf
Enable register native with iwasm (#1120)
Enable register native with iwasm application, add sample and update document.
2022-04-27 11:12:50 +08:00
Wenyong Huang
9013a474bc
Fix ref-types sample invalid externref signature (#1119)
Fix ref-types sample running error due to using invalid externref signatures
2022-04-25 12:59:37 +08:00
liang.he
559a0502f1
Enable socket-api recvmsg() and sendmsg() (#1042)
Implement socket-api `recvmsg()` and `sendmsg()` for wasm app,
add sample and update document.
2022-03-30 15:57:40 +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
Wenyong Huang
a33a385caa
Fix littlevgl link error issues (#1006)
The littlevgl library had changed its name and domain to [LVGL](https://lvgl.io).
See https://blog.lvgl.io/2020-06-01/announcement
We change some names and links accordingly.

Also remove the cloning for tlsf library as it isn't used now.
2022-02-15 08:41:36 +08:00
Wenyong Huang
bb87180b72
Update document and fix wasm_runtime_call_wasm_a issue (#1005)
Update document memory_tune.md: fix embed wamr link error,
fix description error of wasm operand stack size, update picture.

Fix wasm_runtime_call_wasm_a issue reported by #1003 and update
sample basic to call this API.
2022-02-14 17:36:38 +08:00
Wenyong Huang
260d36a62d
Refactor externref related APIs of reference types feature (#971)
Currently when calling wasm_runtime_call_wasm() to invoke wasm function
with externref type argument from runtime embedder, developer needs to
use wasm_externref_obj2ref() to convert externref obj into an internal ref
index firstly, which is not convenient to developer.
To align with GC feature in which all the references passed to
wasm_runtime_call_wasm() can be object pointers directly, we change the
interface of wasm_runtime_call_wasm() to allow to pass object pointer
directly for the externref argument, and refactor the related codes, update
the related samples and the document.
2022-01-19 11:25:08 +08:00
Wenyong Huang
d856af6c33
Specify a commit ID for XNNPACK workload (#966)
XNNPACK code base is updating quickly, we specify a commit ID
for it so as to build XNNPACK workload successfully.
2022-01-18 14:35:35 +08:00
Therdel
3fddd3fde4
Fix wasi checks in multi-module CMakelists (#951) 2022-01-13 10:41:02 +08:00