mirror of
https://github.com/opnsense/src.git
synced 2026-05-14 18:20:21 -04:00
The vDSO (virtual dynamic shared object) is a small shared library that the
kernel maps R/O into the address space of all Linux 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.
Relnotes: yes
Tested by: trasz (arm64)
Differential revision: https://reviews.freebsd.org/D30900
MFC after: 2 weeks
(cherry picked from commit 9931033bbf)
81 lines
1.8 KiB
NASM
81 lines
1.8 KiB
NASM
/* $FreeBSD$ */
|
|
|
|
#include "linux_assym.h" /* system definitions */
|
|
#include <machine/asmacros.h> /* miscellaneous asm macros */
|
|
|
|
#include <amd64/linux/linux_syscall.h> /* system call numbers */
|
|
|
|
.data
|
|
|
|
.globl linux_platform
|
|
linux_platform:
|
|
.asciz "x86_64"
|
|
|
|
|
|
.text
|
|
/*
|
|
* To avoid excess stack frame the signal trampoline code emulates
|
|
* the 'call' instruction.
|
|
*/
|
|
ENTRY(linux_rt_sigcode)
|
|
movq %rsp, %rbx /* preserve sigframe */
|
|
call .getip
|
|
.getip:
|
|
popq %rax
|
|
add $.startrtsigcode-.getip, %rax /* ret address */
|
|
pushq %rax
|
|
jmp *LINUX_RT_SIGF_HANDLER(%rbx)
|
|
.startrtsigcode:
|
|
movq $LINUX_SYS_linux_rt_sigreturn,%rax /* linux_rt_sigreturn() */
|
|
syscall /* enter kernel with args */
|
|
hlt
|
|
.endrtsigcode:
|
|
0: jmp 0b
|
|
|
|
#if 0
|
|
.section .note.Linux, "a",@note
|
|
.long 2f - 1f /* namesz */
|
|
.balign 4
|
|
.long 4f - 3f /* descsz */
|
|
.long 0
|
|
1:
|
|
.asciz "Linux"
|
|
2:
|
|
.balign 4
|
|
3:
|
|
.long LINUX_VERSION_CODE
|
|
4:
|
|
.balign 4
|
|
.previous
|
|
#endif
|
|
|
|
.section .eh_frame,"a",@progbits
|
|
.LSTARTFRAMEDLSI0:
|
|
.long .LENDCIEDLSI0-.LSTARTCIEDLSI0
|
|
.LSTARTCIEDLSI0:
|
|
.long 0 /* CIE ID */
|
|
.byte 1 /* Version number */
|
|
.string "zR" /* NULL-terminated
|
|
* augmentation string
|
|
*/
|
|
.uleb128 1 /* Code alignment factor */
|
|
.sleb128 -4 /* Data alignment factor */
|
|
.byte 8 /* Return address register column */
|
|
.uleb128 1 /* Augmentation value length */
|
|
.byte 0x1b /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
|
|
.byte 0x0c /* DW_CFA_def_cfa */
|
|
.uleb128 4
|
|
.uleb128 4
|
|
.byte 0x88 /* DW_CFA_offset, column 0x8 */
|
|
.uleb128 1
|
|
.align 4
|
|
.LENDCIEDLSI0:
|
|
.long .LENDFDEDLSI0-.LSTARTFDEDLSI0 /* Length FDE */
|
|
.LSTARTFDEDLSI0:
|
|
.long .LSTARTFDEDLSI0-.LSTARTFRAMEDLSI0 /* CIE pointer */
|
|
.long .startrtsigcode-. /* PC-relative start address */
|
|
.long .endrtsigcode-.startrtsigcode
|
|
.uleb128 0
|
|
.align 4
|
|
.LENDFDEDLSI0:
|
|
.previous
|