Skip to content

Commit 2a08b83

Browse files
leitaoIngo Molnar
authored andcommitted
x86/bugs: Use the cpu_smt_possible() helper instead of open-coded code
There is a helper function to check if SMT is available. Use this helper instead of performing the check manually. The helper function cpu_smt_possible() does exactly the same thing as was being done manually inside spectre_v2_user_select_mitigation(). Specifically, it returns false if CONFIG_SMP is disabled, otherwise it checks the cpu_smt_control global variable. This change improves code consistency and reduces duplication. No change in functionality intended. Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Cc: David Kaplan <David.Kaplan@amd.com> Link: https://lore.kernel.org/r/20241031-x86_bugs_last_v2-v2-1-b7ff1dab840e@debian.org
1 parent b8ce25d commit 2a08b83

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,16 +1346,11 @@ static void __init
13461346
spectre_v2_user_select_mitigation(void)
13471347
{
13481348
enum spectre_v2_user_mitigation mode = SPECTRE_V2_USER_NONE;
1349-
bool smt_possible = IS_ENABLED(CONFIG_SMP);
13501349
enum spectre_v2_user_cmd cmd;
13511350

13521351
if (!boot_cpu_has(X86_FEATURE_IBPB) && !boot_cpu_has(X86_FEATURE_STIBP))
13531352
return;
13541353

1355-
if (cpu_smt_control == CPU_SMT_FORCE_DISABLED ||
1356-
cpu_smt_control == CPU_SMT_NOT_SUPPORTED)
1357-
smt_possible = false;
1358-
13591354
cmd = spectre_v2_parse_user_cmdline();
13601355
switch (cmd) {
13611356
case SPECTRE_V2_USER_CMD_NONE:
@@ -1416,7 +1411,7 @@ spectre_v2_user_select_mitigation(void)
14161411
* so allow for STIBP to be selected in those cases.
14171412
*/
14181413
if (!boot_cpu_has(X86_FEATURE_STIBP) ||
1419-
!smt_possible ||
1414+
!cpu_smt_possible() ||
14201415
(spectre_v2_in_eibrs_mode(spectre_v2_enabled) &&
14211416
!boot_cpu_has(X86_FEATURE_AUTOIBRS)))
14221417
return;

0 commit comments

Comments
 (0)