Page MenuHomeFreeBSD

linux(4); Almost complete the vDSO.
ClosedPublic

Authored by dchagin on Jun 25 2021, 3:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 7:52 PM
Unknown Object (File)
Sat, Nov 2, 1:11 PM
Unknown Object (File)
Thu, Oct 17, 2:15 PM
Unknown Object (File)
Oct 4 2024, 11:27 PM
Unknown Object (File)
Oct 1 2024, 1:29 PM
Unknown Object (File)
Sep 27 2024, 8:45 PM
Unknown Object (File)
Sep 27 2024, 12:50 AM
Unknown Object (File)
Sep 26 2024, 3:24 PM

Details

Summary

The vDSO (virtual dynamic shared object) is a small shared library
that the kernel maps R/O into the address space of all processes on
image activation. The vDSO is a fully formed ELF image, shared by all
processes with the same ABI, has no process private data.

The primary purpose of the vDSO:

  • non-executable stack, signal trampolines not copied to the stack;
  • signal trampolines unwind, mandatory for the NPTL;
  • to avoid contex-switch overhead frequently used system calls can be implemented in the vDSO: for now gettimeofday, clock_gettime.

The first two have been implemented, so add the implementation of system
calls.

System calls implemenation based on a native timekeeping code with some
limitations:

  • ifunc can't be used, as vDSO r/o mapped to the process VA and rtld can't relocate symbols;
  • reading HPET memory is not implemented for now (TODO).

In case on any error vDSO system calls fallback to the kernel system
calls. For unimplemented vDSO system calls added prototypes which call
corresponding kernel system call.

PS. arm64 compile tested only.

Test Plan

ltp, glibc tests

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dchagin added reviewers: kib, Linux Emulation.
dchagin changed the repository for this revision from rS FreeBSD src repository - subversion to rG FreeBSD src repository.

ifunc can't be used

For any cases where we would want ifuncs we could "just" select the appropriate implementation in kernel, right? (Subject to the caveat that this might require a lot of additional infrastructure, might not be worth the effort, etc.)

ifunc can't be used

For any cases where we would want ifuncs we could "just" select the appropriate implementation in kernel, right? (Subject to the caveat that this might require a lot of additional infrastructure, might not be worth the effort, etc.)

here means the ifunc in the vDSO, sure, on the kernel side its emulated, see kern_tsc_selector in the machine/linux/linux_sysvec.c

fixed copyright, arm64 write()

sys/x86/linux/linux_vdso_tsc_selector_x86.c
6

We can probably drop the All rights reserved. assuming kib agrees.
For all Foundation copyrights it can be removed.

'all rights' removed, adapted to the previous changes

'all rights' removed, adapted to the previous changes

ok, I understand, patch is difficult to review, so if copyrights is fine, I plan to commit it soon at my own risk)

This revision was not accepted when it landed; it landed in state Needs Review.Jul 20 2021, 7:11 AM
This revision was automatically updated to reflect the committed changes.