Difference between revisions of "Vdso"
Line 1: | Line 1: | ||
=== Overview === | === Overview === | ||
− | '''vDSO''' stands for [http://man7.org/linux/man-pages/man7/vdso.7.html ''virtual dynamic shared object''] and basically is a shared library exported by kernel into every userspace program. It usually | + | '''vDSO''' stands for [http://man7.org/linux/man-pages/man7/vdso.7.html ''virtual dynamic shared object''] and basically is a shared library exported by kernel into every userspace program. It usually exports a few frequently used functions (such as gettimeofday, getcpu and etc) and userspace applications don't call them directly but make use of '''libc''' instead. |
=== A problem === | === A problem === | ||
− | While kernel guarantees backwards compatibility, i.e. | + | While kernel guarantees backwards compatibility, i.e. helper functions won't suddenly disappear, the internal structure of the '''vDSO''' itself may vary the way it wants, userspace programs won't notice such changes but it brings a huge problem to CRIU. The '''vDSO''' structure is highly coupled with the kernel internals so that if application is migrating to a new kernel release with brand new '''vDSO''' old one (which is still sitting in application memory) strictly speaking is no longer usable, because the new kernel implies new '''vDSO''' internal structure. |
+ | |||
+ | === Calls proxification === | ||
+ | |||
+ | To solve this problem CRIU does that named call proxification, where all functions from the original '''vDSO''' code are redirected to a new one provided by the kernel where application is restored. This done in a several steps on restore: | ||
+ | |||
+ | # Scan runtime environment for current '''vDSO''' and parse its structure | ||
+ | # On restore of dumped '''vDSO''' memory area we patch function entry points so that they are redirected to current '''vDSO''' (for x86 architecture is simply a <code>jmp</code> instruction) | ||
+ | |||
+ | After that an restored application can continue using original '''vDSO''' helpers without problems. |
Revision as of 08:04, 14 January 2015
Overview
vDSO stands for virtual dynamic shared object and basically is a shared library exported by kernel into every userspace program. It usually exports a few frequently used functions (such as gettimeofday, getcpu and etc) and userspace applications don't call them directly but make use of libc instead.
A problem
While kernel guarantees backwards compatibility, i.e. helper functions won't suddenly disappear, the internal structure of the vDSO itself may vary the way it wants, userspace programs won't notice such changes but it brings a huge problem to CRIU. The vDSO structure is highly coupled with the kernel internals so that if application is migrating to a new kernel release with brand new vDSO old one (which is still sitting in application memory) strictly speaking is no longer usable, because the new kernel implies new vDSO internal structure.
Calls proxification
To solve this problem CRIU does that named call proxification, where all functions from the original vDSO code are redirected to a new one provided by the kernel where application is restored. This done in a several steps on restore:
- Scan runtime environment for current vDSO and parse its structure
- On restore of dumped vDSO memory area we patch function entry points so that they are redirected to current vDSO (for x86 architecture is simply a
jmp
instruction)
After that an restored application can continue using original vDSO helpers without problems.