Skip to content

Commit 9cea0d4

Browse files
author
Ingo Molnar
committed
Merge branch 'x86/cpu' into x86/core, to resolve conflicts
Conflicts: arch/x86/include/asm/cpufeatures.h Signed-off-by: Ingo Molnar <[email protected]>
2 parents 8c490b4 + 08f253e commit 9cea0d4

File tree

14 files changed

+125
-93
lines changed

14 files changed

+125
-93
lines changed

Documentation/ABI/stable/sysfs-devices-system-cpu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ What: /sys/devices/system/cpu/cpuX/topology/die_cpus
8686
Description: internal kernel map of CPUs within the same die.
8787
Values: hexadecimal bitmask.
8888

89+
What: /sys/devices/system/cpu/cpuX/topology/ppin
90+
Description: per-socket protected processor inventory number
91+
Values: hexadecimal.
92+
8993
What: /sys/devices/system/cpu/cpuX/topology/die_cpus_list
9094
Description: human-readable list of CPUs within the same die.
9195
The format is like 0-3, 8-11, 14,17.

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ What: /sys/devices/system/cpu/cpuX/topology/core_id
7373
/sys/devices/system/cpu/cpuX/topology/physical_package_id
7474
/sys/devices/system/cpu/cpuX/topology/thread_siblings
7575
/sys/devices/system/cpu/cpuX/topology/thread_siblings_list
76+
/sys/devices/system/cpu/cpuX/topology/ppin
7677
Date: December 2008
7778
Contact: Linux kernel mailing list <[email protected]>
7879
Description: CPU topology files that describe a logical CPU's relationship
@@ -103,6 +104,11 @@ Description: CPU topology files that describe a logical CPU's relationship
103104
thread_siblings_list: human-readable list of cpuX's hardware
104105
threads within the same core as cpuX
105106

107+
ppin: human-readable Protected Processor Identification
108+
Number of the socket the cpu# belongs to. There should be
109+
one per physical_package_id. File is readable only to
110+
admin.
111+
106112
See Documentation/admin-guide/cputopology.rst for more information.
107113

108114

arch/x86/include/asm/cpufeatures.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,6 @@
299299
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
300300
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */
301301
#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */
302-
#define X86_FEATURE_AMX_BF16 (18*32+22) /* AMX bf16 Support */
303-
#define X86_FEATURE_AMX_TILE (18*32+24) /* AMX tile Support */
304-
#define X86_FEATURE_AMX_INT8 (18*32+25) /* AMX int8 Support */
305302

306303
/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
307304
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
@@ -391,7 +388,10 @@
391388
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
392389
#define X86_FEATURE_ARCH_LBR (18*32+19) /* Intel ARCH LBR */
393390
#define X86_FEATURE_IBT (18*32+20) /* Indirect Branch Tracking */
391+
#define X86_FEATURE_AMX_BF16 (18*32+22) /* AMX bf16 Support */
394392
#define X86_FEATURE_AVX512_FP16 (18*32+23) /* AVX512 FP16 */
393+
#define X86_FEATURE_AMX_TILE (18*32+24) /* AMX tile Support */
394+
#define X86_FEATURE_AMX_INT8 (18*32+25) /* AMX int8 Support */
395395
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
396396
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
397397
#define X86_FEATURE_FLUSH_L1D (18*32+28) /* Flush L1D cache */

arch/x86/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ struct cpuinfo_x86 {
119119
int x86_cache_mbm_width_offset;
120120
int x86_power;
121121
unsigned long loops_per_jiffy;
122+
/* protected processor identification number */
123+
u64 ppin;
122124
/* cpuid returned max cores value: */
123125
u16 x86_max_cores;
124126
u16 apicid;

arch/x86/include/asm/topology.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu);
110110
#define topology_logical_die_id(cpu) (cpu_data(cpu).logical_die_id)
111111
#define topology_die_id(cpu) (cpu_data(cpu).cpu_die_id)
112112
#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)
113+
#define topology_ppin(cpu) (cpu_data(cpu).ppin)
113114

114115
extern unsigned int __max_die_per_package;
115116

arch/x86/kernel/cpu/amd.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -394,35 +394,6 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
394394
per_cpu(cpu_llc_id, cpu) = c->cpu_die_id = c->phys_proc_id;
395395
}
396396

397-
static void amd_detect_ppin(struct cpuinfo_x86 *c)
398-
{
399-
unsigned long long val;
400-
401-
if (!cpu_has(c, X86_FEATURE_AMD_PPIN))
402-
return;
403-
404-
/* When PPIN is defined in CPUID, still need to check PPIN_CTL MSR */
405-
if (rdmsrl_safe(MSR_AMD_PPIN_CTL, &val))
406-
goto clear_ppin;
407-
408-
/* PPIN is locked in disabled mode, clear feature bit */
409-
if ((val & 3UL) == 1UL)
410-
goto clear_ppin;
411-
412-
/* If PPIN is disabled, try to enable it */
413-
if (!(val & 2UL)) {
414-
wrmsrl_safe(MSR_AMD_PPIN_CTL, val | 2UL);
415-
rdmsrl_safe(MSR_AMD_PPIN_CTL, &val);
416-
}
417-
418-
/* If PPIN_EN bit is 1, return from here; otherwise fall through */
419-
if (val & 2UL)
420-
return;
421-
422-
clear_ppin:
423-
clear_cpu_cap(c, X86_FEATURE_AMD_PPIN);
424-
}
425-
426397
u32 amd_get_nodes_per_socket(void)
427398
{
428399
return nodes_per_socket;
@@ -585,6 +556,8 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)
585556
* the SME physical address space reduction value.
586557
* If BIOS has not enabled SME then don't advertise the
587558
* SME feature (set in scattered.c).
559+
* If the kernel has not enabled SME via any means then
560+
* don't advertise the SME feature.
588561
* For SEV: If BIOS has not enabled SEV then don't advertise the
589562
* SEV and SEV_ES feature (set in scattered.c).
590563
*
@@ -607,6 +580,9 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)
607580
if (IS_ENABLED(CONFIG_X86_32))
608581
goto clear_all;
609582

583+
if (!sme_me_mask)
584+
setup_clear_cpu_cap(X86_FEATURE_SME);
585+
610586
rdmsrl(MSR_K7_HWCR, msr);
611587
if (!(msr & MSR_K7_HWCR_SMMLOCK))
612588
goto clear_sev;
@@ -947,7 +923,6 @@ static void init_amd(struct cpuinfo_x86 *c)
947923
amd_detect_cmp(c);
948924
amd_get_topology(c);
949925
srat_detect_node(c);
950-
amd_detect_ppin(c);
951926

952927
init_amd_cacheinfo(c);
953928

arch/x86/kernel/cpu/common.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,83 @@ EXPORT_SYMBOL_GPL(get_llc_id);
8989
/* L2 cache ID of each logical CPU */
9090
DEFINE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id) = BAD_APICID;
9191

92+
static struct ppin_info {
93+
int feature;
94+
int msr_ppin_ctl;
95+
int msr_ppin;
96+
} ppin_info[] = {
97+
[X86_VENDOR_INTEL] = {
98+
.feature = X86_FEATURE_INTEL_PPIN,
99+
.msr_ppin_ctl = MSR_PPIN_CTL,
100+
.msr_ppin = MSR_PPIN
101+
},
102+
[X86_VENDOR_AMD] = {
103+
.feature = X86_FEATURE_AMD_PPIN,
104+
.msr_ppin_ctl = MSR_AMD_PPIN_CTL,
105+
.msr_ppin = MSR_AMD_PPIN
106+
},
107+
};
108+
109+
static const struct x86_cpu_id ppin_cpuids[] = {
110+
X86_MATCH_FEATURE(X86_FEATURE_AMD_PPIN, &ppin_info[X86_VENDOR_AMD]),
111+
X86_MATCH_FEATURE(X86_FEATURE_INTEL_PPIN, &ppin_info[X86_VENDOR_INTEL]),
112+
113+
/* Legacy models without CPUID enumeration */
114+
X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, &ppin_info[X86_VENDOR_INTEL]),
115+
X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, &ppin_info[X86_VENDOR_INTEL]),
116+
X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, &ppin_info[X86_VENDOR_INTEL]),
117+
X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, &ppin_info[X86_VENDOR_INTEL]),
118+
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, &ppin_info[X86_VENDOR_INTEL]),
119+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, &ppin_info[X86_VENDOR_INTEL]),
120+
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, &ppin_info[X86_VENDOR_INTEL]),
121+
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, &ppin_info[X86_VENDOR_INTEL]),
122+
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &ppin_info[X86_VENDOR_INTEL]),
123+
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &ppin_info[X86_VENDOR_INTEL]),
124+
125+
{}
126+
};
127+
128+
static void ppin_init(struct cpuinfo_x86 *c)
129+
{
130+
const struct x86_cpu_id *id;
131+
unsigned long long val;
132+
struct ppin_info *info;
133+
134+
id = x86_match_cpu(ppin_cpuids);
135+
if (!id)
136+
return;
137+
138+
/*
139+
* Testing the presence of the MSR is not enough. Need to check
140+
* that the PPIN_CTL allows reading of the PPIN.
141+
*/
142+
info = (struct ppin_info *)id->driver_data;
143+
144+
if (rdmsrl_safe(info->msr_ppin_ctl, &val))
145+
goto clear_ppin;
146+
147+
if ((val & 3UL) == 1UL) {
148+
/* PPIN locked in disabled mode */
149+
goto clear_ppin;
150+
}
151+
152+
/* If PPIN is disabled, try to enable */
153+
if (!(val & 2UL)) {
154+
wrmsrl_safe(info->msr_ppin_ctl, val | 2UL);
155+
rdmsrl_safe(info->msr_ppin_ctl, &val);
156+
}
157+
158+
/* Is the enable bit set? */
159+
if (val & 2UL) {
160+
c->ppin = __rdmsr(info->msr_ppin);
161+
set_cpu_cap(c, info->feature);
162+
return;
163+
}
164+
165+
clear_ppin:
166+
clear_cpu_cap(c, info->feature);
167+
}
168+
92169
/* correctly size the local cpu masks */
93170
void __init setup_cpu_local_masks(void)
94171
{
@@ -1710,6 +1787,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
17101787
c->x86_capability[i] |= boot_cpu_data.x86_capability[i];
17111788
}
17121789

1790+
ppin_init(c);
1791+
17131792
/* Init Machine Check Exception if available. */
17141793
mcheck_cpu_init(c);
17151794

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ static struct attribute *default_attrs[] = {
993993
NULL, /* possibly interrupt_enable if supported, see below */
994994
NULL,
995995
};
996+
ATTRIBUTE_GROUPS(default);
996997

997998
#define to_block(k) container_of(k, struct threshold_block, kobj)
998999
#define to_attr(a) container_of(a, struct threshold_attr, attr)
@@ -1029,7 +1030,7 @@ static void threshold_block_release(struct kobject *kobj);
10291030

10301031
static struct kobj_type threshold_ktype = {
10311032
.sysfs_ops = &threshold_ops,
1032-
.default_attrs = default_attrs,
1033+
.default_groups = default_groups,
10331034
.release = threshold_block_release,
10341035
};
10351036

@@ -1101,10 +1102,10 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb
11011102
b->threshold_limit = THRESHOLD_MAX;
11021103

11031104
if (b->interrupt_capable) {
1104-
threshold_ktype.default_attrs[2] = &interrupt_enable.attr;
1105+
default_attrs[2] = &interrupt_enable.attr;
11051106
b->interrupt_enable = 1;
11061107
} else {
1107-
threshold_ktype.default_attrs[2] = NULL;
1108+
default_attrs[2] = NULL;
11081109
}
11091110

11101111
INIT_LIST_HEAD(&b->miscj);

arch/x86/kernel/cpu/mce/core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,7 @@ void mce_setup(struct mce *m)
138138
m->socketid = cpu_data(m->extcpu).phys_proc_id;
139139
m->apicid = cpu_data(m->extcpu).initial_apicid;
140140
m->mcgcap = __rdmsr(MSR_IA32_MCG_CAP);
141-
142-
if (this_cpu_has(X86_FEATURE_INTEL_PPIN))
143-
m->ppin = __rdmsr(MSR_PPIN);
144-
else if (this_cpu_has(X86_FEATURE_AMD_PPIN))
145-
m->ppin = __rdmsr(MSR_AMD_PPIN);
146-
141+
m->ppin = cpu_data(m->extcpu).ppin;
147142
m->microcode = boot_cpu_data.microcode;
148143
}
149144

arch/x86/kernel/cpu/mce/intel.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -470,47 +470,6 @@ void intel_clear_lmce(void)
470470
wrmsrl(MSR_IA32_MCG_EXT_CTL, val);
471471
}
472472

473-
static void intel_ppin_init(struct cpuinfo_x86 *c)
474-
{
475-
unsigned long long val;
476-
477-
/*
478-
* Even if testing the presence of the MSR would be enough, we don't
479-
* want to risk the situation where other models reuse this MSR for
480-
* other purposes.
481-
*/
482-
switch (c->x86_model) {
483-
case INTEL_FAM6_IVYBRIDGE_X:
484-
case INTEL_FAM6_HASWELL_X:
485-
case INTEL_FAM6_BROADWELL_D:
486-
case INTEL_FAM6_BROADWELL_X:
487-
case INTEL_FAM6_SKYLAKE_X:
488-
case INTEL_FAM6_ICELAKE_X:
489-
case INTEL_FAM6_ICELAKE_D:
490-
case INTEL_FAM6_SAPPHIRERAPIDS_X:
491-
case INTEL_FAM6_XEON_PHI_KNL:
492-
case INTEL_FAM6_XEON_PHI_KNM:
493-
494-
if (rdmsrl_safe(MSR_PPIN_CTL, &val))
495-
return;
496-
497-
if ((val & 3UL) == 1UL) {
498-
/* PPIN locked in disabled mode */
499-
return;
500-
}
501-
502-
/* If PPIN is disabled, try to enable */
503-
if (!(val & 2UL)) {
504-
wrmsrl_safe(MSR_PPIN_CTL, val | 2UL);
505-
rdmsrl_safe(MSR_PPIN_CTL, &val);
506-
}
507-
508-
/* Is the enable bit set? */
509-
if (val & 2UL)
510-
set_cpu_cap(c, X86_FEATURE_INTEL_PPIN);
511-
}
512-
}
513-
514473
/*
515474
* Enable additional error logs from the integrated
516475
* memory controller on processors that support this.
@@ -535,7 +494,6 @@ void mce_intel_feature_init(struct cpuinfo_x86 *c)
535494
{
536495
intel_init_cmci();
537496
intel_init_lmce();
538-
intel_ppin_init(c);
539497
intel_imc_init(c);
540498
}
541499

0 commit comments

Comments
 (0)