1 .\" Copyright (C) 2003 Andi Kleen
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH ARCH_PRCTL 2 2021-08-27 "Linux" "Linux Programmer's Manual"
27 arch_prctl \- set architecture-specific thread state
30 .BR "#include <asm/prctl.h>" " /* Definition of " ARCH_* " constants */"
31 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
32 .B #include <unistd.h>
34 .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long " addr );
35 .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long *" addr );
39 glibc provides no wrapper for
41 necessitating the use of
45 sets architecture-specific process or thread state.
52 is interpreted as either an
54 for the "set" operations, or as an
55 .IR "unsigned long\ *" ,
56 for the "get" operations.
58 Subfunctions for both x86 and x86-64 are:
60 .BR ARCH_SET_CPUID " (since Linux 4.12)"
61 .\" commit e9ea1e7f53b852147cbd568b0568c7ad97ec21a3
68 instruction for the calling thread.
69 The instruction is enabled by default.
70 If disabled, any execution of a
72 instruction will instead generate a
75 This feature can be used to emulate
77 results that differ from what the underlying
78 hardware would have produced (e.g., in a paravirtualization setting).
82 setting is preserved across
86 but reset to the default (i.e.,
91 .BR ARCH_GET_CPUID " (since Linux 4.12)"
92 Return the setting of the flag manipulated by
94 as the result of the system call (1 for enabled, 0 for disabled).
98 Subfunctions for x86-64 only are:
101 Set the 64-bit base for the
107 Return the 64-bit base value for the
109 register of the calling thread in the
115 Set the 64-bit base for the
121 Return the 64-bit base value for the
123 register of the calling thread in the
130 returns 0; on error, \-1 is returned, and
132 is set to indicate the error.
137 points to an unmapped address or is outside the process address space.
141 is not a valid subcommand.
145 was requested, but the underlying hardware does not support CPUID faulting.
149 is outside the process address space.
151 .\" Man page written by Andi Kleen.
154 is a Linux/x86-64 extension and should not be used in programs intended
158 is supported only on Linux/x86-64 for 64-bit programs currently.
160 The 64-bit base changes when a new 32-bit segment selector is loaded.
163 is disabled in some kernels.
165 Context switches for 64-bit segment bases are rather expensive.
166 As an optimization, if a 32-bit TLS base address is used,
168 may use a real TLS entry as if
169 .BR set_thread_area (2)
170 had been called, instead of manipulating the segment base register directly.
171 Memory in the first 2\ GB of address space can be allocated by using
177 Because of the aforementioned optimization, using
180 .BR set_thread_area (2)
181 in the same thread is dangerous, as they may overwrite each other's
185 may be already used by the threading library.
188 directly are very likely to crash.
193 .BR set_thread_area (2)
195 AMD X86-64 Programmer's manual