1ARCH_PRCTL(2)              Linux Programmer's Manual             ARCH_PRCTL(2)
2
3
4

NAME

6       arch_prctl - set architecture-specific thread state
7

SYNOPSIS

9       #include <asm/prctl.h>
10       #include <sys/prctl.h>
11
12       int arch_prctl(int code, unsigned long addr);
13       int arch_prctl(int code, unsigned long *addr);
14

DESCRIPTION

16       The  arch_prctl() function sets architecture-specific process or thread
17       state.  code selects a subfunction and passes argument addr to it; addr
18       is  interpreted as either an unsigned long for the "set" operations, or
19       as an unsigned long *, for the "get" operations.
20
21       Sub functions for x86-64 are:
22
23       ARCH_SET_FS
24              Set the 64-bit base for the FS register to addr.
25
26       ARCH_GET_FS
27              Return the 64-bit base value for the FS register of the  current
28              thread in the unsigned long pointed to by addr.
29
30       ARCH_SET_GS
31              Set the 64-bit base for the GS register to addr.
32
33       ARCH_GET_GS
34              Return  the 64-bit base value for the GS register of the current
35              thread in the unsigned long pointed to by addr.
36

RETURN VALUE

38       On success, arch_prctl() returns 0; on error, -1 is returned, and errno
39       is set to indicate the error.
40

ERRORS

42       EFAULT addr  points  to  an  unmapped address or is outside the process
43              address space.
44
45       EINVAL code is not a valid subcommand.
46
47       EPERM  addr is outside the process address space.
48

CONFORMING TO

50       arch_prctl() is a Linux/x86-64 extension and should not be used in pro‐
51       grams intended to be portable.
52

NOTES

54       arch_prctl() is only supported on Linux/x86-64 for 64-bit programs cur‐
55       rently.
56
57       The 64-bit base changes when a new 32-bit segment selector is loaded.
58
59       ARCH_SET_GS is disabled in some kernels.
60
61       Context switches for 64-bit segment bases are rather expensive.  It may
62       be  a  faster alternative to set a 32-bit base using a segment selector
63       by setting up an LDT with modify_ldt(2) or using the set_thread_area(2)
64       system  call  in kernel 2.5 or later.  arch_prctl() is only needed when
65       you want to set bases that are larger than 4GB.  Memory  in  the  first
66       2GB  of  address  space  can  be  allocated  by  using mmap(2) with the
67       MAP_32BIT flag.
68
69       As of version 2.7, glibc provides no prototype for  arch_prctl().   You
70       have to declare it yourself for now.  This may be fixed in future glibc
71       versions.
72
73       FS may be already used by the threading library.
74

SEE ALSO

76       mmap(2), modify_ldt(2), prctl(2), set_thread_area(2)
77
78       AMD X86-64 Programmer's manual
79

COLOPHON

81       This page is part of release 3.25 of the Linux  man-pages  project.   A
82       description  of  the project, and information about reporting bugs, can
83       be found at http://www.kernel.org/doc/man-pages/.
84
85
86
87Linux                             2007-12-26                     ARCH_PRCTL(2)
Impressum