Page MenuHomeFreeBSD

linux(4); Almost complete the vDSO.
ClosedPublic

Authored by dchagin on Jun 25 2021, 3:57 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
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 40096
Build 36985: arc lint + arc unit

Event Timeline

dchagin added reviewers: kib, Linux Emulation.
dchagin changed the repository for this revision from rS FreeBSD src repository - subversion to R10 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
5

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.