OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man2 / arch_prctl.2
1 .\" Copyright (C) 2003 Andi Kleen
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH ARCH_PRCTL 2 2007-12-26 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 arch_prctl \- set architecture-specific thread state
28 .SH SYNOPSIS
29 .nf
30 .B #include <asm/prctl.h>
31 .br
32 .B #include <sys/prctl.h>
33 .sp
34 .BI "int arch_prctl(int " code ", unsigned long " addr );
35 .BI "int arch_prctl(int " code ", unsigned long *" addr );
36 .fi
37 .SH DESCRIPTION
38 The
39 .BR arch_prctl ()
40 function sets architecture-specific process or thread state.
41 .I code
42 selects a subfunction
43 and passes argument
44 .I addr
45 to it;
46 .I addr
47 is interpreted as either an
48 .I "unsigned long"
49 for the "set" operations, or as an
50 .IR "unsigned long\ *" ,
51 for the "get" operations.
52 .LP
53 Subfunctions for x86-64 are:
54 .TP
55 .B ARCH_SET_FS
56 Set the 64-bit base for the
57 .I FS
58 register to
59 .IR addr .
60 .TP
61 .B ARCH_GET_FS
62 Return the 64-bit base value for the
63 .I FS
64 register of the current thread in the
65 .I unsigned long
66 pointed to by
67 .IR addr .
68 .TP
69 .B ARCH_SET_GS
70 Set the 64-bit base for the
71 .I GS
72 register to
73 .IR addr .
74 .TP
75 .B ARCH_GET_GS
76 Return the 64-bit base value for the
77 .I GS
78 register of the current thread in the
79 .I unsigned long
80 pointed to by
81 .IR addr .
82 .SH RETURN VALUE
83 On success,
84 .BR arch_prctl ()
85 returns 0; on error, \-1 is returned, and
86 .I errno
87 is set to indicate the error.
88 .SH ERRORS
89 .TP
90 .B EFAULT
91 .I addr
92 points to an unmapped address or is outside the process address space.
93 .TP
94 .B EINVAL
95 .I code
96 is not a valid subcommand.
97 .TP
98 .B EPERM
99 .I addr
100 is outside the process address space.
101 .\" .SH AUTHOR
102 .\" Man page written by Andi Kleen.
103 .SH CONFORMING TO
104 .BR arch_prctl ()
105 is a Linux/x86-64 extension and should not be used in programs intended
106 to be portable.
107 .SH NOTES
108 .BR arch_prctl ()
109 is supported only on Linux/x86-64 for 64-bit programs currently.
110
111 The 64-bit base changes when a new 32-bit segment selector is loaded.
112
113 .B ARCH_SET_GS
114 is disabled in some kernels.
115
116 Context switches for 64-bit segment bases are rather expensive.
117 It may be a faster alternative to set a 32-bit base using a
118 segment selector by setting up an LDT with
119 .BR modify_ldt (2)
120 or using the
121 .BR set_thread_area (2)
122 system call in kernel 2.5 or later.
123 .BR arch_prctl ()
124 is needed only when you want to set bases that are larger than 4GB.
125 Memory in the first 2GB of address space can be allocated by using
126 .BR mmap (2)
127 with the
128 .B MAP_32BIT
129 flag.
130
131 As of version 2.7, glibc provides no prototype for
132 .BR arch_prctl ().
133 You have to declare it yourself for now.
134 This may be fixed in future glibc versions.
135
136 .I FS
137 may be already used by the threading library.
138 .SH SEE ALSO
139 .BR mmap (2),
140 .BR modify_ldt (2),
141 .BR prctl (2),
142 .BR set_thread_area (2)
143
144 AMD X86-64 Programmer's manual
145 .SH COLOPHON
146 This page is part of release 3.68 of the Linux
147 .I man-pages
148 project.
149 A description of the project,
150 information about reporting bugs,
151 and the latest version of this page,
152 can be found at
153 \%http://www.kernel.org/doc/man\-pages/.