x86 fixes
Subsystems (11)
Linus,
Please pull the latest x86-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus
# HEAD: 6ac389346e6964e1f6a1c675cebf8bd0912526a5 Revert "kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs"
The biggest part is a series of reverts for the macro based GCC inlining workarounds. It caused regressions in distro build and other kernel tooling environments, and the GCC project was very receptive to fixing the underlying inliner weaknesses - so as time ran out we decided to do a reasonably straightforward revert of the patches. The plan is to rely on the 'asm inline' GCC 9 feature, which might be backported to GCC 8 and could thus become reasonably widely available on modern distros.
Other than those reverts, there's misc fixes from all around the place.
I wish our final x86 pull request for v4.20 was smaller...
out-of-topic modifications in x86-urgent-for-linus:
-----------------------------------------------------
Makefile # 6ac389346e69: Revert "kbuild/Makefile: Pre include/asm-generic/bug.h # ffb61c6346d0: Revert "x86/bug: Macrofy the include/linux/compiler.h # 96af6cd02a10: Revert "x86/objtool: Use asm scripts/Kbuild.include # 6ac389346e69: Revert "kbuild/Makefile: Pre scripts/mod/Makefile # 6ac389346e69: Revert "kbuild/Makefile: Pre
Thanks,
Ingo
------------------>
Alistair Strachan (1):
x86/vdso: Pass --eh-frame-hdr to the linker
Chang S. Bae (1):
x86/fsgsbase/64: Fix the base write helper functions
Colin Ian King (1):
x86/mtrr: Don't copy uninitialized gentry fields back to userspace
Dan Williams (1):
x86/mm: Fix decoy address handling vs 32-bit builds
Ingo Molnar (9):
Revert "x86/jump-labels: Macrofy inline assembly code to work around GCC inlining bugs"
Revert "x86/cpufeature: Macrofy inline assembly code to work around GCC inlining bugs"
Revert "x86/extable: Macrofy inline assembly code to work around GCC inlining bugs"
Revert "x86/paravirt: Work around GCC inlining bugs when compiling paravirt ops"
Revert "x86/bug: Macrofy the BUG table section handling, to work around GCC inlining bugs"
Revert "x86/alternatives: Macrofy lock prefixes to work around GCC inlining bugs"
Revert "x86/refcount: Work around GCC inlining bug"
Revert "x86/objtool: Use asm macros to work around GCC inlining bugs"
Revert "kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs"
Kirill A. Shutemov (2):
x86/mm: Fix guard hole handling x86/dump_pagetables: Fix LDT remap address marker
Peter Zijlstra (1):
x86/mm/cpa: Fix cpa_flush_array() TLB invalidation
Reinette Chatre (1):
x86/intel_rdt: Ensure a CPU remains online for the region's pseudo-locking sequence
Makefile | 9 +-- arch/x86/Makefile | 7 -- arch/x86/entry/calling.h | 2 +- arch/x86/entry/vdso/Makefile | 3 +- arch/x86/include/asm/alternative-asm.h | 20 ++---- arch/x86/include/asm/alternative.h | 11 +++- arch/x86/include/asm/asm.h | 53 +++++++++------ arch/x86/include/asm/bug.h | 98 ++++++++++++---------------- arch/x86/include/asm/cpufeature.h | 82 ++++++++++-------------- arch/x86/include/asm/fsgsbase.h | 15 +++-- arch/x86/include/asm/jump_label.h | 72 +++++++++++++++------ arch/x86/include/asm/paravirt_types.h | 56 ++++++++-------- arch/x86/include/asm/pgtable_64_types.h | 5 ++ arch/x86/include/asm/refcount.h | 81 ++++++++++------------- arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 ++ arch/x86/kernel/cpu/mtrr/if.c | 2 + arch/x86/kernel/macros.S | 16 ----- arch/x86/kernel/process_64.c | 99 ++++++++++++++++------------- arch/x86/kernel/ptrace.c | 9 +-- arch/x86/mm/dump_pagetables.c | 15 ++--- arch/x86/mm/pageattr.c | 24 ++++--- arch/x86/mm/pat.c | 13 +++- arch/x86/xen/mmu_pv.c | 11 ++-- include/asm-generic/bug.h | 8 +-- include/linux/compiler.h | 56 ++++------------ scripts/Kbuild.include | 4 +- scripts/mod/Makefile | 2 - 27 files changed, 385 insertions(+), 392 deletions(-) delete mode 100644 arch/x86/kernel/macros.S
Makefile +2 -7
@@ -1081,7 +1081,7 @@ scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) # version.h and scripts_basic is processed / created. # Listed in dependency order -PHONY += prepare archprepare macroprepare prepare0 prepare1 prepare2 prepare3 +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 # prepare3 is used to check if we are building in a separate output directory, # and if so do:
@@ -1104,9 +1104,7 @@ prepare2: prepare3 outputmakefile asm-generic prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h $(cmd_crmodverdir) -macroprepare: prepare1 archmacros - -archprepare: archheaders archscripts macroprepare scripts_basic +archprepare: archheaders archscripts prepare1 scripts_basic prepare0: archprepare gcc-plugins $(Q)$(MAKE) $(build)=.
@@ -1174,9 +1172,6 @@ archheaders: PHONY += archscripts archscripts: -PHONY += archmacros -archmacros: - PHONY += __headers __headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts $(Q)$(MAKE) $(build)=scripts build_unifdef
arch/x86/Makefile +0 -7
@@ -232,13 +232,6 @@ archscripts: scripts_basic archheaders: $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all -archmacros: - $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s - -ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -export ASM_MACRO_FLAGS -KBUILD_CFLAGS += $(ASM_MACRO_FLAGS) - ### # Kernel objects
arch/x86/entry/calling.h +1 -1
@@ -352,7 +352,7 @@ For 32-bit we have the following conventions - kernel is built with .macro CALL_enter_from_user_mode#ifdef CONFIG_CONTEXT_TRACKING #ifdef HAVE_JUMP_LABEL - STATIC_BRANCH_JMP l_yes=.Lafter_call_\@, key=context_tracking_enabled, branch=1 + STATIC_JUMP_IF_FALSE .Lafter_call_\@, context_tracking_enabled, def=0#endif call enter_from_user_mode .Lafter_call_\@:
arch/x86/entry/vdso/Makefile +2 -1
@@ -171,7 +171,8 @@ quiet_cmd_vdso = VDSO $@ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ - $(call ld-option, --build-id) -Bsymbolic + $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \ + -Bsymbolic GCOV_PROFILE := n #
arch/x86/include/asm/alternative-asm.h +6 -14
@@ -7,24 +7,16 @@#include <asm/asm.h> #ifdef CONFIG_SMP -.macro LOCK_PREFIX_HERE + .macro LOCK_PREFIX +672: lock .pushsection .smp_locks,"a" .balign 4 - .long 671f - . # offset + .long 672b - . .popsection -671: -.endm - -.macro LOCK_PREFIX insn:vararg - LOCK_PREFIX_HERE - lock \insn -.endm + .endm #else -.macro LOCK_PREFIX_HERE -.endm - -.macro LOCK_PREFIX insn:vararg -.endm + .macro LOCK_PREFIX + .endm#endif /*
arch/x86/include/asm/alternative.h +9 -2
@@ -31,8 +31,15 @@*/ #ifdef CONFIG_SMP -#define LOCK_PREFIX_HERE "LOCK_PREFIX_HERE\n\t" -#define LOCK_PREFIX "LOCK_PREFIX " +#define LOCK_PREFIX_HERE \ + ".pushsection .smp_locks,\"a\"\n" \ + ".balign 4\n" \ + ".long 671f - .\n"/* offset */ \ +".popsection\n" \ + "671:" + +#define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock; " +#else /* ! CONFIG_SMP */ #define LOCK_PREFIX_HERE ""#define LOCK_PREFIX ""
arch/x86/include/asm/asm.h +33 -20
72 lines not on this page · raw message
arch/x86/include/asm/bug.h +42 -56
119 lines not on this page · raw message
arch/x86/include/asm/cpufeature.h +35 -47
99 lines not on this page · raw message
arch/x86/include/asm/fsgsbase.h +11 -4
@@ -16,8 +16,8 @@*/ extern unsigned long x86_fsbase_read_task (struct task_struct *task);extern unsigned long x86_gsbase_read_task (struct task_struct *task); -extern int x86_fsbase_write_task (struct task_struct *task,unsigned long fsbase); -extern int x86_gsbase_write_task (struct task_struct *task,unsigned long gsbase); +extern void x86_fsbase_write_task (struct task_struct *task,unsigned long fsbase); +extern void x86_gsbase_write_task (struct task_struct *task,unsigned long gsbase);/* Helper functions for reading/writing FS/GS base */
@@ -39,8 +39,15 @@ static inline unsigned long x86_gsbase_read_cpu_inactive(void) return gsbase; } -extern void x86_fsbase_write_cpu (unsigned long fsbase); -extern void x86_gsbase_write_cpu_inactive (unsigned long gsbase); +static inline void x86_fsbase_write_cpu (unsigned long fsbase) +{ +wrmsrl (MSR_FS_BASE , fsbase); +} + +static inline void x86_gsbase_write_cpu_inactive (unsigned long gsbase) +{ +wrmsrl (MSR_KERNEL_GS_BASE , gsbase); +}#endif /* CONFIG_X86_64 */
arch/x86/include/asm/jump_label.h +54 -18
103 lines not on this page · raw message
arch/x86/include/asm/paravirt_types.h +29 -27
93 lines not on this page · raw message
arch/x86/include/asm/pgtable_64_types.h +5 -0
@@ -111,6 +111,11 @@ extern unsigned int ptrs_per_p4d;*/ #define MAXMEM (1UL << MAX_PHYSMEM_BITS) +#define GUARD_HOLE_PGD_ENTRY -256UL +#define GUARD_HOLE_SIZE (16UL << PGDIR_SHIFT) +#define GUARD_HOLE_BASE_ADDR (GUARD_HOLE_PGD_ENTRY << PGDIR_SHIFT) +#define GUARD_HOLE_END_ADDR (GUARD_HOLE_BASE_ADDR + GUARD_HOLE_SIZE) +#define LDT_PGD_ENTRY -240UL#define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#define LDT_END_ADDR (LDT_BASE_ADDR + PGDIR_SIZE)
arch/x86/include/asm/refcount.h +33 -48
132 lines not on this page · raw message
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c +4 -0
@@ -23,6 +23,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/cpu.h> #include <linux/kernfs.h> #include <linux/seq_file.h> #include <linux/slab.h>
@@ -310,9 +311,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,return -EINVAL ; buf[nbytes -1 ] ='\0' ; +cpus_read_lock (); rdtgrp =rdtgroup_kn_lock_live (of->kn);if (!rdtgrp) {rdtgroup_kn_unlock (of->kn); +cpus_read_unlock ();return -ENOENT ; }rdt_last_cmd_clear ();
@@ -367,6 +370,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, out:rdtgroup_kn_unlock (of->kn); +cpus_read_unlock ();return ret ?: nbytes; }
arch/x86/kernel/cpu/mtrr/if.c +2 -0
@@ -165,6 +165,8 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)struct mtrr_gentry gentry;void __user *arg = (void __user *) __arg; +memset (&gentry,0 ,sizeof (gentry)); +switch (cmd) {case MTRRIOC_ADD_ENTRY :case MTRRIOC_SET_ENTRY :
arch/x86/kernel/macros.S deleted +0 -16
@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -/* - * This file includes headers whose assembly part includes macros which are - * commonly used. The macros are precompiled into assmebly file which is later - * assembled together with each compiled file. - */ - -#include <linux/compiler.h> -#include <asm/refcount.h> -#include <asm/alternative-asm.h> -#include <asm/bug.h> -#include <asm/paravirt.h> -#include <asm/asm.h> -#include <asm/cpufeature.h> -#include <asm/jump_label.h>
arch/x86/kernel/process_64.c +55 -44
128 lines not on this page · raw message
arch/x86/kernel/ptrace.c +5 -4
@@ -397,11 +397,12 @@ static int putreg(struct task_struct *child,if (value >=TASK_SIZE_MAX )return -EIO ;/* -* When changing the FS base, use the same -* mechanism as for do_arch_prctl_64(). +* When changing the FS base, use do_arch_prctl_64() +* to set the index to zero and to set the base +* as requested. */ if (child->thread.fsbase != value) -return x86_fsbase_write_task (child, value); +return do_arch_prctl_64 (child,ARCH_SET_FS , value);return 0 ;case offsetof(struct user_regs_struct ,gs_base):/*
@@ -410,7 +411,7 @@ static int putreg(struct task_struct *child,if (value >=TASK_SIZE_MAX )return -EIO ;if (child->thread.gsbase != value) -return x86_gsbase_write_task (child, value); +return do_arch_prctl_64 (child,ARCH_SET_GS , value);return 0 ;#endif }
arch/x86/mm/dump_pagetables.c +6 -9
@@ -55,10 +55,10 @@ struct addr_marker {enum address_markers_idx {USER_SPACE_NR =0 ,KERNEL_SPACE_NR , -LOW_KERNEL_NR , -#if defined(CONFIG_MODIFY_LDT_SYSCALL ) && defined(CONFIG_X86_5LEVEL ) +#ifdef CONFIG_MODIFY_LDT_SYSCALL LDT_NR ,#endif +LOW_KERNEL_NR ,VMALLOC_START_NR ,VMEMMAP_START_NR ,#ifdef CONFIG_KASAN
@@ -66,9 +66,6 @@ enum address_markers_idx { KASAN_SHADOW_END_NR, #endif CPU_ENTRY_AREA_NR, -#if defined(CONFIG_MODIFY_LDT_SYSCALL ) && !defined(CONFIG_X86_5LEVEL ) - LDT_NR, -#endif #ifdef CONFIG_X86_ESPFIX64 ESPFIX_START_NR,#endif
@@ -512,11 +509,11 @@ static inline bool is_hypervisor_range(int idx) {#ifdef CONFIG_X86_64 /* -* ffff800000000000 - ffff87ffffffffff is reserved for -* the hypervisor. +* A hole in the beginning of kernel address space reserved +* for a hypervisor. */ -return (idx >=pgd_index (__PAGE_OFFSET) -16 ) && - (idx <pgd_index (__PAGE_OFFSET)); +return (idx >=pgd_index (GUARD_HOLE_BASE_ADDR )) && + (idx <pgd_index (GUARD_HOLE_END_ADDR ));#else return false;#endif
arch/x86/mm/pageattr.c +16 -8
@@ -285,20 +285,16 @@ static void cpa_flush_all(unsigned long cache)on_each_cpu (__cpa_flush_all, (void *) cache,1 ); } -static bool __cpa_flush_range (unsigned long start,int numpages,int cache) +static bool __inv_flush_all (int cache) {BUG_ON (irqs_disabled () && !early_boot_irqs_disabled); -WARN_ON (PAGE_ALIGN (start) != start); -if (cache && !static_cpu_has (X86_FEATURE_CLFLUSH )) {cpa_flush_all (cache);return true; } -flush_tlb_kernel_range (start, start +PAGE_SIZE * numpages); - -return !cache; +return false; }static void cpa_flush_range (unsigned long start,int numpages,int cache)
@@ -306,7 +302,14 @@ static void cpa_flush_range(unsigned long start, int numpages, int cache)unsigned int i, level;unsigned long addr; -if (__cpa_flush_range (start, numpages, cache)) +WARN_ON (PAGE_ALIGN (start) != start); + +if (__inv_flush_all (cache)) +return ; + +flush_tlb_kernel_range (start, start +PAGE_SIZE * numpages); + +if (!cache)return ;/*
@@ -332,7 +335,12 @@ static void cpa_flush_array(unsigned long baddr, unsigned long *start, {unsigned int i, level; -if (__cpa_flush_range (baddr, numpages, cache)) +if (__inv_flush_all (cache)) +return ; + +flush_tlb_all (); + +if (!cache)return ;/*
arch/x86/mm/pat.c +11 -2
@@ -519,8 +519,13 @@ static u64 sanitize_phys(u64 address)* for a "decoy" virtual address (bit 63 clear) passed to * set_memory_X(). __pa() on a "decoy" address results in a * physical address with bit 63 set. +* +* Decoy addresses are not present for 32-bit builds, see +* set_mce_nospec(). */ -return address & __PHYSICAL_MASK; +if (IS_ENABLED (CONFIG_X86_64 )) +return address & __PHYSICAL_MASK; +return address; }/*
@@ -546,7 +551,11 @@ int reserve_memtype(u64 start, u64 end, enum page_cache_mode req_type, start =sanitize_phys (start); end =sanitize_phys (end); -BUG_ON (start >= end);/* end is exclusive */ +if (start >= end) { +WARN (1 ,"%s failed: [mem %#010Lx-%#010Lx], req %s\n" , __func__, + start, end -1 ,cattr_name (req_type)); +return -EINVAL ; + }if (!pat_enabled ()) {/* This is identical to page table setting without PAT */
arch/x86/xen/mmu_pv.c +6 -5
@@ -648,19 +648,20 @@ static int __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd, unsigned long limit) {int i, nr, flush =0 ; -unsigned hole_low, hole_high; +unsigned hole_low =0 , hole_high =0 ;/* The limit is the last byte to be touched */ limit--;BUG_ON (limit >=FIXADDR_TOP ); +#ifdef CONFIG_X86_64 /* * 64-bit has a great big hole in the middle of the address -* space, which contains the Xen mappings. On 32-bit these -* will end up making a zero-sized hole and so is a no-op. +* space, which contains the Xen mappings. */ - hole_low =pgd_index (USER_LIMIT ); - hole_high =pgd_index (PAGE_OFFSET ); + hole_low =pgd_index (GUARD_HOLE_BASE_ADDR ); + hole_high =pgd_index (GUARD_HOLE_END_ADDR ); +#endif nr =pgd_index (limit) +1 ;for (i =0 ; i < nr; i++) {
include/asm-generic/bug.h +4 -4
@@ -17,8 +17,10 @@ #ifndef __ASSEMBLY__ #include <linux/kernel.h> -struct bug_entry { +#ifdef CONFIG_BUG + #ifdef CONFIG_GENERIC_BUG +struct bug_entry { #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS unsigned long bug_addr; #else
@@ -33,10 +35,8 @@ struct bug_entry {unsigned short line;#endif unsigned short flags; -#endif /* CONFIG_GENERIC_BUG */ }; - -#ifdef CONFIG_BUG +#endif /* CONFIG_GENERIC_BUG */ /* * Don't use BUG() or BUG_ON() unless there's really no way out; one
include/linux/compiler.h +13 -43
71 lines not on this page · raw message
scripts/Kbuild.include +1 -3
@@ -115,9 +115,7 @@ __cc-option = $(call try-run,\ # Do not attempt to build with gcc plugins during cc-option tests. # (And this uses delayed resolution so the flags will be up to date.) -# In addition, do not include the asm macros which are built later. -CC_OPTION_FILTERED = $(GCC_PLUGINS_CFLAGS) $(ASM_MACRO_FLAGS) -CC_OPTION_CFLAGS = $(filter-out $(CC_OPTION_FILTERED),$(KBUILD_CFLAGS)) +CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # cc-option # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
scripts/mod/Makefile +0 -2
@@ -4,8 +4,6 @@ OBJECT_FILES_NON_STANDARD := y hostprogs-y := modpost mk_elfconfig always := $(hostprogs-y) empty.o -CFLAGS_REMOVE_empty.o := $(ASM_MACRO_FLAGS) - modpost-objs := modpost.o file2alias.o sumversion.o devicetable-offsets-file := devicetable-offsets.h
The pull request you sent on Fri, 21 Dec 2018 13:25:45 +0100:
The pull request you sent on Fri, 21 Dec 2018 13:25:45 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-urgent-for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/70ad6368e878857db315788dab36817aa992c86a
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker