aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-21 20:23:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-21 20:23:58 -0400
commit43227e098c36b6338d55bfb232ab52896f782cda (patch)
tree3376c1e10b52eb370ddf9294300e47d115cfe300
parent48b1db7c7a952b5e7021826e727baedae35d7f3f (diff)
parent6f6060a5c9cc76fdbc22748264e6aa3779ec2427 (diff)
Merge branch 'x86-pti-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 pti fixes from Ingo Molnar: "An APM fix, and a BTS hardware-tracing fix related to PTI changes" * 'x86-pti-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/apm: Don't access __preempt_count with zeroed fs x86/events/intel/ds: Fix bts_interrupt_threshold alignment
-rw-r--r--arch/x86/events/intel/ds.c8
-rw-r--r--arch/x86/include/asm/apm.h6
-rw-r--r--arch/x86/kernel/apm_32.c5
3 files changed, 10 insertions, 9 deletions
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index 8a10a045b57b..8cf03f101938 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -408,9 +408,11 @@ static int alloc_bts_buffer(int cpu)
408 ds->bts_buffer_base = (unsigned long) cea; 408 ds->bts_buffer_base = (unsigned long) cea;
409 ds_update_cea(cea, buffer, BTS_BUFFER_SIZE, PAGE_KERNEL); 409 ds_update_cea(cea, buffer, BTS_BUFFER_SIZE, PAGE_KERNEL);
410 ds->bts_index = ds->bts_buffer_base; 410 ds->bts_index = ds->bts_buffer_base;
411 max = BTS_RECORD_SIZE * (BTS_BUFFER_SIZE / BTS_RECORD_SIZE); 411 max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
412 ds->bts_absolute_maximum = ds->bts_buffer_base + max; 412 ds->bts_absolute_maximum = ds->bts_buffer_base +
413 ds->bts_interrupt_threshold = ds->bts_absolute_maximum - (max / 16); 413 max * BTS_RECORD_SIZE;
414 ds->bts_interrupt_threshold = ds->bts_absolute_maximum -
415 (max / 16) * BTS_RECORD_SIZE;
414 return 0; 416 return 0;
415} 417}
416 418
diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
index c356098b6fb9..4d4015ddcf26 100644
--- a/arch/x86/include/asm/apm.h
+++ b/arch/x86/include/asm/apm.h
@@ -7,8 +7,6 @@
7#ifndef _ASM_X86_MACH_DEFAULT_APM_H 7#ifndef _ASM_X86_MACH_DEFAULT_APM_H
8#define _ASM_X86_MACH_DEFAULT_APM_H 8#define _ASM_X86_MACH_DEFAULT_APM_H
9 9
10#include <asm/nospec-branch.h>
11
12#ifdef APM_ZERO_SEGS 10#ifdef APM_ZERO_SEGS
13# define APM_DO_ZERO_SEGS \ 11# define APM_DO_ZERO_SEGS \
14 "pushl %%ds\n\t" \ 12 "pushl %%ds\n\t" \
@@ -34,7 +32,6 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
34 * N.B. We do NOT need a cld after the BIOS call 32 * N.B. We do NOT need a cld after the BIOS call
35 * because we always save and restore the flags. 33 * because we always save and restore the flags.
36 */ 34 */
37 firmware_restrict_branch_speculation_start();
38 __asm__ __volatile__(APM_DO_ZERO_SEGS 35 __asm__ __volatile__(APM_DO_ZERO_SEGS
39 "pushl %%edi\n\t" 36 "pushl %%edi\n\t"
40 "pushl %%ebp\n\t" 37 "pushl %%ebp\n\t"
@@ -47,7 +44,6 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
47 "=S" (*esi) 44 "=S" (*esi)
48 : "a" (func), "b" (ebx_in), "c" (ecx_in) 45 : "a" (func), "b" (ebx_in), "c" (ecx_in)
49 : "memory", "cc"); 46 : "memory", "cc");
50 firmware_restrict_branch_speculation_end();
51} 47}
52 48
53static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in, 49static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,
@@ -60,7 +56,6 @@ static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,
60 * N.B. We do NOT need a cld after the BIOS call 56 * N.B. We do NOT need a cld after the BIOS call
61 * because we always save and restore the flags. 57 * because we always save and restore the flags.
62 */ 58 */
63 firmware_restrict_branch_speculation_start();
64 __asm__ __volatile__(APM_DO_ZERO_SEGS 59 __asm__ __volatile__(APM_DO_ZERO_SEGS
65 "pushl %%edi\n\t" 60 "pushl %%edi\n\t"
66 "pushl %%ebp\n\t" 61 "pushl %%ebp\n\t"
@@ -73,7 +68,6 @@ static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,
73 "=S" (si) 68 "=S" (si)
74 : "a" (func), "b" (ebx_in), "c" (ecx_in) 69 : "a" (func), "b" (ebx_in), "c" (ecx_in)
75 : "memory", "cc"); 70 : "memory", "cc");
76 firmware_restrict_branch_speculation_end();
77 return error; 71 return error;
78} 72}
79 73
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 5d0de79fdab0..ec00d1ff5098 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -240,6 +240,7 @@
240#include <asm/olpc.h> 240#include <asm/olpc.h>
241#include <asm/paravirt.h> 241#include <asm/paravirt.h>
242#include <asm/reboot.h> 242#include <asm/reboot.h>
243#include <asm/nospec-branch.h>
243 244
244#if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) 245#if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
245extern int (*console_blank_hook)(int); 246extern int (*console_blank_hook)(int);
@@ -614,11 +615,13 @@ static long __apm_bios_call(void *_call)
614 gdt[0x40 / 8] = bad_bios_desc; 615 gdt[0x40 / 8] = bad_bios_desc;
615 616
616 apm_irq_save(flags); 617 apm_irq_save(flags);
618 firmware_restrict_branch_speculation_start();
617 APM_DO_SAVE_SEGS; 619 APM_DO_SAVE_SEGS;
618 apm_bios_call_asm(call->func, call->ebx, call->ecx, 620 apm_bios_call_asm(call->func, call->ebx, call->ecx,
619 &call->eax, &call->ebx, &call->ecx, &call->edx, 621 &call->eax, &call->ebx, &call->ecx, &call->edx,
620 &call->esi); 622 &call->esi);
621 APM_DO_RESTORE_SEGS; 623 APM_DO_RESTORE_SEGS;
624 firmware_restrict_branch_speculation_end();
622 apm_irq_restore(flags); 625 apm_irq_restore(flags);
623 gdt[0x40 / 8] = save_desc_40; 626 gdt[0x40 / 8] = save_desc_40;
624 put_cpu(); 627 put_cpu();
@@ -690,10 +693,12 @@ static long __apm_bios_call_simple(void *_call)
690 gdt[0x40 / 8] = bad_bios_desc; 693 gdt[0x40 / 8] = bad_bios_desc;
691 694
692 apm_irq_save(flags); 695 apm_irq_save(flags);
696 firmware_restrict_branch_speculation_start();
693 APM_DO_SAVE_SEGS; 697 APM_DO_SAVE_SEGS;
694 error = apm_bios_call_simple_asm(call->func, call->ebx, call->ecx, 698 error = apm_bios_call_simple_asm(call->func, call->ebx, call->ecx,
695 &call->eax); 699 &call->eax);
696 APM_DO_RESTORE_SEGS; 700 APM_DO_RESTORE_SEGS;
701 firmware_restrict_branch_speculation_end();
697 apm_irq_restore(flags); 702 apm_irq_restore(flags);
698 gdt[0x40 / 8] = save_desc_40; 703 gdt[0x40 / 8] = save_desc_40;
699 put_cpu(); 704 put_cpu();