^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) What: vDSO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) Date: July 2011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) KernelVersion: 3.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Contact: Andy Lutomirski <luto@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) On some architectures, when the kernel loads any userspace program it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) maps an ELF DSO into that program's address space. This DSO is called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) the vDSO and it often contains useful and highly-optimized alternatives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) to real syscalls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) These functions are called just like ordinary C function according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) your platform's ABI. Call them from a sensible context. (For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) if you set CS on x86 to something strange, the vDSO functions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) within their rights to crash.) In addition, if you pass a bad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) pointer to a vDSO function, you might get SIGSEGV instead of -EFAULT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) To find the DSO, parse the auxiliary vector passed to the program's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) entry point. The AT_SYSINFO_EHDR entry will point to the vDSO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The vDSO uses symbol versioning; whenever you request a symbol from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) vDSO, specify the version you are expecting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Programs that dynamically link to glibc will use the vDSO automatically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) Otherwise, you can use the reference parser in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) tools/testing/selftests/vDSO/parse_vdso.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Unless otherwise noted, the set of symbols with any given version and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ABI of those symbols is considered stable. It may vary across architectures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Note:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) As of this writing, this ABI documentation as been confirmed for x86_64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) The maintainers of the other vDSO-using architectures should confirm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) that it is correct for their architecture.