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 bothcranelift_jit::JITModule
andwasmtime_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.
bjorn3 submitted PR review.
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 isMEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
on AArch64: https://github.com/sunfishcode/linux-raw-sys/blob/6d0a83985c28678821d2d67f3047c7fe2b90a6ae/src/v5_4/aarch64/general.rs#L3443
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
.
bjorn3 submitted PR review.
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
ornew
.
bjorn3 submitted PR review.
akirilov-arm submitted PR review.
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.
bjorn3 submitted PR review.
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.
akirilov-arm submitted PR review.
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 insidefinalize_definitions()
and there we handle both normal generated functions and PLT entries together - am I missing something?
akirilov-arm updated PR #3426 from membarrier
to main
.
alexcrichton submitted PR review.
akirilov-arm updated PR #3426 from membarrier
to main
.
akirilov-arm merged PR #3426.
Last updated: Dec 23 2024 at 12:05 UTC