Stream: git-wasmtime

Topic: wasmtime / PR #3426 Call membarrier() after making JIT ma...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:37):

akirilov-arm opened PR #3426 from membarrier to main:

This is the first part of a fix to issue #3310. Unfortunately, there are more calls than necessary to rsix::process::membarrier(rsix::process::MembarrierCommand::RegisterPrivateExpeditedSyncCore) (it is sufficient to call it once per process), but both cranelift_jit::JITModule and wasmtime_jit::CodeMemory are public interfaces, so my current approach is the best I have come up with that hides this AArch64 memory model detail from any crate users; I would appreciate any suggestions for improvements.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:44):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:44):

bjorn3 created PR review comment:

Please avoid rsix in cranelift-jit: https://github.com/bytecodealliance/wasmtime/pull/3395 I think libc::syscall(libc::SYS_membarrier, 32u32) will work. 32 is MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE on AArch64: https://github.com/sunfishcode/linux-raw-sys/blob/6d0a83985c28678821d2d67f3047c7fe2b90a6ae/src/v5_4/aarch64/general.rs#L3443

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:48):

bjorn3 created PR review comment:

Is this for the new libcall PLT entries generated above? I think this will need to be called every time a new PLT entry is generated like in declare_function.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:48):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:50):

bjorn3 created PR review comment:

Also I think this will need to be called every time a new PLT entry is generated like in declare_function or new.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 08 2021 at 11:50):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 18:11):

akirilov-arm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 18:11):

akirilov-arm created PR review comment:

This needs to be called when we are just about to start executing from the generated code, which is usually around the time the code memory's protection is changed from readable and writable to readable and executable. As far as I can tell, generating a new PLT entry involves just writing some data (i.e. instructions) into the instruction stream, but does not create new executable memory (via changing permissions), nor does it involve memory that is simultaneously readable, writable, and executable.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 18:50):

bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 18:50):

bjorn3 created PR review comment:

New PLT entries are handled the same way as adding new functions. Both first write the code to a writeable page and then use mprotect to make it executable.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 21:29):

akirilov-arm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2021 at 21:29):

akirilov-arm created PR review comment:

Sure, but it looks like new_plt_entry() just does an allocation and writes the code. The only place where we make the transition from readable and writable memory to readable and executable is inside finalize_definitions() and there we handle both normal generated functions and PLT entries together - am I missing something?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2021 at 16:54):

akirilov-arm updated PR #3426 from membarrier to main.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 18 2021 at 15:17):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 22 2021 at 19:31):

akirilov-arm updated PR #3426 from membarrier to main.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 25 2021 at 12:25):

akirilov-arm merged PR #3426.


Last updated: Dec 23 2024 at 12:05 UTC