diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2018-11-25 13:33:53 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-11-28 05:57:13 -0500 |
commit | 9137bb27e60e554dab694eafa4cca241fa3a694f (patch) | |
tree | 210ca811947bb90452df9f8a3752402e6252a530 /include/linux/sched.h | |
parent | 6893a959d7fdebbab5f5aa112c277d5a44435ba1 (diff) |
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.
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Casey Schaufler <casey.schaufler@intel.com>
Cc: Asit Mallick <asit.k.mallick@intel.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Jon Masters <jcm@redhat.com>
Cc: Waiman Long <longman9394@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Dave Stewart <david.c.stewart@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20181125185005.866780996@linutronix.de
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index a51c13c2b1a0..d607db5fcc6a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1453,6 +1453,8 @@ static inline bool is_percpu_thread(void) | |||
1453 | #define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */ | 1453 | #define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */ |
1454 | #define PFA_SPEC_SSB_DISABLE 3 /* Speculative Store Bypass disabled */ | 1454 | #define PFA_SPEC_SSB_DISABLE 3 /* Speculative Store Bypass disabled */ |
1455 | #define PFA_SPEC_SSB_FORCE_DISABLE 4 /* Speculative Store Bypass force disabled*/ | 1455 | #define PFA_SPEC_SSB_FORCE_DISABLE 4 /* Speculative Store Bypass force disabled*/ |
1456 | #define PFA_SPEC_IB_DISABLE 5 /* Indirect branch speculation restricted */ | ||
1457 | #define PFA_SPEC_IB_FORCE_DISABLE 6 /* Indirect branch speculation permanently restricted */ | ||
1456 | 1458 | ||
1457 | #define TASK_PFA_TEST(name, func) \ | 1459 | #define TASK_PFA_TEST(name, func) \ |
1458 | static inline bool task_##func(struct task_struct *p) \ | 1460 | static inline bool task_##func(struct task_struct *p) \ |
@@ -1484,6 +1486,13 @@ TASK_PFA_CLEAR(SPEC_SSB_DISABLE, spec_ssb_disable) | |||
1484 | TASK_PFA_TEST(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable) | 1486 | TASK_PFA_TEST(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable) |
1485 | TASK_PFA_SET(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable) | 1487 | TASK_PFA_SET(SPEC_SSB_FORCE_DISABLE, spec_ssb_force_disable) |
1486 | 1488 | ||
1489 | TASK_PFA_TEST(SPEC_IB_DISABLE, spec_ib_disable) | ||
1490 | TASK_PFA_SET(SPEC_IB_DISABLE, spec_ib_disable) | ||
1491 | TASK_PFA_CLEAR(SPEC_IB_DISABLE, spec_ib_disable) | ||
1492 | |||
1493 | TASK_PFA_TEST(SPEC_IB_FORCE_DISABLE, spec_ib_force_disable) | ||
1494 | TASK_PFA_SET(SPEC_IB_FORCE_DISABLE, spec_ib_force_disable) | ||
1495 | |||
1487 | static inline void | 1496 | static inline void |
1488 | current_restore_flags(unsigned long orig_flags, unsigned long flags) | 1497 | current_restore_flags(unsigned long orig_flags, unsigned long flags) |
1489 | { | 1498 | { |