Lines 783-790
Link Here
|
783 |
} |
783 |
} |
784 |
early_param("nospectre_v1", nospectre_v1_cmdline); |
784 |
early_param("nospectre_v1", nospectre_v1_cmdline); |
785 |
|
785 |
|
786 |
static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = |
786 |
enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE; |
787 |
SPECTRE_V2_NONE; |
|
|
788 |
|
787 |
|
789 |
#undef pr_fmt |
788 |
#undef pr_fmt |
790 |
#define pr_fmt(fmt) "RETBleed: " fmt |
789 |
#define pr_fmt(fmt) "RETBleed: " fmt |
Lines 1132-1144
Link Here
|
1132 |
return SPECTRE_V2_USER_CMD_AUTO; |
1131 |
return SPECTRE_V2_USER_CMD_AUTO; |
1133 |
} |
1132 |
} |
1134 |
|
1133 |
|
1135 |
static inline bool spectre_v2_in_eibrs_mode(enum spectre_v2_mitigation mode) |
|
|
1136 |
{ |
1137 |
return mode == SPECTRE_V2_EIBRS || |
1138 |
mode == SPECTRE_V2_EIBRS_RETPOLINE || |
1139 |
mode == SPECTRE_V2_EIBRS_LFENCE; |
1140 |
} |
1141 |
|
1142 |
static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode) |
1134 |
static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode) |
1143 |
{ |
1135 |
{ |
1144 |
return spectre_v2_in_eibrs_mode(mode) || mode == SPECTRE_V2_IBRS; |
1136 |
return spectre_v2_in_eibrs_mode(mode) || mode == SPECTRE_V2_IBRS; |
Lines 1248-1256
Link Here
|
1248 |
[SPECTRE_V2_NONE] = "Vulnerable", |
1240 |
[SPECTRE_V2_NONE] = "Vulnerable", |
1249 |
[SPECTRE_V2_RETPOLINE] = "Mitigation: Retpolines", |
1241 |
[SPECTRE_V2_RETPOLINE] = "Mitigation: Retpolines", |
1250 |
[SPECTRE_V2_LFENCE] = "Mitigation: LFENCE", |
1242 |
[SPECTRE_V2_LFENCE] = "Mitigation: LFENCE", |
1251 |
[SPECTRE_V2_EIBRS] = "Mitigation: Enhanced IBRS", |
1243 |
[SPECTRE_V2_EIBRS] = "Mitigation: Enhanced / Automatic IBRS", |
1252 |
[SPECTRE_V2_EIBRS_LFENCE] = "Mitigation: Enhanced IBRS + LFENCE", |
1244 |
[SPECTRE_V2_EIBRS_LFENCE] = "Mitigation: Enhanced / Automatic IBRS + LFENCE", |
1253 |
[SPECTRE_V2_EIBRS_RETPOLINE] = "Mitigation: Enhanced IBRS + Retpolines", |
1245 |
[SPECTRE_V2_EIBRS_RETPOLINE] = "Mitigation: Enhanced / Automatic IBRS + Retpolines", |
1254 |
[SPECTRE_V2_IBRS] = "Mitigation: IBRS", |
1246 |
[SPECTRE_V2_IBRS] = "Mitigation: IBRS", |
1255 |
}; |
1247 |
}; |
1256 |
|
1248 |
|
Lines 1319-1325
Link Here
|
1319 |
cmd == SPECTRE_V2_CMD_EIBRS_LFENCE || |
1311 |
cmd == SPECTRE_V2_CMD_EIBRS_LFENCE || |
1320 |
cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) && |
1312 |
cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) && |
1321 |
!boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) { |
1313 |
!boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) { |
1322 |
pr_err("%s selected but CPU doesn't have eIBRS. Switching to AUTO select\n", |
1314 |
pr_err("%s selected but CPU doesn't have Enhanced or Automatic IBRS. Switching to AUTO select\n", |
1323 |
mitigation_options[i].option); |
1315 |
mitigation_options[i].option); |
1324 |
return SPECTRE_V2_CMD_AUTO; |
1316 |
return SPECTRE_V2_CMD_AUTO; |
1325 |
} |
1317 |
} |
Lines 1505-1512
Link Here
|
1505 |
pr_err(SPECTRE_V2_EIBRS_EBPF_MSG); |
1497 |
pr_err(SPECTRE_V2_EIBRS_EBPF_MSG); |
1506 |
|
1498 |
|
1507 |
if (spectre_v2_in_ibrs_mode(mode)) { |
1499 |
if (spectre_v2_in_ibrs_mode(mode)) { |
1508 |
x86_spec_ctrl_base |= SPEC_CTRL_IBRS; |
1500 |
if (boot_cpu_has(X86_FEATURE_AUTOIBRS)) { |
1509 |
update_spec_ctrl(x86_spec_ctrl_base); |
1501 |
msr_set_bit(MSR_EFER, _EFER_AUTOIBRS); |
|
|
1502 |
} else { |
1503 |
x86_spec_ctrl_base |= SPEC_CTRL_IBRS; |
1504 |
update_spec_ctrl(x86_spec_ctrl_base); |
1505 |
} |
1510 |
} |
1506 |
} |
1511 |
|
1507 |
|
1512 |
switch (mode) { |
1508 |
switch (mode) { |
Lines 1590-1597
Link Here
|
1590 |
/* |
1586 |
/* |
1591 |
* Retpoline protects the kernel, but doesn't protect firmware. IBRS |
1587 |
* Retpoline protects the kernel, but doesn't protect firmware. IBRS |
1592 |
* and Enhanced IBRS protect firmware too, so enable IBRS around |
1588 |
* and Enhanced IBRS protect firmware too, so enable IBRS around |
1593 |
* firmware calls only when IBRS / Enhanced IBRS aren't otherwise |
1589 |
* firmware calls only when IBRS / Enhanced / Automatic IBRS aren't |
1594 |
* enabled. |
1590 |
* otherwise enabled. |
1595 |
* |
1591 |
* |
1596 |
* Use "mode" to check Enhanced IBRS instead of boot_cpu_has(), because |
1592 |
* Use "mode" to check Enhanced IBRS instead of boot_cpu_has(), because |
1597 |
* the user might select retpoline on the kernel command line and if |
1593 |
* the user might select retpoline on the kernel command line and if |