Skip to content

Commit 5c3b326

Browse files
committed
Merge tag 'x86_urgent_for_v6.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Convert the SSB mitigation to the attack vector controls which got forgotten at the time - Prevent the CPUID topology hierarchy detection on AMD from overwriting the correct initial APIC ID - Fix the case of a machine shipping without microcode in the BIOS, in the AMD microcode loader - Correct the Pentium 4 model range which has a constant TSC * tag 'x86_urgent_for_v6.17_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/bugs: Add attack vector controls for SSB x86/cpu/topology: Use initial APIC ID from XTOPOLOGY leaf on AMD/HYGON x86/microcode/AMD: Handle the case of no BIOS microcode x86/cpu/intel: Fix the constant_tsc model check for Pentium 4
2 parents fe3ad7a + 8b3641d commit 5c3b326

File tree

5 files changed

+45
-16
lines changed

5 files changed

+45
-16
lines changed

Documentation/admin-guide/hw-vuln/attack_vector_controls.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Spectre_v2 X X
215215
Spectre_v2_user X X * (Note 1)
216216
SRBDS X X X X
217217
SRSO X X X X
218-
SSB (Note 4)
218+
SSB X
219219
TAA X X X X * (Note 2)
220220
TSA X X X X
221221
=============== ============== ============ ============= ============== ============ ========
@@ -229,9 +229,6 @@ Notes:
229229
3 -- Disables SMT if cross-thread mitigations are fully enabled, the CPU is
230230
vulnerable, and STIBP is not supported
231231

232-
4 -- Speculative store bypass is always enabled by default (no kernel
233-
mitigation applied) unless overridden with spec_store_bypass_disable option
234-
235232
When an attack-vector is disabled, all mitigations for the vulnerabilities
236233
listed in the above table are disabled, unless mitigation is required for a
237234
different enabled attack-vector or a mitigation is explicitly selected via a

arch/x86/kernel/cpu/bugs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ static bool __init should_mitigate_vuln(unsigned int bug)
416416
cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER) ||
417417
cpu_attack_vector_mitigated(CPU_MITIGATE_GUEST_GUEST) ||
418418
(smt_mitigations != SMT_MITIGATIONS_OFF);
419+
420+
case X86_BUG_SPEC_STORE_BYPASS:
421+
return cpu_attack_vector_mitigated(CPU_MITIGATE_USER_USER);
422+
419423
default:
420424
WARN(1, "Unknown bug %x\n", bug);
421425
return false;
@@ -2710,6 +2714,11 @@ static void __init ssb_select_mitigation(void)
27102714
ssb_mode = SPEC_STORE_BYPASS_DISABLE;
27112715
break;
27122716
case SPEC_STORE_BYPASS_CMD_AUTO:
2717+
if (should_mitigate_vuln(X86_BUG_SPEC_STORE_BYPASS))
2718+
ssb_mode = SPEC_STORE_BYPASS_PRCTL;
2719+
else
2720+
ssb_mode = SPEC_STORE_BYPASS_NONE;
2721+
break;
27132722
case SPEC_STORE_BYPASS_CMD_PRCTL:
27142723
ssb_mode = SPEC_STORE_BYPASS_PRCTL;
27152724
break;

arch/x86/kernel/cpu/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
262262
if (c->x86_power & (1 << 8)) {
263263
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
264264
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
265-
} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_WILLAMETTE) ||
265+
} else if ((c->x86_vfm >= INTEL_P4_PRESCOTT && c->x86_vfm <= INTEL_P4_CEDARMILL) ||
266266
(c->x86_vfm >= INTEL_CORE_YONAH && c->x86_vfm <= INTEL_IVYBRIDGE)) {
267267
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
268268
}

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,28 @@ static int cmp_id(const void *key, const void *elem)
171171
return 1;
172172
}
173173

174+
static u32 cpuid_to_ucode_rev(unsigned int val)
175+
{
176+
union zen_patch_rev p = {};
177+
union cpuid_1_eax c;
178+
179+
c.full = val;
180+
181+
p.stepping = c.stepping;
182+
p.model = c.model;
183+
p.ext_model = c.ext_model;
184+
p.ext_fam = c.ext_fam;
185+
186+
return p.ucode_rev;
187+
}
188+
174189
static bool need_sha_check(u32 cur_rev)
175190
{
191+
if (!cur_rev) {
192+
cur_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax);
193+
pr_info_once("No current revision, generating the lowest one: 0x%x\n", cur_rev);
194+
}
195+
176196
switch (cur_rev >> 8) {
177197
case 0x80012: return cur_rev <= 0x800126f; break;
178198
case 0x80082: return cur_rev <= 0x800820f; break;
@@ -749,8 +769,6 @@ static struct ucode_patch *cache_find_patch(struct ucode_cpu_info *uci, u16 equi
749769
n.equiv_cpu = equiv_cpu;
750770
n.patch_id = uci->cpu_sig.rev;
751771

752-
WARN_ON_ONCE(!n.patch_id);
753-
754772
list_for_each_entry(p, &microcode_cache, plist)
755773
if (patch_cpus_equivalent(p, &n, false))
756774
return p;

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,25 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool has_topoext)
8181

8282
cpuid_leaf(0x8000001e, &leaf);
8383

84-
tscan->c->topo.initial_apicid = leaf.ext_apic_id;
85-
8684
/*
87-
* If leaf 0xb is available, then the domain shifts are set
88-
* already and nothing to do here. Only valid for family >= 0x17.
85+
* If leaf 0xb/0x26 is available, then the APIC ID and the domain
86+
* shifts are set already.
8987
*/
90-
if (!has_topoext && tscan->c->x86 >= 0x17) {
88+
if (!has_topoext) {
89+
tscan->c->topo.initial_apicid = leaf.ext_apic_id;
90+
9191
/*
92-
* Leaf 0x80000008 set the CORE domain shift already.
93-
* Update the SMT domain, but do not propagate it.
92+
* Leaf 0x8000008 sets the CORE domain shift but not the
93+
* SMT domain shift. On CPUs with family >= 0x17, there
94+
* might be hyperthreads.
9495
*/
95-
unsigned int nthreads = leaf.core_nthreads + 1;
96+
if (tscan->c->x86 >= 0x17) {
97+
/* Update the SMT domain, but do not propagate it. */
98+
unsigned int nthreads = leaf.core_nthreads + 1;
9699

97-
topology_update_dom(tscan, TOPO_SMT_DOMAIN, get_count_order(nthreads), nthreads);
100+
topology_update_dom(tscan, TOPO_SMT_DOMAIN,
101+
get_count_order(nthreads), nthreads);
102+
}
98103
}
99104

100105
store_node(tscan, leaf.nnodes_per_socket + 1, leaf.node_id);

0 commit comments

Comments
 (0)