mirror of https://github.com/mkerrisk/man-pages
set_thread_area.2: Various fixes for Andy Lutomirski's patch
Notably, various info about get_thread_area() got dropped during the merge of the two pages. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
5c3f9e21f1
commit
520789667e
|
@ -10,15 +10,26 @@
|
||||||
.SH NAME
|
.SH NAME
|
||||||
set_thread_area \- set a GDT entry for thread-local storage
|
set_thread_area \- set a GDT entry for thread-local storage
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
.nf
|
||||||
.B #include <linux/unistd.h>
|
.B #include <linux/unistd.h>
|
||||||
.br
|
|
||||||
.B #include <asm/ldt.h>
|
.B #include <asm/ldt.h>
|
||||||
.sp
|
|
||||||
.BI "int get_thread_area(struct user_desc *" u_info );
|
.BI "int get_thread_area(struct user_desc *" u_info );
|
||||||
.BI "int set_thread_area(struct user_desc *" u_info );
|
.BI "int set_thread_area(struct user_desc *" u_info );
|
||||||
.in +4n
|
.fi
|
||||||
.nf
|
|
||||||
|
|
||||||
|
.IR Note :
|
||||||
|
There are no glibc wrappers for these system calls; see NOTES.
|
||||||
|
.SH DESCRIPTION
|
||||||
|
Linux dedicates three global descriptor table (GDT) entries for
|
||||||
|
thread-local storage.
|
||||||
|
For more information about the GDT, see the
|
||||||
|
Intel Software Developer's Manual or the AMD Architecture Programming Manual.
|
||||||
|
|
||||||
|
Both of these system calls take an argument that is a pointer
|
||||||
|
to a structure of the following type:
|
||||||
|
|
||||||
|
.in +4n
|
||||||
struct user_desc {
|
struct user_desc {
|
||||||
unsigned int entry_number;
|
unsigned int entry_number;
|
||||||
unsigned long base_addr;
|
unsigned long base_addr;
|
||||||
|
@ -30,21 +41,13 @@ struct user_desc {
|
||||||
unsigned int seg_not_present:1;
|
unsigned int seg_not_present:1;
|
||||||
unsigned int useable:1;
|
unsigned int useable:1;
|
||||||
};
|
};
|
||||||
.fi
|
|
||||||
.in
|
.in
|
||||||
|
|
||||||
.IR Note :
|
|
||||||
There is no glibc wrapper for this system call; see NOTES.
|
|
||||||
.SH DESCRIPTION
|
|
||||||
Linux dedicates three global descriptor table (GDT) entries for
|
|
||||||
thread-local storage. For more information about the LDT, see the
|
|
||||||
Intel Software Developer's Manual or the AMD Architecture Programming Manual.
|
|
||||||
|
|
||||||
.BR get_thread_area ()
|
.BR get_thread_area ()
|
||||||
reads the GDT entry indicated by
|
reads the GDT entry indicated by
|
||||||
.I u_info\->entry_number
|
.I u_info\->entry_number
|
||||||
and fills in the rest of the fields in
|
and fills in the rest of the fields in
|
||||||
.I u_info.
|
.IR u_info .
|
||||||
|
|
||||||
.BR set_thread_area ()
|
.BR set_thread_area ()
|
||||||
sets a TLS entry in the GDT.
|
sets a TLS entry in the GDT.
|
||||||
|
@ -77,56 +80,76 @@ is considered "empty" if
|
||||||
.I read_exec_only
|
.I read_exec_only
|
||||||
and
|
and
|
||||||
.I seg_not_present
|
.I seg_not_present
|
||||||
are set to 1 and all of the other fields are 0. If an "empty" descriptor
|
are set to 1 and all of the other fields are 0.
|
||||||
is passed to
|
If an "empty" descriptor is passed to
|
||||||
.BR set_thread_area,
|
.BR set_thread_area,
|
||||||
the corresponding TLS entry will be cleared. See BUGS for additional
|
the corresponding TLS entry will be cleared.
|
||||||
details.
|
See BUGS for additional details.
|
||||||
.PP
|
.PP
|
||||||
On Linux 3.19 and newer,
|
Since Linux 3.19,
|
||||||
.BR set_thread_area ()
|
.BR set_thread_area ()
|
||||||
cannot be used to write non-present segments, 16-bit segments, or code
|
cannot be used to write non-present segments, 16-bit segments, or code
|
||||||
segments, although clearing a segment is still acceptable.
|
segments, although clearing a segment is still acceptable.
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
.BR set_thread_area ()
|
These system calls
|
||||||
returns 0 on success, and \-1 on failure, with
|
return 0 on success, and \-1 on failure, with
|
||||||
.I errno
|
.I errno
|
||||||
set appropriately.
|
set appropriately.
|
||||||
.SH ERRORS
|
.SH ERRORS
|
||||||
.TP
|
.TP
|
||||||
.B EINVAL
|
|
||||||
\fIu_info\->entry_number\fP is out of bounds.
|
|
||||||
.TP
|
|
||||||
.B EFAULT
|
.B EFAULT
|
||||||
\fIu_info\fP is an invalid pointer.
|
\fIu_info\fP is an invalid pointer.
|
||||||
.TP
|
.TP
|
||||||
.B ESRCH
|
.B EINVAL
|
||||||
A free TLS entry could not be located.
|
\fIu_info\->entry_number\fP is out of bounds.
|
||||||
|
.TP
|
||||||
.B ENOSYS
|
.B ENOSYS
|
||||||
.BR get_thread_area (2)
|
.BR get_thread_area (2)
|
||||||
or
|
or
|
||||||
.BR set_thread_area (2)
|
.BR set_thread_area (2)
|
||||||
was invoked as a 64-bit syscall.
|
was invoked as a 64-bit system call.
|
||||||
|
.TP
|
||||||
|
.B ESRCH
|
||||||
|
.RB ( set_thread_area ())
|
||||||
|
A free TLS entry could not be located.
|
||||||
.SH VERSIONS
|
.SH VERSIONS
|
||||||
A version of
|
|
||||||
.BR set_thread_area ()
|
.BR set_thread_area ()
|
||||||
first appeared in Linux 2.5.29.
|
first appeared in Linux 2.5.29.
|
||||||
|
.BR get_thread_area ()
|
||||||
|
first appeared in Linux 2.5.32.
|
||||||
.SH CONFORMING TO
|
.SH CONFORMING TO
|
||||||
.BR set_thread_area ()
|
.BR set_thread_area ()
|
||||||
is Linux-specific and should not be used in programs that are intended
|
is Linux-specific and should not be used in programs that are intended
|
||||||
to be portable.
|
to be portable.
|
||||||
|
.SH NOTES
|
||||||
|
Glibc does not provide wrappers for these system calls,
|
||||||
|
since they are generally intended for use only by threading libraries.
|
||||||
|
In the unlikely event that you want to call them directly, use
|
||||||
|
.BR syscall (2).
|
||||||
|
.PP
|
||||||
|
.BR arch_prctl (2)
|
||||||
|
can interfere with
|
||||||
|
.BR set_thread_area (2).
|
||||||
|
See
|
||||||
|
.BR arch_prctl (2)
|
||||||
|
for more details.
|
||||||
|
This is not normally a problem, as
|
||||||
|
.BR arch_prctl (2)
|
||||||
|
is normally used only by 64-bit programs.
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
On 64-bit kernels before Linux 3.19, one of the padding bits in
|
On 64-bit kernels before Linux 3.19, one of the padding bits in
|
||||||
.I user_desc,
|
.IR user_desc ,
|
||||||
if set, would prevent the descriptor from being considered empty.
|
if set, would prevent the descriptor from being considered empty.
|
||||||
As a result, the only reliable way to clear a TLS entry is to use
|
As a result, the only reliable way to clear a TLS entry is to use
|
||||||
memset to zero the entire
|
.BR memset (3)
|
||||||
|
to zero the entire
|
||||||
.I user_desc
|
.I user_desc
|
||||||
structure, including padding bits, and then to set the
|
structure, including padding bits, and then to set the
|
||||||
.I read_exec_only
|
.I read_exec_only
|
||||||
and
|
and
|
||||||
.I seg_not_present
|
.I seg_not_present
|
||||||
bits. On Linux 3.19, a
|
bits.
|
||||||
|
On Linux 3.19, a
|
||||||
.I user_desc
|
.I user_desc
|
||||||
consisting entirely of zeros except for
|
consisting entirely of zeros except for
|
||||||
.I entry_number
|
.I entry_number
|
||||||
|
@ -135,20 +158,6 @@ behaved differently on older kernels.
|
||||||
.PP
|
.PP
|
||||||
Prior to Linux 3.19, the DS and ES segment registers must not reference
|
Prior to Linux 3.19, the DS and ES segment registers must not reference
|
||||||
TLS entries.
|
TLS entries.
|
||||||
.SH NOTES
|
|
||||||
Glibc does not provide a wrapper for this system call,
|
|
||||||
since it is generally intended only for use by threading libraries.
|
|
||||||
In the unlikely event that you want to call it directly, use
|
|
||||||
.BR syscall (2).
|
|
||||||
.PP
|
|
||||||
.BR arch_prctl (2)
|
|
||||||
can interfere with
|
|
||||||
.BR set_thread_area (2).
|
|
||||||
See
|
|
||||||
.BR arch_prctl (2)
|
|
||||||
for more details. This is not normally a problem, as
|
|
||||||
.BR arch_prctl (2)
|
|
||||||
is normally only used by 64-bit programs.
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR arch_prctl (2),
|
.BR arch_prctl (2),
|
||||||
.BR modify_ldt (2)
|
.BR modify_ldt (2)
|
||||||
|
|
Loading…
Reference in New Issue