Skip to content

Commit bba072d

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 Thomas Gleixner: "A couple of fixes and updates related to x86: - Fix the W+X check regression on XEN - The real fix for the low identity map trainwreck - Probe legacy PIC early instead of unconditionally allocating legacy irqs - Add cpu verification to long mode entry - Adjust the cache topology to AMD Fam17H systems - Let Merrifield use the TSC across S3" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpu: Call verify_cpu() after having entered long mode too x86/setup: Fix low identity map for >= 2GB kernel range x86/mm: Skip the hypervisor range when walking PGD x86/AMD: Fix last level cache topology for AMD Fam17h systems x86/irq: Probe for PIC presence before allocating descs for legacy IRQs x86/cpu/intel: Enable X86_FEATURE_NONSTOP_TSC_S3 for Merrifield
2 parents 511601b + 04633df commit bba072d

File tree

9 files changed

+73
-16
lines changed

9 files changed

+73
-16
lines changed

arch/x86/include/asm/i8259.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct legacy_pic {
6060
void (*mask_all)(void);
6161
void (*restore_mask)(void);
6262
void (*init)(int auto_eoi);
63+
int (*probe)(void);
6364
int (*irq_pending)(unsigned int irq);
6465
void (*make_irq)(unsigned int irq);
6566
};

arch/x86/kernel/apic/vector.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ int __init arch_probe_nr_irqs(void)
361361
if (nr < nr_irqs)
362362
nr_irqs = nr;
363363

364-
return nr_legacy_irqs();
364+
/*
365+
* We don't know if PIC is present at this point so we need to do
366+
* probe() to get the right number of legacy IRQs.
367+
*/
368+
return legacy_pic->probe();
365369
}
366370

367371
#ifdef CONFIG_X86_IO_APIC

arch/x86/kernel/cpu/amd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
352352
#ifdef CONFIG_SMP
353353
unsigned bits;
354354
int cpu = smp_processor_id();
355+
unsigned int socket_id, core_complex_id;
355356

356357
bits = c->x86_coreid_bits;
357358
/* Low order bits define the core id (index of core in socket) */
@@ -361,6 +362,18 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
361362
/* use socket ID also for last level cache */
362363
per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
363364
amd_get_topology(c);
365+
366+
/*
367+
* Fix percpu cpu_llc_id here as LLC topology is different
368+
* for Fam17h systems.
369+
*/
370+
if (c->x86 != 0x17 || !cpuid_edx(0x80000006))
371+
return;
372+
373+
socket_id = (c->apicid >> bits) - 1;
374+
core_complex_id = (c->apicid & ((1 << bits) - 1)) >> 3;
375+
376+
per_cpu(cpu_llc_id, cpu) = (socket_id << 3) | core_complex_id;
364377
#endif
365378
}
366379

arch/x86/kernel/cpu/intel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
9797
switch (c->x86_model) {
9898
case 0x27: /* Penwell */
9999
case 0x35: /* Cloverview */
100+
case 0x4a: /* Merrifield */
100101
set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC_S3);
101102
break;
102103
default:

arch/x86/kernel/head_64.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ startup_64:
6565
* tables and then reload them.
6666
*/
6767

68+
/* Sanitize CPU configuration */
69+
call verify_cpu
70+
6871
/*
6972
* Compute the delta between the address I am compiled to run at and the
7073
* address I am actually running at.
@@ -174,6 +177,9 @@ ENTRY(secondary_startup_64)
174177
* after the boot processor executes this code.
175178
*/
176179

180+
/* Sanitize CPU configuration */
181+
call verify_cpu
182+
177183
movq $(init_level4_pgt - __START_KERNEL_map), %rax
178184
1:
179185

@@ -288,6 +294,8 @@ ENTRY(secondary_startup_64)
288294
pushq %rax # target address in negative space
289295
lretq
290296

297+
#include "verify_cpu.S"
298+
291299
#ifdef CONFIG_HOTPLUG_CPU
292300
/*
293301
* Boot CPU0 entry point. It's called from play_dead(). Everything has been set

arch/x86/kernel/i8259.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,33 +295,40 @@ static void unmask_8259A(void)
295295
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
296296
}
297297

298-
static void init_8259A(int auto_eoi)
298+
static int probe_8259A(void)
299299
{
300300
unsigned long flags;
301301
unsigned char probe_val = ~(1 << PIC_CASCADE_IR);
302302
unsigned char new_val;
303-
304-
i8259A_auto_eoi = auto_eoi;
305-
306-
raw_spin_lock_irqsave(&i8259A_lock, flags);
307-
308303
/*
309304
* Check to see if we have a PIC.
310305
* Mask all except the cascade and read
311306
* back the value we just wrote. If we don't
312307
* have a PIC, we will read 0xff as opposed to the
313308
* value we wrote.
314309
*/
310+
raw_spin_lock_irqsave(&i8259A_lock, flags);
311+
315312
outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
316313
outb(probe_val, PIC_MASTER_IMR);
317314
new_val = inb(PIC_MASTER_IMR);
318315
if (new_val != probe_val) {
319316
printk(KERN_INFO "Using NULL legacy PIC\n");
320317
legacy_pic = &null_legacy_pic;
321-
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
322-
return;
323318
}
324319

320+
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
321+
return nr_legacy_irqs();
322+
}
323+
324+
static void init_8259A(int auto_eoi)
325+
{
326+
unsigned long flags;
327+
328+
i8259A_auto_eoi = auto_eoi;
329+
330+
raw_spin_lock_irqsave(&i8259A_lock, flags);
331+
325332
outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
326333

327334
/*
@@ -379,6 +386,10 @@ static int legacy_pic_irq_pending_noop(unsigned int irq)
379386
{
380387
return 0;
381388
}
389+
static int legacy_pic_probe(void)
390+
{
391+
return 0;
392+
}
382393

383394
struct legacy_pic null_legacy_pic = {
384395
.nr_legacy_irqs = 0,
@@ -388,6 +399,7 @@ struct legacy_pic null_legacy_pic = {
388399
.mask_all = legacy_pic_noop,
389400
.restore_mask = legacy_pic_noop,
390401
.init = legacy_pic_int_noop,
402+
.probe = legacy_pic_probe,
391403
.irq_pending = legacy_pic_irq_pending_noop,
392404
.make_irq = legacy_pic_uint_noop,
393405
};
@@ -400,6 +412,7 @@ struct legacy_pic default_legacy_pic = {
400412
.mask_all = mask_8259A,
401413
.restore_mask = unmask_8259A,
402414
.init = init_8259A,
415+
.probe = probe_8259A,
403416
.irq_pending = i8259A_irq_pending,
404417
.make_irq = make_8259A_irq,
405418
};

arch/x86/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ void __init setup_arch(char **cmdline_p)
11881188
*/
11891189
clone_pgd_range(initial_page_table,
11901190
swapper_pg_dir + KERNEL_PGD_BOUNDARY,
1191-
KERNEL_PGD_PTRS);
1191+
min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
11921192
#endif
11931193

11941194
tboot_probe();

arch/x86/kernel/verify_cpu.S

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
#include <asm/msr-index.h>
3535

3636
verify_cpu:
37-
pushfl # Save caller passed flags
38-
pushl $0 # Kill any dangerous flags
39-
popfl
37+
pushf # Save caller passed flags
38+
push $0 # Kill any dangerous flags
39+
popf
4040

41+
#ifndef __x86_64__
4142
pushfl # standard way to check for cpuid
4243
popl %eax
4344
movl %eax,%ebx
@@ -48,6 +49,7 @@ verify_cpu:
4849
popl %eax
4950
cmpl %eax,%ebx
5051
jz verify_cpu_no_longmode # cpu has no cpuid
52+
#endif
5153

5254
movl $0x0,%eax # See if cpuid 1 is implemented
5355
cpuid
@@ -130,10 +132,10 @@ verify_cpu_sse_test:
130132
jmp verify_cpu_sse_test # try again
131133

132134
verify_cpu_no_longmode:
133-
popfl # Restore caller passed flags
135+
popf # Restore caller passed flags
134136
movl $1,%eax
135137
ret
136138
verify_cpu_sse_ok:
137-
popfl # Restore caller passed flags
139+
popf # Restore caller passed flags
138140
xorl %eax, %eax
139141
ret

arch/x86/mm/dump_pagetables.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, pgd_t addr,
358358
#define pgd_none(a) pud_none(__pud(pgd_val(a)))
359359
#endif
360360

361+
#ifdef CONFIG_X86_64
362+
static inline bool is_hypervisor_range(int idx)
363+
{
364+
/*
365+
* ffff800000000000 - ffff87ffffffffff is reserved for
366+
* the hypervisor.
367+
*/
368+
return paravirt_enabled() &&
369+
(idx >= pgd_index(__PAGE_OFFSET) - 16) &&
370+
(idx < pgd_index(__PAGE_OFFSET));
371+
}
372+
#else
373+
static inline bool is_hypervisor_range(int idx) { return false; }
374+
#endif
375+
361376
static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
362377
bool checkwx)
363378
{
@@ -381,7 +396,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
381396

382397
for (i = 0; i < PTRS_PER_PGD; i++) {
383398
st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
384-
if (!pgd_none(*start)) {
399+
if (!pgd_none(*start) && !is_hypervisor_range(i)) {
385400
if (pgd_large(*start) || !pgd_present(*start)) {
386401
prot = pgd_flags(*start);
387402
note_page(m, &st, __pgprot(prot), 1);

0 commit comments

Comments
 (0)