mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-08 07:38:10 +00:00
x86/speculation: Merge one test in spectre_v2_user_select_mitigation()
Merge the test whether the CPU supports STIBP into the test which determines whether STIBP is required. Thus try to simplify what is already an insane logic. Remove a superfluous newline in a comment, while at it. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Anthony Steinhauser <asteinhauser@google.com> Link: https://lkml.kernel.org/r/20200615065806.GB14668@zn.tnic
This commit is contained in:
parent
b3a9e3b962
commit
a5ce9f2bb6
1 changed files with 4 additions and 9 deletions
|
@ -763,10 +763,12 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If enhanced IBRS is enabled or SMT impossible, STIBP is not
|
* If no STIBP, enhanced IBRS is enabled or SMT impossible, STIBP is not
|
||||||
* required.
|
* required.
|
||||||
*/
|
*/
|
||||||
if (!smt_possible || spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
|
if (!boot_cpu_has(X86_FEATURE_STIBP) ||
|
||||||
|
!smt_possible ||
|
||||||
|
spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -778,12 +780,6 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)
|
||||||
boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
|
boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
|
||||||
mode = SPECTRE_V2_USER_STRICT_PREFERRED;
|
mode = SPECTRE_V2_USER_STRICT_PREFERRED;
|
||||||
|
|
||||||
/*
|
|
||||||
* If STIBP is not available, clear the STIBP mode.
|
|
||||||
*/
|
|
||||||
if (!boot_cpu_has(X86_FEATURE_STIBP))
|
|
||||||
mode = SPECTRE_V2_USER_NONE;
|
|
||||||
|
|
||||||
spectre_v2_user_stibp = mode;
|
spectre_v2_user_stibp = mode;
|
||||||
|
|
||||||
set_mode:
|
set_mode:
|
||||||
|
@ -1270,7 +1266,6 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
|
||||||
* Indirect branch speculation is always disabled in strict
|
* Indirect branch speculation is always disabled in strict
|
||||||
* mode. It can neither be enabled if it was force-disabled
|
* mode. It can neither be enabled if it was force-disabled
|
||||||
* by a previous prctl call.
|
* by a previous prctl call.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
|
if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
|
||||||
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
|
spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue