Skip to content

Commit 1ce4284

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Last minute x86 fixes: - Fix a softlockup detector warning and long delays if using ptdump with KASAN enabled. - Two more TSC-adjust fixes for interesting firmware interactions. - Two commits to fix an AMD CPU topology enumeration bug that caused a measurable gaming performance regression" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm/ptdump: Fix soft lockup in page table walker x86/tsc: Make the TSC ADJUST sanitizing work for tsc_reliable x86/tsc: Avoid the large time jump when sanitizing TSC ADJUST x86/CPU/AMD: Fix Zen SMT topology x86/CPU/AMD: Bring back Compute Unit ID
2 parents fdb0ee7 + 146fbb7 commit 1ce4284

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

arch/x86/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct cpuinfo_x86 {
104104
__u8 x86_phys_bits;
105105
/* CPUID returned core id bits: */
106106
__u8 x86_coreid_bits;
107+
__u8 cu_id;
107108
/* Max extended CPUID function supported: */
108109
__u32 extended_cpuid_level;
109110
/* Maximum supported CPUID level, -1=no CPUID: */

arch/x86/kernel/cpu/amd.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,22 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
309309

310310
/* get information required for multi-node processors */
311311
if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
312+
u32 eax, ebx, ecx, edx;
312313

313-
node_id = cpuid_ecx(0x8000001e) & 7;
314+
cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
315+
316+
node_id = ecx & 0xff;
317+
smp_num_siblings = ((ebx >> 8) & 0xff) + 1;
318+
319+
if (c->x86 == 0x15)
320+
c->cu_id = ebx & 0xff;
321+
322+
if (c->x86 >= 0x17) {
323+
c->cpu_core_id = ebx & 0xff;
324+
325+
if (smp_num_siblings > 1)
326+
c->x86_max_cores /= smp_num_siblings;
327+
}
314328

315329
/*
316330
* We may have multiple LLCs if L3 caches exist, so check if we

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
10151015
c->x86_model_id[0] = '\0'; /* Unset */
10161016
c->x86_max_cores = 1;
10171017
c->x86_coreid_bits = 0;
1018+
c->cu_id = 0xff;
10181019
#ifdef CONFIG_X86_64
10191020
c->x86_clflush_size = 64;
10201021
c->x86_phys_bits = 36;

arch/x86/kernel/smpboot.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,15 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
433433
int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
434434

435435
if (c->phys_proc_id == o->phys_proc_id &&
436-
per_cpu(cpu_llc_id, cpu1) == per_cpu(cpu_llc_id, cpu2) &&
437-
c->cpu_core_id == o->cpu_core_id)
438-
return topology_sane(c, o, "smt");
436+
per_cpu(cpu_llc_id, cpu1) == per_cpu(cpu_llc_id, cpu2)) {
437+
if (c->cpu_core_id == o->cpu_core_id)
438+
return topology_sane(c, o, "smt");
439+
440+
if ((c->cu_id != 0xff) &&
441+
(o->cu_id != 0xff) &&
442+
(c->cu_id == o->cu_id))
443+
return topology_sane(c, o, "smt");
444+
}
439445

440446
} else if (c->phys_proc_id == o->phys_proc_id &&
441447
c->cpu_core_id == o->cpu_core_id) {

arch/x86/kernel/tsc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ void __init tsc_init(void)
13561356
(unsigned long)cpu_khz / 1000,
13571357
(unsigned long)cpu_khz % 1000);
13581358

1359+
/* Sanitize TSC ADJUST before cyc2ns gets initialized */
1360+
tsc_store_and_check_tsc_adjust(true);
1361+
13591362
/*
13601363
* Secondary CPUs do not run through tsc_init(), so set up
13611364
* all the scale factors for all CPUs, assuming the same
@@ -1386,8 +1389,6 @@ void __init tsc_init(void)
13861389

13871390
if (unsynchronized_tsc())
13881391
mark_tsc_unstable("TSCs unsynchronized");
1389-
else
1390-
tsc_store_and_check_tsc_adjust(true);
13911392

13921393
check_system_tsc_reliable();
13931394

arch/x86/kernel/tsc_sync.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,6 @@ void check_tsc_sync_source(int cpu)
286286
if (unsynchronized_tsc())
287287
return;
288288

289-
if (tsc_clocksource_reliable) {
290-
if (cpu == (nr_cpu_ids-1) || system_state != SYSTEM_BOOTING)
291-
pr_info(
292-
"Skipped synchronization checks as TSC is reliable.\n");
293-
return;
294-
}
295-
296289
/*
297290
* Set the maximum number of test runs to
298291
* 1 if the CPU does not provide the TSC_ADJUST MSR
@@ -380,14 +373,19 @@ void check_tsc_sync_target(void)
380373
int cpus = 2;
381374

382375
/* Also aborts if there is no TSC. */
383-
if (unsynchronized_tsc() || tsc_clocksource_reliable)
376+
if (unsynchronized_tsc())
384377
return;
385378

386379
/*
387380
* Store, verify and sanitize the TSC adjust register. If
388381
* successful skip the test.
382+
*
383+
* The test is also skipped when the TSC is marked reliable. This
384+
* is true for SoCs which have no fallback clocksource. On these
385+
* SoCs the TSC is frequency synchronized, but still the TSC ADJUST
386+
* register might have been wreckaged by the BIOS..
389387
*/
390-
if (tsc_store_and_check_tsc_adjust(false)) {
388+
if (tsc_store_and_check_tsc_adjust(false) || tsc_clocksource_reliable) {
391389
atomic_inc(&skip_test);
392390
return;
393391
}

arch/x86/mm/dump_pagetables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/debugfs.h>
1616
#include <linux/mm.h>
1717
#include <linux/init.h>
18+
#include <linux/sched.h>
1819
#include <linux/seq_file.h>
1920

2021
#include <asm/pgtable.h>
@@ -406,6 +407,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
406407
} else
407408
note_page(m, &st, __pgprot(0), 1);
408409

410+
cond_resched();
409411
start++;
410412
}
411413

0 commit comments

Comments
 (0)