x86/speculation: Change STIPB to STIBP
Subsystems (2)
PATCH 1/2 x86/speculation: Change STIPB to STIBP
STIBP stands for Single Thread Indirect Branch Predictors. The acronym, however, can be easily mis-spelled as STIPB. It is perhaps due to the presence of another related term - IBPB (Indirect Branch Predictor Barrier).
Fix the mis-spelling in the code.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- arch/x86/kernel/process.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -54,7 +54,7 @@u64 __ro_after_init x86_amd_ls_cfg_base;u64 __ro_after_init x86_amd_ls_cfg_ssbd_mask; -/* Control conditional STIPB in switch_to() */ +/* Control conditional STIBP in switch_to() */ DEFINE_STATIC_KEY_FALSE (switch_to_cond_stibp);/* Control conditional IBPB in switch_mm() */ DEFINE_STATIC_KEY_FALSE (switch_mm_cond_ibpb);
@@ -379,12 +379,12 @@ static void __init spec_v2_user_print_cond(const char *reason, bool secure) "always-on" : "conditional"); } -/* If enhanced IBRS is enabled no STIPB required */ +/* If enhanced IBRS is enabled no STIBP required */ if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return ;/* -* If SMT is not possible or STIBP is not available clear the STIPB +* If SMT is not possible or STIBP is not available clear the STIBP * mode. */ if (!smt_possible || !boot_cpu_has (X86_FEATURE_STIBP ))
arch/x86/kernel/process.h +1 -1
@@ -19,7 +19,7 @@ static inline void switch_to_extra(struct task_struct *prev,if (IS_ENABLED (CONFIG_SMP )) {/* * Avoid __switch_to_xtra() invocation when conditional -* STIPB is disabled and the only different bit is +* STIBP is disabled and the only different bit is * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not * in the TIF_WORK_CTXSW masks. */
Signature · 1 line
1.8.3.1
PATCH 2/2 x86/speculation: switch_to_cond_stibp on is the likely case
Since conditional STIBP is the default, it should be treated as the likely case. Changes the use of static_branch_unlikely() to static_branch_likely() for switch_to_cond_stibp.
--- arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -153,7 +153,7 @@ void __init check_bugs(void) hostval |=ssbd_tif_to_spec_ctrl (ti->flags);/* Conditional STIBP enabled? */ -if (static_branch_unlikely (&switch_to_cond_stibp)) +if (static_branch_likely (&switch_to_cond_stibp)) hostval |=stibp_tif_to_spec_ctrl (ti->flags);if (hostval != guestval) {
arch/x86/kernel/process.c +1 -1
@@ -434,7 +434,7 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp,* otherwise avoid the MSR write. */ if (IS_ENABLED (CONFIG_SMP ) && -static_branch_unlikely (&switch_to_cond_stibp)) { +static_branch_likely (&switch_to_cond_stibp)) { updmsr |= !!(tif_diff & _TIF_SPEC_IB); msr |=stibp_tif_to_spec_ctrl (tifn); }
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerRe: [PATCH 2/2] x86/speculation: switch_to_cond_stibp on is the likely case
Quoted 3 lines · Waiman Long
Since conditional STIBP is the default, it should be treated as the likely case. Changes the use of
static_branch_unlikely()tostatic_branch_likely()forswitch_to_cond_stibp.
So now you're making kernels on 'fixed' or unaffected hardware slower.
Quoted 35 lines
Signed-off-by Waiman Long <[email protected]>--- arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/bugs.c +1
-1@@ -153,7 +153,7 @@ void __init check_bugs(void) hostval |=ssbd_tif_to_spec_ctrl (ti->flags);/* Conditional STIBP enabled? */ -if (static_branch_unlikely (&switch_to_cond_stibp)) +if (static_branch_likely (&switch_to_cond_stibp)) hostval |=stibp_tif_to_spec_ctrl (ti->flags);if (hostval != guestval) {arch/x86/kernel/process.c +1
-1@@ -434,7 +434,7 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp,* otherwise avoid the MSR write. */ if (IS_ENABLED (CONFIG_SMP ) && -static_branch_unlikely (&switch_to_cond_stibp)) { +static_branch_likely (&switch_to_cond_stibp)) { updmsr |= !!(tif_diff & _TIF_SPEC_IB); msr |=stibp_tif_to_spec_ctrl (tifn); }Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] x86/speculation: switch_to_cond_stibp on is the likely case
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long
Since conditional STIBP is the default, it should be treated as the likely case. Changes the use of
static_branch_unlikely()tostatic_branch_likely()forswitch_to_cond_stibp.So now you're making kernels on 'fixed' or unaffected hardware slower.
Good point.
The reason I sent out this patch is because of the inconsistency in the use of likely/unlikely hints.
arch/x86/kernel/cpu/bugs.c:156: if
(static_branch_unlikely(&switch_to_cond_stibp))arch/x86/kernel/process.c:440:static_branch_unlikely(&switch_to_cond_stibp)) {
arch/x86/kernel/process.h:26: if
(!static_branch_likely(&switch_to_cond_stibp)) {
So if we are aiming to optimize for "fixed" or unaffected hardware, maybe we should modify the likely hint to unlikely then.
Cheers,
Longman
Peter Zijlstra
maintainerRe: [PATCH 2/2] x86/speculation: switch_to_cond_stibp on is the likely case
Quoted 19 lines · Waiman Long
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long
Since conditional STIBP is the default, it should be treated as the likely case. Changes the use of
static_branch_unlikely()tostatic_branch_likely()forswitch_to_cond_stibp.So now you're making kernels on 'fixed' or unaffected hardware slower.
Good point.
The reason I sent out this patch is because of the inconsistency in the use of likely/unlikely hints.
arch/x86/kernel/cpu/bugs.c:156: if
(static_branch_unlikely(&switch_to_cond_stibp))arch/x86/kernel/process.c:440:static_branch_unlikely(&switch_to_cond_stibp)) {
arch/x86/kernel/process.h:26: if
(!static_branch_likely(&switch_to_cond_stibp)) {
Quoted 2 lines
So if we are aiming to optimize for "fixed" or unaffected hardware, maybe we should modify the likely hint to unlikely then.
Right, I think that makes sense, Thomas?
Re: [PATCH 2/2] x86/speculation: switch_to_cond_stibp on is the likely case
Quoted 20 lines · Peter Zijlstra
Quoted 19 lines · Waiman Long
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Waiman Long
Since conditional STIBP is the default, it should be treated as the likely case. Changes the use of
static_branch_unlikely()tostatic_branch_likely()forswitch_to_cond_stibp.So now you're making kernels on 'fixed' or unaffected hardware slower.
Good point.
The reason I sent out this patch is because of the inconsistency in the use of likely/unlikely hints.
arch/x86/kernel/cpu/bugs.c:156: if
(static_branch_unlikely(&switch_to_cond_stibp))arch/x86/kernel/process.c:440:static_branch_unlikely(&switch_to_cond_stibp)) {
arch/x86/kernel/process.h:26: if
(!static_branch_likely(&switch_to_cond_stibp)) {
Quoted 4 lines
Quoted 2 lines
So if we are aiming to optimize for "fixed" or unaffected hardware, maybe we should modify the likely hint to unlikely then.
Right, I think that makes sense, Thomas?
Yeah, I probably got that wrong in some places. Let me look.
Thanks,
Thomas
tip-bot for Waiman Long
merge bot[tip:x86/pti] x86/speculation: Change misspelled STIPB to STIBP
In reply to Waiman Longx86/speculation: Change misspelled STIPB to STIBP
Commit-ID: aa77bfb354c495fc4361199e63fc5765b9e1e783 Gitweb: https://git.kernel.org/tip/aa77bfb354c495fc4361199e63fc5765b9e1e783 Author: Waiman Long <[email protected]> AuthorDate: Wed, 5 Dec 2018 14:49:27 -0500 Committer: Borislav Petkov <[email protected]> CommitDate: Thu, 6 Dec 2018 11:49:15 +0100
x86/speculation: Change misspelled STIPB to STIBP
STIBP stands for Single Thread Indirect Branch Predictors. The acronym, however, can be easily mis-spelled as STIPB. It is perhaps due to the presence of another related term - IBPB (Indirect Branch Predictor Barrier).
Fix the mis-spelling in the code.
--- arch/x86/kernel/cpu/bugs.c | 6 +++--- arch/x86/kernel/process.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/bugs.c +3 -3
@@ -54,7 +54,7 @@ static u64 __ro_after_init x86_spec_ctrl_mask = SPEC_CTRL_IBRS;u64 __ro_after_init x86_amd_ls_cfg_base;u64 __ro_after_init x86_amd_ls_cfg_ssbd_mask; -/* Control conditional STIPB in switch_to() */ +/* Control conditional STIBP in switch_to() */ DEFINE_STATIC_KEY_FALSE (switch_to_cond_stibp);/* Control conditional IBPB in switch_mm() */ DEFINE_STATIC_KEY_FALSE (switch_mm_cond_ibpb);
@@ -379,12 +379,12 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd) "always-on" : "conditional"); } -/* If enhanced IBRS is enabled no STIPB required */ +/* If enhanced IBRS is enabled no STIBP required */ if (spectre_v2_enabled ==SPECTRE_V2_IBRS_ENHANCED )return ;/* -* If SMT is not possible or STIBP is not available clear the STIPB +* If SMT is not possible or STIBP is not available clear the STIBP * mode. */ if (!smt_possible || !boot_cpu_has (X86_FEATURE_STIBP ))
arch/x86/kernel/process.h +1 -1
@@ -19,7 +19,7 @@ static inline void switch_to_extra(struct task_struct *prev,if (IS_ENABLED (CONFIG_SMP )) {/* * Avoid __switch_to_xtra() invocation when conditional -* STIPB is disabled and the only different bit is +* STIBP is disabled and the only different bit is * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not * in the TIF_WORK_CTXSW masks. */