Update fibers to avoid no-return functions (#12928)* Update fibers to avoid no-return functionsThis commit is aimed at fixing the ASAN false positives in #12899.Initially the fix there was to in
Update fibers to avoid no-return functions (#12928)* Update fibers to avoid no-return functionsThis commit is aimed at fixing the ASAN false positives in #12899.Initially the fix there was to invoke some `__asan_*` intrinsics, andI ended up finding a sort of smaller set of `__asan_*` intrinsics tocall as well. In the end what's happening though is that fibers, uponterminating, have a few frames of Rust code on the stack beforeswitching off. To ASAN these frames never returned so when a stack issubsequently reused ASAN is tricked into thinking this is bufferoverflow or use-after-free since it's stomping on frames that haven'treturned.The fix in this commit is to avoid this style of function which doesn'treturns. Functions which don't return in Rust are easy to leak memoryfrom and are a hazard from a safety perspective as well (e.g. it'sunsafe to skip running destructors of stack variables). I feel we've hadbetter success over time with "all Rust functions always return" and sowhat's what was applied here. Unlike #12899 or my thoughts on that PRthis does not have any new `__asan_*` intrinsic calls. Instead what thisdoes is it shuffles around responsibility for what exact piece of theinfrastructure is responsible for what. Specifically `fiber_start`functions now actually return, meaning the `wasmtime_fiber_start` nakedfunction actually resumes execution, unlike before. The`wasmtime_fiber_start` then delegates to `wasmtime_fiber_switch`immediately to perform the final switch.Effectively there's now only two function frames that never return, andboth of these frames are handwritten inline assembly. This means thatASAN gets to see that all normal functions return and updates all of itsmetadata accordingly. The end result is that the original issue from #12899is fixed and this I feel is in general more robust as well.One caveat is that the handwritten `wasmtime_fiber_start` assembly needsto invoke a sibling `wasmtime_fiber_switch_` function. In lieu of tryingto figure out how to get PIC-vs-not calls working (e.g. static calls)I've opted to use indirect function calls and pointers instead. Thismirrors historical changes in our fiber implementation too.* Fix CI builds* Fix miri
show more ...
Add fiber implementation for riscv32imac (#12506)* Add fiber implementation for riscv32imac* Adjusted formatting around commas* Added padding infront of `last_sp`
Work around naked-function-plus-LTO issue (#11960)This is an attempt to apply a local fix for #11957 which works aroundthe upstream Rust issue mentioned in that issue.
Rewrite `wasmtime_fiber_init` in Rust (#11860)* Rewrite `wasmtime_fiber_init` in RustThis commit updates all implementations of `wasmtime_fiber_init` to bedefined in Rust rather than purely in i
Rewrite `wasmtime_fiber_init` in Rust (#11860)* Rewrite `wasmtime_fiber_init` in RustThis commit updates all implementations of `wasmtime_fiber_init` to bedefined in Rust rather than purely in inline assembly. There was never aneed to define this function in inline assembly and as far as I canremember I did this originally for consistency with the other functions.The motivation for this PR is to avoid the need to figure out how to doPIC-relative addressing in `wasmtime_fiber_init` to get the symboladdress of `wasmtime_fiber_start`. This has apparently never worked oni686 platforms and this is now becoming a problem on nightly Rust whereLLD complains about this (and presumably the default linker didn't?).In rewriting these functions I additionally fixed a few minor issues:* On AArch64 the registers are now ordered differently to make the order more consistent on the stack.* On s390x the unix.rs-specified 16-bytes-at-the-top-of-the-stack is now separate from the 160-byte register save area as opposed to having it folded into the same.* Remove unnecessary comments
Use `naked_asm!`, delete `asm_func!` (#11405)This deletes our home-grown `asm_func!` macro in favor of using`#[unsafe(naked)]` functions within Wasmtime. This is needed forfiber-related bits righ
Use `naked_asm!`, delete `asm_func!` (#11405)This deletes our home-grown `asm_func!` macro in favor of using`#[unsafe(naked)]` functions within Wasmtime. This is needed forfiber-related bits right now where we need tight control over the exactassembly of some functions. This additionally migrates s390x fiber bitsto Rust as inline assembly is now stable for s390x.prtest:full
Add aarch64-apple-ios to platform-check matrix (#9888)* Add aarch64-apple-ios to platform-check matrixThis commit is somewhat of a rebase of #7506 to port most of it to`main`. I've left out any
Add aarch64-apple-ios to platform-check matrix (#9888)* Add aarch64-apple-ios to platform-check matrixThis commit is somewhat of a rebase of #7506 to port most of it to`main`. I've left out any test-related changes since we're not testinganything just yet. I've also found that rustc now has`target_vendor = "apple"` to cover both macOS and iOS targets (andpresumably other targets like tvOS as well if they get added)Closes #7506* Set env var to target iOS during checks
Port wasmtime-fiber to `no_std` and allow `async` feature in `no_std` Wasmtime. (#9689)This PR allows a `no_std` Wasmtime build to be configured with the`async` feature. (Previously, a minimal `no
Port wasmtime-fiber to `no_std` and allow `async` feature in `no_std` Wasmtime. (#9689)This PR allows a `no_std` Wasmtime build to be configured with the`async` feature. (Previously, a minimal `no_std` configuration couldonly run with sync entry points, without suspending of stacks.)The main hurdle to this support was the `wasmtime-fiber` crate.Fortunately, the "unix" variant of fibers was almost entirely portableto a `no_std` environment, owing to the fact that it implementsstack-switching manually in assembly itself. I moved the per-ISAimplementations to a shared submodule and built the nostd platformbackend for `wasmtime-fiber` with a stripped-down version of the unixbackend.The nostd backend does not support mmap'd stacks, does not supportcustom stack allocators, and does not propagate panics.prtest:full