-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic: x86_64: Optimize runtime dynamic patching #1747
base: master
Are you sure you want to change the base?
dynamic: x86_64: Optimize runtime dynamic patching #1747
Commits on Jul 6, 2023
-
utils: Implement syscall wrappers for glibc < 2.30
Glibc < 2.30 doen't provide wrappers for 'gettid()' and 'tgkill()' so we define them. Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 5b06fcc - Browse repository at this point
Copy the full SHA 5b06fccView commit details -
utils: Define signal related functions
Functions to setup real-time signals and broadcast signals to all threads in an application. Useful for runtime synchronization mechanisms. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 66feda0 - Browse repository at this point
Copy the full SHA 66feda0View commit details -
dynamic: x86_64: Skip already patched functions
Skip the functions where uftrace already injected a call to a trampoline. Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 4a5625c - Browse repository at this point
Copy the full SHA 4a5625cView commit details -
dynamic: x86_64: Refactor 'get_target_address'
Refactor for more clarity. Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 6fbfa73 - Browse repository at this point
Copy the full SHA 6fbfa73View commit details -
dynamic: x86_64: Refactor 'patch_code'
Refactor 'patch_code' so it can later be used at runtime. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 9b6b28f - Browse repository at this point
Copy the full SHA 9b6b28fView commit details -
dynamic: x86_64: Factor out 'check_endbr64'
Check if instruction at a given address is ENDBR64. Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 8ab6450 - Browse repository at this point
Copy the full SHA 8ab6450View commit details -
dynamic: x86_64: Protect patch zone with trap
When patching a function at runtime, first insert an int3 trap so any incoming thread is diverted from the patching region, to avoid executing partially modified code. The trap handler emulates a call to the trampoline, thus enabling the instrumentation. The trap is eventually removed in subsequent commits. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 3c5013f - Browse repository at this point
Copy the full SHA 3c5013fView commit details -
dynamic: x86_64: Synchronize cores when patching
When cross-modifying code, the software needs to ensure that all cores will execute valid instructions at any time. When modifications are not atomic, we issue a specific memory barrier (or execute a serializing instruction on Linux < 4.16) to serialize the execution across all cores. This flushes the different caches, especially the processor pipelines that may have partially fetched straddling instructions. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for f07ab57 - Browse repository at this point
Copy the full SHA f07ab57View commit details -
dynamic: x86_64: Move threads out of patching zone
When patching at runtime, no thread can enter the patching region due to the trap that is inserted at the start of it. But threads that entered the region before the trap is installed can still be executing instructions in the region. We broadcast a real-time signal instruction all threads to check their instruction pointer, and execute out-of-line if they are in the patching region. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 2c8e18c - Browse repository at this point
Copy the full SHA 2c8e18cView commit details -
dynamic: Batch function patching process
Synchronization requires sending signals to threads inside the process. This is performed for every symbols, which means a lot of signal can be sent. This has a major performance impact. This commit batches the initial and final steps of the patching process so we only need to send one signal per thread for every batch. Co-authored-by: Gabriel-Andrew Pollo-Guilbert <gabrielpolloguilbert@gmail.com> Signed-off-by: Clément Guidi <cguidi@ciena.com>
Configuration menu - View commit details
-
Copy full SHA for 9270d6b - Browse repository at this point
Copy the full SHA 9270d6bView commit details