Skip to content

Commit 1474630

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: "Hopefully the last round of fixes for 3.19 - regression fix for the LDT changes - regression fix for XEN interrupt handling caused by the APIC changes - regression fixes for the PAT changes - last minute fixes for new the MPX support - regression fix for 32bit UP - fix for a long standing relocation issue on 64bit tagged for stable - functional fix for the Hyper-V clocksource tagged for stable - downgrade of a pr_err which tends to confuse users Looks a bit on the large side, but almost half of it are valuable comments" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/tsc: Change Fast TSC calibration failed from error to info x86/apic: Re-enable PCI_MSI support for non-SMP X86_32 x86, mm: Change cachemode exports to non-gpl x86, tls: Interpret an all-zero struct user_desc as "no segment" x86, tls, ldt: Stop checking lm in LDT_empty x86, mpx: Strictly enforce empty prctl() args x86, mpx: Fix potential performance issue on unmaps x86, mpx: Explicitly disable 32-bit MPX support on 64-bit kernels x86, hyperv: Mark the Hyper-V clocksource as being continuous x86: Don't rely on VMWare emulating PAT MSR correctly x86, irq: Properly tag virtualization entry in /proc/interrupts x86, boot: Skip relocs when load address unchanged x86/xen: Override ACPI IRQ management callback __acpi_unregister_gsi ACPI: pci: Do not clear pci_dev->irq in acpi_pci_irq_disable() x86/xen: Treat SCI interrupt as normal GSI interrupt
2 parents 4d2f0ef + 5204521 commit 1474630

16 files changed

Lines changed: 106 additions & 77 deletions

File tree

‎arch/x86/Kconfig‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ source "kernel/Kconfig.preempt"
857857

858858
config X86_UP_APIC
859859
bool "Local APIC support on uniprocessors"
860-
depends on X86_32 && !SMP && !X86_32_NON_STANDARD && !PCI_MSI
860+
depends on X86_32 && !SMP && !X86_32_NON_STANDARD
861861
---help---
862862
A local APIC (Advanced Programmable Interrupt Controller) is an
863863
integrated interrupt controller in the CPU. If you have a single-CPU
@@ -868,6 +868,10 @@ config X86_UP_APIC
868868
performance counters), and the NMI watchdog which detects hard
869869
lockups.
870870

871+
config X86_UP_APIC_MSI
872+
def_bool y
873+
select X86_UP_APIC if X86_32 && !SMP && !X86_32_NON_STANDARD && PCI_MSI
874+
871875
config X86_UP_IOAPIC
872876
bool "IO-APIC support on uniprocessors"
873877
depends on X86_UP_APIC

‎arch/x86/boot/compressed/misc.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
373373
unsigned long output_len,
374374
unsigned long run_size)
375375
{
376+
unsigned char *output_orig = output;
377+
376378
real_mode = rmode;
377379

378380
sanitize_boot_params(real_mode);
@@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
421423
debug_putstr("\nDecompressing Linux... ");
422424
decompress(input_data, input_len, NULL, NULL, output, NULL, error);
423425
parse_elf(output);
424-
handle_relocations(output, output_len);
426+
/*
427+
* 32-bit always performs relocations. 64-bit relocations are only
428+
* needed if kASLR has chosen a different load address.
429+
*/
430+
if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig)
431+
handle_relocations(output, output_len);
425432
debug_putstr("done.\nBooting the kernel.\n");
426433
return output;
427434
}

‎arch/x86/include/asm/acpi.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void acpi_pic_sci_set_trigger(unsigned int, u16);
5050

5151
extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
5252
int trigger, int polarity);
53+
extern void (*__acpi_unregister_gsi)(u32 gsi);
5354

5455
static inline void disable_acpi(void)
5556
{

‎arch/x86/include/asm/desc.h‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
251251
gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
252252
}
253253

254-
#define _LDT_empty(info) \
254+
/* This intentionally ignores lm, since 32-bit apps don't have that field. */
255+
#define LDT_empty(info) \
255256
((info)->base_addr == 0 && \
256257
(info)->limit == 0 && \
257258
(info)->contents == 0 && \
@@ -261,11 +262,18 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
261262
(info)->seg_not_present == 1 && \
262263
(info)->useable == 0)
263264

264-
#ifdef CONFIG_X86_64
265-
#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
266-
#else
267-
#define LDT_empty(info) (_LDT_empty(info))
268-
#endif
265+
/* Lots of programs expect an all-zero user_desc to mean "no segment at all". */
266+
static inline bool LDT_zero(const struct user_desc *info)
267+
{
268+
return (info->base_addr == 0 &&
269+
info->limit == 0 &&
270+
info->contents == 0 &&
271+
info->read_exec_only == 0 &&
272+
info->seg_32bit == 0 &&
273+
info->limit_in_pages == 0 &&
274+
info->seg_not_present == 0 &&
275+
info->useable == 0);
276+
}
269277

270278
static inline void clear_LDT(void)
271279
{

‎arch/x86/include/asm/mmu_context.h‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,25 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm,
130130
static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
131131
unsigned long start, unsigned long end)
132132
{
133-
mpx_notify_unmap(mm, vma, start, end);
133+
/*
134+
* mpx_notify_unmap() goes and reads a rarely-hot
135+
* cacheline in the mm_struct. That can be expensive
136+
* enough to be seen in profiles.
137+
*
138+
* The mpx_notify_unmap() call and its contents have been
139+
* observed to affect munmap() performance on hardware
140+
* where MPX is not present.
141+
*
142+
* The unlikely() optimizes for the fast case: no MPX
143+
* in the CPU, or no MPX use in the process. Even if
144+
* we get this wrong (in the unlikely event that MPX
145+
* is widely enabled on some system) the overhead of
146+
* MPX itself (reading bounds tables) is expected to
147+
* overwhelm the overhead of getting this unlikely()
148+
* consistently wrong.
149+
*/
150+
if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX)))
151+
mpx_notify_unmap(mm, vma, start, end);
134152
}
135153

136154
#endif /* _ASM_X86_MMU_CONTEXT_H */

‎arch/x86/kernel/acpi/boot.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -611,20 +611,20 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
611611

612612
int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
613613
{
614-
int irq;
615-
616-
if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
617-
*irqp = gsi;
618-
} else {
619-
mutex_lock(&acpi_ioapic_lock);
620-
irq = mp_map_gsi_to_irq(gsi,
621-
IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
622-
mutex_unlock(&acpi_ioapic_lock);
623-
if (irq < 0)
624-
return -1;
625-
*irqp = irq;
614+
int rc, irq, trigger, polarity;
615+
616+
rc = acpi_get_override_irq(gsi, &trigger, &polarity);
617+
if (rc == 0) {
618+
trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
619+
polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
620+
irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
621+
if (irq >= 0) {
622+
*irqp = irq;
623+
return 0;
624+
}
626625
}
627-
return 0;
626+
627+
return -1;
628628
}
629629
EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
630630

‎arch/x86/kernel/cpu/mshyperv.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static struct clocksource hyperv_cs = {
107107
.rating = 400, /* use this when running on Hyperv*/
108108
.read = read_hv_clock,
109109
.mask = CLOCKSOURCE_MASK(64),
110+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
110111
};
111112

112113
static void __init ms_hyperv_init_platform(void)

‎arch/x86/kernel/irq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
127127
seq_puts(p, " Machine check polls\n");
128128
#endif
129129
#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
130-
seq_printf(p, "%*s: ", prec, "THR");
130+
seq_printf(p, "%*s: ", prec, "HYP");
131131
for_each_online_cpu(j)
132132
seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
133133
seq_puts(p, " Hypervisor callback interrupts\n");

‎arch/x86/kernel/tls.c‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,28 @@ static int get_free_idx(void)
2929

3030
static bool tls_desc_okay(const struct user_desc *info)
3131
{
32-
if (LDT_empty(info))
32+
/*
33+
* For historical reasons (i.e. no one ever documented how any
34+
* of the segmentation APIs work), user programs can and do
35+
* assume that a struct user_desc that's all zeros except for
36+
* entry_number means "no segment at all". This never actually
37+
* worked. In fact, up to Linux 3.19, a struct user_desc like
38+
* this would create a 16-bit read-write segment with base and
39+
* limit both equal to zero.
40+
*
41+
* That was close enough to "no segment at all" until we
42+
* hardened this function to disallow 16-bit TLS segments. Fix
43+
* it up by interpreting these zeroed segments the way that they
44+
* were almost certainly intended to be interpreted.
45+
*
46+
* The correct way to ask for "no segment at all" is to specify
47+
* a user_desc that satisfies LDT_empty. To keep everything
48+
* working, we accept both.
49+
*
50+
* Note that there's a similar kludge in modify_ldt -- look at
51+
* the distinction between modes 1 and 0x11.
52+
*/
53+
if (LDT_empty(info) || LDT_zero(info))
3354
return true;
3455

3556
/*
@@ -71,7 +92,7 @@ static void set_tls_desc(struct task_struct *p, int idx,
7192
cpu = get_cpu();
7293

7394
while (n-- > 0) {
74-
if (LDT_empty(info))
95+
if (LDT_empty(info) || LDT_zero(info))
7596
desc->a = desc->b = 0;
7697
else
7798
fill_ldt(desc, info);

‎arch/x86/kernel/tsc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static unsigned long quick_pit_calibrate(void)
617617
goto success;
618618
}
619619
}
620-
pr_err("Fast TSC calibration failed\n");
620+
pr_info("Fast TSC calibration failed\n");
621621
return 0;
622622

623623
success:

0 commit comments

Comments
 (0)