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:
@@ -54,6 +54,15 @@ impl CodeMemory {
|
||||
/// The returned `CodeMemory` manages the internal `MmapVec` and the
|
||||
/// `publish` method is used to actually make the memory executable.
|
||||
pub fn new(mmap: MmapVec) -> Self {
|
||||
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
||||
{
|
||||
// This is a requirement of the `membarrier` call executed by the `publish` method.
|
||||
rsix::process::membarrier(
|
||||
rsix::process::MembarrierCommand::RegisterPrivateExpeditedSyncCore,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Self {
|
||||
mmap: ManuallyDrop::new(mmap),
|
||||
unwind_registration: ManuallyDrop::new(None),
|
||||
@@ -159,6 +168,15 @@ impl CodeMemory {
|
||||
.make_executable(text_range.clone())
|
||||
.expect("unable to make memory executable");
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
|
||||
{
|
||||
// Ensure that no processor has fetched a stale instruction stream.
|
||||
rsix::process::membarrier(
|
||||
rsix::process::MembarrierCommand::PrivateExpeditedSyncCore,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// With all our memory set up use the platform-specific
|
||||
// `UnwindRegistration` implementation to inform the general
|
||||
// runtime that there's unwinding information available for all
|
||||
|
||||
Reference in New Issue
Block a user