PR_SET_SPECULATION_CTRL2const
Set the state of a speculation misfeature for the calling thread
Usage
#include <linux/prctl.h> /* Definition of PR_* constants */ #include <sys/prctl.h>
int prctl(PR_SET_SPECULATION_CTRL, long misfeature, long val, 0L, 0L);
Library
Standard C library (libc, -lc)
Overview
Sets the state of the speculation misfeature specified in misfeature. The speculation-misfeature settings are per-thread attributes.
Currently, misfeature must be one of:
|
Set the state of the speculative store bypass misfeature. |
|---|---|
|
Set the state of the indirect branch speculation misfeature. |
The val argument is used to hand in the control value, which is one of the following:
PR_SPEC_ENABLE-
The speculation feature is enabled, mitigation is disabled.
PR_SPEC_DISABLE-
The speculation feature is disabled, mitigation is enabled.
PR_SPEC_FORCE_DISABLE-
Same as
PR_SPEC_DISABLE, but cannot be undone.
PR_SPEC_DISABLE_NOEXEC(since Linux 5.1)-
Same as
PR_SPEC_DISABLE, but the state will be cleared on execve(2). Currently only supported forPR_SPEC_STORE_BYPASS.
The speculation feature can also be controlled by the spec_store_bypass_disable boot parameter. This parameter may enforce a read-only policy which will result in the prctl() call failing with the error ENXIO. For further details, see the kernel source file Documentation/admin-guide/kernel-parameters.rst.
Return value
On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error.
Errors
- ENODEV
-
The kernel or CPU does not support the requested speculation misfeature.
- ENXIO
-
The control of the selected speculation misfeature is not possible. See
PR_GET_SPECULATION_CTRLfor the bit fields to determine which option is available.
- EPERM
-
The speculation was disabled with
PR_SPEC_FORCE_DISABLEand caller tried to enable it again.
- ERANGE
-
misfeature is not a valid value.
Releases
2 releases since Debian 13 (Trixie); the text changed 1 time.