PR_SET_SPECULATION_CTRL(2const)
β¨ PR_SET_SPECULATION_CTRL β¨
okay bestie, so this one is PR_SET_SPECULATION_CTRL from the (2const) girlies β it lives in the land of prctl(2) constants, and it's literally the "set the state of a speculation misfeature for the calling thread" page. yes, per-thread. yes, that matters. π
πΈ LIBRARY πΈ
Standard C library (libc, -lc). the classic. the icon. π
π¦ SYNOPSIS π¦
#include <linux/prctl.h> /* Definition of PR_* constants */
#include <sys/prctl.h>
int prctl(PR_SET_SPECULATION_CTRL, long misfeature, long val, 0L, 0L);
note how those last two args are just 0L and 0L, they're not doing anything, they're just there for the vibe. okay not for the vibe, for the API. whatever. β¨
π DESCRIPTION π
So what it does: it sets the state of the speculation misfeature that you name in misfeature. And the important lil detail β these speculation-misfeature settings are per-thread attributes. not global. not per-process. per. thread. okay? periodt. π
Right now, misfeature has to be one of these two besties:
PR_SPEC_STORE_BYPASSβ sets the state of the speculative store bypass misfeature.PR_SPEC_INDIRECT_BRANCH(since Linux 4.20) β sets the state of the indirect branch speculation misfeature.
Then there's the val argument, which is where you hand in the actual control value. and val is one of these:
PR_SPEC_ENABLEβ the speculation feature is enabled, mitigation is disabled. (living dangerously, we love a bold choice π«Ά)PR_SPEC_DISABLEβ the speculation feature is disabled, mitigation is enabled. (safe queen behavior π )PR_SPEC_FORCE_DISABLEβ same asPR_SPEC_DISABLE, but it cannot be undone. no takebacks. no regrets. it's giving irreversible. πPR_SPEC_DISABLE_NOEXEC(since Linux 5.1) β same asPR_SPEC_DISABLE, but the state will be cleared onexecve(2). And heads up β this one is currently only supported forPR_SPEC_STORE_BYPASS.
Alsooo, the speculation feature can also be controlled by the spec_store_bypass_disable boot parameter. And plot twist: 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 π
Slay: on success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error. that's the whole story bestie. π
π ERRORS π
ENODEVβ the kernel or CPU does not support the requested speculation misfeature. (they simply don't have it in them π)ENXIOβ the control of the selected speculation misfeature is not possible. SeePR_GET_SPECULATION_CTRLfor the bit fields to determine which option is available. πEPERMβ the speculation was disabled withPR_SPEC_FORCE_DISABLEand the caller tried to enable it again. yeahβ¦ that's the irreversible thing from earlier. told you. πERANGEβmisfeatureis not a valid value.
β STANDARDS β
Linux. that's it, that's the standard. π§
π HISTORY π
Linux 4.17.
π§ SEE ALSO π§
okay that's the whole page bestie, you ate that π«Ά stay speculative, stay per-thread, and remember: PR_SPEC_FORCE_DISABLE is forever. mwah. π
this has been a Linux man-pages 6.20 moment, dated 2026-02-08, brought to you by the PR_SET_SPECULATION_CTRL(2const) girlies. no cap. β¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2018, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
- Copyright 2018, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms