]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/arch_prctl.2
modify_ldt.2: Overhaul the documentation
[thirdparty/man-pages.git] / man2 / arch_prctl.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2003 Andi Kleen
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
4784c377 24.\"
498c6aa6 25.TH ARCH_PRCTL 2 2007-12-26 "Linux" "Linux Programmer's Manual"
fea681da 26.SH NAME
498c6aa6 27arch_prctl \- set architecture-specific thread state
fea681da 28.SH SYNOPSIS
498c6aa6 29.nf
fea681da 30.B #include <asm/prctl.h>
3af8df2f 31.br
fea681da
MK
32.B #include <sys/prctl.h>
33.sp
52e87bbe 34.BI "int arch_prctl(int " code ", unsigned long " addr );
498c6aa6
MK
35.BI "int arch_prctl(int " code ", unsigned long *" addr );
36.fi
fea681da
MK
37.SH DESCRIPTION
38The
e511ffb6 39.BR arch_prctl ()
498c6aa6 40function sets architecture-specific process or thread state.
fea681da
MK
41.I code
42selects a subfunction
43and passes argument
c13182ef 44.I addr
498c6aa6
MK
45to it;
46.I addr
47is interpreted as either an
48.I "unsigned long"
49for the "set" operations, or as an
5049da5b 50.IR "unsigned long\ *" ,
498c6aa6 51for the "get" operations.
fea681da 52.LP
09ddc8db 53Subfunctions for x86-64 are:
fea681da
MK
54.TP
55.B ARCH_SET_FS
d4725a0e 56Set the 64-bit base for the
fea681da
MK
57.I FS
58register to
59.IR addr .
60.TP
61.B ARCH_GET_FS
d4725a0e 62Return the 64-bit base value for the
fea681da 63.I FS
c13182ef 64register of the current thread in the
fea681da 65.I unsigned long
40725279 66pointed to by
498c6aa6 67.IR addr .
fea681da
MK
68.TP
69.B ARCH_SET_GS
d4725a0e 70Set the 64-bit base for the
fea681da
MK
71.I GS
72register to
73.IR addr .
74.TP
75.B ARCH_GET_GS
d4725a0e 76Return the 64-bit base value for the
fea681da 77.I GS
c13182ef 78register of the current thread in the
fea681da 79.I unsigned long
40725279 80pointed to by
498c6aa6 81.IR addr .
3961a41b 82.SH RETURN VALUE
498c6aa6 83On success,
3961a41b
MK
84.BR arch_prctl ()
85returns 0; on error, \-1 is returned, and
86.I errno
87is set to indicate the error.
a1d5f77c
MK
88.SH ERRORS
89.TP
90.B EFAULT
91.I addr
92points to an unmapped address or is outside the process address space.
93.TP
94.B EINVAL
95.I code
96is not a valid subcommand.
97.TP
98.B EPERM
99.I addr
100is outside the process address space.
101.\" .SH AUTHOR
102.\" Man page written by Andi Kleen.
47297adb 103.SH CONFORMING TO
a1d5f77c
MK
104.BR arch_prctl ()
105is a Linux/x86-64 extension and should not be used in programs intended
106to be portable.
fea681da 107.SH NOTES
31e9a9ec 108.BR arch_prctl ()
33a0ccb2 109is supported only on Linux/x86-64 for 64-bit programs currently.
fea681da 110
d4725a0e 111The 64-bit base changes when a new 32-bit segment selector is loaded.
fea681da
MK
112
113.B ARCH_SET_GS
114is disabled in some kernels.
115
d4725a0e
MK
116Context switches for 64-bit segment bases are rather expensive.
117It may be a faster alternative to set a 32-bit base using a
118segment selector by setting up an LDT with
fea681da 119.BR modify_ldt (2)
c13182ef 120or using the
fea681da 121.BR set_thread_area (2)
498c6aa6 122system call in kernel 2.5 or later.
e511ffb6 123.BR arch_prctl ()
33a0ccb2 124is needed only when you want to set bases that are larger than 4GB.
fea681da
MK
125Memory in the first 2GB of address space can be allocated by using
126.BR mmap (2)
127with the
49363fa6 128.B MAP_32BIT
fea681da
MK
129flag.
130
498c6aa6 131As of version 2.7, glibc provides no prototype for
64f828d5
MK
132.BR arch_prctl ().
133You have to declare it yourself for now.
134This may be fixed in future glibc versions.
fea681da 135
c13182ef 136.I FS
fea681da 137may be already used by the threading library.
47297adb 138.SH SEE ALSO
fea681da
MK
139.BR mmap (2),
140.BR modify_ldt (2),
141.BR prctl (2),
142.BR set_thread_area (2)
173fe7e7 143
fea681da 144AMD X86-64 Programmer's manual