ARCH_PRCTL
Section: Linux Programmer's Manual (2)
Updated: 2020-04-11
Index
JM Home Page
roff page
 
名前
arch_prctl - アーキテクチャー固有のスレッド状態を設定する
 
書式
#include <asm/prctl.h>
#include <sys/prctl.h>
int arch_prctl(int code, unsigned long addr);
int arch_prctl(int code, unsigned long *addr);
 
説明
arch_prctl() はアーキテクチャー固有のプロセス状態またはスレッド状態を設定する。 code は副機能を選択し、引数
addr を副機能に渡す。 addr は、"set" 操作では unsigned long として、"get" 操作では
unsigned long * として解釈される。
x86 と x86-64 の両方での使える副機能は以下の通り:
- ARCH_SET_CPUID (Linux 4.12 以降)
 - 
Enable (addr != 0)  or disable (addr == 0)  the cpuid instruction
for the calling thread.  The instruction is enabled by default.  If
disabled, any execution of a cpuid instruction will instead generate a
SIGSEGV signal.  This feature can be used to emulate cpuid results
that differ from what the underlying hardware would have produced (e.g., in
a paravirtualization setting).
 - 
The ARCH_SET_CPUID setting is preserved across fork(2)  and
clone(2)  but reset to the default (i.e., cpuid enabled) on
execve(2).
 - ARCH_GET_CPUID (Linux 4.12 以降)
 - 
Return the setting of the flag manipulated by ARCH_SET_CPUID as the
result of the system call (1 for enabled, 0 for disabled).  addr is
ignored.
 - x86-64 のみで使える副機能は以下の通り:
 - 
 - ARCH_SET_FS
 - 
FS レジスターの 64 ビットベースを addr に設定する。
 - ARCH_GET_FS
 - 
呼び出し元のスレッドの FS レジスターの 64 ビットベース値を、 addr が指す unsigned long の領域に格納する。
 - ARCH_SET_GS
 - 
GS レジスターの 64 ビットベースを addr に設定する。
 - ARCH_GET_GS
 - 
呼び出し元のスレッドの GS レジスターの 64 ビットベース値を、 addr が指す unsigned long の領域に格納する。
 
 
返り値
成功すると、 arch_prctl()  は 0 を返す。エラーの場合、-1 を返し、 errno をエラーを示す値に設定する。
 
エラー
- EFAULT
 - 
addr がアンマップされたアドレスを指しているか、プロセスのアドレス空間の外にある。
 - EINVAL
 - 
code が有効なサブコマンドでない。
 - EPERM
 - 
addr がプロセスのアドレス空間の外にある。
 - ENODEV
 - 
ARCH_SET_CPUID was requested, but the underlying hardware does not
support CPUID faulting.
 
 
準拠
arch_prctl()  は Linux/x86-64 拡張であり、移植性を意図したプログラムでは使うべきでない。
 
注意
arch_prctl()  は現在のところ Linux/x86-64 上の 64 ビットプログラムでのみサポートされている。
新しい 32 ビットセグメントセレクタがロードされた場合、 64 ビットベースは変更される。
ARCH_SET_GS が無効にされているカーネルもある。
Context switches for 64-bit segment bases are rather expensive.  As an
optimization, if a 32-bit TLS base address is used, arch_prctl()  may use
a real TLS entry as if set_thread_area(2)  had been called, instead of
manipulating the segment base register directly.  Memory in the first 2 GB
of address space can be allocated by using mmap(2)  with the MAP_32BIT
flag.
Because of the aforementioned optimization, using arch_prctl()  and
set_thread_area(2)  in the same thread is dangerous, as they may
overwrite each other's TLS entries.
バージョン 2.7 時点では、glibc には arch_prctl()  のプロトタイプがない。
今のところユーザーは自分自身で宣言する必要がある。 これは将来の glibc のバージョンで修正されるかもしれない。
FS may be already used by the threading library.  Programs that use
ARCH_SET_FS directly are very likely to crash.
 
関連項目
mmap(2), modify_ldt(2), prctl(2), set_thread_area(2)
AMD X86-64 Programmer's manual
 
この文書について
この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
https://www.kernel.org/doc/man-pages/ に書かれている。
 Index
- 名前
 - 
 - 書式
 - 
 - 説明
 - 
 - 返り値
 - 
 - エラー
 - 
 - 準拠
 - 
 - 注意
 - 
 - 関連項目
 - 
 - この文書について
 - 
 
This document was created by
man2html,
using the manual pages.
Time: 16:46:40 GMT, November 24, 2023