---
name: "PR_SET_SPECULATION_CTRL"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/PR_SET_SPECULATION_CTRL"
---

# PR\_SET\_SPECULATION\_CTRL(2const)

set the state of a speculation misfeature for the calling thread

## NAME

PR\_SET\_SPECULATION\_CTRL - set the state of a speculation misfeature for the calling thread

## LIBRARY

Standard C library (*libc*, *-lc*)

## 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);**

## DESCRIPTION

Sets the state of the speculation misfeature specified in *misfeature*. The speculation-misfeature settings are per-thread attributes.

Currently, *misfeature* must be one of:

- **PR\_SPEC\_STORE\_BYPASS**

  Set the state of the speculative store bypass misfeature.

- **PR\_SPEC\_INDIRECT\_BRANCH** (since Linux 4.20)

  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)](/execve/2.md). Currently only supported for **PR\_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\_CTRL** for the bit fields to determine which option is available.

- **EPERM**

  The speculation was disabled with **PR\_SPEC\_FORCE\_DISABLE** and caller tried to enable it again.

- **ERANGE**

  *misfeature* is not a valid value.

## STANDARDS

Linux.

## HISTORY

Linux 4.17.

## SEE ALSO

[**prctl**(2)](/prctl/2.md), [**PR\_GET\_SPECULATION\_CTRL**(2const)](/PR_GET_SPECULATION_CTRL/2const.md)
