Skip to content

Commit e3420f9

Browse files
committed
Merge tag 'x86_cpu_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpu model updates from Borislav Petkov: - Add Emerald Rapids to the list of Intel models supporting PPIN - Finally use a CPUID bit for split lock detection instead of enumerating every model - Make sure automatic IBRS is set on AMD, even though the AP bringup code does that now by replicating the MSR which contains the switch * tag 'x86_cpu_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu: Add Xeon Emerald Rapids to list of CPUs that support PPIN x86/split_lock: Enumerate architectural split lock disable bit x86/CPU/AMD: Make sure EFER[AIBRSE] is set
2 parents 1699dbe + 36168bc commit e3420f9

5 files changed

Lines changed: 43 additions & 46 deletions

File tree

arch/x86/kernel/cpu/amd.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,17 @@ static void init_amd(struct cpuinfo_x86 *c)
10091009
msr_set_bit(MSR_K7_HWCR, MSR_K7_HWCR_IRPERF_EN_BIT);
10101010

10111011
check_null_seg_clears_base(c);
1012+
1013+
/*
1014+
* Make sure EFER[AIBRSE - Automatic IBRS Enable] is set. The APs are brought up
1015+
* using the trampoline code and as part of it, MSR_EFER gets prepared there in
1016+
* order to be replicated onto them. Regardless, set it here again, if not set,
1017+
* to protect against any future refactoring/code reorganization which might
1018+
* miss setting this important bit.
1019+
*/
1020+
if (spectre_v2_in_eibrs_mode(spectre_v2_enabled) &&
1021+
cpu_has(c, X86_FEATURE_AUTOIBRS))
1022+
WARN_ON_ONCE(msr_set_bit(MSR_EFER, _EFER_AUTOIBRS));
10121023
}
10131024

10141025
#ifdef CONFIG_X86_32

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,7 @@ static int __init nospectre_v1_cmdline(char *str)
784784
}
785785
early_param("nospectre_v1", nospectre_v1_cmdline);
786786

787-
static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
788-
SPECTRE_V2_NONE;
787+
enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE;
789788

790789
#undef pr_fmt
791790
#define pr_fmt(fmt) "RETBleed: " fmt
@@ -1133,13 +1132,6 @@ spectre_v2_parse_user_cmdline(void)
11331132
return SPECTRE_V2_USER_CMD_AUTO;
11341133
}
11351134

1136-
static inline bool spectre_v2_in_eibrs_mode(enum spectre_v2_mitigation mode)
1137-
{
1138-
return mode == SPECTRE_V2_EIBRS ||
1139-
mode == SPECTRE_V2_EIBRS_RETPOLINE ||
1140-
mode == SPECTRE_V2_EIBRS_LFENCE;
1141-
}
1142-
11431135
static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode)
11441136
{
11451137
return spectre_v2_in_eibrs_mode(mode) || mode == SPECTRE_V2_IBRS;

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static const struct x86_cpu_id ppin_cpuids[] = {
121121
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &ppin_info[X86_VENDOR_INTEL]),
122122
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &ppin_info[X86_VENDOR_INTEL]),
123123
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &ppin_info[X86_VENDOR_INTEL]),
124+
X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, &ppin_info[X86_VENDOR_INTEL]),
124125
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &ppin_info[X86_VENDOR_INTEL]),
125126
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &ppin_info[X86_VENDOR_INTEL]),
126127

arch/x86/kernel/cpu/cpu.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,12 @@ unsigned int aperfmperf_get_khz(int cpu);
8383
extern void x86_spec_ctrl_setup_ap(void);
8484
extern void update_srbds_msr(void);
8585

86+
extern enum spectre_v2_mitigation spectre_v2_enabled;
87+
88+
static inline bool spectre_v2_in_eibrs_mode(enum spectre_v2_mitigation mode)
89+
{
90+
return mode == SPECTRE_V2_EIBRS ||
91+
mode == SPECTRE_V2_EIBRS_RETPOLINE ||
92+
mode == SPECTRE_V2_EIBRS_LFENCE;
93+
}
8694
#endif /* ARCH_X86_CPU_H */

arch/x86/kernel/cpu/intel.c

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,31 +1451,13 @@ void handle_bus_lock(struct pt_regs *regs)
14511451
}
14521452

14531453
/*
1454-
* Bits in the IA32_CORE_CAPABILITIES are not architectural, so they should
1455-
* only be trusted if it is confirmed that a CPU model implements a
1456-
* specific feature at a particular bit position.
1457-
*
1458-
* The possible driver data field values:
1459-
*
1460-
* - 0: CPU models that are known to have the per-core split-lock detection
1461-
* feature even though they do not enumerate IA32_CORE_CAPABILITIES.
1462-
*
1463-
* - 1: CPU models which may enumerate IA32_CORE_CAPABILITIES and if so use
1464-
* bit 5 to enumerate the per-core split-lock detection feature.
1454+
* CPU models that are known to have the per-core split-lock detection
1455+
* feature even though they do not enumerate IA32_CORE_CAPABILITIES.
14651456
*/
14661457
static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
1467-
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0),
1468-
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L, 0),
1469-
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, 0),
1470-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT, 1),
1471-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, 1),
1472-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_L, 1),
1473-
X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L, 1),
1474-
X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE, 1),
1475-
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, 1),
1476-
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, 1),
1477-
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, 1),
1478-
X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE, 1),
1458+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0),
1459+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L, 0),
1460+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, 0),
14791461
{}
14801462
};
14811463

@@ -1487,24 +1469,27 @@ static void __init split_lock_setup(struct cpuinfo_x86 *c)
14871469
if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
14881470
return;
14891471

1472+
/* Check for CPUs that have support but do not enumerate it: */
14901473
m = x86_match_cpu(split_lock_cpu_ids);
1491-
if (!m)
1492-
return;
1474+
if (m)
1475+
goto supported;
14931476

1494-
switch (m->driver_data) {
1495-
case 0:
1496-
break;
1497-
case 1:
1498-
if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
1499-
return;
1500-
rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
1501-
if (!(ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT))
1502-
return;
1503-
break;
1504-
default:
1477+
if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITIES))
15051478
return;
1506-
}
15071479

1480+
/*
1481+
* Not all bits in MSR_IA32_CORE_CAPS are architectural, but
1482+
* MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT is. All CPUs that set
1483+
* it have split lock detection.
1484+
*/
1485+
rdmsrl(MSR_IA32_CORE_CAPS, ia32_core_caps);
1486+
if (ia32_core_caps & MSR_IA32_CORE_CAPS_SPLIT_LOCK_DETECT)
1487+
goto supported;
1488+
1489+
/* CPU is not in the model list and does not have the MSR bit: */
1490+
return;
1491+
1492+
supported:
15081493
cpu_model_supports_sld = true;
15091494
__split_lock_setup();
15101495
}

0 commit comments

Comments
 (0)