1ARCH_PRCTL(2) Linux Programmer's Manual ARCH_PRCTL(2)
2
3
4
6 arch_prctl - set architecture specific thread state
7
9 #include <asm/prctl.h>
10
11 #include <sys/prctl.h>
12
13 int arch_prctl(int code, unsigned long addr)
14
16 The arch_prctl() function sets architecture specific process or thread
17 state. code selects a subfunction and passes argument addr to it.
18
19 Sub functions for x86-64 are:
20
21 ARCH_SET_FS
22 Set the 64bit base for the FS register to addr.
23
24 ARCH_GET_FS
25 Return the 64bit base value for the FS register of the current
26 thread in the unsigned long pointed to by the address parameter
27
28 ARCH_SET_GS
29 Set the 64bit base for the GS register to addr.
30
31 ARCH_GET_GS
32 Return the 64bit base value for the GS register of the current
33 thread in the unsigned long pointed to by the address parameter.
34
36 arch_prctl() is only supported on Linux/x86-64 for 64bit programs cur‐
37 rently.
38
39 The 64bit base changes when a new 32bit segment selector is loaded.
40
41 ARCH_SET_GS is disabled in some kernels.
42
43 Context switches for 64bit segment bases are rather expensive. It may
44 be a faster alternative to set a 32bit base using a segment selector by
45 setting up an LDT with modify_ldt(2) or using the set_thread_area(2)
46 system call in a 2.5 kernel. arch_prctl() is only needed when you want
47 to set bases that are larger than 4GB. Memory in the first 2GB of
48 address space can be allocated by using mmap(2) with the MAP_32BIT
49 flag.
50
51 As of version 2.3.5, glibc provides no prototype for arch_prctl(). You
52 have to declare it yourself for now. This may be fixed in future glibc
53 versions.
54
55 FS may be already used by the threading library.
56
58 EFAULT addr points to an unmapped address or is outside the process
59 address space.
60
61 EINVAL code is not a valid subcommand.
62
63 EPERM addr is outside the process address space.
64
66 Man page written by Andi Kleen.
67
69 arch_prctl() is a Linux/x86-64 extension and should not be used in pro‐
70 grams intended to be portable.
71
73 mmap(2), modify_ldt(2), prctl(2), set_thread_area(2)
74
75 AMD X86-64 Programmer's manual
76
77
78
79Linux 2.4.20 2003-02-02 ARCH_PRCTL(2)