arch_prctl(2) System Calls Manual arch_prctl(2)

arch_prctl - fija el estado de un hilo para una arquitectura específica

Biblioteca Estándar C (libc, -lc)

#include <asm/prctl.h>        /* Definition of ARCH_* constants */
#include <sys/syscall.h>      /* Definition of SYS_* constants */
#include <unistd.h>
int syscall(SYS_arch_prctl, int code, unsigned long addr);
int syscall(SYS_arch_prctl, int code, unsigned long *addr);

Note: glibc provides no wrapper for arch_prctl(), necessitating the use of syscall(2).

arch_prctl() sets architecture-specific process or thread state. code selects a subfunction and passes argument addr to it; addr is interpreted as either an unsigned long for the "set" operations, or as an unsigned long *, for the "get" operations.

Las subfunciones para la arquitectura x86-64 y x86 son:

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).
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.
Establece la base de 64 bits para el registro FS a addr.
Devuelve el valor de base de 64 bits para el registro FS del hilo invocante en la variable unsigned long apuntada por addr.
Establece la base de 64 bits para el registro GS a addr.
Devuelve el valor de base 64 bits para el registro GS del hilo actual en la variable unsigned long apuntada por el parámetro addr.

En caso de éxito arch_prctl() devuelve cero. En caso de error se devuelve -1, y errno se define para indicar el tipo de error.

addr apunta a una dirección no asignada o que está fuera del espacio de direcciones del proceso.
code no es un subcomando válido.
Se solicitó ARCH_SET_CPUID, pero el hardware subyacente no incluye soporte para error de CPUID.
addr está fuera del espacio de direcciones.

Linux/x86-64.

En la actualidad arch_prctl() es soportada solamente por la plataforma Linux/x86-64 para programas de 64 bits.

La base de 64 bits cambia cuando se carga un nuevo selector de segmento de 32 bits.

ARCH_SET_GS está deshabilitado en algunos núcleos.

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.

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)

Manual del Programador de AMD X86-64

La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars <mpi79470@alu.um.es> y Marcos Fouces <marcos@debian.org>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

31 Octubre 2023 Páginas de manual de Linux 6.06