History

x86/speculation: Add prctl() control for indirect branch speculation

Add the PR_SPEC_INDIRECT_BRANCH option for the PR_GET_SPECULATION_CTRL and PR_SET_SPECULATION_CTRL prctls to allow fine grained per task control of indirect branch speculation via STIBP and IBPB. Invocations: Check indirect branch speculation status with - prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, 0, 0, 0); Enable indirect branch speculation with - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, PR_SPEC_ENABLE, 0, 0); Disable indirect branch speculation with - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, PR_SPEC_DISABLE, 0, 0); Force disable indirect branch speculation with - prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_INDIRECT_BRANCH, PR_SPEC_FORCE_DISABLE, 0, 0); See Documentation/userspace-api/spec_ctrl.rst.

Thomas Gleixner committed 7 years ago

Commit 9137bb21 parent 6893a957 files · +93 −0Browse files

Showing the changes to include/uapi/linux (1 of 7 files). Show all

Unified · Split

include/uapi/linux/prctl.h+1−0
@@ -212,6 +212,7 @@ struct prctl_mm_map { · 211 unmodified lines
212212 #define PR_SET_SPECULATION_CTRL 53
213213 /* Speculation control variants */
214214 # define PR_SPEC_STORE_BYPASS 0
215+# define PR_SPEC_INDIRECT_BRANCH 1
215216 /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
216217 # define PR_SPEC_NOT_AFFECTED 0
217218 # define PR_SPEC_PRCTL (1UL << 0)