Skip to content

Commit d286236

Browse files
committed
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 and PTI fixes from Ingo Molnar: "Misc fixes: - fix EFI pagetables freeing - fix vsyscall pagetable setting on Xen PV guests - remove ancient CONFIG_X86_PPRO_FENCE=y - x86 is TSO again - fix two binutils (ld) development version related incompatibilities - clean up breakpoint handling - fix an x86 self-test" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/entry/64: Don't use IST entry for #BP stack x86/efi: Free efi_pgd with free_pages() x86/vsyscall/64: Use proper accessor to update P4D entry x86/cpu: Remove the CONFIG_X86_PPRO_FENCE=y quirk x86/boot/64: Verify alignment of the LOAD segment x86/build/64: Force the linker to use 2MB page size selftests/x86/ptrace_syscall: Fix for yet more glibc interference
2 parents 9fd64e8 + d8ba61b commit d286236

File tree

14 files changed

+30
-97
lines changed

14 files changed

+30
-97
lines changed

arch/x86/Kconfig.cpu

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,6 @@ config X86_L1_CACHE_SHIFT
315315
default "4" if MELAN || M486 || MGEODEGX1
316316
default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
317317

318-
config X86_PPRO_FENCE
319-
bool "PentiumPro memory ordering errata workaround"
320-
depends on M686 || M586MMX || M586TSC || M586 || M486 || MGEODEGX1
321-
---help---
322-
Old PentiumPro multiprocessor systems had errata that could cause
323-
memory operations to violate the x86 ordering standard in rare cases.
324-
Enabling this option will attempt to work around some (but not all)
325-
occurrences of this problem, at the cost of much heavier spinlock and
326-
memory barrier operations.
327-
328-
If unsure, say n here. Even distro kernels should think twice before
329-
enabling this: there are few systems, and an unlikely bug.
330-
331318
config X86_F00F_BUG
332319
def_bool y
333320
depends on M586MMX || M586TSC || M586 || M486

arch/x86/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr)
223223

224224
LDFLAGS := -m elf_$(UTS_MACHINE)
225225

226+
#
227+
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
228+
# the linker to force 2MB page size regardless of the default page size used
229+
# by the linker.
230+
#
231+
ifdef CONFIG_X86_64
232+
LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
233+
endif
234+
226235
# Speed up the build
227236
KBUILD_CFLAGS += -pipe
228237
# Workaround for a gcc prelease that unfortunately was shipped in a suse release

arch/x86/boot/compressed/misc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ static void parse_elf(void *output)
309309

310310
switch (phdr->p_type) {
311311
case PT_LOAD:
312+
#ifdef CONFIG_X86_64
313+
if ((phdr->p_align % 0x200000) != 0)
314+
error("Alignment of LOAD segment isn't multiple of 2MB");
315+
#endif
312316
#ifdef CONFIG_RELOCATABLE
313317
dest = output;
314318
dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);

arch/x86/entry/entry_64.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ apicinterrupt3 HYPERV_REENLIGHTENMENT_VECTOR \
11381138
#endif /* CONFIG_HYPERV */
11391139

11401140
idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
1141-
idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
1141+
idtentry int3 do_int3 has_error_code=0
11421142
idtentry stack_segment do_stack_segment has_error_code=1
11431143

11441144
#ifdef CONFIG_XEN

arch/x86/entry/vdso/vdso32/vclock_gettime.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#undef CONFIG_OPTIMIZE_INLINING
66
#endif
77

8-
#undef CONFIG_X86_PPRO_FENCE
9-
108
#ifdef CONFIG_X86_64
119

1210
/*

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void __init set_vsyscall_pgtable_user_bits(pgd_t *root)
347347
set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER));
348348
p4d = p4d_offset(pgd, VSYSCALL_ADDR);
349349
#if CONFIG_PGTABLE_LEVELS >= 5
350-
p4d->p4d |= _PAGE_USER;
350+
set_p4d(p4d, __p4d(p4d_val(*p4d) | _PAGE_USER));
351351
#endif
352352
pud = pud_offset(p4d, VSYSCALL_ADDR);
353353
set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER));

arch/x86/include/asm/barrier.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
5252
#define barrier_nospec() alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, \
5353
"lfence", X86_FEATURE_LFENCE_RDTSC)
5454

55-
#ifdef CONFIG_X86_PPRO_FENCE
56-
#define dma_rmb() rmb()
57-
#else
5855
#define dma_rmb() barrier()
59-
#endif
6056
#define dma_wmb() barrier()
6157

6258
#ifdef CONFIG_X86_32
@@ -68,30 +64,6 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
6864
#define __smp_wmb() barrier()
6965
#define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
7066

71-
#if defined(CONFIG_X86_PPRO_FENCE)
72-
73-
/*
74-
* For this option x86 doesn't have a strong TSO memory
75-
* model and we should fall back to full barriers.
76-
*/
77-
78-
#define __smp_store_release(p, v) \
79-
do { \
80-
compiletime_assert_atomic_type(*p); \
81-
__smp_mb(); \
82-
WRITE_ONCE(*p, v); \
83-
} while (0)
84-
85-
#define __smp_load_acquire(p) \
86-
({ \
87-
typeof(*p) ___p1 = READ_ONCE(*p); \
88-
compiletime_assert_atomic_type(*p); \
89-
__smp_mb(); \
90-
___p1; \
91-
})
92-
93-
#else /* regular x86 TSO memory ordering */
94-
9567
#define __smp_store_release(p, v) \
9668
do { \
9769
compiletime_assert_atomic_type(*p); \
@@ -107,8 +79,6 @@ do { \
10779
___p1; \
10880
})
10981

110-
#endif
111-
11282
/* Atomic operations are already serializing on x86 */
11383
#define __smp_mb__before_atomic() barrier()
11484
#define __smp_mb__after_atomic() barrier()

arch/x86/include/asm/io.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,6 @@ extern void set_iounmap_nonlazy(void);
232232
*/
233233
#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
234234

235-
/*
236-
* Cache management
237-
*
238-
* This needed for two cases
239-
* 1. Out of order aware processors
240-
* 2. Accidentally out of order processors (PPro errata #51)
241-
*/
242-
243-
static inline void flush_write_buffers(void)
244-
{
245-
#if defined(CONFIG_X86_PPRO_FENCE)
246-
asm volatile("lock; addl $0,0(%%esp)": : :"memory");
247-
#endif
248-
}
249-
250235
#endif /* __KERNEL__ */
251236

252237
extern void native_io_delay(void);

arch/x86/kernel/idt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ static const __initconst struct idt_data early_pf_idts[] = {
160160
*/
161161
static const __initconst struct idt_data dbg_idts[] = {
162162
INTG(X86_TRAP_DB, debug),
163-
INTG(X86_TRAP_BP, int3),
164163
};
165164
#endif
166165

@@ -183,7 +182,6 @@ gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss;
183182
static const __initconst struct idt_data ist_idts[] = {
184183
ISTG(X86_TRAP_DB, debug, DEBUG_STACK),
185184
ISTG(X86_TRAP_NMI, nmi, NMI_STACK),
186-
SISTG(X86_TRAP_BP, int3, DEBUG_STACK),
187185
ISTG(X86_TRAP_DF, double_fault, DOUBLEFAULT_STACK),
188186
#ifdef CONFIG_X86_MCE
189187
ISTG(X86_TRAP_MC, &machine_check, MCE_STACK),

arch/x86/kernel/pci-nommu.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page,
3737
WARN_ON(size == 0);
3838
if (!check_addr("map_single", dev, bus, size))
3939
return NOMMU_MAPPING_ERROR;
40-
flush_write_buffers();
4140
return bus;
4241
}
4342

@@ -72,25 +71,9 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
7271
return 0;
7372
s->dma_length = s->length;
7473
}
75-
flush_write_buffers();
7674
return nents;
7775
}
7876

79-
static void nommu_sync_single_for_device(struct device *dev,
80-
dma_addr_t addr, size_t size,
81-
enum dma_data_direction dir)
82-
{
83-
flush_write_buffers();
84-
}
85-
86-
87-
static void nommu_sync_sg_for_device(struct device *dev,
88-
struct scatterlist *sg, int nelems,
89-
enum dma_data_direction dir)
90-
{
91-
flush_write_buffers();
92-
}
93-
9477
static int nommu_mapping_error(struct device *dev, dma_addr_t dma_addr)
9578
{
9679
return dma_addr == NOMMU_MAPPING_ERROR;
@@ -101,8 +84,6 @@ const struct dma_map_ops nommu_dma_ops = {
10184
.free = dma_generic_free_coherent,
10285
.map_sg = nommu_map_sg,
10386
.map_page = nommu_map_page,
104-
.sync_single_for_device = nommu_sync_single_for_device,
105-
.sync_sg_for_device = nommu_sync_sg_for_device,
10687
.is_phys = 1,
10788
.mapping_error = nommu_mapping_error,
10889
.dma_supported = x86_dma_supported,

arch/x86/kernel/traps.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ do_general_protection(struct pt_regs *regs, long error_code)
577577
}
578578
NOKPROBE_SYMBOL(do_general_protection);
579579

580-
/* May run on IST stack. */
581580
dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
582581
{
583582
#ifdef CONFIG_DYNAMIC_FTRACE
@@ -592,6 +591,13 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
592591
if (poke_int3_handler(regs))
593592
return;
594593

594+
/*
595+
* Use ist_enter despite the fact that we don't use an IST stack.
596+
* We can be called from a kprobe in non-CONTEXT_KERNEL kernel
597+
* mode or even during context tracking state changes.
598+
*
599+
* This means that we can't schedule. That's okay.
600+
*/
595601
ist_enter(regs);
596602
RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
597603
#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
@@ -609,15 +615,10 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
609615
SIGTRAP) == NOTIFY_STOP)
610616
goto exit;
611617

612-
/*
613-
* Let others (NMI) know that the debug stack is in use
614-
* as we may switch to the interrupt stack.
615-
*/
616-
debug_stack_usage_inc();
617618
cond_local_irq_enable(regs);
618619
do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL);
619620
cond_local_irq_disable(regs);
620-
debug_stack_usage_dec();
621+
621622
exit:
622623
ist_exit(regs);
623624
}

arch/x86/platform/efi/efi_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int __init efi_alloc_page_tables(void)
227227
if (!pud) {
228228
if (CONFIG_PGTABLE_LEVELS > 4)
229229
free_page((unsigned long) pgd_page_vaddr(*pgd));
230-
free_page((unsigned long)efi_pgd);
230+
free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER);
231231
return -ENOMEM;
232232
}
233233

arch/x86/um/asm/barrier.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030

3131
#endif /* CONFIG_X86_32 */
3232

33-
#ifdef CONFIG_X86_PPRO_FENCE
34-
#define dma_rmb() rmb()
35-
#else /* CONFIG_X86_PPRO_FENCE */
3633
#define dma_rmb() barrier()
37-
#endif /* CONFIG_X86_PPRO_FENCE */
3834
#define dma_wmb() barrier()
3935

4036
#include <asm-generic/barrier.h>

tools/testing/selftests/x86/ptrace_syscall.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ static void test_ptrace_syscall_restart(void)
183183
if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
184184
err(1, "PTRACE_TRACEME");
185185

186+
pid_t pid = getpid(), tid = syscall(SYS_gettid);
187+
186188
printf("\tChild will make one syscall\n");
187-
raise(SIGSTOP);
189+
syscall(SYS_tgkill, pid, tid, SIGSTOP);
188190

189191
syscall(SYS_gettid, 10, 11, 12, 13, 14, 15);
190192
_exit(0);
@@ -301,9 +303,11 @@ static void test_restart_under_ptrace(void)
301303
if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
302304
err(1, "PTRACE_TRACEME");
303305

306+
pid_t pid = getpid(), tid = syscall(SYS_gettid);
307+
304308
printf("\tChild will take a nap until signaled\n");
305309
setsigign(SIGUSR1, SA_RESTART);
306-
raise(SIGSTOP);
310+
syscall(SYS_tgkill, pid, tid, SIGSTOP);
307311

308312
syscall(SYS_pause, 0, 0, 0, 0, 0, 0);
309313
_exit(0);

0 commit comments

Comments
 (0)