vdso(7): new man page
so i've slapped this together. i think the HISTORY section could use more filling out, but that'd probably be more for funsies rather than usefulness.
might also be helpful if someone could do fact checking on what i've written for the HISTORY. this predates my involvement in the linux world, so i'm just making educated guesses.
-mike
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain. Suck it.
.\" %%%LICENSE_END
.\"
.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual"
.SH NAME
vDSO \- overview of the virtual ELF dynamic shared object
.SH SYNOPSIS
.B #include <sys/auxv.h>
.B void *vdso = (uintptr_t)getauxval(AT_SYSINFO_EHDR);
.SH DESCRIPTION
The "vDSO" is a small shared library that the kernel automatically maps into the address space of all userspace applications.
Applications themselves usually need not concern themselves with this as it is most commonly called by the C library.
This way you can write using standard functions and the C library will take care of using any available functionality.
Why does this object exist at all?
There are some facilities the kernel provides that userspace ends up using frequently to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context overhead from exiting userspace and entering the kernel.
The rest of this documentation is geared towards the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example Background
Making syscalls themselves can incur significant penalty.
In x86 systems, you can trigger a software interrupt (int $0x80) to tell the kernel you wish to make a syscall.
Internally, this means the call has to go through the normal interrupt layers to save/restore context before it even gets a chance to start processing the system call.
Wouldn't it be nicer if you could start processing the system call immediately? With newer revisions of the x86 architecture, there is now a syscall/sysenter instruction that does exactly that (jumps directly to the system call entry). However, rather than require the C library to figure out if this functionality is available itself, the vDSO includes symbols that can be used. This is typically referred to using the term "vsyscall".
Another frequent system call is gettimeofday().
This is called both directly by userspace applications as well as indirectly by the C library.
Think timestamps or timing loops or polling -- all of these frequently need to know what time it is right now.
This information is also not secret -- any application in any privilege mode (root or any user) will get the same answer.
Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access.
Now a call to gettimeofday() changes from a syscall to a normal function call and a few memory accesses.
.SS Finding The vDSO
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector.
Specifically, via the
.B AT_SYSINFO_EHDR
tag.
For some architectures, there is also a
.B AT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently disabled or set to 0 (meaning it's not available).
It is a throw back to the initial vDSO work (see
.IR HISTORY
below for more details) and should be avoided.
See
.BR getauxval (3)
for more details on accessing these fields.
.SS File Format
Since the vDSO is a fully formed ELF, you can do symbol lookups on it. This allows new symbols to be added with newer kernel releases, and for the C library to detect available functionality at runtime when running under different kernel versions.
Often times the C library will do detection with the first call and then cache the result for subsequent calls.
All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function signature without breaking backwards compatibility.
This means changing the arguments that it accepts as well as the return value. When looking up a symbol in the vDSO, you must always include the version you are writing against.
Typically the vDSO follows the naming convention of prefixing all symbols with "__vdso_" or "__kernel_" so as to distinguish from other standard symbols. e.g. The "gettimeofday" function is named "__vdso_gettimeofday". .SH NOTES
.SS Source
When you compile the kernel, it will automatically compile and link the vDSO code for you.
You will frequently find it under the arch specific dir:
find arch/$ARCH/ -name '*vdso*.so'
Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under an x86_64 64bit kernel, you'll get the same vDSO.
So when referring to sections below, use the userspace ABI.
.SS vDSO Names
The name of this shared object varies across architectures.
It will often show up in things like glibc's ldd output.
The exact name should not matter to any code, so please do not hardcode it. .if t \{\
.ft CW
\}
.TS
l l.
arch vdso name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64 linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SS aarch64 functions
.\" See linux/arch/arm64/kernel/vdso/vdso.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6.39__kernel_gettimeofday LINUX_2.6.39__kernel_clock_gettime LINUX_2.6.39__kernel_clock_getres LINUX_2.6.39
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" See linux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
As this cpu lacks a MMU, it doesn't setup a vDSO in the normal sense. Instead, it maps at boot time a few raw functions into a fixed location in memory.
Userspace apps then call directly into that.
There is no provision for backwards compatibility beyond sniffing raw opcodes, but as this is an embedded CPU, it can get away with things -- some of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For documentation on this format, it's better you refer to the public docs:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" See linux/arch/ia64/kernel/gate.lds.S
.\" Also linux/arch/ia64/kernel/fsys.S and linux/Documentation/ia64/fsys.txt .if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtramp LINUX_2.5__kernel_syscall_via_break LINUX_2.5__kernel_syscall_via_epc LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
The Itanium port actually likes to get tricky.
In addition to the vDSO above, it also has "light-weight system calls" aka "fast syscalls" aka "fsys".
You can invoke these via the __kernel_syscall_via_epc vDSO helper. The system calls listed here have the same semantics as if you called them directly via
.BR syscall (3),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/32 functions
.\" See linux/arch/powerpc/kernel/vdso32/vdso32.lds.S
The functions marked with a
.I *
below are only available when the kernel is
a powerpc64 (64bit) kernel.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu \fI*\fR LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt32 LINUX_2.6.15__kernel_sigtramp32 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" See linux/arch/powerpc/kernel/vdso64/vdso64.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt64 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" See linux/arch/s390/kernel/vdso32/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" See linux/arch/s390/kernel/vdso64/vdso64.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" See linux/arch/sh/kernel/vsyscall/vsyscall.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6__kernel_sigreturn LINUX_2.6__kernel_vsyscall LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" See linux/arch/x86/vdso/vdso32/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturn LINUX_2.5__kernel_rt_sigreturn LINUX_2.5__kernel_vsyscall LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
.SS x86_64 functions
.\" See linux/arch/x86/vdso/vdso.lds.S
Each of these symbols are also available without the "__vdso_" prefix, but you should ignore those and stick to the names below.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" See linux/arch/x86/vdso/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SH HISTORY
The vDSO was originally just a single function -- the vsyscall.
In older kernels, you might see that in a process's memory map rather than vdso. Overtime, people realized that this was a great way to pass more functionality to userspace, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)
The docs/examples/sources in the Linux sources:
.nfDocumentation/ABI/stable/vdsolinux/Documentation/ia64/fsys.txtDocumentation/vDSO/*
find arch/ -iname '*vdso*' -o -iname '*gate*'
.fi
Quoted 3 lines · Mike Frysinger
so i've slapped this together. i think the HISTORY section could use more filling out, but that'd probably be more for funsies rather than usefulness.
This looks good to me. It may be worth mentioning that programs must not assume anything about where the vDSO is mapped -- that may change from kernel to kernel or exec to exec, unless the particular architecture makes some guarantee.
Quoted 5 lines
.SS Example Background
Making syscalls themselves can incur significant penalty.
In x86 systems, you can trigger a software interrupt (int $0x80) to tell the kernel you wish to make a syscall.
Internally, this means the call has to go through the normal interrupt layers
Quoted 8 lines
to save/restore context before it even gets a chance to start processing the system call.
Wouldn't it be nicer if you could start processing the system call immediately? With newer revisions of the x86 architecture, there is now a syscall/sysenter instruction that does exactly that (jumps directly to the system call entry). However, rather than require the C library to figure out if this functionality is available itself, the vDSO includes symbols that can be used. This is typically referred to using the term "vsyscall".
I find this a bit confusing. The term "vsyscall" means something different on x86_64, and syscall and sysenter are different instructions. How about this:
Making syscalls can be slow.
In x86 32-bit systems, you can trigger a software interrupt (int $0x80) to tell the
kernel you wish to make a syscall. This instruction is expensive: it goes through the full interrupt handling paths in microcode and in the kernel. Newer processors have faster, incompatible ways to issue system calls, and the kernel abstracts these through an entry point in the vdso. (The terminology can be confusing. On x86_32, this function is called __kernel_vsyscall, but on x86_64, the term "vsyscall" refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.)
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · On Thursday 11 April 2013 14:31:55 Andy Lutomirski wrote:
Quoted 3 lines · Mike Frysinger
so i've slapped this together. i think the HISTORY section could use more filling out, but that'd probably be more for funsies rather than usefulness.
This looks good to me. It may be worth mentioning that programs must not assume anything about where the vDSO is mapped -- that may change from kernel to kernel or exec to exec, unless the particular architecture makes some guarantee.
good idea
Quoted 19 lines
Quoted 6 lines
.SS Example Background
Making syscalls themselves can incur significant penalty.
In x86 systems, you can trigger a software interrupt (int $0x80) to tell the kernel you wish to make a syscall.
Internally, this means the call has to go through the normal interrupt layers to save/restore context before it even gets a chance to startQuoted 8 lines
processing the system call.
Wouldn't it be nicer if you could start processing the system call immediately? With newer revisions of the x86 architecture, there is now a syscall/sysenter instruction that does exactly that (jumps directly to the system call entry). However, rather than require the C library to figure out if this functionality is available itself, the vDSO includes symbols that can be used. This is typically referred to using the term "vsyscall".I find this a bit confusing. The term "vsyscall" means something different on
x86_64, and syscall and sysenter are different instructions. How about this:
Quoted 11 lines
Making syscalls can be slow.
In x86 32-bit systems, you can trigger a software interrupt (int $0x80) to tell the
kernel you wish to make a syscall. This instruction is expensive: it goes through the full interrupt handling paths in microcode and in the kernel. Newer processors have faster, incompatible ways to issue system calls, and the kernel abstracts these through an entry point in the vdso. (The terminology can be confusing. Onx86_32, this function is called__kernel_vsyscall, but onx86_64, the term "vsyscall" refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.)
i've merged in your suggestions. is the current (small) HISTORY section correct then ? you can find it at the bottom of the page. -mike
here's v2 w/Andy's feedback
-mike
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain. Suck it.
.\" %%%LICENSE_END
.\"
.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual"
.SH NAME
vDSO \- overview of the virtual ELF dynamic shared object
.SH SYNOPSIS
.B #include <sys/auxv.h>
.B void *vdso = (uintptr_t)getauxval(AT_SYSINFO_EHDR);
.SH DESCRIPTION
The "vDSO" is a small shared library that the kernel automatically maps into the address space of all userspace applications.
Applications themselves usually need not concern themselves with this as it is most commonly called by the C library.
This way you can write using standard functions and the C library will take care of using any available functionality.
Why does this object exist at all?
There are some facilities the kernel provides that userspace ends up using frequently to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context overhead from exiting userspace and entering the kernel.
The rest of this documentation is geared towards the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example Background
Making syscalls can be slow.
In x86 32bit systems, you can trigger a software interrupt (int $0x80) to tell the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.
Note that the terminology can be confusing.
On x86 systems, the vDSO function is named "__kernel_vsyscall", but on x86_64, the term "vsyscall" also refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.
Another frequent system call is gettimeofday().
This is called both directly by userspace applications as well as indirectly by the C library.
Think timestamps or timing loops or polling -- all of these frequently need to know what time it is right now.
This information is also not secret -- any application in any privilege mode (root or any user) will get the same answer.
Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access.
Now a call to gettimeofday() changes from a syscall to a normal function call and a few memory accesses.
.SS Finding The vDSO
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector.
Specifically, via the
.B AT_SYSINFO_EHDR
tag.
You must not assume the vDSO is mapped at any particular location in the user's memory map.
The base address will usually be randomized at runtime every time a new is processed (at
.BR execve (2)
time).
This is done for security reasons to prevent standard "return-to-libc" attacks.
For some architectures, there is also a
.B AT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently omitted or set to 0 (meaning it's not available).
It is a throw back to the initial vDSO work (see
.IR HISTORY
below) and should be avoided.
Refer to
.BR getauxval (3)
for more details on accessing these fields.
.SS File Format
Since the vDSO is a fully formed ELF, you can do symbol lookups on it. This allows new symbols to be added with newer kernel releases, and for the C library to detect available functionality at runtime when running under different kernel versions.
Often times the C library will do detection with the first call and then cache the result for subsequent calls.
All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function signature without breaking backwards compatibility.
This means changing the arguments that it accepts as well as the return value. When looking up a symbol in the vDSO, you must always include the version you are writing against.
Typically the vDSO follows the naming convention of prefixing all symbols with "__vdso_" or "__kernel_" so as to distinguish from other standard symbols. e.g. The "gettimeofday" function is named "__vdso_gettimeofday".
You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
.SH NOTES
.SS Source
When you compile the kernel, it will automatically compile and link the vDSO code for you.
You will frequently find it under the arch specific dir:
.br
find arch/$ARCH/ -name '*vdso*.so*' -o -name '*gate*.so*'
Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under an x86_64 64bit kernel, you'll get the same vDSO.
So when referring to sections below, use the userspace ABI.
.SS vDSO Names
The name of this shared object varies across architectures.
It will often show up in things like glibc's ldd output.
The exact name should not matter to any code, so please do not hardcode it. .if t \{\
.ft CW
\}
.TS
l l.
user ABI vDSO name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64 linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SS aarch64 functions
.\" See linux/arch/arm64/kernel/vdso/vdso.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6.39__kernel_gettimeofday LINUX_2.6.39__kernel_clock_gettime LINUX_2.6.39__kernel_clock_getres LINUX_2.6.39
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" See linux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
As this cpu lacks a MMU, it doesn't setup a vDSO in the normal sense. Instead, it maps at boot time a few raw functions into a fixed location in memory.
Userspace apps then call directly into that.
There is no provision for backwards compatibility beyond sniffing raw opcodes, but as this is an embedded CPU, it can get away with things -- some of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For documentation on this format, it's better you refer to the public docs:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" See linux/arch/ia64/kernel/gate.lds.S
.\" Also linux/arch/ia64/kernel/fsys.S and linux/Documentation/ia64/fsys.txt .if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtramp LINUX_2.5__kernel_syscall_via_break LINUX_2.5__kernel_syscall_via_epc LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
The Itanium port actually likes to get tricky.
In addition to the vDSO above, it also has "light-weight system calls" aka "fast syscalls" aka "fsys".
You can invoke these via the __kernel_syscall_via_epc vDSO helper. The system calls listed here have the same semantics as if you called them directly via
.BR syscall (3),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/32 functions
.\" See linux/arch/powerpc/kernel/vdso32/vdso32.lds.S
The functions marked with a
.I *
below are only available when the kernel is
a powerpc64 (64bit) kernel.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu \fI*\fR LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt32 LINUX_2.6.15__kernel_sigtramp32 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" See linux/arch/powerpc/kernel/vdso64/vdso64.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt64 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" See linux/arch/s390/kernel/vdso32/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" See linux/arch/s390/kernel/vdso64/vdso64.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" See linux/arch/sh/kernel/vsyscall/vsyscall.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6__kernel_sigreturn LINUX_2.6__kernel_vsyscall LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" See linux/arch/x86/vdso/vdso32/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturn LINUX_2.5__kernel_rt_sigreturn LINUX_2.5__kernel_vsyscall LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
.SS x86_64 functions
.\" See linux/arch/x86/vdso/vdso.lds.S
Each of these symbols are also available without the "__vdso_" prefix, but you should ignore those and stick to the names below.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" See linux/arch/x86/vdso/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SH HISTORY
The vDSO was originally just a single function -- the vsyscall.
In older kernels, you might see that in a process's memory map rather than vdso. Overtime, people realized that this was a great way to pass more functionality to userspace, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)
The docs/examples/sources in the Linux sources:
.nfDocumentation/ABI/stable/vdso linux/Documentation/ia64/fsys.txt Documentation/vDSO/* (includes examples of using the vDSO) find arch/ -iname '*vdso*' -o -iname '*gate*'
.fi
Hi Mike,
Quoted 1 line · Mike Frysinger
here's v2 w/Andy's feedback
Thanks for this--it's a nice piece of work. Could you take a look at my comments below and send a v3, please.
Quoted 4 lines
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain. Suck it.
Okay -- not my first choice for a license, but so be it. But, how about we lose the "Suck it."...
Quoted 9 lines
.\" %%%LICENSE_END
.\"
.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual" .SH NAME
vDSO \- overview of the virtual ELF dynamic shared object .SH SYNOPSIS
.B #include <sys/auxv.h>.B void *vdso = (uintptr_t)getauxval(AT_SYSINFO_EHDR);
Add space before "getauxval". (Usual convention for casts in code examples in man pages.)
Quoted 3 lines
.SH DESCRIPTION
The "vDSO" is a small shared library that the kernel automatically maps into the address space of all userspace applications.
1,$s/userspace applications/user-space applications/
Quoted 2 lines
Applications themselves usually need not concern themselves with this as it is most commonly called by the C library.
This last sentence doesn't quite make sense, since "this" and "it" refer to different things (I believe). Do you want something like:
Applications generally do not need to care about the details since the vDSO is automatically employed by the C library
?
Quoted 4 lines
This way you can write using standard functions and the C library will take care of using any available functionality.
Why does this object exist at all?
s/this object/the vDSO/
Quoted 1 line
There are some facilities the kernel provides that userspace ends up using
s/userspace/user space/
(When used as a noun, and in other places in the page as well)
Quoted 9 lines
frequently to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context overhead from exiting userspace and entering the kernel.
The rest of this documentation is geared towards the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example Background
Convention for SS headings is that only the first word is capitalized (unless English usage dictates otherwise--e.g., for a proper noun)
Quoted 1 line
Making syscalls can be slow.
1,$s/syscall/system call/
(and other instances in the page)
Quoted 1 line
In x86 32bit systems, you can trigger a software interrupt (int $0x80) to tell
s/32bit/32-bit/
Quoted 8 lines
the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.
That last point (after the comma) is the most interesting (IMO) of the use cases of the vDSO. If you cared to expand on the details (i.e., are what are mechanics of the operation of those functions provided by the kernel), I think that would be interesting for the reader.
Quoted 4 lines
Note that the terminology can be confusing.
On x86 systems, the vDSO function is named "__kernel_vsyscall", but onx86_64, the term "vsyscall" also refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.
s/cpu/CPU/
Quoted 4 lines
Another frequent system call is
gettimeofday().
This is called both directly by userspace applications as well as indirectly by the C library.
Think timestamps or timing loops or polling -- all of these frequently need to
Quoted 8 lines
know what time it is right now.
This information is also not secret -- any application in any privilege mode (root or any user) will get the same answer.
Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access.
Now a call togettimeofday()changes from a syscall to a normal function call and a few memory accesses.
.SS Finding The vDSO
s/The/the/
Quoted 9 lines
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector.
Specifically, via the
.BAT_SYSINFO_EHDR
tag.You must not assume the vDSO is mapped at any particular location in the user's memory map.
The base address will usually be randomized at runtime every time a new is
Missing word after "new".
Quoted 11 lines
processed (at
.BR execve (2)
time).
This is done for security reasons to prevent standard "return-to-libc" attacks.For some architectures, there is also a
.BAT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently omitted or set to 0 (meaning it's not available).
It is a throw back to the initial vDSO work (see
s/throw back/throwback/
Quoted 7 lines
.IR HISTORY
below) and should be avoided.Refer to
.BR getauxval (3)
for more details on accessing these fields.
.SS File Format
s/Format/format/
Quoted 1 line
Since the vDSO is a fully formed ELF, you can do symbol lookups on it.
Missing word after ELF.
Quoted 8 lines
This allows new symbols to be added with newer kernel releases, and for the C library to detect available functionality at runtime when running under different kernel versions.
Often times the C library will do detection with the first call and then cache the result for subsequent calls.All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function
s/situation/case that it is necessary/
Quoted 2 lines
signature without breaking backwards compatibility.
This means changing the arguments that it accepts as well as the return value.
What is "it" in the previous line? (Please replace with a suitable noun.)
Quoted 5 lines
When looking up a symbol in the vDSO, you must always include the version you are writing against.
Typically the vDSO follows the naming convention of prefixing all symbols with "
__vdso_" or "__kernel_" so as to distinguish from other standard symbols.
s/distinguish/distinguish them/
Quoted 4 lines
e.g. The "gettimeofday" function is named "
__vdso_gettimeofday".You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
That last sentence is a little incomplete. Could you expand/reword a little please.
Quoted 5 lines
.SH NOTES
.SS Source
When you compile the kernel, it will automatically compile and link the vDSO code for you.
You will frequently find it under the arch specific dir:
s/arch specific dir/architecture-specific directory/
Quoted 1 line
.br
Change that last to a blank line, and then indent the next line by 4 spaces.
Quoted 5 lines
find
arch/$ARCH/-name '*vdso*.so*' -o -name '*gate*.so*'Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under an
s/i.e. If/In other words, if/
s/32bit/32-big/g
Quoted 1 line
x86_6464bit kernel, you'll get the same vDSO.
s/64bit/64-bit/
Quoted 1 line
So when referring to sections below, use the userspace ABI.
It's not clear what you mean here when you say "use the userspace ABI." Could you clarify?
Quoted 1 line
.SS vDSO Names
s/Names/names/
Quoted 3 lines
The name of this shared object varies across architectures.
It will often show up in things like glibc'slddoutput.
The exact name should not matter to any code, so please do not hardcode it.
s/please//
Quoted 35 lines
.if t \{\
.ft CW
\}
.TS
l l.
user ABI vDSO name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SS aarch64 functions
.\" Seelinux/arch/arm64/kernel/vdso/vdso.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6.39__kernel_gettimeofdayLINUX_2.6.39__kernel_clock_gettimeLINUX_2.6.39__kernel_clock_getresLINUX_2.6.39
Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" Seelinux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
Thanks -- adding references like the above in the source is helpful for future maintenance.
Quoted 1 line
As this cpu lacks a MMU, it doesn't setup a vDSO in the normal sense.
s/cpu/CPU/
s/MMU/memory-management unit (MMU)/
s/setup/set up/
Quoted 3 lines
Instead, it maps at boot time a few raw functions into a fixed location in memory.
Userspace apps then call directly into that.
s/apps/applications/
Quoted 26 lines
There is no provision for backwards compatibility beyond sniffing raw opcodes, but as this is an embedded CPU, it can get away with things -- some of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For documentation on this format, it's better you refer to the public docs:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" Seelinux/arch/ia64/kernel/gate.lds.S
.\" Alsolinux/arch/ia64/kernel/fsys.Sandlinux/Documentation/ia64/fsys.txt.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtrampLINUX_2.5__kernel_syscall_via_breakLINUX_2.5__kernel_syscall_via_epcLINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
Quoted 2 lines
The Itanium port actually likes to get tricky.
In addition to the vDSO above, it also has "light-weight system calls" aka
s/aka/also known as/
Quoted 1 line
"fast syscalls" aka "fsys".
s/aka/or/
Quoted 23 lines
You can invoke these via the
__kernel_syscall_via_epcvDSO helper. The system calls listed here have the same semantics as if you called them directly via
.BR syscall (3),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
Quoted 8 lines
.ft P
\}
.SS ppc/32 functions
.\" Seelinux/arch/powerpc/kernel/vdso32/vdso32.lds.SThe functions marked with a
.I *
below are only available when the kernel is
a powerpc64 (64bit) kernel.
s/64bit/64-bit/
Quoted 110 lines
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettimeLINUX_2.6.15__kernel_datapage_offsetLINUX_2.6.15__kernel_get_syscall_mapLINUX_2.6.15__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpu\fI*\fR LINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt32LINUX_2.6.15__kernel_sigtramp32LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" Seelinux/arch/powerpc/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettimeLINUX_2.6.15__kernel_datapage_offsetLINUX_2.6.15__kernel_get_syscall_mapLINUX_2.6.15__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpuLINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt64LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" Seelinux/arch/s390/kernel/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" Seelinux/arch/s390/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" Seelinux/arch/sh/kernel/vsyscall/vsyscall.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6__kernel_sigreturnLINUX_2.6__kernel_vsyscallLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" Seelinux/arch/x86/vdso/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturnLINUX_2.5__kernel_rt_sigreturnLINUX_2.5__kernel_vsyscallLINUX_2.5
Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SSx86_64functions
.\" Seelinux/arch/x86/vdso/vdso.lds.S
Each of these symbols are also available without the "__vdso_" prefix, but
Either:
s/Each of these symbols are/All of these symbols are/ or
s/Each of these symbols are/Each of these symbols is/
Quoted 28 lines
you should ignore those and stick to the names below. .if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" Seelinux/arch/x86/vdso/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6
Quoted 8 lines
__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SH HISTORY
Better to have this as
.SS History
Quoted 3 lines
The vDSO was originally just a single function -- the vsyscall.
In older kernels, you might see that in a process's memory map rather than vdso. Overtime, people realized that this was a great way to pass more functionality
s/Overtime/Over time/
Quoted 6 lines
to userspace, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)
Quoted 8 lines
The docs/examples/sources in the Linux sources:
.nfDocumentation/ABI/stable/vdsolinux/Documentation/ia64/fsys.txtDocumentation/vDSO/*(includes examples of using the vDSO) findarch/-iname '*vdso*' -o -iname '*gate*'
.fi
In the next iteration, could you include a second (separate) patch to syscalls.2 and getauxval.3 that adds
.BR vdso (7)
under SEE ALSO.
Thanks,
Michael
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Mike,
Ping!
Cheers,
Michael
Quoted 553 lines · Michael Kerrisk
Hi Mike,
Quoted 1 line · Mike Frysinger
here's v2 w/Andy's feedback
Thanks for this--it's a nice piece of work. Could you take a look at my comments below and send a v3, please.
Quoted 4 lines
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain. Suck it.Okay -- not my first choice for a license, but so be it. But, how about we lose the "Suck it."...
Quoted 9 lines
.\" %%%LICENSE_END
.\"
.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual" .SH NAME
vDSO \- overview of the virtual ELF dynamic shared object .SH SYNOPSIS
.B #include <sys/auxv.h>.B void *vdso = (uintptr_t)getauxval(AT_SYSINFO_EHDR);
Add space before "getauxval". (Usual convention for casts in code examples in man pages.)
Quoted 3 lines
.SH DESCRIPTION
The "vDSO" is a small shared library that the kernel automatically maps into the address space of all userspace applications.1,$s/userspace applications/user-space applications/
Quoted 2 lines
Applications themselves usually need not concern themselves with this as it is most commonly called by the C library.
This last sentence doesn't quite make sense, since "this" and "it" refer to different things (I believe). Do you want something like:
Applications generally do not need to care about the details since the vDSO is automatically employed by the C library
?
Quoted 4 lines
This way you can write using standard functions and the C library will take care of using any available functionality.
Why does this object exist at all?
s/this object/the vDSO/
Quoted 1 line
There are some facilities the kernel provides that userspace ends up using
s/userspace/user space/
(When used as a noun, and in other places in the page as well)
Quoted 9 lines
frequently to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context overhead from exiting userspace and entering the kernel.
The rest of this documentation is geared towards the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example BackgroundConvention for SS headings is that only the first word is capitalized (unless English usage dictates otherwise--e.g., for a proper noun)
Quoted 1 line
Making syscalls can be slow.
1,$s/syscall/system call/
(and other instances in the page)
Quoted 1 line
In x86 32bit systems, you can trigger a software interrupt (int $0x80) to tell
s/32bit/32-bit/
Quoted 8 lines
the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.That last point (after the comma) is the most interesting (IMO) of the use cases of the vDSO. If you cared to expand on the details (i.e., are what are mechanics of the operation of those functions provided by the kernel), I think that would be interesting for the reader.
Quoted 4 lines
Note that the terminology can be confusing.
On x86 systems, the vDSO function is named "__kernel_vsyscall", but onx86_64, the term "vsyscall" also refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.s/cpu/CPU/
Quoted 4 lines
Another frequent system call is
gettimeofday().
This is called both directly by userspace applications as well as indirectly by the C library.
Think timestamps or timing loops or polling -- all of these frequently need toQuoted 8 lines
know what time it is right now.
This information is also not secret -- any application in any privilege mode (root or any user) will get the same answer.
Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access.
Now a call togettimeofday()changes from a syscall to a normal function call and a few memory accesses.
.SS Finding The vDSOs/The/the/
Quoted 9 lines
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector.
Specifically, via the
.BAT_SYSINFO_EHDR
tag.You must not assume the vDSO is mapped at any particular location in the user's memory map.
The base address will usually be randomized at runtime every time a new isMissing word after "new".
Quoted 11 lines
processed (at
.BR execve (2)
time).
This is done for security reasons to prevent standard "return-to-libc" attacks.For some architectures, there is also a
.BAT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently omitted or set to 0 (meaning it's not available).
It is a throw back to the initial vDSO work (sees/throw back/throwback/
Quoted 7 lines
.IR HISTORY
below) and should be avoided.Refer to
.BR getauxval (3)
for more details on accessing these fields.
.SS File Formats/Format/format/
Quoted 1 line
Since the vDSO is a fully formed ELF, you can do symbol lookups on it.
Missing word after ELF.
Quoted 8 lines
This allows new symbols to be added with newer kernel releases, and for the C library to detect available functionality at runtime when running under different kernel versions.
Often times the C library will do detection with the first call and then cache the result for subsequent calls.All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function
s/situation/case that it is necessary/
Quoted 2 lines
signature without breaking backwards compatibility.
This means changing the arguments that it accepts as well as the return value.What is "it" in the previous line? (Please replace with a suitable noun.)
Quoted 5 lines
When looking up a symbol in the vDSO, you must always include the version you are writing against.
Typically the vDSO follows the naming convention of prefixing all symbols with "
__vdso_" or "__kernel_" so as to distinguish from other standard symbols.s/distinguish/distinguish them/
Quoted 4 lines
e.g. The "gettimeofday" function is named "
__vdso_gettimeofday".You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
That last sentence is a little incomplete. Could you expand/reword a little please.
Quoted 5 lines
.SH NOTES
.SS Source
When you compile the kernel, it will automatically compile and link the vDSO code for you.
You will frequently find it under the arch specific dir:s/arch specific dir/architecture-specific directory/
Quoted 1 line
.br
Change that last to a blank line, and then indent the next line by 4 spaces.
Quoted 5 lines
find
arch/$ARCH/-name '*vdso*.so*' -o -name '*gate*.so*'Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under ans/i.e. If/In other words, if/
s/32bit/32-big/gQuoted 1 line
x86_6464bit kernel, you'll get the same vDSO.s/64bit/64-bit/
Quoted 1 line
So when referring to sections below, use the userspace ABI.
It's not clear what you mean here when you say "use the userspace ABI." Could you clarify?
Quoted 1 line
.SS vDSO Names
s/Names/names/
Quoted 3 lines
The name of this shared object varies across architectures.
It will often show up in things like glibc'slddoutput.
The exact name should not matter to any code, so please do not hardcode it.s/please//
Quoted 35 lines
.if t \{\
.ft CW
\}
.TS
l l.
user ABI vDSO name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SS aarch64 functions
.\" Seelinux/arch/arm64/kernel/vdso/vdso.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6.39__kernel_gettimeofdayLINUX_2.6.39__kernel_clock_gettimeLINUX_2.6.39__kernel_clock_getresLINUX_2.6.39Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" Seelinux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-codeThanks -- adding references like the above in the source is helpful for future maintenance.
Quoted 1 line
As this cpu lacks a MMU, it doesn't setup a vDSO in the normal sense.
s/cpu/CPU/
s/MMU/memory-management unit (MMU)/
s/setup/set up/Quoted 3 lines
Instead, it maps at boot time a few raw functions into a fixed location in memory.
Userspace apps then call directly into that.s/apps/applications/
Quoted 26 lines
There is no provision for backwards compatibility beyond sniffing raw opcodes, but as this is an embedded CPU, it can get away with things -- some of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For documentation on this format, it's better you refer to the public docs:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" Seelinux/arch/ia64/kernel/gate.lds.S
.\" Alsolinux/arch/ia64/kernel/fsys.Sandlinux/Documentation/ia64/fsys.txt.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtrampLINUX_2.5__kernel_syscall_via_breakLINUX_2.5__kernel_syscall_via_epcLINUX_2.5
.TE
.if t \{\
.in
.ft P
\}Quoted 2 lines
The Itanium port actually likes to get tricky.
In addition to the vDSO above, it also has "light-weight system calls" akas/aka/also known as/
Quoted 1 line
"fast syscalls" aka "fsys".
s/aka/or/
Quoted 23 lines
You can invoke these via the
__kernel_syscall_via_epcvDSO helper. The system calls listed here have the same semantics as if you called them directly via
.BR syscall (3),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.inQuoted 8 lines
.ft P
\}
.SS ppc/32 functions
.\" Seelinux/arch/powerpc/kernel/vdso32/vdso32.lds.SThe functions marked with a
.I *
below are only available when the kernel is
a powerpc64 (64bit) kernel.s/64bit/64-bit/
Quoted 110 lines
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15 __kernel_datapage_offset LINUX_2.6.15 __kernel_get_syscall_map LINUX_2.6.15
__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpu\fI*\fR LINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt32LINUX_2.6.15__kernel_sigtramp32LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" Seelinux/arch/powerpc/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15 __kernel_datapage_offset LINUX_2.6.15 __kernel_get_syscall_map LINUX_2.6.15
__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpuLINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt64LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" Seelinux/arch/s390/kernel/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" Seelinux/arch/s390/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" Seelinux/arch/sh/kernel/vsyscall/vsyscall.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6__kernel_sigreturnLINUX_2.6__kernel_vsyscallLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" Seelinux/arch/x86/vdso/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturnLINUX_2.5__kernel_rt_sigreturnLINUX_2.5__kernel_vsyscallLINUX_2.5Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SSx86_64functions
.\" Seelinux/arch/x86/vdso/vdso.lds.S
Each of these symbols are also available without the "__vdso_" prefix, butEither:
s/Each of these symbols are/All of these symbols are/ or
s/Each of these symbols are/Each of these symbols is/Quoted 28 lines
you should ignore those and stick to the names below. .if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" Seelinux/arch/x86/vdso/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6Quoted 8 lines
__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SH HISTORYBetter to have this as
.SS History
Quoted 3 lines
The vDSO was originally just a single function -- the vsyscall.
In older kernels, you might see that in a process's memory map rather than vdso. Overtime, people realized that this was a great way to pass more functionalitys/Overtime/Over time/
Quoted 6 lines
to userspace, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)Quoted 8 lines
The docs/examples/sources in the Linux sources:
.nfDocumentation/ABI/stable/vdsolinux/Documentation/ia64/fsys.txtDocumentation/vDSO/*(includes examples of using the vDSO) findarch/-iname '*vdso*' -o -iname '*gate*'
.fiIn the next iteration, could you include a second (separate) patch to syscalls.2 and getauxval.3 that adds
.BR vdso (7)
under SEE ALSO.Thanks,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Author of "The Linux Programming Interface"; http://man7.org/tlpi/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Mike,
This page seems to have fallen on the floor. Would you have time to look at my comments below and submit a new version of this page?
Cheers,
Michael
Quoted 567 lines · Michael Kerrisk (man-pages)
Hi Mike,
Ping!
Cheers,
Michael
Quoted 553 lines · Michael Kerrisk
Hi Mike,
Quoted 1 line · Mike Frysinger
here's v2 w/Andy's feedback
Thanks for this--it's a nice piece of work. Could you take a look at my comments below and send a v3, please.
Quoted 4 lines
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain. Suck it.Okay -- not my first choice for a license, but so be it. But, how about we lose the "Suck it."...
Quoted 9 lines
.\" %%%LICENSE_END
.\"
.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual" .SH NAME
vDSO \- overview of the virtual ELF dynamic shared object .SH SYNOPSIS
.B #include <sys/auxv.h>.B void *vdso = (uintptr_t)getauxval(AT_SYSINFO_EHDR);
Add space before "getauxval". (Usual convention for casts in code examples in man pages.)
Quoted 3 lines
.SH DESCRIPTION
The "vDSO" is a small shared library that the kernel automatically maps into the address space of all userspace applications.1,$s/userspace applications/user-space applications/
Quoted 2 lines
Applications themselves usually need not concern themselves with this as it is most commonly called by the C library.
This last sentence doesn't quite make sense, since "this" and "it" refer to different things (I believe). Do you want something like:
Applications generally do not need to care about the details since the vDSO is automatically employed by the C library
?
Quoted 4 lines
This way you can write using standard functions and the C library will take care of using any available functionality.
Why does this object exist at all?
s/this object/the vDSO/
Quoted 1 line
There are some facilities the kernel provides that userspace ends up using
s/userspace/user space/
(When used as a noun, and in other places in the page as well)
Quoted 9 lines
frequently to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context overhead from exiting userspace and entering the kernel.
The rest of this documentation is geared towards the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example BackgroundConvention for SS headings is that only the first word is capitalized (unless English usage dictates otherwise--e.g., for a proper noun)
Quoted 1 line
Making syscalls can be slow.
1,$s/syscall/system call/
(and other instances in the page)
Quoted 1 line
In x86 32bit systems, you can trigger a software interrupt (int $0x80) to tell
s/32bit/32-bit/
Quoted 8 lines
the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.That last point (after the comma) is the most interesting (IMO) of the use cases of the vDSO. If you cared to expand on the details (i.e., are what are mechanics of the operation of those functions provided by the kernel), I think that would be interesting for the reader.
Quoted 4 lines
Note that the terminology can be confusing.
On x86 systems, the vDSO function is named "__kernel_vsyscall", but onx86_64, the term "vsyscall" also refers to an obsolete way to ask the kernel what time it is or what cpu the caller is on.s/cpu/CPU/
Quoted 4 lines
Another frequent system call is
gettimeofday().
This is called both directly by userspace applications as well as indirectly by the C library.
Think timestamps or timing loops or polling -- all of these frequently need toQuoted 8 lines
know what time it is right now.
This information is also not secret -- any application in any privilege mode (root or any user) will get the same answer.
Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access.
Now a call togettimeofday()changes from a syscall to a normal function call and a few memory accesses.
.SS Finding The vDSOs/The/the/
Quoted 9 lines
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector.
Specifically, via the
.BAT_SYSINFO_EHDR
tag.You must not assume the vDSO is mapped at any particular location in the user's memory map.
The base address will usually be randomized at runtime every time a new isMissing word after "new".
Quoted 11 lines
processed (at
.BR execve (2)
time).
This is done for security reasons to prevent standard "return-to-libc" attacks.For some architectures, there is also a
.BAT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently omitted or set to 0 (meaning it's not available).
It is a throw back to the initial vDSO work (sees/throw back/throwback/
Quoted 7 lines
.IR HISTORY
below) and should be avoided.Refer to
.BR getauxval (3)
for more details on accessing these fields.
.SS File Formats/Format/format/
Quoted 1 line
Since the vDSO is a fully formed ELF, you can do symbol lookups on it.
Missing word after ELF.
Quoted 8 lines
This allows new symbols to be added with newer kernel releases, and for the C library to detect available functionality at runtime when running under different kernel versions.
Often times the C library will do detection with the first call and then cache the result for subsequent calls.All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function
s/situation/case that it is necessary/
Quoted 2 lines
signature without breaking backwards compatibility.
This means changing the arguments that it accepts as well as the return value.What is "it" in the previous line? (Please replace with a suitable noun.)
Quoted 5 lines
When looking up a symbol in the vDSO, you must always include the version you are writing against.
Typically the vDSO follows the naming convention of prefixing all symbols with "
__vdso_" or "__kernel_" so as to distinguish from other standard symbols.s/distinguish/distinguish them/
Quoted 4 lines
e.g. The "gettimeofday" function is named "
__vdso_gettimeofday".You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
That last sentence is a little incomplete. Could you expand/reword a little please.
Quoted 5 lines
.SH NOTES
.SS Source
When you compile the kernel, it will automatically compile and link the vDSO code for you.
You will frequently find it under the arch specific dir:s/arch specific dir/architecture-specific directory/
Quoted 1 line
.br
Change that last to a blank line, and then indent the next line by 4 spaces.
Quoted 5 lines
find
arch/$ARCH/-name '*vdso*.so*' -o -name '*gate*.so*'Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under ans/i.e. If/In other words, if/
s/32bit/32-big/gQuoted 1 line
x86_6464bit kernel, you'll get the same vDSO.s/64bit/64-bit/
Quoted 1 line
So when referring to sections below, use the userspace ABI.
It's not clear what you mean here when you say "use the userspace ABI." Could you clarify?
Quoted 1 line
.SS vDSO Names
s/Names/names/
Quoted 3 lines
The name of this shared object varies across architectures.
It will often show up in things like glibc'slddoutput.
The exact name should not matter to any code, so please do not hardcode it.s/please//
Quoted 35 lines
.if t \{\
.ft CW
\}
.TS
l l.
user ABI vDSO name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SS aarch64 functions
.\" Seelinux/arch/arm64/kernel/vdso/vdso.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6.39__kernel_gettimeofdayLINUX_2.6.39__kernel_clock_gettimeLINUX_2.6.39__kernel_clock_getresLINUX_2.6.39Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" Seelinux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-codeThanks -- adding references like the above in the source is helpful for future maintenance.
Quoted 1 line
As this cpu lacks a MMU, it doesn't setup a vDSO in the normal sense.
s/cpu/CPU/
s/MMU/memory-management unit (MMU)/
s/setup/set up/Quoted 3 lines
Instead, it maps at boot time a few raw functions into a fixed location in memory.
Userspace apps then call directly into that.s/apps/applications/
Quoted 26 lines
There is no provision for backwards compatibility beyond sniffing raw opcodes, but as this is an embedded CPU, it can get away with things -- some of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For documentation on this format, it's better you refer to the public docs:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" Seelinux/arch/ia64/kernel/gate.lds.S
.\" Alsolinux/arch/ia64/kernel/fsys.Sandlinux/Documentation/ia64/fsys.txt.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtrampLINUX_2.5__kernel_syscall_via_breakLINUX_2.5__kernel_syscall_via_epcLINUX_2.5
.TE
.if t \{\
.in
.ft P
\}Quoted 2 lines
The Itanium port actually likes to get tricky.
In addition to the vDSO above, it also has "light-weight system calls" akas/aka/also known as/
Quoted 1 line
"fast syscalls" aka "fsys".
s/aka/or/
Quoted 23 lines
You can invoke these via the
__kernel_syscall_via_epcvDSO helper. The system calls listed here have the same semantics as if you called them directly via
.BR syscall (3),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.inQuoted 8 lines
.ft P
\}
.SS ppc/32 functions
.\" Seelinux/arch/powerpc/kernel/vdso32/vdso32.lds.SThe functions marked with a
.I *
below are only available when the kernel is
a powerpc64 (64bit) kernel.s/64bit/64-bit/
Quoted 110 lines
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15 __kernel_datapage_offset LINUX_2.6.15 __kernel_get_syscall_map LINUX_2.6.15
__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpu\fI*\fR LINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt32LINUX_2.6.15__kernel_sigtramp32LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" Seelinux/arch/powerpc/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15 __kernel_datapage_offset LINUX_2.6.15 __kernel_get_syscall_map LINUX_2.6.15
__kernel_get_tbfreqLINUX_2.6.15__kernel_getcpuLINUX_2.6.15__kernel_gettimeofdayLINUX_2.6.15__kernel_sigtramp_rt64LINUX_2.6.15__kernel_sync_dicacheLINUX_2.6.15__kernel_sync_dicache_p5LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" Seelinux/arch/s390/kernel/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" Seelinux/arch/s390/kernel/vdso64/vdso64.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getresLINUX_2.6.29__kernel_clock_gettimeLINUX_2.6.29__kernel_gettimeofdayLINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" Seelinux/arch/sh/kernel/vsyscall/vsyscall.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturnLINUX_2.6__kernel_sigreturnLINUX_2.6__kernel_vsyscallLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" Seelinux/arch/x86/vdso/vdso32/vdso32.lds.S.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturnLINUX_2.5__kernel_rt_sigreturnLINUX_2.5__kernel_vsyscallLINUX_2.5Quoted 8 lines
.TE
.if t \{\
.in
.ft P
\}
.SSx86_64functions
.\" Seelinux/arch/x86/vdso/vdso.lds.S
Each of these symbols are also available without the "__vdso_" prefix, butEither:
s/Each of these symbols are/All of these symbols are/ or
s/Each of these symbols are/Each of these symbols is/Quoted 28 lines
you should ignore those and stick to the names below. .if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" Seelinux/arch/x86/vdso/vdso32.lds.S
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettimeLINUX_2.6__vdso_getcpuLINUX_2.6Quoted 8 lines
__vdso_gettimeofdayLINUX_2.6__vdso_timeLINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SH HISTORYBetter to have this as
.SS History
Quoted 3 lines
The vDSO was originally just a single function -- the vsyscall.
In older kernels, you might see that in a process's memory map rather than vdso. Overtime, people realized that this was a great way to pass more functionalitys/Overtime/Over time/
Quoted 6 lines
to userspace, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)Quoted 8 lines
The docs/examples/sources in the Linux sources:
.nfDocumentation/ABI/stable/vdsolinux/Documentation/ia64/fsys.txtDocumentation/vDSO/*(includes examples of using the vDSO) findarch/-iname '*vdso*' -o -iname '*gate*'
.fiIn the next iteration, could you include a second (separate) patch to syscalls.2 and getauxval.3 that adds
.BR vdso (7)
under SEE ALSO.Thanks,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · On Wednesday 22 May 2013 09:22:09 Michael Kerrisk wrote:
Quoted 1 line · Mike Frysinger
here's v2 w/Andy's feedback
Thanks for this--it's a nice piece of work. Could you take a look at my comments below and send a v3, please.
anything i didn't explicitly respond to below i merged with my version
Quoted 9 lines
Quoted 8 lines
the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.
Quoted 4 lines
That last point (after the comma) is the most interesting (IMO) of the use cases of the vDSO. If you cared to expand on the details (i.e., are what are mechanics of the operation of those functions provided by the kernel), I think that would be interesting for the reader.
i think the paragraph after this explains things somewhat as you'd like (where it talks about gettimeofday) ?
Quoted 5 lines
Quoted 3 lines
All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function
s/situation/case that it is necessary/
hmm, i see what you mean, but i think your version isn't really better ... just different. i'll just delete the (...) text.
Quoted 5 lines
Quoted 2 lines
You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
That last sentence is a little incomplete. Could you expand/reword a little please.
it's meant as a follow up to the previous sentence. so the implication is that there are no functions which violate the C ABI for your particular target. arguments get passed in the standard way (registers/stack), and all the registers have corresponding behavior: scratch are scratch, caller- preserved are caller-preserved, callee-preserved are callee-preserved, etc...
Quoted 5 lines
Quoted 3 lines
Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under ans/i.e. If/In other words, if/
i.e. shows up a lot in man pages as does e.g. (and both show up in this new vdso(7) page) ...
Quoted 4 lines
Quoted 1 line
So when referring to sections below, use the userspace ABI.
It's not clear what you mean here when you say "use the userspace ABI." Could you clarify?
the two sentences that preceded this one explained things ... -mike
PATCH v3 1/1 vdso(7): new man page
In reply to a message not in the archive--- man2/syscall.2 | 6 +- man2/syscalls.2 | 3 +- man3/getauxval.3 | 4 +- man7/libc.7 | 5 +- man7/vdso.7 | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 468 insertions(+), 7 deletions(-) create mode 100644 man7/vdso.7
man2/syscall.2 +4 -2
@@ -145,7 +145,8 @@ The details for various architectures are listed in the two tables below. The first table lists the instruction used to transition to kernel mode, (which might not be the fastest or best way to transition to the kernel, -so you might have to refer to the VDSO), +so you might have to refer to +.BR vdso (7)), the register used to indicate the system call number, and the register used to return the system call result. .if t \{\
@@ -219,4 +220,5 @@ main(int argc, char *argv[]) .SH SEE ALSO .BR _syscall (2), .BR intro (2), -.BR syscalls (2) +.BR syscalls (2), +.BR vdso (7)
man2/syscalls.2 +2 -1
@@ -833,4 +833,5 @@ and similarly .SH SEE ALSO .BR syscall (2), .BR unimplemented (2), -.BR libc (7) +.BR libc (7), +.BR vdso (7)
man3/getauxval.3 +1 -3
@@ -210,7 +210,5 @@ see for more information. .SH SEE ALSO .BR secure_getenv (3), +.BR vdso (7), .BR ld-linux.so (8) - -The kernel source file -.IR Documentation/ABI/stable/vdso
man7/libc.7 +4 -1
@@ -98,6 +98,9 @@ Details of these libraries are generally not covered by the project. .SH SEE ALSO .BR syscalls (2), +.BR getauxval (3), +.BR proc (5), .BR feature_test_macros (7), .BR man-pages (7), -.BR standards (7) +.BR standards (7), +.BR vdso (7)
man7/vdso.7 new file +457 -0
457 lines not on this page · raw message
Signature · 6 lines
1.8.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Mike,
Thanks for following up on this.
Quoted 18 lines · Mike Frysinger
Quoted 5 lines · On Wednesday 22 May 2013 09:22:09 Michael Kerrisk wrote:
Quoted 1 line · Mike Frysinger
here's v2 w/Andy's feedback
Thanks for this--it's a nice piece of work. Could you take a look at my comments below and send a v3, please.
anything i didn't explicitly respond to below i merged with my version
Quoted 9 lines
Quoted 8 lines
the kernel you wish to make a syscall.
However, this instruction is expensive: it goes through the full interrupt handling paths in the processor's microcode as well as in the kernel. Newer processors have faster (but backwards incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at runtime itself, it can use functions provided by the kernel in the vDSO.
Quoted 7 lines
Quoted 4 lines
That last point (after the comma) is the most interesting (IMO) of the use cases of the vDSO. If you cared to expand on the details (i.e., are what are mechanics of the operation of those functions provided by the kernel), I think that would be interesting for the reader.
i think the paragraph after this explains things somewhat as you'd like (where it talks about gettimeofday) ?
Yes, thanks.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
All symbols are also versioned (using the GNU version format). This allows the kernel (in the very unlikely situation) to update the function
s/situation/case that it is necessary/
hmm, i see what you mean, but i think your version isn't really better ... just different. i'll just delete the (...) text.
Okay.
Quoted 12 lines
Quoted 5 lines
Quoted 2 lines
You use the standard C calling conventions when calling any of these functions. No need to worry about weird register or stack behavior.
That last sentence is a little incomplete. Could you expand/reword a little please.
it's meant as a follow up to the previous sentence. so the implication is that there are no functions which violate the C ABI for your particular target. arguments get passed in the standard way (registers/stack), and all the registers have corresponding behavior: scratch are scratch, caller- preserved are caller-preserved, callee-preserved are callee-preserved, etc...
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Note that the vDSO that is used is based on the ABI of your userspace code and not the ABI of the kernel.
i.e. If you run an i386 32bit ELF under an i386 32bit kernel or under ans/i.e. If/In other words, if/
i.e. shows up a lot in man pages as does e.g. (and both show up in this new vdso(7) page) ...
I should have been clearer. I disfavor the use of "e.g." and "i.e.", except in parenthetical asides. There were a very few exceptions to that guideline, and I just now went through and stamped out most of them. And I edited your page to be consistent with the guideline.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So when referring to sections below, use the userspace ABI.
It's not clear what you mean here when you say "use the userspace ABI." Could you clarify?
the two sentences that preceded this one explained things ...
Sorry -- I still don't get it... (See my other reply.)
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Mike,
Thanks for the updated patch.
I've applied your patches for the next man-pages release, but would be happy if you could answer the questions below.
Quoted 84 lines · Mike Frysinger
--- man2/syscall.2 | 6 +- man2/syscalls.2 | 3 +- man3/getauxval.3 | 4 +- man7/libc.7 | 5 +- man7/vdso.7 | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 468 insertions(+), 7 deletions(-) create mode 100644 man7/vdso.7man2/syscall.2 +4
-2@@ -145,7 +145,8 @@ The details for various architectures are listed in the two tables below. The first table lists the instruction used to transition to kernel mode, (which might not be the fastest or best way to transition to the kernel, -so you might have to refer to the VDSO), +so you might have to refer to +.BR vdso (7)), the register used to indicate the system call number, and the register used to return the system call result. .if t \{\@@ -219,4 +220,5 @@ main(int argc, char *argv[]) .SH SEE ALSO .BR _syscall (2), .BR intro (2), -.BR syscalls (2) +.BR syscalls (2), +.BR vdso (7)man2/syscalls.2 +2
-1@@ -833,4 +833,5 @@ and similarly .SH SEE ALSO .BR syscall (2), .BR unimplemented (2), -.BR libc (7) +.BR libc (7), +.BR vdso (7)man3/getauxval.3 +1
-3@@ -210,7 +210,5 @@ see for more information. .SH SEE ALSO .BR secure_getenv (3), +.BR vdso (7), .BR ld-linux.so (8) - -The kernel source file -.IR Documentation/ABI/stable/vdsoman7/libc.7 +4
-1@@ -98,6 +98,9 @@ Details of these libraries are generally not covered by the project. .SH SEE ALSO .BR syscalls (2), +.BR getauxval (3), +.BR proc (5), .BR feature_test_macros (7), .BR man-pages (7), -.BR standards (7) +.BR standards (7), +.BR vdso (7)man7/vdso.7 new file +9
-0@@ -0,0 +1,457 @@ +.\" Written by Mike Frysinger <[email protected]> +.\" +.\" %%%LICENSE_START(PUBLIC_DOMAIN) +.\" This page is in the public domain. +.\" %%%LICENSE_END +.\" +.TH VDSO 7 2013-04-09 "Linux" "Linux Programmer's Manual" +.SH NAME +vDSO \- overview of the virtual ELF dynamic shared object
man7/vdso.7 line 19
Quoted 10 lines
man7/vdso.7 new file +10
-0+.SH SYNOPSIS +.B #include <sys/auxv.h> + +.B void *vdso = (uintptr_t) getauxval(AT_SYSINFO_EHDR); +.SH DESCRIPTION +The "vDSO" is a small shared library that the kernel automatically maps into the +address space of all user-space applications. +Applications themselves usually need not concern themselves with these details +as the vDSO is most commonly called by the C library. +This way you can write using standard functions and the C library will take care
After "write" I added "programs". Okay?
man7/vdso.7 line 20
Quoted 1 line
man7/vdso.7 new file +1
-0+of using any available functionality.
I made this piece:
of using any functionality that is available via the vDSO.
Okay?
man7/vdso.7 line 23
Quoted 3 lines
man7/vdso.7 new file +3
-0+ +Why does the vDSO exist at all? +There are some facilities the kernel provides that user space ends up using
I changed "facilities" to "system calls". Okay?
Quoted 12 lines
man7/vdso.7 new file +12
-0+frequently to the point that such calls can dominate overall performance. +This is due both to the frequency of the call as well as the context overhead +from exiting user space and entering the kernel. + +The rest of this documentation is geared towards the curious and/or C library +writers rather than general developers. +If you're trying to call the vDSO in your own application rather than using +the C library, you're most likely doing it wrong. +.SS Example background +Making system calls can be slow. +In x86 32-bit systems, you can trigger a software interrupt (int $0x80) to tell +the kernel you wish to make a system call.
man7/vdso.7 line 45
Quoted 10 lines
man7/vdso.7 new file +10
-0+However, this instruction is expensive: it goes through the full interrupt +handling paths in the processor's microcode as well as in the kernel. +Newer processors have faster (but backwards incompatible) instructions to +initiate system calls. +Rather than require the C library to figure out if this functionality is +available at runtime itself, it can use functions provided by the kernel in +the vDSO. + +Note that the terminology can be confusing. +On x86 systems, the vDSO function is named "__kernel_vsyscall", but on x86_64,
After "function" I added
used to determine the preferred method of making a system call is
Okay?
Quoted 66 lines
man7/vdso.7 new file +66
-0+the term "vsyscall" also refers to an obsolete way to ask the kernel what time +it is or what CPU the caller is on. + +One system call frequently called is gettimeofday(). +This is called both directly by user-space applications as well as indirectly by +the C library. +Think timestamps or timing loops or polling -- all of these frequently need to +know what time it is right now. +This information is also not secret -- any application in any privilege mode +(root or any user) will get the same answer. +Thus the kernel arranges for the information required to answer this question +to be placed in memory the process can access. +Now a call to gettimeofday() changes from a system call to a normal function +call and a few memory accesses. +.SS Finding the vDSO +The base address of the vDSO (if one exists) is passed by the kernel to each +program in the initial auxiliary vector. +Specifically, via the +.B AT_SYSINFO_EHDR +tag. + +You must not assume the vDSO is mapped at any particular location in the +user's memory map. +The base address will usually be randomized at runtime every time a new +process image is created (at +.BR execve (2) +time). +This is done for security reasons to prevent standard "return-to-libc" attacks. + +For some architectures, there is also a +.B AT_SYSINFO +tag. +This is used only for locating the vsyscall entry point and is frequently +omitted or set to 0 (meaning it's not available). +It is a throwback to the initial vDSO work (see +.IR HISTORY +below) and should be avoided. + +Refer to +.BR getauxval (3) +for more details on accessing these fields. +.SS File format +Since the vDSO is a fully formed ELF image, you can do symbol lookups on it. +This allows new symbols to be added with newer kernel releases, and for the +C library to detect available functionality at runtime when running under +different kernel versions. +Often times the C library will do detection with the first call and then +cache the result for subsequent calls. + +All symbols are also versioned (using the GNU version format). +This allows the kernel to update the function signature without breaking +backwards compatibility. +This means changing the arguments that the function accepts as well as the +return value. +Thus, when looking up a symbol in the vDSO, you must always include the version +to match the ABI you expect. + +Typically the vDSO follows the naming convention of prefixing all symbols with +"__vdso_" or "__kernel_" so as to distinguish them from other standard symbols. +e.g. The "gettimeofday" function is named "__vdso_gettimeofday". + +You use the standard C calling conventions when calling any of these functions. +No need to worry about weird register or stack behavior. +.SH NOTES +.SS Source +When you compile the kernel, it will automatically compile and link the vDSO
man7/vdso.7 line 121
Quoted 10 lines
man7/vdso.7 new file +10
-0+code for you. +You will frequently find it under the architecture-specific dir: + + find arch/$ARCH/ -name '*vdso*.so*' -o -name '*gate*.so*' + +Note that the vDSO that is used is based on the ABI of your user-space code +and not the ABI of the kernel. +i.e. If you run an i386 32-bit ELF under an i386 32-bit kernel or under an +x86_64 64-bit kernel, you'll get the same vDSO. +So when referring to sections below, use the user-space ABI.
I still can't make any sense of that last sentence. What are "sections" in this context? What does it mean to "*use* the user-space ABI"?
Quoted 36 lines
man7/vdso.7 new file +36
-0+.SS vDSO names +The name of this shared object varies across architectures. +It will often show up in things like glibc's `ldd` output. +The exact name should not matter to any code, so do not hardcode it. +.if t \{\ +.ft CW +\} +.TS +l l. +user ABI vDSO name +_ +aarch64 linux-vdso.so.1 +ia64 linux-gate.so.1 +ppc/32 linux-vdso32.so.1 +ppc/64 linux-vdso64.so.1 +s390 linux-vdso32.so.1 +s390x linux-vdso64.so.1 +sh linux-gate.so.1 +i386 linux-gate.so.1 +x86_64 linux-vdso.so.1 +x86/x32 linux-vdso.so.1 +.TE +.if t \{\ +.in +.ft P +\} +.SS arm functions +.\" See linux/arch/arm/kernel/entry-armv.S +.\" See linux/Documentation/arm/kernel_user_helpers.txt +The arm port has a code page full of utility functions. +Since it's just a raw page of code, there is no ELF information for doing +symbol lookups or versioning. +It does provide support for different versions though. + +For documentation on this code page, it's better you refer to the kernel doc +as it's extremely detailed and covers everything you need to know:
man7/vdso.7 line 167
Quoted 10 lines
man7/vdso.7 new file +10
-0+.br +Documentation/arm/kernel_user_helpers.txt +.SS aarch64 functions +.\" See linux/arch/arm64/kernel/vdso/vdso.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version
You don't explicitly say what tables such as the below are about. Could you provide me with a sentence to describe them?
Cheers,
Michael
Quoted 291 lines
man7/vdso.7 new file +290
-0+_ +__kernel_rt_sigreturn LINUX_2.6.39 +__kernel_gettimeofday LINUX_2.6.39 +__kernel_clock_gettime LINUX_2.6.39 +__kernel_clock_getres LINUX_2.6.39 +.TE +.if t \{\ +.in +.ft P +\} +.SS bfin (Blackfin) functions +.\" See linux/arch/blackfin/kernel/fixed_code.S +.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code +As this CPU lacks a memory management unit (MMU), it doesn't set up a vDSO in +the normal sense. +Instead, it maps at boot time a few raw functions into a fixed location in +memory. +User-space applications then call directly into that region. +There is no provision for backwards compatibility beyond sniffing raw opcodes, +but as this is an embedded CPU, it can get away with things -- some of the +object formats it runs aren't even ELF based (they're bFLT/FLAT). + +For documentation on this code page, it's better you refer to the public docs: +.br +http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code +.SS ia64 (Itanium) functions +.\" See linux/arch/ia64/kernel/gate.lds.S +.\" Also linux/arch/ia64/kernel/fsys.S and linux/Documentation/ia64/fsys.txt +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_sigtramp LINUX_2.5 +__kernel_syscall_via_break LINUX_2.5 +__kernel_syscall_via_epc LINUX_2.5 +.TE +.if t \{\ +.in +.ft P +\} + +The Itanium port actually likes to get tricky. +In addition to the vDSO above, it also has "light-weight system calls" (also +known as "fast syscalls" or "fsys"). +You can invoke these via the __kernel_syscall_via_epc vDSO helper. +The system calls listed here have the same semantics as if you called them +directly via +.BR syscall (3), +so refer to the relevant +documentation for each. +The table below lists the functions available via this mechanism. +.if t \{\ +.ft CW +\} +.TS +l. +function +_ +clock_gettime +getcpu +getpid +getppid +gettimeofday +set_tid_address +.TE +.if t \{\ +.in +.ft P +\} +.SS parisc (hppa) functions +.\" See linux/arch/parisc/kernel/syscall.S +.\" See linux/Documentation/parisc/registers +The parisc port has a code page full of utility functions called a gateway page. +Rather than use the normal ELF aux vector approach, it passes the address of +the page to the process via the SR2 register. +The permissions on the page are such that merely executing those addresses +automatically executes with kernel privileges and not in user-space. +This is done to match the way HP-UX works. + +Since it's just a raw page of code, there is no ELF information for doing +symbol lookups or versioning. +Simply call into the appropriate offset via the branch instruction, e.g.: +.br +ble <offset>(%sr2, %r0) +.if t \{\ +.ft CW +\} +.TS +l l. +offset function +_ +00b0 lws_entry +00e0 set_thread_pointer +0100 linux_gateway_entry (syscall) +0268 syscall_nosys +0274 tracesys +0324 tracesys_next +0368 tracesys_exit +03a0 tracesys_sigexit +03b8 lws_start +03dc lws_exit_nosys +03e0 lws_exit +03e4 lws_compare_and_swap64 +03e8 lws_compare_and_swap +0404 cas_wouldblock +0410 cas_action +.TE +.if t \{\ +.in +.ft P +\} +.SS ppc/32 functions +.\" See linux/arch/powerpc/kernel/vdso32/vdso32.lds.S +The functions marked with a +.I * +below are only available when the kernel is +a powerpc64 (64-bit) kernel. +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_clock_getres LINUX_2.6.15 +__kernel_clock_gettime LINUX_2.6.15 +__kernel_datapage_offset LINUX_2.6.15 +__kernel_get_syscall_map LINUX_2.6.15 +__kernel_get_tbfreq LINUX_2.6.15 +__kernel_getcpu \fI*\fR LINUX_2.6.15 +__kernel_gettimeofday LINUX_2.6.15 +__kernel_sigtramp_rt32 LINUX_2.6.15 +__kernel_sigtramp32 LINUX_2.6.15 +__kernel_sync_dicache LINUX_2.6.15 +__kernel_sync_dicache_p5 LINUX_2.6.15 +.TE +.if t \{\ +.in +.ft P +\} +.SS ppc/64 functions +.\" See linux/arch/powerpc/kernel/vdso64/vdso64.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_clock_getres LINUX_2.6.15 +__kernel_clock_gettime LINUX_2.6.15 +__kernel_datapage_offset LINUX_2.6.15 +__kernel_get_syscall_map LINUX_2.6.15 +__kernel_get_tbfreq LINUX_2.6.15 +__kernel_getcpu LINUX_2.6.15 +__kernel_gettimeofday LINUX_2.6.15 +__kernel_sigtramp_rt64 LINUX_2.6.15 +__kernel_sync_dicache LINUX_2.6.15 +__kernel_sync_dicache_p5 LINUX_2.6.15 +.TE +.if t \{\ +.in +.ft P +\} +.SS s390 functions +.\" See linux/arch/s390/kernel/vdso32/vdso32.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_clock_getres LINUX_2.6.29 +__kernel_clock_gettime LINUX_2.6.29 +__kernel_gettimeofday LINUX_2.6.29 +.TE +.if t \{\ +.in +.ft P +\} +.SS s390x functions +.\" See linux/arch/s390/kernel/vdso64/vdso64.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_clock_getres LINUX_2.6.29 +__kernel_clock_gettime LINUX_2.6.29 +__kernel_gettimeofday LINUX_2.6.29 +.TE +.if t \{\ +.in +.ft P +\} +.SS sh (SuperH) functions +.\" See linux/arch/sh/kernel/vsyscall/vsyscall.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_rt_sigreturn LINUX_2.6 +__kernel_sigreturn LINUX_2.6 +__kernel_vsyscall LINUX_2.6 +.TE +.if t \{\ +.in +.ft P +\} +.SS i386 functions +.\" See linux/arch/x86/vdso/vdso32/vdso32.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__kernel_sigreturn LINUX_2.5 +__kernel_rt_sigreturn LINUX_2.5 +__kernel_vsyscall LINUX_2.5 +.TE +.if t \{\ +.in +.ft P +\} +.SS x86_64 functions +.\" See linux/arch/x86/vdso/vdso.lds.S +All of these symbols are also available without the "__vdso_" prefix, but +you should ignore those and stick to the names below. +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__vdso_clock_gettime LINUX_2.6 +__vdso_getcpu LINUX_2.6 +__vdso_gettimeofday LINUX_2.6 +__vdso_time LINUX_2.6 +.TE +.if t \{\ +.in +.ft P +\} +.SS x86/x32 functions +.\" See linux/arch/x86/vdso/vdso32.lds.S +.if t \{\ +.ft CW +\} +.TS +l l. +symbol version +_ +__vdso_clock_gettime LINUX_2.6 +__vdso_getcpu LINUX_2.6 +__vdso_gettimeofday LINUX_2.6 +__vdso_time LINUX_2.6 +.TE +.if t \{\ +.in +.ft P +\} +.SS History +The vDSO was originally just a single function -- the vsyscall. +In older kernels, you might see that in a process's memory map rather than vdso. +Over time, people realized that this was a great way to pass more functionality +to user space, so it was reconceived as a vDSO in the current format. +.SH SEE ALSO +.BR syscalls (2), +.BR getauxval (3), +.BR proc (5) + +The docs/examples/sources in the Linux sources: +.nf +Documentation/ABI/stable/vdso +linux/Documentation/ia64/fsys.txt +Documentation/vDSO/* (includes examples of using the vDSO) +find arch/ -iname '*vdso*' -o -iname '*gate*' +.fi
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · On Wednesday 01 January 2014 05:38:20 Michael Kerrisk (man-pages) wrote:
Quoted 6 lines · Mike Frysinger
+The "vDSO" is a small shared library that the kernel automatically maps into the +address space of all user-space applications. +Applications themselves usually need not concern themselves with these details +as the vDSO is most commonly called by the C library. +This way you can write using standard functions and the C library will take care
After "write" I added "programs". Okay?
you can write libraries too, but i think either wording is fine. or maybe change "write" to "code" ?
Quoted 7 lines
Quoted 1 line
+of using any available functionality.
I made this piece:
of using any functionality that is available via the vDSO.
Okay?
np
Quoted 5 lines
Quoted 3 lines
(quoted diff) +2
-0+Why does the vDSO exist at all? +There are some facilities the kernel provides that user space ends upusing
I changed "facilities" to "system calls". Okay?
that wasn't exactly what i was going for, but the nuances are probably lost, so it doesn't matter (the vDSO isn't purely a replacement for syscalls).
Quoted 9 lines
Quoted 3 lines
(quoted diff) +2
-0+Note that the terminology can be confusing. +On x86 systems, the vDSO function is named "__kernel_vsyscall", but on
x86_64,After "function" I added
used to determine the preferred method of making a system call is
Okay?
maybe put in paren ? either works.
Quoted 8 lines
Quoted 5 lines
Note that the vDSO that is used is based on the ABI of your user-space code and not the ABI of the kernel.
i.e. If you run an i386 32-bit ELF under an i386 32-bit kernel or under anx86_6464-bit kernel, you'll get the same vDSO.
So when referring to sections below, use the user-space ABI.I still can't make any sense of that last sentence. What are "sections" in this context?
"sections" refers to the .SS stuff following this paragraph. e.g.
.SS i386 functions .SS x86_64 functions .SS x86/x32 functions
so if your userspace program is compiled as a 32bit i386 ELF, you should refer to the "i386 functions" section even if your kernel is a 64bit x86_64 build. but if your userspace program is a 64bit x86_64 program, then refer to thex86_64 section. a single kernel can support many ABIs and execute them
simultaneously. but the vDSO that is available is determined by the format of your program, not the kernel.
Quoted 1 line
What does it mean to "*use* the user-space ABI"?
use the userspace ABI as the index into the following sections.
Quoted 11 lines
Review
Quoted 8 lines
+.SS aarch64 functions
+.\" Seelinux/arch/arm64/kernel/vdso/vdso.lds.S
+.if t \{\
+.ft CW
+\}
+.TS(quoted diff) +2
-0+l l. +symbol versionYou don't explicitly say what tables such as the below are about. Could you provide me with a sentence to describe them?
i only documented the deviations as they don't follow the vDSO standards (ELF object that has dynamic symbol information available). all the standard ones may follow Documentation/ABI/stable/vdso/ and Documentation/vDSO/*. but i guess a one line sentence could be added to each of these telling people to look at the kernel's vDSO/ dir for more details.
-mike
Quoted 11 lines · Mike Frysinger
Quoted 9 lines · On Wednesday 01 January 2014 05:38:20 Michael Kerrisk (man-pages) wrote:
Quoted 6 lines · Mike Frysinger
+The "vDSO" is a small shared library that the kernel automatically maps into the +address space of all user-space applications. +Applications themselves usually need not concern themselves with these details +as the vDSO is most commonly called by the C library. +This way you can write using standard functions and the C library will take care
After "write" I added "programs". Okay?
Quoted 2 lines
you can write libraries too, but i think either wording is fine. or maybe change "write" to "code" ?
Okay. I made it:
This way you can code in the normal way using standard functions
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
(quoted diff) +2
-0+Why does the vDSO exist at all? +There are some facilities the kernel provides that user space ends upusing
I changed "facilities" to "system calls". Okay?
that wasn't exactly what i was going for, but the nuances are probably lost, so it doesn't matter (the vDSO isn't purely a replacement for syscalls).
I wondered whether you intended further nuances, but after mentioning "facilities", you seemed to discuss only system calls.
[...]
Quoted 21 lines
Quoted 8 lines
Quoted 5 lines
Note that the vDSO that is used is based on the ABI of your user-space code and not the ABI of the kernel.
i.e. If you run an i386 32-bit ELF under an i386 32-bit kernel or under anx86_6464-bit kernel, you'll get the same vDSO.
So when referring to sections below, use the user-space ABI.I still can't make any sense of that last sentence. What are "sections" in this context?
"sections" refers to the .SS stuff following this paragraph. e.g.
.SS i386 functions .SS x86_64 functions .SS x86/x32 functionsso if your userspace program is compiled as a 32bit i386 ELF, you should refer to the "i386 functions" section even if your kernel is a 64bit
x86_64build. but if your userspace program is a 64bitx86_64program, then refer to thex86_64section. a single kernel can support many ABIs and execute them
simultaneously. but the vDSO that is available is determined by the format of your program, not the kernel.
Quoted 3 lines
Quoted 1 line
What does it mean to "*use* the user-space ABI"?
use the userspace ABI as the index into the following sections.
Thanks. I reworked that to:
Thus, the name of the user-space ABI should be used to determine which of the sections below is relevant.
Quoted 12 lines
Quoted 11 lines
Review
Quoted 8 lines
+.SS aarch64 functions
+.\" Seelinux/arch/arm64/kernel/vdso/vdso.lds.S
+.if t \{\
+.ft CW
+\}
+.TS(quoted diff) +2
-0+l l. +symbol versionYou don't explicitly say what tables such as the below are about. Could you provide me with a sentence to describe them?
Quoted 6 lines
i only documented the deviations as they don't follow the vDSO standards (ELF object that has dynamic symbol information available). all the standard ones may follow
Documentation/ABI/stable/vdso/andDocumentation/vDSO/*. but i guess a one line sentence could be added to each of these telling people to look at the kernel's vDSO/ dir for more details.
-mike
I reworked here somewhat, putting the arch-specific details under a new .SH heading, and adding
The table below lists the symbols exported by the vDSO.
at the start of many of the subsections.
I've appended the updated page. Could you please take a quick look to make sure it's okay.
Cheers,
Michael
.\" Written by Mike Frysinger <[email protected]> .\"
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This page is in the public domain.
.\" %%%LICENSE_END
.\"
.\" Useful background:
.\" http://articles.manugarg.com/systemcallinlinux2_6.html .\" https://lwn.net/Articles/446528/ .\" http://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken .\" http://www.trilithium.com/johan/2005/08/linux-gate/
.\"
.TH VDSO 7 2014-01-01 "Linux" "Linux Programmer's Manual" .SH NAME
vDSO \- overview of the virtual ELF dynamic shared object .SH SYNOPSIS
.B #include <sys/auxv.h>
.B void *vdso = (uintptr_t) getauxval(AT_SYSINFO_EHDR);
.SH DESCRIPTION
The "vDSO" is a small shared library that
the kernel automatically maps into the
address space of all user-space applications.
Applications usually do not need to concern themselves with these details as the vDSO is most commonly called by the C library.
This way you can code in the normal way using standard functions and the C library will take care
of using any functionality that is available via the vDSO.
Why does the vDSO exist at all?
There are some system calls the kernel provides that user space code ends up using frequently,
to the point that such calls can dominate overall performance. This is due both to the frequency of the call as well as the context-switch overhead that results from
from exiting user space and entering the kernel.
The rest of this documentation is geared toward the curious and/or C library writers rather than general developers.
If you're trying to call the vDSO in your own application rather than using the C library, you're most likely doing it wrong.
.SS Example background
Making system calls can be slow.
In x86 32-bit systems, you can trigger a software interrupt
.RI ( "int $0x80" )
to tell the kernel you wish to make a system call.
However, this instruction is expensive: it goes through
the full interrupt-handling paths
in the processor's microcode as well as in the kernel.
Newer processors have faster (but backward incompatible) instructions to initiate system calls.
Rather than require the C library to figure out if this functionality is available at run time,
the C library can use functions provided by the kernel in
the vDSO.
Note that the terminology can be confusing.
On x86 systems, the vDSO function
used to determine the preferred method of making a system call is named "__kernel_vsyscall", but on x86_64,
the term "vsyscall" also refers to an obsolete way to ask the kernel what time it is or what CPU the caller is on.
One frequently used system call is
.BR gettimeofday (2).
This system call is called both directly by user-space applications as well as indirectly by
the C library.
Think timestamps or timing loops or polling\(emall of these frequently need to know what time it is right now.
This information is also not secret\(emany application in any privilege mode (root or any unprivileged user) will get the same answer. Thus the kernel arranges for the information required to answer this question to be placed in memory the process can access. Now a call to
.BR gettimeofday (2)
changes from a system call to a normal function
call and a few memory accesses.
.SS Finding the vDSO
The base address of the vDSO (if one exists) is passed by the kernel to each program in the initial auxiliary vector (see
.BR getauxval (3)),
via the
.B AT_SYSINFO_EHDR
tag.
You must not assume the vDSO is mapped at any particular location in the user's memory map.
The base address will usually be randomized at run time every time a new process image is created (at
.BR execve (2)
time).
This is done for security reasons,
to prevent "return-to-libc" attacks.
For some architectures, there is also an
.B AT_SYSINFO
tag.
This is used only for locating the vsyscall entry point and is frequently omitted or set to 0 (meaning it's not available).
This tag is a throwback to the initial vDSO work (see
.IR History
below) and its use should be avoided.
.SS File format
Since the vDSO is a fully formed ELF image, you can do symbol lookups on it. This allows new symbols to be added with newer kernel releases, and allows the C library to detect available functionality at run time when running under different kernel versions. Oftentimes the C library will do detection with the first call and then cache the result for subsequent calls.
All symbols are also versioned (using the GNU version format). This allows the kernel to update the function signature without breaking backward compatibility.
This means changing the arguments that the function accepts as well as the return value.
Thus, when looking up a symbol in the vDSO,
you must always include the version
to match the ABI you expect.
Typically the vDSO follows the naming convention of prefixing all symbols with "__vdso_" or "__kernel_"
so as to distinguish them from other standard symbols.
For example, the "gettimeofday" function is named "__vdso_gettimeofday".
You use the standard C calling conventions when calling
any of these functions.
No need to worry about weird register or stack behavior. .SH NOTES
.SS Source
When you compile the kernel,
it will automatically compile and link the vDSO code for you. You will frequently find it under the architecture-specific directory:
find arch/$ARCH/ -name '*vdso*.so*' -o -name '*gate*.so*'
.SS vDSO names
The name of vDSO shared object varies across architectures. It will often show up in things like glibc's
.BR ldd (1)
output.
The exact name should not matter to any code, so do not hardcode it. .if t \{\
.ft CW
\}
.TS
l l.
user ABI vDSO name
_
aarch64 linux-vdso.so.1
ia64 linux-gate.so.1
ppc/32 linux-vdso32.so.1
ppc/64 linux-vdso64.so.1
s390 linux-vdso32.so.1
s390x linux-vdso64.so.1
sh linux-gate.so.1
i386 linux-gate.so.1x86_64 linux-vdso.so.1
x86/x32 linux-vdso.so.1
.TE
.if t \{\
.in
.ft P
\}
.SH ARCHITECTURE_SPECIFIC NOTES
The subsections below provide architecture-specific notes on the vDSO.
Note that the vDSO that is used is based on the ABI of your user-space code and not the ABI of the kernel.
Thus, for example,
when you run an i386 32-bit ELF binary,
you'll get the same vDSO regardless of whether you run it under an i386 32-bit kernel or under an x86_64 64-bit kernel.
Thus, the name of the user-space ABI should be used to determine which of the sections below is relevant.
.SS ARM functions
.\" See linux/arch/arm/kernel/entry-armv.S
.\" See linux/Documentation/arm/kernel_user_helpers.txt
The ARM port has a code page full of utility functions.
Since it's just a raw page of code, there is no ELF information for doing symbol lookups or versioning.
It does provide support for different versions though.
For information on this code page,
it's best to refer to the kernel documentation
as it's extremely detailed and covers everything you need to know:
.IR Documentation/arm/kernel_user_helpers.txt .
.SS aarch64 functions
.\" See linux/arch/arm64/kernel/vdso/vdso.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6.39__kernel_gettimeofday LINUX_2.6.39__kernel_clock_gettime LINUX_2.6.39__kernel_clock_getres LINUX_2.6.39
.TE
.if t \{\
.in
.ft P
\}
.SS bfin (Blackfin) functions
.\" See linux/arch/blackfin/kernel/fixed_code.S
.\" See http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
As this CPU lacks a memory management unit (MMU),
it doesn't set up a vDSO in the normal sense.
Instead, it maps at boot time a few raw functions into
a fixed location in memory.
User-space applications then call directly into that region. There is no provision for backward compatibility
beyond sniffing raw opcodes,
but as this is an embedded CPU, it can get away with things\(emsome of the object formats it runs aren't even ELF based (they're bFLT/FLAT).
For information on this code page,
it's best to refer to the public documentation:
.br
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code
.SS ia64 (Itanium) functions
.\" See linux/arch/ia64/kernel/gate.lds.S
.\" Also linux/arch/ia64/kernel/fsys.S and linux/Documentation/ia64/fsys.txt The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigtramp LINUX_2.5__kernel_syscall_via_break LINUX_2.5__kernel_syscall_via_epc LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
The Itanium port is somewhat tricky.
In addition to the vDSO above, it also has "light-weight system calls" (also known as "fast syscalls" or "fsys").
You can invoke these via the
.I __kernel_syscall_via_epc
vDSO helper.
The system calls listed here have the same semantics as if you called them directly via
.BR syscall (2),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
.ft P
\}
.SS parisc (hppa) functions
.\" See linux/arch/parisc/kernel/syscall.S
.\" See linux/Documentation/parisc/registers
The parisc port has a code page full of utility functions called a gateway page.
Rather than use the normal ELF auxiliary vector approach,
it passes the address of
the page to the process via the SR2 register.
The permissions on the page are such that merely executing those addresses automatically executes with kernel privileges and not in user-space. This is done to match the way HP-UX works.
Since it's just a raw page of code, there is no ELF information for doing symbol lookups or versioning.
Simply call into the appropriate offset via the branch instruction, for example:
ble <offset>(%sr2, %r0)
.if t \{\
.ft CW
\}
.TS
l l.
offset function
_
00b0 lws_entry
00e0 set_thread_pointer
0100 linux_gateway_entry (syscall)
0268 syscall_nosys
0274 tracesys
0324 tracesys_next
0368 tracesys_exit
03a0 tracesys_sigexit
03b8 lws_start
03dc lws_exit_nosys
03e0 lws_exit
03e4 lws_compare_and_swap64
03e8 lws_compare_and_swap
0404 cas_wouldblock
0410 cas_action
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/32 functions
.\" See linux/arch/powerpc/kernel/vdso32/vdso32.lds.S
The table below lists the symbols exported by the vDSO.
The functions marked with a
.I *
are available only when the kernel is
a PowerPC64 (64-bit) kernel.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu \fI*\fR LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt32 LINUX_2.6.15__kernel_sigtramp32 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS ppc/64 functions
.\" See linux/arch/powerpc/kernel/vdso64/vdso64.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.15__kernel_clock_gettime LINUX_2.6.15__kernel_datapage_offset LINUX_2.6.15__kernel_get_syscall_map LINUX_2.6.15__kernel_get_tbfreq LINUX_2.6.15__kernel_getcpu LINUX_2.6.15__kernel_gettimeofday LINUX_2.6.15__kernel_sigtramp_rt64 LINUX_2.6.15__kernel_sync_dicache LINUX_2.6.15__kernel_sync_dicache_p5 LINUX_2.6.15
.TE
.if t \{\
.in
.ft P
\}
.SS s390 functions
.\" See linux/arch/s390/kernel/vdso32/vdso32.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS s390x functions
.\" See linux/arch/s390/kernel/vdso64/vdso64.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_clock_getres LINUX_2.6.29__kernel_clock_gettime LINUX_2.6.29__kernel_gettimeofday LINUX_2.6.29
.TE
.if t \{\
.in
.ft P
\}
.SS sh (SuperH) functions
.\" See linux/arch/sh/kernel/vsyscall/vsyscall.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_rt_sigreturn LINUX_2.6__kernel_sigreturn LINUX_2.6__kernel_vsyscall LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS i386 functions
.\" See linux/arch/x86/vdso/vdso32/vdso32.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___kernel_sigreturn LINUX_2.5__kernel_rt_sigreturn LINUX_2.5__kernel_vsyscall LINUX_2.5
.TE
.if t \{\
.in
.ft P
\}
.SS x86_64 functions
.\" See linux/arch/x86/vdso/vdso.lds.S
The table below lists the symbols exported by the vDSO.
All of these symbols are also available without the "__vdso_" prefix, but you should ignore those and stick to the names below.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS x86/x32 functions
.\" See linux/arch/x86/vdso/vdso32.lds.S
The table below lists the symbols exported by the vDSO.
.if t \{\
.ft CW
\}
.TS
l l.
symbol version
___vdso_clock_gettime LINUX_2.6__vdso_getcpu LINUX_2.6__vdso_gettimeofday LINUX_2.6__vdso_time LINUX_2.6
.TE
.if t \{\
.in
.ft P
\}
.SS History
The vDSO was originally just a single function\(emthe vsyscall. In older kernels, you might see that name
in a process's memory map rather than "vdso".
Over time, people realized that this mechanism
was a great way to pass more functionality
to user space, so it was reconceived as a vDSO in the current format. .SH SEE ALSO
.BR syscalls (2),
.BR getauxval (3),
.BR proc (5)
The documents, examples, and source code in the Linux source code tree:
.in +4n
.nf
Documentation/ABI/stable/vdso Documentation/ia64/fsys.txtDocumentation/vDSO/* (includes examples of using the vDSO)
find arch/ -iname '*vdso*' -o -iname '*gate*'
.fi
.in
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · On Wednesday 01 January 2014 14:56:15 Michael Kerrisk (man-pages) wrote:
.SH DESCRIPTION
The "vDSO" is a small shared library that
the kernel automatically maps into the
address space of all user-space applications.
Applications usually do not need to concern themselves with these details as the vDSO is most commonly called by the C library.
This way you can code in the normal way using standard functions and the C library will take care
of using any functionality that is available via the vDSO.
seems like sentences in this new version are excessively wrapped. for example, this first one will easily fit into two lines. is this just due to the editing process ? content changed but things weren't re-wrapped ? or do you not wrap to 80 cols ? (this is beyond the rule of "wrap to commas and periods").
Quoted 2 lines
There are some system calls the kernel provides that user space code ends up using frequently,
shouldn't this be "user-space" now ?
Quoted 1 line
.SH
ARCHITECTURE_SPECIFICNOTES
change the _ to a space ?
Quoted 2 lines
The subsections below provide architecture-specific notes on the vDSO.
another example of a sentence easily fitting on one line (there are many)
Quoted 8 lines
Note that the vDSO that is used is based on the ABI of your user-space code and not the ABI of the kernel.
Thus, for example,
when you run an i386 32-bit ELF binary,
you'll get the same vDSO regardless of whether you run it under an i386 32-bit kernel or under anx86_6464-bit kernel.
Thus, the name of the user-space ABI should be used to determine which of the sections below is relevant.
having two sentences in a row start with "Thus" is a little funny sounding. could change one to "So" and largely be the same.
Quoted 16 lines
The system calls listed here have the same semantics as if you called them directly via
.BR syscall (2),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpid
Quoted 8 lines
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
.ft P
\}
my troff foo is not strong. this section renders funny for me -- there's three blank lines above the table. do you see the same thing ?
The Itanium port is somewhat tricky. In addition to the vDSO above, it also has "light-weight system calls" (also known as "fast syscalls" or "fsys"). You can invoke these via the __kernel_syscall_via_epc vDSO helper. The system calls listed here have the same semantics as if you called them directly via syscall(2), so refer to the relevant documentation for each. The table below lists the functions available via this mechanism.
function
────────────────
clock_gettime
getcpu
Quoted 10 lines
.SS parisc (hppa) functions
.\" Seelinux/arch/parisc/kernel/syscall.S
.\" See linux/Documentation/parisc/registers
The parisc port has a code page full of utility functions called a gateway page.
Rather than use the normal ELF auxiliary vector approach,
it passes the address of
the page to the process via the SR2 register.
The permissions on the page are such that merely executing those addresses automatically executes with kernel privileges and not in user-space.
should be "user space" i think.
-mike
Hi Mike,
Quoted 11 lines · Mike Frysinger
Quoted 9 lines · On Wednesday 01 January 2014 14:56:15 Michael Kerrisk (man-pages) wrote:
.SH DESCRIPTION
The "vDSO" is a small shared library that
the kernel automatically maps into the
address space of all user-space applications.
Applications usually do not need to concern themselves with these details as the vDSO is most commonly called by the C library.
This way you can code in the normal way using standard functions and the C library will take care
of using any functionality that is available via the vDSO.
Quoted 5 lines
seems like sentences in this new version are excessively wrapped. for example, this first one will easily fit into two lines. is this just due to the editing process ? content changed but things weren't re-wrapped ? or do you not wrap to 80 cols ? (this is beyond the rule of "wrap to commas and periods").
I prefer wrapping to about 75 columns or less. (I document this in man-pages(7), but perhaps that's not prominently enough.) Reduces the chances of wrapping problems with patches in some mailers. (And I may have been overenthusiastic in wrapping lines that were close to 75 chars.)
Quoted 4 lines
Quoted 2 lines
There are some system calls the kernel provides that user space code ends up using frequently,
shouldn't this be "user-space" now ?
Yep.
Quoted 3 lines
Quoted 1 line
.SH
ARCHITECTURE_SPECIFICNOTESchange the _ to a space ?
Typo. Should have been "-"
Quoted 14 lines
Quoted 2 lines
The subsections below provide architecture-specific notes on the vDSO.
another example of a sentence easily fitting on one line (there are many)
Quoted 8 lines
Note that the vDSO that is used is based on the ABI of your user-space code and not the ABI of the kernel.
Thus, for example,
when you run an i386 32-bit ELF binary,
you'll get the same vDSO regardless of whether you run it under an i386 32-bit kernel or under anx86_6464-bit kernel.
Thus, the name of the user-space ABI should be used to determine which of the sections below is relevant.
Quoted 2 lines
having two sentences in a row start with "Thus" is a little funny sounding. could change one to "So" and largely be the same.
Thanks. Fixed now.
Quoted 25 lines
Quoted 16 lines
The system calls listed here have the same semantics as if you called them directly via
.BR syscall (2),
so refer to the relevant
documentation for each.
The table below lists the functions available via this mechanism. .if t \{\
.ft CW
\}
.TS
l.
function
_clock_gettime
getcpu
getpidQuoted 8 lines
getppid
gettimeofdayset_tid_address
.TE
.if t \{\
.in
.ft P
\}
Quoted 2 lines
my troff foo is not strong. this section renders funny for me -- there's three blank lines above the table. do you see the same thing ?
Strange. I don't.
Quoted 26 lines
The Itanium port is somewhat tricky. In addition to the vDSO above, it also has "light-weight system calls" (also known as "fast syscalls" or "fsys"). You can invoke these via the
__kernel_syscall_via_epcvDSO helper. The system calls listed here have the same semantics as if you called them directly via syscall(2), so refer to the relevant documentation for each. The table below lists the functions available via this mechanism.function
────────────────
clock_gettime
getcpuQuoted 10 lines
.SS parisc (hppa) functions
.\" Seelinux/arch/parisc/kernel/syscall.S
.\" See linux/Documentation/parisc/registers
The parisc port has a code page full of utility functions called a gateway page.
Rather than use the normal ELF auxiliary vector approach,
it passes the address of
the page to the process via the SR2 register.
The permissions on the page are such that merely executing those addresses automatically executes with kernel privileges and not in user-space.
Quoted 1 line
should be "user space" i think.
Yup.
Thanks for checking the page, Mike.
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html