Skip to content

Commit

Permalink
add note on self modifying code and cacheflush
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVentura committed Mar 28, 2024
1 parent be2248d commit c213a0d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/vdso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ impl vDSO {
unsafe {
std::ptr::copy_nonoverlapping(opcodes.as_ptr(), dst_addr as *mut u8, opcodes.len())
};
// https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/caches-and-self-modifying-code
// We need to clear the instruction cache, otherwise it's possible that the old
// instructions (the trampoline) get executed with the new data (the original vDSO
// function)
unsafe {
//doesn't exist ((
//libc::cacheflush(dst_addr, opcodes.len(), libc::BCACHE);
}
self.change_mode(false);
}

Expand Down

0 comments on commit c213a0d

Please sign in to comment.