Skip to contentSkip to conversation

Documentation/x86: Fix PR_SET_SPECULATION_CTRL error codes

PATCH Applied Brendan Jackman 2 participants 2 messages Nov 11, 2025 – Dec 29, 2025 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Documentation/x86: Fix PR_SET_SPECULATION_CTRL error codes

If you force-disable mitigations on the kcmdline, for SPEC_STORE_BYPASS this ends up with the prctl returning -ENXIO, but contrary to the current docs for the other controls it returns -EPERM. Fix that.

Note that this return value should probably be considered a bug. But, making the behaviour consistent with the current docs seems more likely to break existing users than help anyone out in practice, so just "fix" it by specifying it as correct.

Since this is getting more wordy and confusing, also be more explicit about "control is not possible" be mentioning the boot configuration, to better distinguish this case conceptually from the FORCE_DISABLE failure mode.

---
Changes in v2:
- Fixed erroneous reference to PR_SPEC_STORE_BYPASS returning -EPERM.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 Documentation/userspace-api/spec_ctrl.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Documentation/userspace-api/spec_ctrl.rst +8 -4
index ca89151fc0a8e7205e0a0062134d63b213b9ef11..61fe020b23a2ca632879597bd47a321bdedd9faf 100644
@@ -81,11 +81,15 @@ Value   Meaning
 ERANGE  arg3 is incorrect, i.e. it's neither PR_SPEC_ENABLE nor
         PR_SPEC_DISABLE nor PR_SPEC_FORCE_DISABLE.
 
-ENXIO   Control of the selected speculation misfeature is not possible.
-        See PR_GET_SPECULATION_CTRL.
+ENXIO   For PR_SPEC_STORE_BYPASS: control of the selected speculation misfeature
+        is not possible via prctl, because of the system's boot configuration.
+
+EPERM   Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller tried to
+        enable it again.
+
+EPERM   For PR_SPEC_L1D_FLUSH and PR_SPEC_INDIRECT_BRANCH: control of the
+        mitigation is not possible because of the system's boot configuration.
 
-EPERM   Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller
-        tried to enable it again.
 ======= =================================================================
 
 Speculation misfeature controls

---
base-commit: 131f3d9446a6075192cdd91f197989d98302faa6
change-id: 20251030-b4-prctl-docs-2-d5e24dbb758d

Best regards,

Signature · 1 line
Brendan Jackman <[email protected]>
#1 lore raw
The following commit has been merged into the x86/bugs branch of tip:

The following commit has been merged into the x86/bugs branch of tip:

Commit-ID:     4992ed7813c54f0a676b7707d1f8f16552fdb240
Gitweb:        https://git.kernel.org/tip/4992ed7813c54f0a676b7707d1f8f16552fdb240
Author:        Brendan Jackman <[email protected]>
AuthorDate:    Tue, 11 Nov 2025 17:41:08 
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Mon, 29 Dec 2025 16:27:45 +01:00

Documentation/x86: Fix PR_SET_SPECULATION_CTRL error codes

If you force-disable mitigations on the kernel cmdline, for SPEC_STORE_BYPASS this ends up with the prctl returning -ENXIO, but contrary to the current docs for the other controls it returns -EPERM. Fix that.

Note that this return value should probably be considered a bug. But, making the behaviour consistent with the current docs seems more likely to break existing users than help anyone out in practice, so just "fix" it by specifying it as correct.

Since this is getting more wordy and confusing, also be more explicit about "control is not possible" be mentioning the boot configuration, to better distinguish this case conceptually from the FORCE_DISABLE failure mode.

---
 Documentation/userspace-api/spec_ctrl.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Documentation/userspace-api/spec_ctrl.rst +8 -4
index ca89151..61fe020 100644
@@ -81,11 +81,15 @@ Value   Meaning
 ERANGE  arg3 is incorrect, i.e. it's neither PR_SPEC_ENABLE nor
         PR_SPEC_DISABLE nor PR_SPEC_FORCE_DISABLE.
 
-ENXIO   Control of the selected speculation misfeature is not possible.
-        See PR_GET_SPECULATION_CTRL.
+ENXIO   For PR_SPEC_STORE_BYPASS: control of the selected speculation misfeature
+        is not possible via prctl, because of the system's boot configuration.
+
+EPERM   Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller tried to
+        enable it again.
+
+EPERM   For PR_SPEC_L1D_FLUSH and PR_SPEC_INDIRECT_BRANCH: control of the
+        mitigation is not possible because of the system's boot configuration.
 
-EPERM   Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller
-        tried to enable it again.
 ======= =================================================================
 
 Speculation misfeature controls