Skip to content

Commit 43227e0

Browse files
committed
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
2 parents 48b1db7 + 6f6060a commit 43227e0

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

arch/x86/events/intel/ds.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,11 @@ static int alloc_bts_buffer(int cpu)
408408
ds->bts_buffer_base = (unsigned long) cea;
409409
ds_update_cea(cea, buffer, BTS_BUFFER_SIZE, PAGE_KERNEL);
410410
ds->bts_index = ds->bts_buffer_base;
411-
max = BTS_RECORD_SIZE * (BTS_BUFFER_SIZE / BTS_RECORD_SIZE);
412-
ds->bts_absolute_maximum = ds->bts_buffer_base + max;
413-
ds->bts_interrupt_threshold = ds->bts_absolute_maximum - (max / 16);
411+
max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
412+
ds->bts_absolute_maximum = ds->bts_buffer_base +
413+
max * BTS_RECORD_SIZE;
414+
ds->bts_interrupt_threshold = ds->bts_absolute_maximum -
415+
(max / 16) * BTS_RECORD_SIZE;
414416
return 0;
415417
}
416418

arch/x86/include/asm/apm.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#ifndef _ASM_X86_MACH_DEFAULT_APM_H
88
#define _ASM_X86_MACH_DEFAULT_APM_H
99

10-
#include <asm/nospec-branch.h>
11-
1210
#ifdef APM_ZERO_SEGS
1311
# define APM_DO_ZERO_SEGS \
1412
"pushl %%ds\n\t" \
@@ -34,7 +32,6 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
3432
* N.B. We do NOT need a cld after the BIOS call
3533
* because we always save and restore the flags.
3634
*/
37-
firmware_restrict_branch_speculation_start();
3835
__asm__ __volatile__(APM_DO_ZERO_SEGS
3936
"pushl %%edi\n\t"
4037
"pushl %%ebp\n\t"
@@ -47,7 +44,6 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
4744
"=S" (*esi)
4845
: "a" (func), "b" (ebx_in), "c" (ecx_in)
4946
: "memory", "cc");
50-
firmware_restrict_branch_speculation_end();
5147
}
5248

5349
static 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,
6056
* N.B. We do NOT need a cld after the BIOS call
6157
* because we always save and restore the flags.
6258
*/
63-
firmware_restrict_branch_speculation_start();
6459
__asm__ __volatile__(APM_DO_ZERO_SEGS
6560
"pushl %%edi\n\t"
6661
"pushl %%ebp\n\t"
@@ -73,7 +68,6 @@ static inline bool apm_bios_call_simple_asm(u32 func, u32 ebx_in,
7368
"=S" (si)
7469
: "a" (func), "b" (ebx_in), "c" (ecx_in)
7570
: "memory", "cc");
76-
firmware_restrict_branch_speculation_end();
7771
return error;
7872
}
7973

arch/x86/kernel/apm_32.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
#include <asm/olpc.h>
241241
#include <asm/paravirt.h>
242242
#include <asm/reboot.h>
243+
#include <asm/nospec-branch.h>
243244

244245
#if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
245246
extern int (*console_blank_hook)(int);
@@ -614,11 +615,13 @@ static long __apm_bios_call(void *_call)
614615
gdt[0x40 / 8] = bad_bios_desc;
615616

616617
apm_irq_save(flags);
618+
firmware_restrict_branch_speculation_start();
617619
APM_DO_SAVE_SEGS;
618620
apm_bios_call_asm(call->func, call->ebx, call->ecx,
619621
&call->eax, &call->ebx, &call->ecx, &call->edx,
620622
&call->esi);
621623
APM_DO_RESTORE_SEGS;
624+
firmware_restrict_branch_speculation_end();
622625
apm_irq_restore(flags);
623626
gdt[0x40 / 8] = save_desc_40;
624627
put_cpu();
@@ -690,10 +693,12 @@ static long __apm_bios_call_simple(void *_call)
690693
gdt[0x40 / 8] = bad_bios_desc;
691694

692695
apm_irq_save(flags);
696+
firmware_restrict_branch_speculation_start();
693697
APM_DO_SAVE_SEGS;
694698
error = apm_bios_call_simple_asm(call->func, call->ebx, call->ecx,
695699
&call->eax);
696700
APM_DO_RESTORE_SEGS;
701+
firmware_restrict_branch_speculation_end();
697702
apm_irq_restore(flags);
698703
gdt[0x40 / 8] = save_desc_40;
699704
put_cpu();

0 commit comments

Comments
 (0)