Skip to content

Commit 2594b71

Browse files
committed
Merge tag 'x86_cpu_for_v5.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpu updates from Borislav Petkov: - New AMD models support - Allow MONITOR/MWAIT to be used for C1 state entry on Hygon too - Use the special RAPL CPUID bit to detect the functionality on AMD and Hygon instead of doing family matching. - Add support for new Intel microcode deprecating TSX on some models and do not enable kernel workarounds for those CPUs when TSX transactions always abort, as a result of that microcode update. * tag 'x86_cpu_for_v5.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/tsx: Clear CPUID bits when TSX always force aborts x86/events/intel: Do not deploy TSX force abort workaround when TSX is deprecated x86/msr: Define new bits in TSX_FORCE_ABORT MSR perf/x86/rapl: Use CPUID bit on AMD and Hygon parts x86/cstate: Allow ACPI C1 FFH MWAIT use on Hygon systems x86/amd_nb: Add AMD family 19h model 50h PCI ids x86/cpu: Fix core name for Sapphire Rapids
2 parents f565b20 + 2936493 commit 2594b71

13 files changed

Lines changed: 71 additions & 11 deletions

File tree

arch/x86/events/intel/core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6015,7 +6015,13 @@ __init int intel_pmu_init(void)
60156015
tsx_attr = hsw_tsx_events_attrs;
60166016
intel_pmu_pebs_data_source_skl(pmem);
60176017

6018-
if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) {
6018+
/*
6019+
* Processors with CPUID.RTM_ALWAYS_ABORT have TSX deprecated by default.
6020+
* TSX force abort hooks are not required on these systems. Only deploy
6021+
* workaround when microcode has not enabled X86_FEATURE_RTM_ALWAYS_ABORT.
6022+
*/
6023+
if (boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT) &&
6024+
!boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)) {
60196025
x86_pmu.flags |= PMU_FL_TFA;
60206026
x86_pmu.get_event_constraints = tfa_get_event_constraints;
60216027
x86_pmu.enable_all = intel_tfa_pmu_enable_all;

arch/x86/events/rapl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,14 @@ static struct rapl_model model_spr = {
764764
.rapl_msrs = intel_rapl_spr_msrs,
765765
};
766766

767-
static struct rapl_model model_amd_fam17h = {
767+
static struct rapl_model model_amd_hygon = {
768768
.events = BIT(PERF_RAPL_PKG),
769769
.msr_power_unit = MSR_AMD_RAPL_POWER_UNIT,
770770
.rapl_msrs = amd_rapl_msrs,
771771
};
772772

773773
static const struct x86_cpu_id rapl_model_match[] __initconst = {
774+
X86_MATCH_FEATURE(X86_FEATURE_RAPL, &model_amd_hygon),
774775
X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &model_snb),
775776
X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &model_snbep),
776777
X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, &model_snb),
@@ -803,9 +804,6 @@ static const struct x86_cpu_id rapl_model_match[] __initconst = {
803804
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, &model_skl),
804805
X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, &model_skl),
805806
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &model_spr),
806-
X86_MATCH_VENDOR_FAM(AMD, 0x17, &model_amd_fam17h),
807-
X86_MATCH_VENDOR_FAM(HYGON, 0x18, &model_amd_fam17h),
808-
X86_MATCH_VENDOR_FAM(AMD, 0x19, &model_amd_fam17h),
809807
{},
810808
};
811809
MODULE_DEVICE_TABLE(x86cpu, rapl_model_match);

arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
#define X86_FEATURE_EXTD_APICID ( 3*32+26) /* Extended APICID (8 bits) */
109109
#define X86_FEATURE_AMD_DCM ( 3*32+27) /* AMD multi-node processor */
110110
#define X86_FEATURE_APERFMPERF ( 3*32+28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */
111-
/* free ( 3*32+29) */
111+
#define X86_FEATURE_RAPL ( 3*32+29) /* AMD/Hygon RAPL interface */
112112
#define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */
113113
#define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */
114114

@@ -378,6 +378,7 @@
378378
#define X86_FEATURE_AVX512_VP2INTERSECT (18*32+ 8) /* AVX-512 Intersect for D/Q */
379379
#define X86_FEATURE_SRBDS_CTRL (18*32+ 9) /* "" SRBDS mitigation MSR available */
380380
#define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */
381+
#define X86_FEATURE_RTM_ALWAYS_ABORT (18*32+11) /* "" RTM transaction always aborts */
381382
#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
382383
#define X86_FEATURE_SERIALIZE (18*32+14) /* SERIALIZE instruction */
383384
#define X86_FEATURE_HYBRID_CPU (18*32+15) /* "" This part has CPUs of more than one type */

arch/x86/include/asm/intel-family.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102

103103
#define INTEL_FAM6_TIGERLAKE_L 0x8C /* Willow Cove */
104104
#define INTEL_FAM6_TIGERLAKE 0x8D /* Willow Cove */
105-
#define INTEL_FAM6_SAPPHIRERAPIDS_X 0x8F /* Willow Cove */
105+
106+
#define INTEL_FAM6_SAPPHIRERAPIDS_X 0x8F /* Golden Cove */
106107

107108
#define INTEL_FAM6_ALDERLAKE 0x97 /* Golden Cove / Gracemont */
108109
#define INTEL_FAM6_ALDERLAKE_L 0x9A /* Golden Cove / Gracemont */

arch/x86/include/asm/msr-index.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@
772772

773773
#define MSR_TFA_RTM_FORCE_ABORT_BIT 0
774774
#define MSR_TFA_RTM_FORCE_ABORT BIT_ULL(MSR_TFA_RTM_FORCE_ABORT_BIT)
775+
#define MSR_TFA_TSX_CPUID_CLEAR_BIT 1
776+
#define MSR_TFA_TSX_CPUID_CLEAR BIT_ULL(MSR_TFA_TSX_CPUID_CLEAR_BIT)
777+
#define MSR_TFA_SDV_ENABLE_RTM_BIT 2
778+
#define MSR_TFA_SDV_ENABLE_RTM BIT_ULL(MSR_TFA_SDV_ENABLE_RTM_BIT)
775779

776780
/* P4/Xeon+ specific */
777781
#define MSR_IA32_MCG_EAX 0x00000180

arch/x86/kernel/acpi/cstate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ static int __init ffh_cstate_init(void)
197197
struct cpuinfo_x86 *c = &boot_cpu_data;
198198

199199
if (c->x86_vendor != X86_VENDOR_INTEL &&
200-
c->x86_vendor != X86_VENDOR_AMD)
200+
c->x86_vendor != X86_VENDOR_AMD &&
201+
c->x86_vendor != X86_VENDOR_HYGON)
201202
return -1;
202203

203204
cpu_cstate_entry = alloc_percpu(struct cstate_entry);

arch/x86/kernel/amd_nb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define PCI_DEVICE_ID_AMD_17H_M60H_DF_F4 0x144c
2626
#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F4 0x1444
2727
#define PCI_DEVICE_ID_AMD_19H_DF_F4 0x1654
28+
#define PCI_DEVICE_ID_AMD_19H_M50H_DF_F4 0x166e
2829

2930
/* Protect the PCI config register pairs used for SMN and DF indirect access. */
3031
static DEFINE_MUTEX(smn_mutex);
@@ -57,6 +58,7 @@ static const struct pci_device_id amd_nb_misc_ids[] = {
5758
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
5859
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) },
5960
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) },
61+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F3) },
6062
{}
6163
};
6264

@@ -72,6 +74,7 @@ static const struct pci_device_id amd_nb_link_ids[] = {
7274
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F4) },
7375
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F4) },
7476
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F4) },
77+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F4) },
7578
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
7679
{}
7780
};

arch/x86/kernel/cpu/amd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ static void early_init_amd(struct cpuinfo_x86 *c)
646646
if (c->x86_power & BIT(12))
647647
set_cpu_cap(c, X86_FEATURE_ACC_POWER);
648648

649+
/* Bit 14 indicates the Runtime Average Power Limit interface. */
650+
if (c->x86_power & BIT(14))
651+
set_cpu_cap(c, X86_FEATURE_RAPL);
652+
649653
#ifdef CONFIG_X86_64
650654
set_cpu_cap(c, X86_FEATURE_SYSCALL32);
651655
#else

arch/x86/kernel/cpu/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern const struct cpu_dev *const __x86_cpu_dev_start[],
4848
enum tsx_ctrl_states {
4949
TSX_CTRL_ENABLE,
5050
TSX_CTRL_DISABLE,
51+
TSX_CTRL_RTM_ALWAYS_ABORT,
5152
TSX_CTRL_NOT_SUPPORTED,
5253
};
5354

@@ -56,6 +57,7 @@ extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state;
5657
extern void __init tsx_init(void);
5758
extern void tsx_enable(void);
5859
extern void tsx_disable(void);
60+
extern void tsx_clear_cpuid(void);
5961
#else
6062
static inline void tsx_init(void) { }
6163
#endif /* CONFIG_CPU_SUP_INTEL */

arch/x86/kernel/cpu/hygon.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ static void early_init_hygon(struct cpuinfo_x86 *c)
260260
if (c->x86_power & BIT(12))
261261
set_cpu_cap(c, X86_FEATURE_ACC_POWER);
262262

263+
/* Bit 14 indicates the Runtime Average Power Limit interface. */
264+
if (c->x86_power & BIT(14))
265+
set_cpu_cap(c, X86_FEATURE_RAPL);
266+
263267
#ifdef CONFIG_X86_64
264268
set_cpu_cap(c, X86_FEATURE_SYSCALL32);
265269
#endif

0 commit comments

Comments
 (0)