@@ -233,7 +233,8 @@ static void x86_amd_ssb_disable(void)
233
233
#define pr_fmt (fmt ) "MDS: " fmt
234
234
235
235
/* Default mitigation for MDS-affected CPUs */
236
- static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL ;
236
+ static enum mds_mitigations mds_mitigation __ro_after_init =
237
+ IS_ENABLED (CONFIG_MITIGATION_MDS ) ? MDS_MITIGATION_FULL : MDS_MITIGATION_OFF ;
237
238
static bool mds_nosmt __ro_after_init = false;
238
239
239
240
static const char * const mds_strings [] = {
@@ -293,7 +294,8 @@ enum taa_mitigations {
293
294
};
294
295
295
296
/* Default mitigation for TAA-affected CPUs */
296
- static enum taa_mitigations taa_mitigation __ro_after_init = TAA_MITIGATION_VERW ;
297
+ static enum taa_mitigations taa_mitigation __ro_after_init =
298
+ IS_ENABLED (CONFIG_MITIGATION_TAA ) ? TAA_MITIGATION_VERW : TAA_MITIGATION_OFF ;
297
299
static bool taa_nosmt __ro_after_init ;
298
300
299
301
static const char * const taa_strings [] = {
@@ -391,7 +393,8 @@ enum mmio_mitigations {
391
393
};
392
394
393
395
/* Default mitigation for Processor MMIO Stale Data vulnerabilities */
394
- static enum mmio_mitigations mmio_mitigation __ro_after_init = MMIO_MITIGATION_VERW ;
396
+ static enum mmio_mitigations mmio_mitigation __ro_after_init =
397
+ IS_ENABLED (CONFIG_MITIGATION_MMIO_STALE_DATA ) ? MMIO_MITIGATION_VERW : MMIO_MITIGATION_OFF ;
395
398
static bool mmio_nosmt __ro_after_init = false;
396
399
397
400
static const char * const mmio_strings [] = {
@@ -605,7 +608,8 @@ enum srbds_mitigations {
605
608
SRBDS_MITIGATION_HYPERVISOR ,
606
609
};
607
610
608
- static enum srbds_mitigations srbds_mitigation __ro_after_init = SRBDS_MITIGATION_FULL ;
611
+ static enum srbds_mitigations srbds_mitigation __ro_after_init =
612
+ IS_ENABLED (CONFIG_MITIGATION_SRBDS ) ? SRBDS_MITIGATION_FULL : SRBDS_MITIGATION_OFF ;
609
613
610
614
static const char * const srbds_strings [] = {
611
615
[SRBDS_MITIGATION_OFF ] = "Vulnerable" ,
@@ -731,11 +735,8 @@ enum gds_mitigations {
731
735
GDS_MITIGATION_HYPERVISOR ,
732
736
};
733
737
734
- #if IS_ENABLED (CONFIG_MITIGATION_GDS_FORCE )
735
- static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FORCE ;
736
- #else
737
- static enum gds_mitigations gds_mitigation __ro_after_init = GDS_MITIGATION_FULL ;
738
- #endif
738
+ static enum gds_mitigations gds_mitigation __ro_after_init =
739
+ IS_ENABLED (CONFIG_MITIGATION_GDS ) ? GDS_MITIGATION_FULL : GDS_MITIGATION_OFF ;
739
740
740
741
static const char * const gds_strings [] = {
741
742
[GDS_MITIGATION_OFF ] = "Vulnerable" ,
@@ -871,7 +872,8 @@ enum spectre_v1_mitigation {
871
872
};
872
873
873
874
static enum spectre_v1_mitigation spectre_v1_mitigation __ro_after_init =
874
- SPECTRE_V1_MITIGATION_AUTO ;
875
+ IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V1 ) ?
876
+ SPECTRE_V1_MITIGATION_AUTO : SPECTRE_V1_MITIGATION_NONE ;
875
877
876
878
static const char * const spectre_v1_strings [] = {
877
879
[SPECTRE_V1_MITIGATION_NONE ] = "Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers" ,
@@ -986,7 +988,7 @@ static const char * const retbleed_strings[] = {
986
988
static enum retbleed_mitigation retbleed_mitigation __ro_after_init =
987
989
RETBLEED_MITIGATION_NONE ;
988
990
static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init =
989
- RETBLEED_CMD_AUTO ;
991
+ IS_ENABLED ( CONFIG_MITIGATION_RETBLEED ) ? RETBLEED_CMD_AUTO : RETBLEED_CMD_OFF ;
990
992
991
993
static int __ro_after_init retbleed_nosmt = false;
992
994
@@ -1447,17 +1449,18 @@ static void __init spec_v2_print_cond(const char *reason, bool secure)
1447
1449
1448
1450
static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline (void )
1449
1451
{
1450
- enum spectre_v2_mitigation_cmd cmd = SPECTRE_V2_CMD_AUTO ;
1452
+ enum spectre_v2_mitigation_cmd cmd ;
1451
1453
char arg [20 ];
1452
1454
int ret , i ;
1453
1455
1456
+ cmd = IS_ENABLED (CONFIG_MITIGATION_SPECTRE_V2 ) ? SPECTRE_V2_CMD_AUTO : SPECTRE_V2_CMD_NONE ;
1454
1457
if (cmdline_find_option_bool (boot_command_line , "nospectre_v2" ) ||
1455
1458
cpu_mitigations_off ())
1456
1459
return SPECTRE_V2_CMD_NONE ;
1457
1460
1458
1461
ret = cmdline_find_option (boot_command_line , "spectre_v2" , arg , sizeof (arg ));
1459
1462
if (ret < 0 )
1460
- return SPECTRE_V2_CMD_AUTO ;
1463
+ return cmd ;
1461
1464
1462
1465
for (i = 0 ; i < ARRAY_SIZE (mitigation_options ); i ++ ) {
1463
1466
if (!match_option (arg , ret , mitigation_options [i ].option ))
@@ -1467,8 +1470,8 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
1467
1470
}
1468
1471
1469
1472
if (i >= ARRAY_SIZE (mitigation_options )) {
1470
- pr_err ("unknown option (%s). Switching to AUTO select \n" , arg );
1471
- return SPECTRE_V2_CMD_AUTO ;
1473
+ pr_err ("unknown option (%s). Switching to default mode \n" , arg );
1474
+ return cmd ;
1472
1475
}
1473
1476
1474
1477
if ((cmd == SPECTRE_V2_CMD_RETPOLINE ||
@@ -2021,18 +2024,20 @@ static const struct {
2021
2024
2022
2025
static enum ssb_mitigation_cmd __init ssb_parse_cmdline (void )
2023
2026
{
2024
- enum ssb_mitigation_cmd cmd = SPEC_STORE_BYPASS_CMD_AUTO ;
2027
+ enum ssb_mitigation_cmd cmd ;
2025
2028
char arg [20 ];
2026
2029
int ret , i ;
2027
2030
2031
+ cmd = IS_ENABLED (CONFIG_MITIGATION_SSB ) ?
2032
+ SPEC_STORE_BYPASS_CMD_AUTO : SPEC_STORE_BYPASS_CMD_NONE ;
2028
2033
if (cmdline_find_option_bool (boot_command_line , "nospec_store_bypass_disable" ) ||
2029
2034
cpu_mitigations_off ()) {
2030
2035
return SPEC_STORE_BYPASS_CMD_NONE ;
2031
2036
} else {
2032
2037
ret = cmdline_find_option (boot_command_line , "spec_store_bypass_disable" ,
2033
2038
arg , sizeof (arg ));
2034
2039
if (ret < 0 )
2035
- return SPEC_STORE_BYPASS_CMD_AUTO ;
2040
+ return cmd ;
2036
2041
2037
2042
for (i = 0 ; i < ARRAY_SIZE (ssb_mitigation_options ); i ++ ) {
2038
2043
if (!match_option (arg , ret , ssb_mitigation_options [i ].option ))
@@ -2043,8 +2048,8 @@ static enum ssb_mitigation_cmd __init ssb_parse_cmdline(void)
2043
2048
}
2044
2049
2045
2050
if (i >= ARRAY_SIZE (ssb_mitigation_options )) {
2046
- pr_err ("unknown option (%s). Switching to AUTO select \n" , arg );
2047
- return SPEC_STORE_BYPASS_CMD_AUTO ;
2051
+ pr_err ("unknown option (%s). Switching to default mode \n" , arg );
2052
+ return cmd ;
2048
2053
}
2049
2054
}
2050
2055
@@ -2371,7 +2376,8 @@ EXPORT_SYMBOL_GPL(itlb_multihit_kvm_mitigation);
2371
2376
#define pr_fmt (fmt ) "L1TF: " fmt
2372
2377
2373
2378
/* Default mitigation for L1TF-affected CPUs */
2374
- enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH ;
2379
+ enum l1tf_mitigations l1tf_mitigation __ro_after_init =
2380
+ IS_ENABLED (CONFIG_MITIGATION_L1TF ) ? L1TF_MITIGATION_FLUSH : L1TF_MITIGATION_OFF ;
2375
2381
#if IS_ENABLED (CONFIG_KVM_INTEL )
2376
2382
EXPORT_SYMBOL_GPL (l1tf_mitigation );
2377
2383
#endif
@@ -2551,10 +2557,9 @@ static void __init srso_select_mitigation(void)
2551
2557
{
2552
2558
bool has_microcode = boot_cpu_has (X86_FEATURE_IBPB_BRTYPE );
2553
2559
2554
- if (cpu_mitigations_off ())
2555
- return ;
2556
-
2557
- if (!boot_cpu_has_bug (X86_BUG_SRSO )) {
2560
+ if (!boot_cpu_has_bug (X86_BUG_SRSO ) ||
2561
+ cpu_mitigations_off () ||
2562
+ srso_cmd == SRSO_CMD_OFF ) {
2558
2563
if (boot_cpu_has (X86_FEATURE_SBPB ))
2559
2564
x86_pred_cmd = PRED_CMD_SBPB ;
2560
2565
return ;
@@ -2585,11 +2590,6 @@ static void __init srso_select_mitigation(void)
2585
2590
}
2586
2591
2587
2592
switch (srso_cmd ) {
2588
- case SRSO_CMD_OFF :
2589
- if (boot_cpu_has (X86_FEATURE_SBPB ))
2590
- x86_pred_cmd = PRED_CMD_SBPB ;
2591
- return ;
2592
-
2593
2593
case SRSO_CMD_MICROCODE :
2594
2594
if (has_microcode ) {
2595
2595
srso_mitigation = SRSO_MITIGATION_MICROCODE ;
@@ -2643,6 +2643,8 @@ static void __init srso_select_mitigation(void)
2643
2643
pr_err ("WARNING: kernel not compiled with MITIGATION_SRSO.\n" );
2644
2644
}
2645
2645
break ;
2646
+ default :
2647
+ break ;
2646
2648
}
2647
2649
2648
2650
out :
0 commit comments