Call membarrier() after making JIT mappings executable on AArch64 Linux
The membarrier() system call ensures that no processor has fetched a stale instruction stream. Copyright (c) 2021, Arm Limited.
This commit is contained in:
@@ -428,6 +428,14 @@ impl JITModule {
|
||||
self.memory.readonly.set_readonly();
|
||||
self.memory.code.set_readable_and_executable();
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
||||
{
|
||||
let cmd: libc::c_int = 32; // MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
|
||||
|
||||
// Ensure that no processor has fetched a stale instruction stream.
|
||||
unsafe { libc::syscall(libc::SYS_membarrier, cmd) };
|
||||
}
|
||||
|
||||
for update in self.pending_got_updates.drain(..) {
|
||||
unsafe { update.entry.as_ref() }.store(update.ptr as *mut _, Ordering::SeqCst);
|
||||
}
|
||||
@@ -489,6 +497,15 @@ impl JITModule {
|
||||
module.libcall_plt_entries.insert(libcall, plt_entry);
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
||||
{
|
||||
let cmd: libc::c_int = 64; // MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
|
||||
|
||||
// This is a requirement of the membarrier() call executed by
|
||||
// the finalize_definitions() method.
|
||||
unsafe { libc::syscall(libc::SYS_membarrier, cmd) };
|
||||
}
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user