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