1 .\" Copyright (C) 2003 Andi Kleen
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH ARCH_PRCTL 2 2021-08-27 "Linux" "Linux Programmer's Manual"
7 arch_prctl \- set architecture-specific thread state
10 .RI ( libc ", " \-lc )
13 .BR "#include <asm/prctl.h>" " /* Definition of " ARCH_* " constants */"
14 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
15 .B #include <unistd.h>
17 .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long " addr );
18 .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long *" addr );
22 glibc provides no wrapper for
24 necessitating the use of
28 sets architecture-specific process or thread state.
35 is interpreted as either an
37 for the "set" operations, or as an
38 .IR "unsigned long\ *" ,
39 for the "get" operations.
41 Subfunctions for both x86 and x86-64 are:
43 .BR ARCH_SET_CPUID " (since Linux 4.12)"
44 .\" commit e9ea1e7f53b852147cbd568b0568c7ad97ec21a3
51 instruction for the calling thread.
52 The instruction is enabled by default.
53 If disabled, any execution of a
55 instruction will instead generate a
58 This feature can be used to emulate
60 results that differ from what the underlying
61 hardware would have produced (e.g., in a paravirtualization setting).
65 setting is preserved across
69 but reset to the default (i.e.,
74 .BR ARCH_GET_CPUID " (since Linux 4.12)"
75 Return the setting of the flag manipulated by
77 as the result of the system call (1 for enabled, 0 for disabled).
81 Subfunctions for x86-64 only are:
84 Set the 64-bit base for the
90 Return the 64-bit base value for the
92 register of the calling thread in the
98 Set the 64-bit base for the
104 Return the 64-bit base value for the
106 register of the calling thread in the
113 returns 0; on error, \-1 is returned, and
115 is set to indicate the error.
120 points to an unmapped address or is outside the process address space.
124 is not a valid subcommand.
128 was requested, but the underlying hardware does not support CPUID faulting.
132 is outside the process address space.
134 .\" Man page written by Andi Kleen.
137 is a Linux/x86-64 extension and should not be used in programs intended
141 is supported only on Linux/x86-64 for 64-bit programs currently.
143 The 64-bit base changes when a new 32-bit segment selector is loaded.
146 is disabled in some kernels.
148 Context switches for 64-bit segment bases are rather expensive.
149 As an optimization, if a 32-bit TLS base address is used,
151 may use a real TLS entry as if
152 .BR set_thread_area (2)
153 had been called, instead of manipulating the segment base register directly.
154 Memory in the first 2\ GB of address space can be allocated by using
160 Because of the aforementioned optimization, using
163 .BR set_thread_area (2)
164 in the same thread is dangerous, as they may overwrite each other's
168 may be already used by the threading library.
171 directly are very likely to crash.
176 .BR set_thread_area (2)
178 AMD X86-64 Programmer's manual