Linux 4.14.18
Greg KH
maintainerI'm announcing the release of the 4.14.18 kernel.
All users of the 4.14 kernel series must upgrade.
The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary
thanks,
greg k-h
------------
Documentation/admin-guide/kernel-parameters.txt | 2 Documentation/speculation.txt | 90 +++ Makefile | 2 arch/powerpc/Kconfig | 1 arch/powerpc/kernel/setup_64.c | 38 + arch/x86/entry/common.c | 9 arch/x86/entry/entry_32.S | 3 arch/x86/entry/entry_64.S | 130 ---- arch/x86/entry/syscall_64.c | 7 arch/x86/include/asm/asm-prototypes.h | 4 arch/x86/include/asm/barrier.h | 28 + arch/x86/include/asm/cpufeature.h | 7 arch/x86/include/asm/cpufeatures.h | 22 arch/x86/include/asm/disabled-features.h | 3 arch/x86/include/asm/fixmap.h | 6 arch/x86/include/asm/msr-index.h | 12 arch/x86/include/asm/msr.h | 3 arch/x86/include/asm/nospec-branch.h | 86 --- arch/x86/include/asm/pgtable_32_types.h | 5 arch/x86/include/asm/processor.h | 5 arch/x86/include/asm/required-features.h | 3 arch/x86/include/asm/syscall.h | 6 arch/x86/include/asm/thread_info.h | 3 arch/x86/include/asm/tlbflush.h | 2 arch/x86/include/asm/uaccess.h | 15 arch/x86/include/asm/uaccess_32.h | 6 arch/x86/include/asm/uaccess_64.h | 12 arch/x86/kernel/alternative.c | 28 - arch/x86/kernel/cpu/bugs.c | 134 +++- arch/x86/kernel/cpu/common.c | 70 ++ arch/x86/kernel/cpu/intel.c | 66 ++ arch/x86/kernel/cpu/scattered.c | 2 arch/x86/kernel/process_64.c | 4 arch/x86/kernel/ptrace.c | 2 arch/x86/kernel/signal.c | 2 arch/x86/kvm/cpuid.c | 22 arch/x86/kvm/cpuid.h | 1 arch/x86/kvm/emulate.c | 9 arch/x86/kvm/svm.c | 116 ++++ arch/x86/kvm/vmx.c | 660 ++++++++++++++---------- arch/x86/kvm/x86.c | 1 arch/x86/lib/Makefile | 1 arch/x86/lib/getuser.S | 10 arch/x86/lib/retpoline.S | 57 ++ arch/x86/lib/usercopy_32.c | 8 arch/x86/mm/tlb.c | 33 + drivers/auxdisplay/img-ascii-lcd.c | 4 drivers/fpga/fpga-region.c | 13 drivers/iio/accel/kxsd9-i2c.c | 3 drivers/iio/adc/qcom-vadc-common.c | 4 drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 4 drivers/tty/serial/serial_core.c | 2 include/linux/fdtable.h | 5 include/linux/init.h | 9 include/linux/module.h | 9 include/linux/nospec.h | 72 ++ kernel/module.c | 11 net/wireless/nl80211.c | 9 scripts/faddr2line | 8 scripts/mod/modpost.c | 9 sound/soc/codecs/pcm512x-spi.c | 4 tools/objtool/check.c | 89 +-- tools/objtool/orc_gen.c | 5 63 files changed, 1354 insertions(+), 642 deletions(-)
Andi Kleen (1):
module/retpoline: Warn about missing retpoline in module
Andy Lutomirski (3):
x86/entry/64: Remove the SYSCALL64 fast path x86/entry/64: Push extra regs right away x86/asm: Move 'status' from thread_struct to thread_info
Arnd Bergmann (1):
x86/pti: Mark constant arrays as __initconst
Ashok Raj (1):
KVM/x86: Add IBPB support
Borislav Petkov (5):
x86/alternative: Print unadorned pointers x86/nospec: Fix header guards names
x86/bugs: Drop one "mitigation" from dmesg x86/retpoline: Simplify vmexit_fill_RSB() x86/speculation: Simplify indirect_branch_prediction_barrier()
Colin Ian King (1):
x86/spectre: Fix spelling mistake: "vunerable"-> "vulnerable"
Dan Williams (12):
array_index_nospec: Sanitize speculative array de-references
x86: Implement array_index_mask_nospec
x86: Introduce barrier_nospec
x86: Introduce __uaccess_begin_nospec() and uaccess_try_nospec x86/usercopy: Replace open coded stac/clac with __uaccess_{begin, end} x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec x86/get_user: Use pointer masking to limit speculation x86/syscall: Sanitize syscall table de-references under speculation vfs, fdtable: Prevent bounds-check bypass via speculative execution
nl80211: Sanitize array index in parse_txq_params x86/spectre: Report get_user mitigation for spectre_v1 x86/kvm: Update spectre-v1 mitigation
Darren Kenny (1):
x86/speculation: Fix typo IBRS_ATT, which should be IBRS_ALL
David Woodhouse (10):
x86/cpufeatures: Add CPUID_7_EDX CPUID leaf
x86/cpufeatures: Add Intel feature bits for Speculation Control x86/cpufeatures: Add AMD feature bits for Speculation Control x86/msr: Add definitions for new speculation control MSRs x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support x86/cpufeatures: Clean up Spectre v2 related CPUID flags x86/cpuid: Fix up "virtual" IBRS/IBPB/STIBP feature bits on Intel x86/retpoline: Avoid retpolines for built-in __init functions
Dou Liyang (1):
x86/spectre: Check CONFIG_RETPOLINE in command line parser
Greg Kroah-Hartman (1):
Linux 4.14.18
Ian Abbott (1):
fpga: region: release of_parse_phandle nodes after use
Jesse Chan (3):
auxdisplay: img-ascii-lcd: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
pinctrl: pxa: pxa2xx: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
ASoC: pcm512x: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
Jim Mattson (1):
KVM: nVMX: Eliminate vmcs02 pool
Josh Poimboeuf (4):
objtool: Improve retpoline alternative handling
objtool: Add support for alternatives at the end of a section
objtool: Warn on stripped section symbol x86/paravirt: Remove 'noreplace-paravirt' cmdline option
KarimAllah Ahmed (5):
x86/spectre: Simplify spectre_v2 command line parsing KVM/x86: Update the reverse_cpuid list to include CPUID_7_EDX KVM/VMX: Emulate MSR_IA32_ARCH_CAPABILITIES KVM/VMX: Allow direct access to MSR_IA32_SPEC_CTRL KVM/SVM: Allow direct access to MSR_IA32_SPEC_CTRL
Linus Walleij (1):
iio: adc/accel: Fix up module licenses
Liu, Changcheng (1):
scripts/faddr2line: fix CROSS_COMPILE unset error
Mark Rutland (1):
Documentation: Document array_index_nospec
Michael Ellerman (2):
powerpc/64s: Wire up cpu_show_meltdown() powerpc/64s: Allow control of RFI flush via debugfs
Paolo Bonzini (2):
KVM: VMX: introduce alloc_loaded_vmcs
KVM: VMX: make MSR bitmaps per-VCPU
Peter Zijlstra (2):
KVM: x86: Make indirect calls in emulator speculation safe
KVM: VMX: Make indirect call speculation safe
Sebastian Andrzej Siewior (1):
serial: core: mark port as initialized after successful IRQ change
Thomas Gleixner (1):
x86/cpu/bugs: Make retpoline module warning conditional
Tim Chen (1):
x86/speculation: Use Indirect Branch Prediction Barrier in context switch
Waiman Long (1):
x86/retpoline: Remove the esp/rsp thunk
William Grant (1):
x86/mm: Fix overlap of i386 CPU_ENTRY_AREA with FIX_BTMAP
Greg KH
maintainerDocumentation/admin-guide/kernel-parameters.txt +0 -2
@@ -2718,8 +2718,6 @@ norandmaps Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space - noreplace-paravirt [X86,IA-64,PV_OPS] Don't patch paravirt_ops - noreplace-smp [X86-32,SMP] Don't replace SMP instructions with UP alternatives
Documentation/speculation.txt new file +90 -0
90 lines not on this page · raw message
Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 4 PATCHLEVEL = 14 -SUBLEVEL = 17 +SUBLEVEL = 18 EXTRAVERSION = NAME = Petit Gorille
arch/powerpc/Kconfig +1 -0
@@ -164,6 +164,7 @@ config PPC select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_VULNERABILITIES if PPC_BOOK3S_64 select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_SMP_IDLE_THREAD
arch/powerpc/kernel/setup_64.c +38 -0
@@ -38,6 +38,7 @@#include <linux/memory.h> #include <linux/nmi.h> +#include <asm/debugfs.h> #include <asm/io.h> #include <asm/kdump.h> #include <asm/prom.h>
@@ -884,4 +885,41 @@ void __init setup_rfi_flush(enum l1d_flush_type types, bool enable)if (!no_rfi_flush)rfi_flush_enable (enable); } + +#ifdef CONFIG_DEBUG_FS +static int rfi_flush_set (void *data,u64 val) +{ +if (val ==1 ) +rfi_flush_enable (true); +else if (val ==0 ) +rfi_flush_enable (false); +else +return -EINVAL ; + +return 0 ; +} + +static int rfi_flush_get (void *data,u64 *val) +{ + *val = rfi_flush ?1 :0 ; +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (fops_rfi_flush, rfi_flush_get, rfi_flush_set,"%llu\n" ); + +static __init int rfi_flush_debugfs_init (void ) +{ +debugfs_create_file ("rfi_flush" ,0600 , powerpc_debugfs_root,NULL , &fops_rfi_flush); +return 0 ; +} +device_initcall (rfi_flush_debugfs_init); +#endif + +ssize_t cpu_show_meltdown (struct device *dev,struct device_attribute *attr,char *buf) +{ +if (rfi_flush) +return sprintf (buf,"Mitigation: RFI Flush\n" ); + +return sprintf (buf,"Vulnerable\n" ); +}#endif /* CONFIG_PPC_BOOK3S_64 */
arch/x86/entry/common.c +6 -3
@@ -21,6 +21,7 @@#include <linux/export.h> #include <linux/context_tracking.h> #include <linux/user-return-notifier.h> +#include <linux/nospec.h> #include <linux/uprobes.h> #include <linux/livepatch.h> #include <linux/syscalls.h>
@@ -208,7 +209,7 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs)* special case only applies after poking regs and before the * very next return to user mode. */ - current->thread.status &= ~(TS_COMPAT |TS_I386_REGS_POKED ); + ti->status &= ~(TS_COMPAT |TS_I386_REGS_POKED );#endif user_enter_irqoff ();
@@ -284,7 +285,8 @@ __visible void do_syscall_64(struct pt_regs *regs)* regs->orig_ax, which changes the behavior of some syscalls. */ if (likely ((nr & __SYSCALL_MASK) < NR_syscalls)) { - regs->ax = sys_call_table[nr & __SYSCALL_MASK]( + nr =array_index_nospec (nr & __SYSCALL_MASK, NR_syscalls); + regs->ax = sys_call_table[nr]( regs->di, regs->si, regs->dx, regs->r10, regs->r8, regs->r9); }
@@ -306,7 +308,7 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs)unsigned int nr = (unsigned int )regs->orig_ax;#ifdef CONFIG_IA32_EMULATION - current->thread.status |=TS_COMPAT ; + ti->status |=TS_COMPAT ;#endif if (READ_ONCE (ti->flags) & _TIF_WORK_SYSCALL_ENTRY) {
@@ -320,6 +322,7 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) }if (likely (nr < IA32_NR_syscalls)) { + nr =array_index_nospec (nr, IA32_NR_syscalls);/* * It's possible that a 32-bit syscall implementation * takes a 64-bit parameter but nonetheless assumes that
arch/x86/entry/entry_32.S +2 -1
@@ -252,7 +252,8 @@ ENTRY(__switch_to_asm) * exist, overwrite the RSB with entries which capture * speculative execution to prevent attack. */ - FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW + /* Clobbers %ebx */ + FILL_RETURN_BUFFER RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW #endif /* restore callee-saved registers */
arch/x86/entry/entry_64.S +9 -121
161 lines not on this page · raw message
arch/x86/entry/syscall_64.c +2 -5
@@ -7,14 +7,11 @@#include <asm/asm-offsets.h> #include <asm/syscall.h> -#define __SYSCALL_64_QUAL_ (sym) sym -#define __SYSCALL_64_QUAL_ptregs (sym) ptregs_##sym - -#define __SYSCALL_64 (nr, sym, qual) extern asmlinkage long __SYSCALL_64_QUAL_##qual(sym)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); +#define __SYSCALL_64 (nr, sym, qual) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);#include <asm/syscalls_64.h> #undef __SYSCALL_64 -#define __SYSCALL_64 (nr, sym, qual) [nr] = __SYSCALL_64_QUAL_##qual(sym), +#define __SYSCALL_64 (nr, sym, qual) [nr] = sym,extern long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long );
arch/x86/include/asm/asm-prototypes.h +3 -1
@@ -38,5 +38,7 @@ INDIRECT_THUNK(dx)INDIRECT_THUNK (si) INDIRECT_THUNK(di) INDIRECT_THUNK(bp) -INDIRECT_THUNK(sp) +asmlinkage void __fill_rsb(void); +asmlinkage void __clear_rsb(void); +#endif /* CONFIG_RETPOLINE */
arch/x86/include/asm/barrier.h +28 -0
@@ -24,6 +24,34 @@#define wmb () asm volatile("sfence" ::: "memory")#endif +/** +* array_index_mask_nospec() - generate a mask that is ~0UL when the +* bounds check succeeds and 0 otherwise +* @index: array element index +* @size: number of elements in array +* +* Returns: +* 0 - (index < size) +*/ +static inline unsigned long array_index_mask_nospec (unsigned long index, +unsigned long size) +{ +unsigned long mask; + + asm ("cmp %1,%2; sbb %0,%0;" + :"=r" (mask) + :"r" (size),"r" (index) + :"cc" ); +return mask; +} + +/* Override the default implementation from linux/nospec.h. */ +#define array_index_mask_nospec array_index_mask_nospec + +/* Prevent speculative execution past this barrier. */ +#define barrier_nospec () alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, \ + "lfence", X86_FEATURE_LFENCE_RDTSC) +#ifdef CONFIG_X86_PPRO_FENCE #define dma_rmb () rmb()#else
arch/x86/include/asm/cpufeature.h +5 -2
@@ -29,6 +29,7 @@ enum cpuid_leafsCPUID_8000_000A_EDX ,CPUID_7_ECX ,CPUID_8000_0007_EBX , + CPUID_7_EDX, };#ifdef CONFIG_X86_FEATURE_NAMES
@@ -79,8 +80,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 15, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 18)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19))#define DISABLED_MASK_BIT_SET (feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -101,8 +103,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 15, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 18)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19))#define cpu_has (c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
arch/x86/include/asm/cpufeatures.h +16 -6
@@ -13,7 +13,7 @@/* * Defines x86 CPU feature bits */ -#define NCAPINTS 18/* N 32-bit words worth of info */ +#define NCAPINTS 19/* N 32-bit words worth of info */ #define NBUGINTS 1/* N 32-bit bug flags */ /*
@@ -203,14 +203,14 @@#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ #define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ -#define X86_FEATURE_RETPOLINE ( 7*32+12)/* Generic Retpoline mitigation for Spectre variant 2 */ -#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* AMD Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* "" AMD Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_INTEL_PPIN ( 7*32+14)/* Intel Processor Inventory Number */ -#define X86_FEATURE_AVX512_4VNNIW ( 7*32+16)/* AVX-512 Neural Network Instructions */ -#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17)/* AVX-512 Multiply Accumulation Single precision */ #define X86_FEATURE_MBA ( 7*32+18)/* Memory Bandwidth Allocation */ -#define X86_FEATURE_RSB_CTXSW ( 7*32+19)/* Fill RSB on context switches */ +#define X86_FEATURE_RSB_CTXSW ( 7*32+19)/* "" Fill RSB on context switches */ + +#define X86_FEATURE_USE_IBPB ( 7*32+21)/* "" Indirect Branch Prediction Barrier enabled */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0)/* Intel TPR Shadow */
@@ -271,6 +271,9 @@#define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1)/* Instructions Retired Count */ #define X86_FEATURE_XSAVEERPTR (13*32+ 2)/* Always save/restore FP error pointers */ +#define X86_FEATURE_IBPB (13*32+12)/* Indirect Branch Prediction Barrier */ +#define X86_FEATURE_IBRS (13*32+14)/* Indirect Branch Restricted Speculation */ +#define X86_FEATURE_STIBP (13*32+15)/* Single Thread Indirect Branch Predictors */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ #define X86_FEATURE_DTHERM (14*32+ 0)/* Digital Thermal Sensor */
@@ -319,6 +322,13 @@#define X86_FEATURE_SUCCOR (17*32+ 1)/* Uncorrectable error containment and recovery */ #define X86_FEATURE_SMCA (17*32+ 3)/* Scalable MCA */ +/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ +#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2)/* AVX-512 Neural Network Instructions */ +#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3)/* AVX-512 Multiply Accumulation Single precision */ +#define X86_FEATURE_SPEC_CTRL (18*32+26)/* "" Speculation Control (IBRS + IBPB) */ +#define X86_FEATURE_INTEL_STIBP (18*32+27)/* "" Single Thread Indirect Branch Predictors */ +#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29)/* IA32_ARCH_CAPABILITIES MSR (Intel) */ +/* * BUG word(s) */
arch/x86/include/asm/disabled-features.h +2 -1
@@ -71,6 +71,7 @@#define DISABLED_MASK15 0#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57)#define DISABLED_MASK17 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18) +#define DISABLED_MASK18 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)#endif /* _ASM_X86_DISABLED_FEATURES_H */
arch/x86/include/asm/fixmap.h +4 -2
@@ -137,8 +137,10 @@ enum fixed_addresses {extern void reserve_top_address (unsigned long reserve); -#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) -#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) +#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) +#define FIXADDR_TOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) +#define FIXADDR_TOT_START (FIXADDR_TOP - FIXADDR_TOT_SIZE)extern int fixmaps_set;
arch/x86/include/asm/msr-index.h +12 -0
@@ -39,6 +39,13 @@/* Intel MSRs. Some also available on other CPUs */ +#define MSR_IA32_SPEC_CTRL 0x00000048/* Speculation Control */ +#define SPEC_CTRL_IBRS (1 << 0)/* Indirect Branch Restricted Speculation */ +#define SPEC_CTRL_STIBP (1 << 1)/* Single Thread Indirect Branch Predictors */ + +#define MSR_IA32_PRED_CMD 0x00000049/* Prediction Command */ +#define PRED_CMD_IBPB (1 << 0)/* Indirect Branch Prediction Barrier */ +#define MSR_PPIN_CTL 0x0000004e#define MSR_PPIN 0x0000004f
@@ -57,6 +64,11 @@#define SNB_C3_AUTO_UNDEMOTE (1UL << 28)#define MSR_MTRRcap 0x000000fe + +#define MSR_IA32_ARCH_CAPABILITIES 0x0000010a +#define ARCH_CAP_RDCL_NO (1 << 0)/* Not susceptible to Meltdown */ +#define ARCH_CAP_IBRS_ALL (1 << 1)/* Enhanced IBRS support */ +#define MSR_IA32_BBL_CR_CTL 0x00000119#define MSR_IA32_BBL_CR_CTL3 0x0000011e
arch/x86/include/asm/msr.h +1 -2
@@ -214,8 +214,7 @@ static __always_inline unsigned long long rdtsc_ordered(void)* that some other imaginary CPU is updating continuously with a * time stamp. */ -alternative_2 ("" ,"mfence" ,X86_FEATURE_MFENCE_RDTSC , -"lfence" ,X86_FEATURE_LFENCE_RDTSC ); +barrier_nospec ();return rdtsc (); }
arch/x86/include/asm/nospec-branch.h +19 -67
114 lines not on this page · raw message
arch/x86/include/asm/pgtable_32_types.h +3 -2
@@ -44,8 +44,9 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */*/ #define CPU_ENTRY_AREA_PAGES (NR_CPUS * 40) -#define CPU_ENTRY_AREA_BASE \ - ((FIXADDR_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) & PMD_MASK) +#define CPU_ENTRY_AREA_BASE \ + ((FIXADDR_TOT_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) \ + & PMD_MASK)#define PKMAP_BASE \ ((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
arch/x86/include/asm/processor.h +3 -2
@@ -459,8 +459,6 @@ struct thread_struct {unsigned short gsindex;#endif -u32 status;/* thread synchronous flags */ -#ifdef CONFIG_X86_64 unsigned long fsbase;unsigned long gsbase;
@@ -970,4 +968,7 @@ bool xen_set_default_idle(void);void stop_this_cpu (void *dummy);void df_debug (struct pt_regs *regs,long error_code); + +void __ibp_barrier (void ); +#endif /* _ASM_X86_PROCESSOR_H */
arch/x86/include/asm/required-features.h +2 -1
@@ -106,6 +106,7 @@#define REQUIRED_MASK15 0#define REQUIRED_MASK16 (NEED_LA57)#define REQUIRED_MASK17 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18) +#define REQUIRED_MASK18 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
arch/x86/include/asm/syscall.h +3 -3
@@ -60,7 +60,7 @@ static inline long syscall_get_error(struct task_struct *task,* TS_COMPAT is set for 32-bit syscall entries and then * remains set until we return to user mode. */ -if (task->thread.status & (TS_COMPAT |TS_I386_REGS_POKED )) +if (task->thread_info.status & (TS_COMPAT |TS_I386_REGS_POKED ))/* * Sign-extend the value so (int)-EFOO becomes (long)-EFOO * and will match correctly in comparisons.
@@ -116,7 +116,7 @@ static inline void syscall_get_arguments(struct task_struct *task, unsigned long *args) {# ifdef CONFIG_IA32_EMULATION -if (task->thread.status &TS_COMPAT ) +if (task->thread_info.status &TS_COMPAT )switch (i) {case 0 :if (!n--)break ;
@@ -177,7 +177,7 @@ static inline void syscall_set_arguments(struct task_struct *task, const unsigned long *args) {# ifdef CONFIG_IA32_EMULATION -if (task->thread.status &TS_COMPAT ) +if (task->thread_info.status &TS_COMPAT )switch (i) {case 0 :if (!n--)break ;
arch/x86/include/asm/thread_info.h +2 -1
@@ -55,6 +55,7 @@ struct task_struct;struct thread_info {unsigned long flags;/* low level flags */ +u32 status;/* thread synchronous flags */ };#define INIT_THREAD_INFO (tsk) \
@@ -221,7 +222,7 @@ static inline int arch_within_stack_frames(const void * const stack,#define in_ia32_syscall () true#else #define in_ia32_syscall () (IS_ENABLED(CONFIG_IA32_EMULATION) && \ - current->thread.status & TS_COMPAT) + current_thread_info()->status & TS_COMPAT)#endif /*
arch/x86/include/asm/tlbflush.h +2 -0
@@ -174,6 +174,8 @@ struct tlb_state {struct mm_struct *loaded_mm;u16 loaded_mm_asid;u16 next_asid; +/* last user mm's ctx id */ +u64 last_ctx_id;/* * We can be in one of several states:
arch/x86/include/asm/uaccess.h +12 -3
@@ -124,6 +124,11 @@ extern int __get_user_bad(void);#define __uaccess_begin () stac()#define __uaccess_end () clac() +#define __uaccess_begin_nospec () \ +({ \ + stac(); \ + barrier_nospec(); \ +})/* * This is a type: either unsigned long, if the argument fits into
@@ -445,7 +450,7 @@ do { \ ({ \ int __gu_err; \ __inttype(*(ptr)) __gu_val; \ - __uaccess_begin(); \ + __uaccess_begin_nospec(); \ __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \ __uaccess_end(); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \
@@ -487,6 +492,10 @@ struct __large_struct { unsigned long buf[100]; };__uaccess_begin (); \barrier (); +#define uaccess_try_nospec do { \ + current->thread.uaccess_err = 0; \ + __uaccess_begin_nospec(); \ +#define uaccess_catch (err) \ __uaccess_end(); \ (err) |= (current->thread.uaccess_err ? -EFAULT : 0); \
@@ -548,7 +557,7 @@ struct __large_struct { unsigned long buf[100]; };* get_user_ex(...); * } get_user_catch(err) */ -#define get_user_try uaccess_try +#define get_user_try uaccess_try_nospec#define get_user_catch (err) uaccess_catch(err)#define get_user_ex (x, ptr) do { \
@@ -582,7 +591,7 @@ extern void __cmpxchg_wrong_size(void)__typeof__ (ptr) __uval = (uval); \ __typeof__(*(ptr)) __old = (old); \ __typeof__(*(ptr)) __new = (new); \ -__uaccess_begin (); \ +__uaccess_begin_nospec (); \switch (size) { \case 1 : \ { \
arch/x86/include/asm/uaccess_32.h +3 -3
@@ -29,21 +29,21 @@ raw_copy_from_user(void *to, const void __user *from, unsigned long n)switch (n) {case 1 : ret =0 ; -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u8 *)to, from, ret,"b" ,"b" ,"=q" ,1 );__uaccess_end ();return ret;case 2 : ret =0 ; -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u16 *)to, from, ret,"w" ,"w" ,"=r" ,2 );__uaccess_end ();return ret;case 4 : ret =0 ; -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u32 *)to, from, ret,"l" ,"k" ,"=r" ,4 );__uaccess_end ();
arch/x86/include/asm/uaccess_64.h +6 -6
@@ -55,31 +55,31 @@ raw_copy_from_user(void *dst, const void __user *src, unsigned long size)return copy_user_generic (dst, (__force void *)src, size);switch (size) {case 1 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u8 *)dst, (u8 __user *)src, ret,"b" ,"b" ,"=q" ,1 );__uaccess_end ();return ret;case 2 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u16 *)dst, (u16 __user *)src, ret,"w" ,"w" ,"=r" ,2 );__uaccess_end ();return ret;case 4 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u32 *)dst, (u32 __user *)src, ret,"l" ,"k" ,"=r" ,4 );__uaccess_end ();return ret;case 8 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u64 *)dst, (u64 __user *)src, ret,"q" ,"" ,"=r" ,8 );__uaccess_end ();return ret;case 10 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u64 *)dst, (u64 __user *)src, ret,"q" ,"" ,"=r" ,10 );if (likely (!ret))
@@ -89,7 +89,7 @@ raw_copy_from_user(void *dst, const void __user *src, unsigned long size)__uaccess_end ();return ret;case 16 : -__uaccess_begin (); +__uaccess_begin_nospec ();__get_user_asm_nozero (*(u64 *)dst, (u64 __user *)src, ret,"q" ,"" ,"=r" ,16 );if (likely (!ret))
arch/x86/kernel/alternative.c +7 -21
@@ -46,17 +46,6 @@ static int __init setup_noreplace_smp(char *str) }__setup ("noreplace-smp" , setup_noreplace_smp); -#ifdef CONFIG_PARAVIRT -static int __initdata_or_module noreplace_paravirt = 0; - -static int __init setup_noreplace_paravirt (char *str) -{ - noreplace_paravirt =1 ; -return 1 ; -} -__setup ("noreplace-paravirt" , setup_noreplace_paravirt); -#endif - #define DPRINTK(fmt, args...) \ do { \ if (debug_alternative) \
@@ -298,7 +287,7 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf) tgt_rip = next_rip + o_dspl; n_dspl = tgt_rip - orig_insn; -DPRINTK ("target RIP: %p, new_displ: 0x%x" , tgt_rip, n_dspl); +DPRINTK ("target RIP: %px, new_displ: 0x%x" , tgt_rip, n_dspl);if (tgt_rip - orig_insn >=0 ) {if (n_dspl -2 <=127 )
@@ -355,7 +344,7 @@ static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *insadd_nops (instr + (a->instrlen - a->padlen), a->padlen);local_irq_restore (flags); -DUMP_BYTES (instr, a->instrlen,"%p: [%d:%d) optimized NOPs: " , +DUMP_BYTES (instr, a->instrlen,"%px: [%d:%d) optimized NOPs: " , instr, a->instrlen - a->padlen, a->padlen); }
@@ -376,7 +365,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,u8 *instr, *replacement;u8 insnbuf[MAX_PATCH_LEN ]; -DPRINTK ("alt table %p -> %p" , start, end); +DPRINTK ("alt table %px, -> %px" , start, end);/* * The scan order should be from start to end. A later scanned * alternative code can overwrite previously scanned alternative code.
@@ -400,14 +389,14 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,continue ; } -DPRINTK ("feat: %d*32+%d, old: (%p, len: %d), repl: (%p, len: %d), pad: %d" , +DPRINTK ("feat: %d*32+%d, old: (%px len: %d), repl: (%px, len: %d), pad: %d" , a->cpuid >>5 , a->cpuid &0x1f , instr, a->instrlen, replacement, a->replacementlen, a->padlen); -DUMP_BYTES (instr, a->instrlen,"%p: old_insn: " , instr); -DUMP_BYTES (replacement, a->replacementlen,"%p: rpl_insn: " , replacement); +DUMP_BYTES (instr, a->instrlen,"%px: old_insn: " , instr); +DUMP_BYTES (replacement, a->replacementlen,"%px: rpl_insn: " , replacement);memcpy (insnbuf, replacement, a->replacementlen); insnbuf_sz = a->replacementlen;
@@ -433,7 +422,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, a->instrlen - a->replacementlen); insnbuf_sz += a->instrlen - a->replacementlen; } -DUMP_BYTES (insnbuf, insnbuf_sz,"%p: final_insn: " , instr); +DUMP_BYTES (insnbuf, insnbuf_sz,"%px: final_insn: " , instr);text_poke_early (instr, insnbuf, insnbuf_sz); }
@@ -599,9 +588,6 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,struct paravirt_patch_site *p;char insnbuf[MAX_PATCH_LEN ]; -if (noreplace_paravirt) -return ; -for (p = start; p < end; p++) {unsigned int used;
arch/x86/kernel/cpu/bugs.c +98 -36
195 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +65 -5
106 lines not on this page · raw message
arch/x86/kernel/cpu/intel.c +66 -0
78 lines not on this page · raw message
arch/x86/kernel/cpu/scattered.c +0 -2
@@ -21,8 +21,6 @@ struct cpuid_bit {static const struct cpuid_bit cpuid_bits[] = { {X86_FEATURE_APERFMPERF ,CPUID_ECX ,0 ,0x00000006 ,0 }, {X86_FEATURE_EPB ,CPUID_ECX ,3 ,0x00000006 ,0 }, - {X86_FEATURE_AVX512_4VNNIW ,CPUID_EDX ,2 ,0x00000007 ,0 }, - {X86_FEATURE_AVX512_4FMAPS ,CPUID_EDX ,3 ,0x00000007 ,0 }, {X86_FEATURE_CAT_L3 ,CPUID_EBX ,1 ,0x00000010 ,0 }, {X86_FEATURE_CAT_L2 ,CPUID_EBX ,2 ,0x00000010 ,0 }, {X86_FEATURE_CDP_L3 ,CPUID_ECX ,2 ,0x00000010 ,1 },
arch/x86/kernel/process_64.c +2 -2
@@ -557,7 +557,7 @@ static void __set_personality_x32(void)* Pretend to come from a x32 execve. */ task_pt_regs (current)->orig_ax = __NR_x32_execve | __X32_SYSCALL_BIT; - current->thread.status &= ~TS_COMPAT ; +current_thread_info ()->status &= ~TS_COMPAT ;#endif }
@@ -571,7 +571,7 @@ static void __set_personality_ia32(void) current->personality |= force_personality32;/* Prepare the first "return" to user space */ task_pt_regs (current)->orig_ax = __NR_ia32_execve; - current->thread.status |=TS_COMPAT ; +current_thread_info ()->status |=TS_COMPAT ;#endif }
arch/x86/kernel/ptrace.c +1 -1
@@ -935,7 +935,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 value)*/ regs->orig_ax = value;if (syscall_get_nr (child, regs) >=0 ) - child->thread.status |=TS_I386_REGS_POKED ; + child->thread_info.status |=TS_I386_REGS_POKED ;break ; case offsetof(struct user32, regs.eflags):
arch/x86/kernel/signal.c +1 -1
@@ -787,7 +787,7 @@ static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)* than the tracee. */ #ifdef CONFIG_IA32_EMULATION -if (current->thread.status & (TS_COMPAT |TS_I386_REGS_POKED )) +if (current_thread_info ()->status & (TS_COMPAT |TS_I386_REGS_POKED ))return __NR_ia32_restart_syscall;#endif #ifdef CONFIG_X86_X32_ABI
arch/x86/kvm/cpuid.c +16 -6
@@ -67,9 +67,7 @@ u64 kvm_supported_xcr0(void)#define F (x) bit(X86_FEATURE_##x) -/* These are scattered features in cpufeatures.h. */ -#define KVM_CPUID_BIT_AVX512_4VNNIW 2 -#define KVM_CPUID_BIT_AVX512_4FMAPS 3 +/* For scattered features from cpufeatures.h; we currently expose none */ #define KF (x) bit(KVM_CPUID_BIT_##x)int kvm_update_cpuid (struct kvm_vcpu *vcpu)
@@ -367,6 +365,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |0 /* SKINIT, WDT, LWP */ |F (FMA4 ) |F (TBM ); +/* cpuid 0x80000008.ebx */ +const u32 kvm_cpuid_8000_0008_ebx_x86_features = +F (IBPB ) |F (IBRS ); +/* cpuid 0xC0000001.edx */ const u32 kvm_cpuid_C000_0001_edx_x86_features = F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) |
@@ -392,7 +394,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,/* cpuid 7.0.edx*/ const u32 kvm_cpuid_7_0_edx_x86_features = -KF (AVX512_4VNNIW ) |KF (AVX512_4FMAPS ); +F (AVX512_4VNNIW ) |F (AVX512_4FMAPS ) |F (SPEC_CTRL ) | +F (ARCH_CAPABILITIES );/* all calls to cpuid_count() should be made on the same cpu */ get_cpu ();
@@ -477,7 +480,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,if (!tdp_enabled || !boot_cpu_has (X86_FEATURE_OSPKE )) entry->ecx &= ~F (PKU ); entry->edx &= kvm_cpuid_7_0_edx_x86_features; - entry->edx &=get_scattered_cpuid_leaf (7 ,0 ,CPUID_EDX ); +cpuid_mask (&entry->edx,CPUID_7_EDX ); }else { entry->ebx =0 ; entry->ecx =0 ;
@@ -627,7 +630,14 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,if (!g_phys_as) g_phys_as = phys_as; entry->eax = g_phys_as | (virt_as <<8 ); - entry->ebx = entry->edx =0 ; + entry->edx =0 ; +/* IBRS and IBPB aren't necessarily present in hardware cpuid */ +if (boot_cpu_has (X86_FEATURE_IBPB )) + entry->ebx |=F (IBPB ); +if (boot_cpu_has (X86_FEATURE_IBRS )) + entry->ebx |=F (IBRS ); + entry->ebx &= kvm_cpuid_8000_0008_ebx_x86_features; +cpuid_mask (&entry->ebx,CPUID_8000_0008_EBX );break ; }case 0x80000019 :
arch/x86/kvm/cpuid.h +1 -0
@@ -54,6 +54,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_8000_000A_EDX] = {0x8000000a, 0, CPUID_EDX}, [CPUID_7_ECX] = { 7, 0, CPUID_ECX}, [CPUID_8000_0007_EBX] = {0x80000007, 0, CPUID_EBX}, + [CPUID_7_EDX] = { 7, 0, CPUID_EDX}, }; static __always_inline struct cpuid_reg x86_feature_cpuid(unsigned x86_feature)
arch/x86/kvm/emulate.c +5 -4
@@ -25,6 +25,7 @@#include <asm/kvm_emulate.h> #include <linux/stringify.h> #include <asm/debugreg.h> +#include <asm/nospec-branch.h> #include "x86.h" #include "tss.h"
@@ -1021,8 +1022,8 @@ static __always_inline u8 test_cc(unsigned int condition, unsigned long flags)void (*fop)(void ) = (void *)em_setcc +4 * (condition &0xf ); flags = (flags &EFLAGS_MASK ) |X86_EFLAGS_IF ; - asm("push %[flags]; popf; call *%[fastop]" - :"=a" (rc) : [fastop]"r" (fop), [flags]"r" (flags)); + asm("push %[flags]; popf; " CALL_NOSPEC + :"=a" (rc) : [thunk_target]"r" (fop), [flags]"r" (flags));return rc; }
@@ -5350,9 +5351,9 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))if (!(ctxt->d & ByteOp)) fop +=__ffs (ctxt->dst.bytes) *FASTOP_SIZE ; - asm("push %[flags]; popf; call *%[fastop]; pushf; pop %[flags]\n" + asm("push %[flags]; popf; " CALL_NOSPEC " ; pushf; pop %[flags]\n" :"+a" (ctxt->dst.val),"+d" (ctxt->src.val), [flags]"+D" (flags), - [fastop]"+S"(fop), ASM_CALL_CONSTRAINT + [thunk_target]"+S"(fop), ASM_CALL_CONSTRAINT :"c" (ctxt->src2.val)); ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK ) | (flags &EFLAGS_MASK );
arch/x86/kvm/svm.c +116 -0
187 lines not on this page · raw message
arch/x86/kvm/vmx.c +391 -269
1,017 lines not on this page · raw message
arch/x86/kvm/x86.c +1 -0
@@ -1006,6 +1006,7 @@ static u32 msrs_to_save[] = {#endif MSR_IA32_TSC ,MSR_IA32_CR_PAT ,MSR_VM_HSAVE_PA ,MSR_IA32_FEATURE_CONTROL ,MSR_IA32_BNDCFGS ,MSR_TSC_AUX , + MSR_IA32_SPEC_CTRL, MSR_IA32_ARCH_CAPABILITIES };static unsigned num_msrs_to_save;
arch/x86/lib/Makefile +1 -0
@@ -27,6 +27,7 @@ lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o lib-$(CONFIG_RETPOLINE) += retpoline.o +OBJECT_FILES_NON_STANDARD_retpoline.o :=y obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
arch/x86/lib/getuser.S +10 -0
@@ -40,6 +40,8 @@ ENTRY(__get_user_1) mov PER_CPU_VAR(current_task), %_ASM_DX cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 1: movzbl (%_ASM_AX),%edx xor %eax,%eax
@@ -54,6 +56,8 @@ ENTRY(__get_user_2) mov PER_CPU_VAR(current_task), %_ASM_DX cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 2: movzwl -1(%_ASM_AX),%edx xor %eax,%eax
@@ -68,6 +72,8 @@ ENTRY(__get_user_4) mov PER_CPU_VAR(current_task), %_ASM_DX cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 3: movl -3(%_ASM_AX),%edx xor %eax,%eax
@@ -83,6 +89,8 @@ ENTRY(__get_user_8) mov PER_CPU_VAR(current_task), %_ASM_DX cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 4: movq -7(%_ASM_AX),%rdx xor %eax,%eax
@@ -94,6 +102,8 @@ ENTRY(__get_user_8) mov PER_CPU_VAR(current_task), %_ASM_DX cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX jae bad_get_user_8 + sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */ + and %_ASM_DX, %_ASM_AX ASM_STAC 4: movl -7(%_ASM_AX),%edx 5: movl -3(%_ASM_AX),%ecx
arch/x86/lib/retpoline.S +56 -1
72 lines not on this page · raw message
arch/x86/lib/usercopy_32.c +4 -4
@@ -331,12 +331,12 @@ do { \unsigned long __copy_user_ll (void *to,const void *from,unsigned long n) { -stac (); +__uaccess_begin_nospec ();if (movsl_is_ok (to, from, n))__copy_user (to, from, n);else n =__copy_user_intel (to, from, n); -clac (); +__uaccess_end ();return n; }EXPORT_SYMBOL (__copy_user_ll);
@@ -344,7 +344,7 @@ EXPORT_SYMBOL(__copy_user_ll);unsigned long __copy_from_user_ll_nocache_nozero (void *to,const void __user *from,unsigned long n) { -stac (); +__uaccess_begin_nospec ();#ifdef CONFIG_X86_INTEL_USERCOPY if (n >64 &&static_cpu_has (X86_FEATURE_XMM2 )) n =__copy_user_intel_nocache (to, from, n);
@@ -353,7 +353,7 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr#else __copy_user (to, from, n);#endif -clac (); +__uaccess_end ();return n; }EXPORT_SYMBOL (__copy_from_user_ll_nocache_nozero);
arch/x86/mm/tlb.c +32 -1
@@ -6,13 +6,14 @@#include <linux/interrupt.h> #include <linux/export.h> #include <linux/cpu.h> +#include <linux/debugfs.h> #include <asm/tlbflush.h> #include <asm/mmu_context.h> +#include <asm/nospec-branch.h> #include <asm/cache.h> #include <asm/apic.h> #include <asm/uv/uv.h> -#include <linux/debugfs.h> /* * TLB flushing, formerly SMP-only
@@ -247,6 +248,27 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, }else {u16 new_asid;bool need_flush; +u64 last_ctx_id =this_cpu_read (cpu_tlbstate.last_ctx_id); + +/* +* Avoid user/user BTB poisoning by flushing the branch +* predictor when switching between processes. This stops +* one process from doing Spectre-v2 attacks on another. +* +* As an optimization, flush indirect branches only when +* switching into processes that disable dumping. This +* protects high value processes like gpg, without having +* too high performance overhead. IBPB is *expensive*! +* +* This will not flush branches when switching into kernel +* threads. It will also not flush if we switch to idle +* thread and back to the same process. It will flush if we +* switch to a different non-dumpable process. +*/ +if (tsk && tsk->mm && + tsk->mm->context.ctx_id != last_ctx_id && +get_dumpable (tsk->mm) !=SUID_DUMP_USER ) +indirect_branch_prediction_barrier ();if (IS_ENABLED (CONFIG_VMAP_STACK )) {/*
@@ -292,6 +314,14 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,trace_tlb_flush_rcuidle (TLB_FLUSH_ON_TASK_SWITCH ,0 ); } +/* +* Record last user mm's context id, so we can avoid +* flushing branch buffer with IBPB if we switch back +* to the same user. +*/ +if (next != &init_mm) +this_cpu_write (cpu_tlbstate.last_ctx_id, next->context.ctx_id); +this_cpu_write (cpu_tlbstate.loaded_mm, next);this_cpu_write (cpu_tlbstate.loaded_mm_asid, new_asid); }
@@ -369,6 +399,7 @@ void initialize_tlbstate_and_flush(void)write_cr3 (build_cr3 (mm->pgd,0 ));/* Reinitialize tlbstate. */ +this_cpu_write (cpu_tlbstate.last_ctx_id, mm->context.ctx_id);this_cpu_write (cpu_tlbstate.loaded_mm_asid,0 );this_cpu_write (cpu_tlbstate.next_asid,1 );this_cpu_write (cpu_tlbstate.ctxs[0 ].ctx_id, mm->context.ctx_id);
drivers/auxdisplay/img-ascii-lcd.c +4 -0
@@ -443,3 +443,7 @@ static struct platform_driver img_ascii_lcd_driver = { .remove = img_ascii_lcd_remove, };module_platform_driver (img_ascii_lcd_driver); + +MODULE_DESCRIPTION ("Imagination Technologies ASCII LCD Display" ); +MODULE_AUTHOR ("Paul Burton <[email protected]>" ); +MODULE_LICENSE ("GPL" );
drivers/fpga/fpga-region.c +10 -3
@@ -147,6 +147,7 @@ static struct fpga_manager *fpga_region_get_manager(struct fpga_region *region) mgr_node =of_parse_phandle (np,"fpga-mgr" ,0 );if (mgr_node) { mgr =of_fpga_mgr_get (mgr_node); +of_node_put (mgr_node);of_node_put (np);return mgr; }
@@ -192,10 +193,13 @@ static int fpga_region_get_bridges(struct fpga_region *region, parent_br = region_np->parent;/* If overlay has a list of bridges, use it. */ -if (of_parse_phandle (overlay,"fpga-bridges" ,0 )) + br =of_parse_phandle (overlay,"fpga-bridges" ,0 ); +if (br) { +of_node_put (br); np = overlay; -else + }else { np = region_np; + }for (i =0 ; ; i++) { br =of_parse_phandle (np,"fpga-bridges" , i);
@@ -203,12 +207,15 @@ static int fpga_region_get_bridges(struct fpga_region *region,break ;/* If parent bridge is in list, skip it. */ -if (br == parent_br) +if (br == parent_br) { +of_node_put (br);continue ; + }/* If node is a bridge, get it and add to list */ ret =fpga_bridge_get_to_list (br, region->info, ®ion->bridge_list); +of_node_put (br);/* If any of the bridges are in use, give up */ if (ret == -EBUSY ) {
drivers/iio/accel/kxsd9-i2c.c +3 -0
@@ -63,3 +63,6 @@ static struct i2c_driver kxsd9_i2c_driver = { .id_table = kxsd9_i2c_id, };module_i2c_driver (kxsd9_i2c_driver); + +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("KXSD9 accelerometer I2C interface" );
drivers/iio/adc/qcom-vadc-common.c +4 -0
@@ -5,6 +5,7 @@#include <linux/math64.h> #include <linux/log2.h> #include <linux/err.h> +#include <linux/module.h> #include "qcom-vadc-common.h"
@@ -229,3 +230,6 @@ int qcom_vadc_decimation_from_dt(u32 value)return __ffs64 (value /VADC_DECIMATION_MIN ); }EXPORT_SYMBOL (qcom_vadc_decimation_from_dt); + +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("Qualcomm ADC common functionality" );
drivers/pinctrl/pxa/pinctrl-pxa2xx.c +4 -0
@@ -436,3 +436,7 @@ int pxa2xx_pinctrl_exit(struct platform_device *pdev)return 0 ; }EXPORT_SYMBOL_GPL (pxa2xx_pinctrl_exit); + +MODULE_AUTHOR ("Robert Jarzmik <[email protected]>" ); +MODULE_DESCRIPTION ("Marvell PXA2xx pinctrl driver" ); +MODULE_LICENSE ("GPL v2" );
drivers/tty/serial/serial_core.c +2 -0
@@ -987,6 +987,8 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, } }else { retval =uart_startup (tty, state,1 ); +if (retval ==0 ) +tty_port_set_initialized (port, true);if (retval >0 ) retval =0 ; }
include/linux/fdtable.h +4 -1
@@ -10,6 +10,7 @@#include <linux/compiler.h> #include <linux/spinlock.h> #include <linux/rcupdate.h> +#include <linux/nospec.h> #include <linux/types.h> #include <linux/init.h> #include <linux/fs.h>
@@ -82,8 +83,10 @@ static inline struct file *__fcheck_files(struct files_struct *files, unsigned i {struct fdtable *fdt =rcu_dereference_raw (files->fdt); -if (fd < fdt->max_fds) +if (fd < fdt->max_fds) { + fd =array_index_nospec (fd, fdt->max_fds);return rcu_dereference_raw (fdt->fd[fd]); + }return NULL ; }
include/linux/init.h +8 -1
@@ -5,6 +5,13 @@#include <linux/compiler.h> #include <linux/types.h> +/* Built-in __init functions needn't be compiled with retpoline */ +#if defined(RETPOLINE ) && !defined(MODULE ) +#define __noretpoline __attribute__((indirect_branch("keep"))) +#else +#define __noretpoline +#endif +/* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data) * as `initialization' functions. The kernel can take this
@@ -40,7 +47,7 @@/* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold __inittrace __latent_entropy +#define __init __section(.init.text) __cold __inittrace __latent_entropy __noretpoline#define __initdata __section(.init.data)#define __initconst __section(.init.rodata)#define __exitdata __section(.exit.data)
include/linux/module.h +9 -0
@@ -794,6 +794,15 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,static inline void module_bug_cleanup (struct module *mod) {}#endif /* CONFIG_GENERIC_BUG */ +#ifdef RETPOLINE +extern bool retpoline_module_ok (bool has_retpoline); +#else +static inline bool retpoline_module_ok (bool has_retpoline) +{ +return true; +} +#endif +#ifdef CONFIG_MODULE_SIG
Lines of this file are not shown. View the raw message.
include/linux/nospec.h new file +72 -0
72 lines not on this page · raw message
tools/objtool/check.c +47 -42
89 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.