Linux 3.16.53
I'm announcing the release of the 3.16.53 kernel.
All users of the 3.16 kernel series should upgrade.
The updated 3.16.y git tree can be found at:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-3.16.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git
The diff from 3.16.52 is attached to this message.
Ben.
------------
Documentation/kernel-parameters.txt | 12 + Documentation/x86/tlb.txt | 75 +++++ Makefile | 2 +- arch/arm/include/asm/mmu_context.h | 2 + arch/x86/boot/compressed/misc.h | 1 + arch/x86/ia32/ia32entry.S | 7 + arch/x86/include/asm/alternative-asm.h | 43 ++- arch/x86/include/asm/alternative.h | 65 ++-- arch/x86/include/asm/cmdline.h | 2 + arch/x86/include/asm/cpufeature.h | 34 +- arch/x86/include/asm/desc.h | 2 +- arch/x86/include/asm/hardirq.h | 6 +- arch/x86/include/asm/hw_irq.h | 2 +- arch/x86/include/asm/kaiser.h | 141 +++++++++ arch/x86/include/asm/mmu.h | 6 - arch/x86/include/asm/mmu_context.h | 83 +---- arch/x86/include/asm/pgtable.h | 28 +- arch/x86/include/asm/pgtable_64.h | 25 +- arch/x86/include/asm/pgtable_types.h | 29 +- arch/x86/include/asm/processor.h | 38 +-- arch/x86/include/asm/smap.h | 4 +- arch/x86/include/asm/tlbflush.h | 261 ++++++++++------ arch/x86/include/asm/virtext.h | 3 +- arch/x86/include/asm/vsyscall.h | 2 + arch/x86/include/uapi/asm/processor-flags.h | 3 +- arch/x86/kernel/alternative.c | 158 ++++++++-- arch/x86/kernel/cpu/amd.c | 7 - arch/x86/kernel/cpu/bugs.c | 8 + arch/x86/kernel/cpu/common.c | 113 +++++-- arch/x86/kernel/cpu/intel.c | 26 -- arch/x86/kernel/cpu/mcheck/mce.c | 3 +- arch/x86/kernel/cpu/mcheck/p5.c | 3 +- arch/x86/kernel/cpu/mcheck/winchip.c | 3 +- arch/x86/kernel/cpu/perf_event.c | 7 +- arch/x86/kernel/cpu/perf_event_intel_ds.c | 56 +++- arch/x86/kernel/entry_32.S | 2 +- arch/x86/kernel/entry_64.S | 190 +++++++++-- arch/x86/kernel/espfix_64.c | 10 + arch/x86/kernel/head_64.S | 35 ++- arch/x86/kernel/i387.c | 3 +- arch/x86/kernel/irq.c | 3 +- arch/x86/kernel/irqinit.c | 2 +- arch/x86/kernel/kvmclock.c | 5 + arch/x86/kernel/ldt.c | 27 +- arch/x86/kernel/paravirt_patch_64.c | 2 - arch/x86/kernel/process.c | 7 +- arch/x86/kernel/process_64.c | 2 +- arch/x86/kernel/reboot.c | 4 + arch/x86/kernel/setup.c | 7 + arch/x86/kernel/tracepoint.c | 2 + arch/x86/kernel/vm86_32.c | 2 +- arch/x86/kernel/vsyscall_64.c | 12 +- arch/x86/kernel/xsave.c | 3 +- arch/x86/kvm/vmx.c | 4 +- arch/x86/kvm/x86.c | 3 +- arch/x86/lib/clear_page_64.S | 4 +- arch/x86/lib/cmdline.c | 165 +++++++++- arch/x86/lib/copy_page_64.S | 2 +- arch/x86/lib/copy_user_64.S | 15 +- arch/x86/lib/memcpy_64.S | 8 +- arch/x86/lib/memmove_64.S | 2 +- arch/x86/lib/memset_64.S | 8 +- arch/x86/mm/Makefile | 4 +- arch/x86/mm/init.c | 6 +- arch/x86/mm/init_64.c | 10 + arch/x86/mm/kaiser.c | 469 ++++++++++++++++++++++++++++ arch/x86/mm/pageattr.c | 63 +++- arch/x86/mm/pgtable.c | 27 +- arch/x86/mm/tlb.c | 255 +++++++++------ arch/x86/xen/enlighten.c | 10 +- drivers/lguest/x86/core.c | 5 +- drivers/vhost/vhost.c | 1 + include/asm-generic/vmlinux.lds.h | 7 + include/linux/kaiser.h | 52 +++ include/linux/mmu_context.h | 7 + include/linux/mmzone.h | 3 +- include/linux/percpu-defs.h | 32 +- init/main.c | 2 + kernel/fork.c | 6 + kernel/sched/core.c | 4 +- mm/mmu_context.c | 2 +- mm/vmstat.c | 1 + security/Kconfig | 10 + 83 files changed, 2180 insertions(+), 585 deletions(-)
Aaron Lu (1):
x86/irq: Do not substract irq_tlb_count from irq_call_count
Andy Lutomirski (18):
x86: Clean up cr4 manipulation
x86/mm: Add INVPCID helpers
x86/mm: Add a 'noinvpcid' boot option to turn off INVPCID x86/mm: If INVPCID is available, use it to flush global mappings sched/core: Add switch_mm_irqs_off() and use it in the scheduler x86/mm: Build arch/x86/mm/tlb.c even on !SMP
x86/mm, sched/core: Uninline switch_mm()
x86/mm, sched/core: Turn off IRQs in switch_mm()
sched/core: Idle_task_exit() shouldn't use switch_mm_irqs_off() x86/vm86/32: Switch to flush_tlb_mm_range() in mark_screen_rdonly() x86/mm: Remove flush_tlb() and flush_tlb_current_task()
x86/mm: Make flush_tlb_mm_range() more predictable
x86/mm: Reimplement flush_tlb_page() using flush_tlb_mm_range() x86/mm: Remove the UP asm/tlbflush.h code, always use the (formerly) SMP code x86/mm: Disable PCID on 32-bit kernels
x86/mm: Add the 'nopcid' boot option to turn off PCID
x86/mm: Enable CR4.PCIDE on supported systems
x86/mm/64: Fix reboot interaction with CR4.PCIDE
Ben Hutchings (3):
drivers/vhost: Fix mmu_context.h assumption
x86: kvmclock: Disable use from vDSO if KPTI is enabled Linux 3.16.53
Borislav Petkov (10):
x86/mm: Fix INVPCID asm constraint
kaiser: Set _PAGE_USER of the vsyscall page x86/alternatives: Cleanup DPRINTK macro x86/alternatives: Add instruction padding x86/alternatives: Make JMPs more robust x86/alternatives: Use optimized NOPs for padding x86/kaiser: Rename and simplify X86_FEATURE_KAISER handling x86/kaiser: Check boottime cmdline params x86/kaiser: Reenable PARAVIRT
x86/kaiser: Move feature detection up
Dave Hansen (9):
x86/mm: Clean up the TLB flushing code
x86/mm: Rip out complicated, out-of-date, buggy TLB flushing x86/mm: Fix missed global TLB flush stat
x86/mm: New tunable for single vs full TLB flush x86/mm: Set TLB flush tunable to sane value (33) x86/boot: Fix early command-line parsing when matching at end x86/boot: Fix early command-line parsing when partial word matches x86/boot: Simplify early command line parsing x86/boot: Pass in size to early cmdline parsing
Hugh Dickins (5):
kaiser: alloc_ldt_struct() use get_zeroed_page()
kaiser: add "nokaiser" boot option, using ALTERNATIVE
kaiser: use ALTERNATIVE instead of x86_cr3_pcid_noflush
kaiser: asm/tlbflush.h handle noPGE at lower level
kaiser: kaiser_flush_tlb_on_return_to_user() check PCID
Ingo Molnar (1):
mm/mmu_context, sched/core: Fix mmu_context.h assumption
Jeremiah Mahler (1):
x86/mm: Fix sparse 'tlb_single_page_flush_ceiling' warning and make the variable read-mostly
Jiri Kosina (2):
kaiser: disabled on Xen PV
kaiser: x86: Fix NMI handling
Kees Cook (2):
KPTI: Rename to PAGE_TABLE_ISOLATION
KPTI: Report when enabled
Richard Fellner (1):
KAISER: Kernel Address Isolation
Steven Rostedt (1):
ARM: Hide finish_arch_post_lock_switch() from modules
Thomas Gleixner (1):
x86/paravirt: Dont patch flush_tlb_single
Tom Lendacky (1):
x86/boot: Add early cmdline parsing for options with arguments
Documentation/kernel-parameters.txt +12 -0
@@ -2225,8 +2225,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. nointroute [IA-64] + noinvpcid [X86] Disable the INVPCID cpu feature. + nojitter [IA-64] Disables jitter checking for ITC timers. + nopti [X86-64] Disable KAISER isolation of kernel from user. + no-kvmclock [X86,KVM] Disable paravirtualized KVM clock driver no-kvmapf [X86,KVM] Disable paravirtualized asynchronous page
@@ -2259,6 +2263,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. nopat [X86] Disable PAT (page attribute table extension of pagetables) support. + nopcid [X86-64] Disable the PCID cpu feature. + norandmaps Don't use address space randomization. Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space
@@ -2746,6 +2752,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. pt. [PARIDE] See Documentation/blockdev/paride.txt. + pti= [X86_64] + Control KAISER user/kernel address space isolation: + on - enable + off - disable + auto - default setting + pty.legacy_count= [KNL] Number of legacy pty's. Overwrites compiled-in default number.
Documentation/x86/tlb.txt new file +75 -0
75 lines not on this page · raw message
Makefile +1 -1
@@ -1,6 +1,6 @@ VERSION = 3 PATCHLEVEL = 16 -SUBLEVEL = 52 +SUBLEVEL = 53 EXTRAVERSION = NAME = Museum of Fishiegoodies
arch/arm/include/asm/mmu_context.h +2 -0
@@ -61,6 +61,7 @@ static inline void check_and_switch_context(struct mm_struct *mm,cpu_switch_mm (mm->pgd, mm); } +#ifndef MODULE #define finish_arch_post_lock_switch \ finish_arch_post_lock_switchstatic inline void finish_arch_post_lock_switch (void )
@@ -82,6 +83,7 @@ static inline void finish_arch_post_lock_switch(void)preempt_enable_no_resched (); } } +#endif /* !MODULE */ #endif /* CONFIG_MMU */
arch/x86/boot/compressed/misc.h +1 -0
@@ -9,6 +9,7 @@*/ #undef CONFIG_PARAVIRT#undef CONFIG_PARAVIRT_SPINLOCKS +#undef CONFIG_PAGE_TABLE_ISOLATION#include <linux/linkage.h> #include <linux/screen_info.h>
arch/x86/ia32/ia32entry.S +7 -0
@@ -15,6 +15,8 @@ #include <asm/irqflags.h> #include <asm/asm.h> #include <asm/smap.h> +#include <asm/pgtable_types.h> +#include <asm/kaiser.h> #include <linux/linkage.h> #include <linux/err.h>
@@ -121,6 +123,7 @@ ENTRY(ia32_sysenter_target) CFI_DEF_CFA rsp,0 CFI_REGISTER rsp,rbp SWAPGS_UNSAFE_STACK + SWITCH_KERNEL_CR3_NO_STACK movq PER_CPU_VAR(kernel_stack), %rsp addq $(KERNEL_STACK_OFFSET),%rsp /*
@@ -192,6 +195,7 @@ ENTRY(ia32_sysenter_target) popq_cfi %rcx /* User %esp */ CFI_REGISTER rsp,rcx TRACE_IRQS_ON + SWITCH_USER_CR3 ENABLE_INTERRUPTS_SYSEXIT32 CFI_RESTORE_STATE
@@ -296,6 +300,7 @@ ENTRY(ia32_cstar_target) CFI_REGISTER rip,rcx /*CFI_REGISTER rflags,r11*/ SWAPGS_UNSAFE_STACK + SWITCH_KERNEL_CR3_NO_STACK movl %esp,%r8d CFI_REGISTER rsp,r8 movq PER_CPU_VAR(kernel_stack),%rsp
@@ -350,6 +355,7 @@ ENTRY(ia32_cstar_target) xorq %r9,%r9 xorq %r8,%r8 TRACE_IRQS_ON + SWITCH_USER_CR3 movl RSP-ARGOFFSET(%rsp),%esp CFI_RESTORE rsp USERGS_SYSRET32
@@ -424,6 +430,7 @@ ENTRY(ia32_syscall) PARAVIRT_ADJUST_EXCEPTION_FRAME ASM_CLAC /* Do this early to minimize exposure */ SWAPGS + SWITCH_KERNEL_CR3_NO_STACK /* * No need to follow this irqs on/off section: the syscall * disabled irqs and here we enable it straight after entry:
arch/x86/include/asm/alternative-asm.h +42 -1
54 lines not on this page · raw message
arch/x86/include/asm/alternative.h +40 -25
104 lines not on this page · raw message
arch/x86/include/asm/cmdline.h +2 -0
@@ -2,5 +2,7 @@#define _ASM_X86_CMDLINE_Hint cmdline_find_option_bool (const char *cmdline_ptr,const char *option); +int cmdline_find_option (const char *cmdline_ptr,const char *option, +char *buffer,int bufsize);#endif /* _ASM_X86_CMDLINE_H */
arch/x86/include/asm/cpufeature.h +21 -13
@@ -186,6 +186,10 @@#define X86_FEATURE_DTHERM (7*32+ 7)/* Digital Thermal Sensor */ #define X86_FEATURE_HW_PSTATE (7*32+ 8)/* AMD HW-PState */ #define X86_FEATURE_PROC_FEEDBACK (7*32+ 9)/* AMD ProcFeedbackInterface */ +#define X86_FEATURE_INVPCID_SINGLE (7*32+10)/* Effectively INVPCID && CR4.PCIDE=1 */ + +/* Because the ALTERNATIVE scheme is for members of the X86_FEATURE club... */ +#define X86_FEATURE_KAISER (7*32+31)/* "" CONFIG_PAGE_TABLE_ISOLATION w/o nokaiser */ /* Virtualization flags: Linux defined, word 8 */ #define X86_FEATURE_TPR_SHADOW (8*32+ 0)/* Intel TPR Shadow */
@@ -389,6 +393,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) " .word %P0\n" /* 1: do replace */ " .byte 2b - 1b\n" /* source len */ " .byte 0\n" /* replacement len */ + " .byte 0\n" /* pad len */ ".previous\n" /* skipping size check since replacement size = 0 */ : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
@@ -403,6 +408,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) " .word %P0\n" /* feature bit */ " .byte 2b - 1b\n" /* source len */ " .byte 0\n" /* replacement len */ + " .byte 0\n" /* pad len */ ".previous\n" /* skipping size check since replacement size = 0 */ : : "i" (bit) : : t_no);
@@ -428,6 +434,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)" .word %P1\n" /* feature bit */ " .byte 2b - 1b\n" /* source len */ " .byte 4f - 3f\n" /* replacement len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
@@ -454,31 +461,30 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) static __always_inline __pure bool _static_cpu_has_safe(u16 bit) {#ifdef CC_HAVE_ASM_GOTO -/* -* We need to spell the jumps to the compiler because, depending on the offset, -* the replacement jump can be bigger than the original jump, and this we cannot -* have. Thus, we force the jump to the widest, 4-byte, signed relative -* offset even though the last would often fit in less bytes. -*/ -asm_volatile_goto ("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" +asm_volatile_goto ("1: jmp %l[t_dynamic]\n" "2:\n" +".skip -(((5f-4f) - (2b-1b)) > 0) * " +"((5f-4f) - (2b-1b)),0x90\n" +"3:\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n" /* src offset */ -" .long 3f - .\n" /* repl offset */ +" .long 4f - .\n" /* repl offset */ " .word %P1\n" /* always replace */ -" .byte 2b - 1b\n" /* src len */ -" .byte 4f - 3f\n" /* repl len */ +" .byte 3b - 1b\n" /* src len */ +" .byte 5f - 4f\n" /* repl len */ +" .byte 3b - 2b\n" /* pad len */ ".previous\n" ".section .altinstr_replacement,\"ax\"\n" -"3: .byte 0xe9\n .long %l[t_no] - 2b\n" -"4:\n" +"4: jmp %l[t_no]\n" +"5:\n" ".previous\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n" /* src offset */ " .long 0\n" /* no replacement */ " .word %P0\n" /* feature bit */ -" .byte 2b - 1b\n" /* src len */ +" .byte 3b - 1b\n" /* src len */ " .byte 0\n" /* repl len */ +" .byte 0\n" /* pad len */ ".previous\n" : : "i" (bit), "i" (X86_FEATURE_ALWAYS) : : t_dynamic, t_no);
@@ -498,6 +504,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)" .word %P2\n" /* always replace */ " .byte 2b - 1b\n" /* source len */ " .byte 4f - 3f\n" /* replacement len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
@@ -512,6 +519,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)" .word %P1\n" /* feature bit */ " .byte 4b - 3b\n" /* src len */ " .byte 6f - 5f\n" /* repl len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
arch/x86/include/asm/desc.h +1 -1
@@ -43,7 +43,7 @@ struct gdt_page {struct desc_struct gdt[GDT_ENTRIES ]; } __attribute__((aligned(PAGE_SIZE))); -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page); +DECLARE_PER_CPU_PAGE_ALIGNED_USER_MAPPED(struct gdt_page, gdt_page);static inline struct desc_struct *get_cpu_gdt_table (unsigned int cpu) {
arch/x86/include/asm/hardirq.h +1 -5
@@ -21,12 +21,8 @@ typedef struct {#ifdef CONFIG_SMP unsigned int irq_resched_count;unsigned int irq_call_count; -/* -* irq_tlb_count is double-counted in irq_call_count, so it must be -* subtracted from irq_call_count when displaying irq_call_count -*/ -unsigned int irq_tlb_count;#endif +unsigned int irq_tlb_count;#ifdef CONFIG_X86_THERMAL_VECTOR unsigned int irq_thermal_count;#endif
arch/x86/include/asm/hw_irq.h +1 -1
@@ -194,7 +194,7 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);#define VECTOR_RETRIGGERED (-2)typedef int vector_irq_t [NR_VECTORS ]; -DECLARE_PER_CPU (vector_irq_t, vector_irq); +DECLARE_PER_CPU_USER_MAPPED (vector_irq_t, vector_irq);extern void setup_vector_irq (int cpu);#ifdef CONFIG_X86_IO_APIC
arch/x86/include/asm/kaiser.h new file +141 -0
141 lines not on this page · raw message
arch/x86/include/asm/mmu.h +0 -6
@@ -20,12 +20,6 @@ typedef struct { void __user *vdso; } mm_context_t; -#ifdef CONFIG_SMP void leave_mm (int cpu); -#else -static inline void leave_mm (int cpu) -{ -} -#endif #endif /* _ASM_X86_MMU_H */
arch/x86/include/asm/mmu_context.h +5 -78
94 lines not on this page · raw message
arch/x86/include/asm/pgtable.h +26 -2
@@ -17,6 +17,12 @@#ifndef __ASSEMBLY__#include <asm/x86_init.h> +#ifdef CONFIG_PAGE_TABLE_ISOLATION +extern int kaiser_enabled; +#else +#define kaiser_enabled 0 +#endif +void ptdump_walk_pgd_level (struct seq_file *m,pgd_t *pgd);/*
@@ -641,7 +647,17 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)static inline int pgd_bad (pgd_t pgd) { -return (pgd_flags (pgd) & ~_PAGE_USER) != _KERNPG_TABLE; +pgdval_t ignore_flags = _PAGE_USER; +/* +* We set NX on KAISER pgds that map userspace memory so +* that userspace can not meaningfully use the kernel +* page table by accident; it will fault on the first +* instruction it tries to run. See native_set_pgd(). +*/ +if (kaiser_enabled) + ignore_flags |= _PAGE_NX; + +return (pgd_flags (pgd) & ~ignore_flags) != _KERNPG_TABLE; }static inline int pgd_none (pgd_t pgd)
@@ -843,7 +859,15 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,*/ static inline void clone_pgd_range (pgd_t *dst,pgd_t *src,int count) { -memcpy (dst, src, count *sizeof (pgd_t)); +memcpy (dst, src, count *sizeof (pgd_t)); +#ifdef CONFIG_PAGE_TABLE_ISOLATION +if (kaiser_enabled) { +/* Clone the shadow pgd part as well */ +memcpy (native_get_shadow_pgd (dst), +native_get_shadow_pgd (src), + count *sizeof (pgd_t)); + } +#endif }#define PTE_SHIFT ilog2(PTRS_PER_PTE)
arch/x86/include/asm/pgtable_64.h +24 -1
@@ -106,9 +106,32 @@ static inline void native_pud_clear(pud_t *pud)native_set_pud (pud,native_make_pud (0 )); } +#ifdef CONFIG_PAGE_TABLE_ISOLATION +extern pgd_t kaiser_set_shadow_pgd (pgd_t *pgdp,pgd_t pgd); + +static inline pgd_t *native_get_shadow_pgd (pgd_t *pgdp) +{ +#ifdef CONFIG_DEBUG_VM +/* linux/mmdebug.h may not have been included at this point */ +BUG_ON (!kaiser_enabled); +#endif +return (pgd_t *)((unsigned long )pgdp | (unsigned long )PAGE_SIZE ); +} +#else +static inline pgd_t kaiser_set_shadow_pgd (pgd_t *pgdp,pgd_t pgd) +{ +return pgd; +} +static inline pgd_t *native_get_shadow_pgd (pgd_t *pgdp) +{ +BUILD_BUG_ON (1 ); +return NULL ; +} +#endif /* CONFIG_PAGE_TABLE_ISOLATION */ +static inline void native_set_pgd (pgd_t *pgdp,pgd_t pgd) { - *pgdp = pgd; + *pgdp =kaiser_set_shadow_pgd (pgdp, pgd); }static inline void native_pgd_clear (pgd_t *pgd)
arch/x86/include/asm/pgtable_types.h +28 -1
@@ -116,7 +116,7 @@#endif #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE) -#define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) +#define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ _PAGE_ACCESSED | _PAGE_DIRTY)
@@ -129,6 +129,33 @@ _PAGE_SOFT_DIRTY | _PAGE_NUMA)#define _HPAGE_CHG_MASK (_PAGE_CHG_MASK | _PAGE_PSE | _PAGE_NUMA) +/* The ASID is the lower 12 bits of CR3 */ +#define X86_CR3_PCID_ASID_MASK (_AC((1<<12)-1,UL)) + +/* Mask for all the PCID-related bits in CR3: */ +#define X86_CR3_PCID_MASK (X86_CR3_PCID_NOFLUSH | X86_CR3_PCID_ASID_MASK) +#define X86_CR3_PCID_ASID_KERN (_AC(0x0,UL)) + +#if defined(CONFIG_PAGE_TABLE_ISOLATION ) && defined(CONFIG_X86_64 ) +/* Let X86_CR3_PCID_ASID_USER be usable for the X86_CR3_PCID_NOFLUSH bit */ +#define X86_CR3_PCID_ASID_USER (_AC(0x80,UL)) + +#define X86_CR3_PCID_KERN_FLUSH (X86_CR3_PCID_ASID_KERN) +#define X86_CR3_PCID_USER_FLUSH (X86_CR3_PCID_ASID_USER) +#define X86_CR3_PCID_KERN_NOFLUSH (X86_CR3_PCID_NOFLUSH | X86_CR3_PCID_ASID_KERN) +#define X86_CR3_PCID_USER_NOFLUSH (X86_CR3_PCID_NOFLUSH | X86_CR3_PCID_ASID_USER) +#else +#define X86_CR3_PCID_ASID_USER (_AC(0x0,UL)) +/* +* PCIDs are unsupported on 32-bit and none of these bits can be +* set in CR3: +*/ +#define X86_CR3_PCID_KERN_FLUSH (0) +#define X86_CR3_PCID_USER_FLUSH (0) +#define X86_CR3_PCID_KERN_NOFLUSH (0) +#define X86_CR3_PCID_USER_NOFLUSH (0) +#endif +#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)#define _PAGE_CACHE_WB (0)#define _PAGE_CACHE_WC (_PAGE_PWT)
arch/x86/include/asm/processor.h +2 -36
@@ -72,7 +72,6 @@ extern u16 __read_mostly tlb_lld_4k[NR_INFO];extern u16 __read_mostly tlb_lld_2m[NR_INFO ];extern u16 __read_mostly tlb_lld_4m[NR_INFO ];extern u16 __read_mostly tlb_lld_1g[NR_INFO ]; -extern s8 __read_mostly tlb_flushall_shift;/* * CPU type and hardware bug flags. Kept separately for each CPU.
@@ -283,7 +282,7 @@ struct tss_struct { }____cacheline_aligned ; -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss); +DECLARE_PER_CPU_SHARED_ALIGNED_USER_MAPPED(struct tss_struct, init_tss);/* * Save the original ist values for checking stack pointers during debugging
@@ -579,39 +578,6 @@ static inline void load_sp0(struct tss_struct *tss,#define set_iopl_mask native_set_iopl_mask#endif /* CONFIG_PARAVIRT */ -/* -* Save the cr4 feature set we're using (ie -* Pentium 4MB enable and PPro Global page -* enable), so that any CPU's that boot up -* after us can get the correct flags. -*/ -extern unsigned long mmu_cr4_features; -extern u32 *trampoline_cr4_features; - -static inline void set_in_cr4 (unsigned long mask) -{ -unsigned long cr4; - - mmu_cr4_features |= mask; -if (trampoline_cr4_features) - *trampoline_cr4_features = mmu_cr4_features; - cr4 =read_cr4 (); - cr4 |= mask; -write_cr4 (cr4); -} - -static inline void clear_in_cr4 (unsigned long mask) -{ -unsigned long cr4; - - mmu_cr4_features &= ~mask; -if (trampoline_cr4_features) - *trampoline_cr4_features = mmu_cr4_features; - cr4 =read_cr4 (); - cr4 &= ~mask; -write_cr4 (cr4); -} -typedef struct {unsigned long seg; }mm_segment_t ;
@@ -930,7 +896,7 @@ extern unsigned long KSTK_ESP(struct task_struct *task);/* * User space RSP while inside the SYSCALL fast path */ -DECLARE_PER_CPU(unsigned long, old_rsp); +DECLARE_PER_CPU_USER_MAPPED(unsigned long, old_rsp);#endif /* CONFIG_X86_64 */
arch/x86/include/asm/smap.h +2 -2
@@ -33,7 +33,7 @@ 662: __ASM_CLAC ; \ .popsection ; \ .pushsection .altinstructions, "a" ; \ - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3 ; \ + altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3, 0 ; \ .popsection #define ASM_STAC \
@@ -42,7 +42,7 @@ 662: __ASM_STAC ; \ .popsection ; \ .pushsection .altinstructions, "a" ; \ - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3 ; \ + altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3, 0 ; \ .popsection #else /* CONFIG_X86_SMAP */
arch/x86/include/asm/tlbflush.h +166 -95
335 lines not on this page · raw message
arch/x86/include/asm/virtext.h +2 -1
@@ -19,6 +19,7 @@#include <asm/vmx.h> #include <asm/svm.h> +#include <asm/tlbflush.h> /* * VMX functions:
@@ -40,7 +41,7 @@ static inline int cpu_has_vmx(void)static inline void cpu_vmxoff (void ) { asm volatile (ASM_VMX_VMXOFF : : : "cc"); -write_cr4 (read_cr4 () & ~X86_CR4_VMXE ); +cr4_clear_bits (X86_CR4_VMXE ); }static inline int cpu_vmx_enabled (void )
arch/x86/include/asm/vsyscall.h +2 -0
@@ -10,6 +10,7 @@/* kernel space (writeable) */ extern int vgetcpu_mode;extern struct timezone sys_tz; +extern unsigned long vsyscall_pgprot;#include <asm/vvar.h>
@@ -20,6 +21,7 @@ extern void map_vsyscall(void);* Returns true if handled. */ extern bool emulate_vsyscall (struct pt_regs *regs,unsigned long address); +extern bool vsyscall_enabled (void );#ifdef CONFIG_X86_64
arch/x86/include/uapi/asm/processor-flags.h +2 -1
@@ -79,7 +79,8 @@#define X86_CR3_PWT _BITUL(X86_CR3_PWT_BIT)#define X86_CR3_PCD_BIT 4/* Page Cache Disable */ #define X86_CR3_PCD _BITUL(X86_CR3_PCD_BIT) -#define X86_CR3_PCID_MASK _AC(0x00000fff,UL)/* PCID Mask */ +#define X86_CR3_PCID_NOFLUSH_BIT 63/* Preserve old PCID */ +#define X86_CR3_PCID_NOFLUSH _BITULL(X86_CR3_PCID_NOFLUSH_BIT)/* * Intel CPU features in CR4
arch/x86/kernel/alternative.c +136 -22
212 lines not on this page · raw message
arch/x86/kernel/cpu/amd.c +0 -7
@@ -762,11 +762,6 @@ static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) }#endif -static void cpu_set_tlb_flushall_shift (struct cpuinfo_x86 *c) -{ - tlb_flushall_shift =6 ; -} -static void cpu_detect_tlb_amd (struct cpuinfo_x86 *c) {u32 ebx, eax, ecx, edx;
@@ -814,8 +809,6 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c) tlb_lli_2m[ENTRIES ] = eax & mask; tlb_lli_4m[ENTRIES ] = tlb_lli_2m[ENTRIES ] >>1 ; - -cpu_set_tlb_flushall_shift (c); }static const struct cpu_dev amd_cpu_dev = {
arch/x86/kernel/cpu/bugs.c +8 -0
@@ -65,6 +65,14 @@ static void __init check_fpu(void)void __init check_bugs (void ) { +#ifdef CONFIG_X86_32 +/* +* Regardless of whether PCID is enumerated, the SDM says +* that it can't be enabled in 32-bit mode. +*/ +setup_clear_cpu_cap (X86_FEATURE_PCID ); +#endif +identify_boot_cpu ();#ifndef CONFIG_SMP pr_info ("CPU: " );
arch/x86/kernel/cpu/common.c +94 -19
199 lines not on this page · raw message
arch/x86/kernel/cpu/intel.c +0 -26
@@ -663,31 +663,6 @@ static void intel_tlb_lookup(const unsigned char desc) } } -static void intel_tlb_flushall_shift_set (struct cpuinfo_x86 *c) -{ -switch ((c->x86 <<8 ) + c->x86_model) { -case 0x60f :/* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */ -case 0x616 :/* single-core 65 nm celeron/core2solo "Merom-L"/"Conroe-L" */ -case 0x617 :/* current 45 nm celeron/core2/xeon "Penryn"/"Wolfdale" */ -case 0x61d :/* six-core 45 nm xeon "Dunnington" */ - tlb_flushall_shift =-1 ; -break ; -case 0x63a :/* Ivybridge */ - tlb_flushall_shift =2 ; -break ; -case 0x61a :/* 45 nm nehalem, "Bloomfield" */ -case 0x61e :/* 45 nm nehalem, "Lynnfield" */ -case 0x625 :/* 32 nm nehalem, "Clarkdale" */ -case 0x62c :/* 32 nm nehalem, "Gulftown" */ -case 0x62e :/* 45 nm nehalem-ex, "Beckton" */ -case 0x62f :/* 32 nm Xeon E7 */ -case 0x62a :/* SandyBridge */ -case 0x62d :/* SandyBridge, "Romely-EP" */ -default : - tlb_flushall_shift =6 ; - } -} -static void intel_detect_tlb (struct cpuinfo_x86 *c) {int i, j, n;
@@ -712,7 +687,6 @@ static void intel_detect_tlb(struct cpuinfo_x86 *c)for (j =1 ; j <16 ; j++)intel_tlb_lookup (desc[j]); } -intel_tlb_flushall_shift_set (c); }static const struct cpu_dev intel_cpu_dev = {
arch/x86/kernel/cpu/mcheck/mce.c +2 -1
@@ -43,6 +43,7 @@#include <linux/export.h> #include <asm/processor.h> +#include <asm/tlbflush.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -1470,7 +1471,7 @@ static void __mcheck_cpu_init_generic(void)bitmap_fill (all_banks,MAX_NR_BANKS );machine_check_poll (MCP_UC | m_fl, &all_banks); -set_in_cr4 (X86_CR4_MCE ); +cr4_set_bits (X86_CR4_MCE );rdmsrl (MSR_IA32_MCG_CAP , cap);if (cap &MCG_CTL_P )
arch/x86/kernel/cpu/mcheck/p5.c +2 -1
@@ -8,6 +8,7 @@#include <linux/smp.h> #include <asm/processor.h> +#include <asm/tlbflush.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -59,7 +60,7 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c) "Intel old style machine check architecture supported.\n");/* Enable MCE: */ -set_in_cr4 (X86_CR4_MCE ); +cr4_set_bits (X86_CR4_MCE );printk (KERN_INFO "Intel old style machine check reporting enabled on CPU#%d.\n" ,smp_processor_id ());
arch/x86/kernel/cpu/mcheck/winchip.c +2 -1
@@ -7,6 +7,7 @@#include <linux/types.h> #include <asm/processor.h> +#include <asm/tlbflush.h> #include <asm/mce.h> #include <asm/msr.h>
@@ -31,7 +32,7 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c) lo &= ~(1 <<4 );/* Enable MCE */ wrmsr (MSR_IDT_FCR1 , lo, hi); -set_in_cr4 (X86_CR4_MCE ); +cr4_set_bits (X86_CR4_MCE );printk (KERN_INFO "Winchip machine check reporting enabled on CPU#0.\n" );
arch/x86/kernel/cpu/perf_event.c +4 -3
@@ -31,6 +31,7 @@#include <asm/nmi.h> #include <asm/smp.h> #include <asm/alternative.h> +#include <asm/tlbflush.h> #include <asm/mmu_context.h> #include <asm/timer.h> #include <asm/desc.h>
@@ -1340,7 +1341,7 @@ x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)case CPU_STARTING :if (x86_pmu.attr_rdpmc) -set_in_cr4 (X86_CR4_PCE ); +cr4_set_bits (X86_CR4_PCE );if (x86_pmu.cpu_starting) x86_pmu.cpu_starting (cpu);break ;
@@ -1855,9 +1856,9 @@ static void change_rdpmc(void *info)bool enable = !!(unsigned long )info;if (enable) -set_in_cr4 (X86_CR4_PCE ); +cr4_set_bits (X86_CR4_PCE );else -clear_in_cr4 (X86_CR4_PCE ); +cr4_clear_bits (X86_CR4_PCE ); } static ssize_t set_attr_rdpmc(struct device *cdev,
arch/x86/kernel/cpu/perf_event_intel_ds.c +44 -12
115 lines not on this page · raw message
arch/x86/kernel/entry_32.S +1 -1
@@ -821,7 +821,7 @@ ENTRY(simd_coprocessor_error) 661: pushl_cfi $do_general_protection 662: .section .altinstructions,"a" - altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f + altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f, 0 .previous .section .altinstr_replacement,"ax" 663: pushl $do_simd_coprocessor_error
arch/x86/kernel/entry_64.S +163 -27
295 lines not on this page · raw message
arch/x86/kernel/espfix_64.c +10 -0
@@ -41,6 +41,7 @@#include <asm/pgalloc.h> #include <asm/setup.h> #include <asm/espfix.h> +#include <asm/kaiser.h> /* * Note: we only need 6*8 = 48 bytes for the espfix stack, but round
@@ -129,6 +130,15 @@ void __init init_espfix_bsp(void)/* Install the espfix pud into the kernel page directory */ pgd_p = &init_level4_pgt[pgd_index (ESPFIX_BASE_ADDR )];pgd_populate (&init_mm, pgd_p, (pud_t *)espfix_pud_page); +/* +* Just copy the top-level PGD that is mapping the espfix +* area to ensure it is mapped into the shadow user page +* tables. +*/ +if (kaiser_enabled) { +set_pgd (native_get_shadow_pgd (pgd_p), +__pgd (_KERNPG_TABLE |__pa ((pud_t *)espfix_pud_page))); + }/* Randomize the locations */ init_espfix_random ();
arch/x86/kernel/head_64.S +30 -5
@@ -183,8 +183,8 @@ ENTRY(secondary_startup_64) movq $(init_level4_pgt - __START_KERNEL_map), %rax 1: - /* Enable PAE mode and PGE */ - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx + /* Enable PAE and PSE, but defer PGE until kaiser_enabled is decided */ + movl $(X86_CR4_PAE | X86_CR4_PSE), %ecx movq %rcx, %cr4 /* Setup early boot stage 4 level pagetables. */
@@ -441,6 +441,27 @@ ENDPROC(early_idt_handler_common) .balign PAGE_SIZE; \ GLOBAL(name) +#ifdef CONFIG_PAGE_TABLE_ISOLATION +/* + * Each PGD needs to be 8k long and 8k aligned. We do not + * ever go out to userspace with these, so we do not + * strictly *need* the second page, but this allows us to + * have a single set_pgd() implementation that does not + * need to worry about whether it has 4k or 8k to work + * with. + * + * This ensures PGDs are 8k long: + */ +#define KAISER_USER_PGD_FILL 512 +/* This ensures they are 8k-aligned: */ +#define NEXT_PGD_PAGE(name) \ + .balign 2 * PAGE_SIZE; \ +GLOBAL(name) +#else +#define NEXT_PGD_PAGE(name) NEXT_PAGE(name) +#define KAISER_USER_PGD_FILL 0 +#endif + /* Automate the creation of 1 to 1 mapping pmd entries */ #define PMDS(START, PERM, COUNT) \ i = 0 ; \
@@ -450,9 +471,10 @@ GLOBAL(name) .endr __INITDATA -NEXT_PAGE(early_level4_pgt) +NEXT_PGD_PAGE(early_level4_pgt) .fill 511,8,0 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .fill KAISER_USER_PGD_FILL,8,0 NEXT_PAGE(early_dynamic_pgts) .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
@@ -460,16 +482,18 @@ NEXT_PAGE(early_dynamic_pgts) .data #ifndef CONFIG_XEN -NEXT_PAGE(init_level4_pgt) +NEXT_PGD_PAGE(init_level4_pgt) .fill 512,8,0 + .fill KAISER_USER_PGD_FILL,8,0 #else -NEXT_PAGE(init_level4_pgt) +NEXT_PGD_PAGE(init_level4_pgt) .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE .org init_level4_pgt + L4_PAGE_OFFSET*8, 0 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE .org init_level4_pgt + L4_START_KERNEL*8, 0 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .fill KAISER_USER_PGD_FILL,8,0 NEXT_PAGE(level3_ident_pgt) .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
@@ -480,6 +504,7 @@ NEXT_PAGE(level2_ident_pgt) */ PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD) #endif + .fill KAISER_USER_PGD_FILL,8,0 NEXT_PAGE(level3_kernel_pgt) .fill L3_START_KERNEL,8,0
arch/x86/kernel/i387.c +2 -1
@@ -13,6 +13,7 @@#include <asm/sigcontext.h> #include <asm/processor.h> #include <asm/math_emu.h> +#include <asm/tlbflush.h> #include <asm/uaccess.h> #include <asm/ptrace.h> #include <asm/i387.h>
@@ -181,7 +182,7 @@ void fpu_init(void)if (cpu_has_xmm) cr4_mask |=X86_CR4_OSXMMEXCPT ;if (cr4_mask) -set_in_cr4 (cr4_mask); +cr4_set_bits (cr4_mask); cr0 =read_cr0 (); cr0 &= ~(X86_CR0_TS |X86_CR0_EM );/* clear TS and EM */
arch/x86/kernel/irq.c +1 -2
@@ -96,8 +96,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_printf (p," Rescheduling interrupts\n" );seq_printf (p,"%*s: " , prec,"CAL" );for_each_online_cpu (j) -seq_printf (p,"%10u " ,irq_stats (j)->irq_call_count - -irq_stats (j)->irq_tlb_count); +seq_printf (p,"%10u " ,irq_stats (j)->irq_call_count);seq_printf (p," Function call interrupts\n" );seq_printf (p,"%*s: " , prec,"TLB" );for_each_online_cpu (j)
arch/x86/kernel/irqinit.c +1 -1
@@ -51,7 +51,7 @@ static struct irqaction irq2 = { .flags = IRQF_NO_THREAD, }; -DEFINE_PER_CPU(vector_irq_t, vector_irq) = { +DEFINE_PER_CPU_USER_MAPPED(vector_irq_t, vector_irq) = { [0 ... NR_VECTORS - 1] = VECTOR_UNDEFINED, };
arch/x86/kernel/kvmclock.c +5 -0
@@ -24,6 +24,7 @@#include <linux/percpu.h> #include <linux/hardirq.h> #include <linux/memblock.h> +#include <linux/kaiser.h> #include <asm/x86_init.h> #include <asm/reboot.h>
@@ -281,6 +282,10 @@ int __init kvm_setup_vsyscall_timeinfo(void)if (!hv_clock)return 0 ; +/* FIXME: Need to add pvclock pages to user-space page tables */ +if (kaiser_enabled) +return 0 ; + size =PAGE_ALIGN (sizeof (struct pvclock_vsyscall_time_info )*NR_CPUS );preempt_disable ();
arch/x86/kernel/ldt.c +21 -6
@@ -15,6 +15,7 @@#include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/uaccess.h> +#include <linux/kaiser.h> #include <asm/ldt.h> #include <asm/desc.h>
@@ -33,11 +34,21 @@ static void flush_ldt(void *current_mm)set_ldt (pc->ldt->entries, pc->ldt->size); } +static void __free_ldt_struct (struct ldt_struct *ldt) +{ +if (ldt->size *LDT_ENTRY_SIZE >PAGE_SIZE ) +vfree (ldt->entries); +else +free_page ((unsigned long )ldt->entries); +kfree (ldt); +} +/* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */ static struct ldt_struct *alloc_ldt_struct (int size) {struct ldt_struct *new_ldt;int alloc_size; +int ret;if (size >LDT_ENTRIES )return NULL ;
@@ -58,14 +69,20 @@ static struct ldt_struct *alloc_ldt_struct(int size)if (alloc_size >PAGE_SIZE ) new_ldt->entries =vzalloc (alloc_size);else - new_ldt->entries =kzalloc (PAGE_SIZE ,GFP_KERNEL ); + new_ldt->entries = (void *)get_zeroed_page (GFP_KERNEL );if (!new_ldt->entries) {kfree (new_ldt);return NULL ; } + ret =kaiser_add_mapping ((unsigned long )new_ldt->entries, alloc_size, + __PAGE_KERNEL); new_ldt->size = size; +if (ret) { +__free_ldt_struct (new_ldt); +return NULL ; + }return new_ldt; }
@@ -91,12 +108,10 @@ static void free_ldt_struct(struct ldt_struct *ldt)if (likely (!ldt))return ; +kaiser_remove_mapping ((unsigned long )ldt->entries, + ldt->size *LDT_ENTRY_SIZE );paravirt_free_ldt (ldt->entries, ldt->size); -if (ldt->size *LDT_ENTRY_SIZE >PAGE_SIZE ) -vfree (ldt->entries); -else -kfree (ldt->entries); -kfree (ldt); +__free_ldt_struct (ldt); }/*
arch/x86/kernel/paravirt_patch_64.c +0 -2
@@ -9,7 +9,6 @@ DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax");DEF_NATIVE (pv_mmu_ops, read_cr2,"movq %cr2, %rax" );DEF_NATIVE (pv_mmu_ops, read_cr3,"movq %cr3, %rax" );DEF_NATIVE (pv_mmu_ops, write_cr3,"movq %rdi, %cr3" ); -DEF_NATIVE (pv_mmu_ops, flush_tlb_single,"invlpg (%rdi)" );DEF_NATIVE (pv_cpu_ops, clts,"clts" );DEF_NATIVE (pv_cpu_ops, wbinvd,"wbinvd" );
@@ -57,7 +56,6 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,PATCH_SITE (pv_mmu_ops, read_cr3);PATCH_SITE (pv_mmu_ops, write_cr3);PATCH_SITE (pv_cpu_ops, clts); -PATCH_SITE (pv_mmu_ops, flush_tlb_single);PATCH_SITE (pv_cpu_ops, wbinvd); patch_site:
arch/x86/kernel/process.c +4 -3
@@ -29,6 +29,7 @@#include <asm/fpu-internal.h> #include <asm/debugreg.h> #include <asm/nmi.h> +#include <asm/tlbflush.h> /* * per-CPU TSS segments. Threads are completely 'soft' on Linux,
@@ -37,7 +38,7 @@* section. Since TSS's are completely CPU-local, we want them * on exact cacheline boundaries, to eliminate cacheline ping-pong. */ -__visible DEFINE_PER_CPU_SHARED_ALIGNED (struct tss_struct ,init_tss ) =INIT_TSS ; +__visible DEFINE_PER_CPU_SHARED_ALIGNED_USER_MAPPED (struct tss_struct ,init_tss ) =INIT_TSS ;#ifdef CONFIG_X86_64 static DEFINE_PER_CPU(unsigned char, is_idle);
@@ -139,7 +140,7 @@ void flush_thread(void)static void hard_disable_TSC (void ) { -write_cr4 (read_cr4 () |X86_CR4_TSD ); +cr4_set_bits (X86_CR4_TSD ); }void disable_TSC (void )
@@ -156,7 +157,7 @@ void disable_TSC(void)static void hard_enable_TSC (void ) { -write_cr4 (read_cr4 () & ~X86_CR4_TSD ); +cr4_clear_bits (X86_CR4_TSD ); }static void enable_TSC (void )
arch/x86/kernel/process_64.c +1 -1
@@ -53,7 +53,7 @@ asmlinkage extern void ret_from_fork(void); -__visible DEFINE_PER_CPU (unsigned long ,old_rsp ); +__visible DEFINE_PER_CPU_USER_MAPPED (unsigned long ,old_rsp );/* Prints also some state that isn't saved in the pt_regs */ void __show_regs (struct pt_regs *regs,int all)
arch/x86/kernel/reboot.c +4 -0
@@ -92,6 +92,10 @@ void __noreturn machine_real_restart(unsigned int type)load_cr3 (initial_page_table);#else write_cr3 (real_mode_header->trampoline_pgd); + +/* Exiting long mode will fail if CR4.PCIDE is set. */ +if (static_cpu_has (X86_FEATURE_PCID )) +cr4_clear_bits (X86_CR4_PCIDE );#endif /* Jump to the identity-mapped low memory code */
arch/x86/kernel/setup.c +7 -0
@@ -110,6 +110,7 @@#include <asm/mce.h> #include <asm/alternative.h> #include <asm/prom.h> +#include <asm/kaiser.h> /* * max_low_pfn_mapped: highest direct mapped pfn under 4GB
@@ -1019,6 +1020,12 @@ void __init setup_arch(char **cmdline_p)*/ init_hypervisor_platform (); +/* +* This needs to happen right after XENPV is set on xen and +* kaiser_enabled is checked below in cleanup_highmap(). +*/ +kaiser_check_boottime_disable (); + x86_init.resources.probe_roms ();/* after parse_early_param, so could debug it */
arch/x86/kernel/tracepoint.c +2 -0
@@ -9,10 +9,12 @@#include <linux/atomic.h> atomic_t trace_idt_ctr =ATOMIC_INIT (0 ); +__aligned(PAGE_SIZE) struct desc_ptr trace_idt_descr = {NR_VECTORS *16 -1 , (unsigned long ) trace_idt_table };/* No need to be aligned, but done to keep all IDTs defined the same way. */ +__aligned(PAGE_SIZE) gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;static int trace_irq_vector_refcount;
arch/x86/kernel/vm86_32.c +1 -1
@@ -194,7 +194,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)pte_unmap_unlock (pte, ptl); out:up_write (&mm->mmap_sem); -flush_tlb (); +flush_tlb_mm_range (mm,0xA0000 ,0xA0000 +32 *PAGE_SIZE ,0UL ); }
arch/x86/kernel/vsyscall_64.c +9 -3
@@ -55,6 +55,7 @@DEFINE_VVAR (int, vgetcpu_mode);static enum {EMULATE ,NATIVE ,NONE } vsyscall_mode =EMULATE ; +unsigned long vsyscall_pgprot = __PAGE_KERNEL_VSYSCALL;static int __init vsyscall_setup (char *str) {
@@ -75,6 +76,11 @@ static int __init vsyscall_setup(char *str) }early_param ("vsyscall" , vsyscall_setup); +bool vsyscall_enabled (void ) +{ +return vsyscall_mode !=NONE ; +} +static void warn_bad_vsyscall (const char *level,struct pt_regs *regs,const char *message) {
@@ -331,10 +337,10 @@ void __init map_vsyscall(void)extern char __vsyscall_page;unsigned long physaddr_vsyscall =__pa_symbol (&__vsyscall_page); +if (vsyscall_mode !=NATIVE ) + vsyscall_pgprot = __PAGE_KERNEL_VVAR;__set_fixmap (VSYSCALL_PAGE , physaddr_vsyscall, - vsyscall_mode ==NATIVE - ?PAGE_KERNEL_VSYSCALL - :PAGE_KERNEL_VVAR ); +__pgprot (vsyscall_pgprot));BUILD_BUG_ON ((unsigned long )__fix_to_virt (VSYSCALL_PAGE ) != (unsigned long )VSYSCALL_ADDR ); }
arch/x86/kernel/xsave.c +2 -1
@@ -11,6 +11,7 @@#include <asm/i387.h> #include <asm/fpu-internal.h> #include <asm/sigframe.h> +#include <asm/tlbflush.h> #include <asm/xcr.h> /*
@@ -450,7 +451,7 @@ static void prepare_fx_sw_frame(void)*/ static inline void xstate_enable (void ) { -set_in_cr4 (X86_CR4_OSXSAVE ); +cr4_set_bits (X86_CR4_OSXSAVE );xsetbv (XCR_XFEATURE_ENABLED_MASK , pcntxt_mask); }
arch/x86/kvm/vmx.c +2 -2
@@ -2738,7 +2738,7 @@ static int hardware_enable(void *garbage)/* enable and lock */ wrmsrl (MSR_IA32_FEATURE_CONTROL , old | test_bits); } -write_cr4 (read_cr4 () |X86_CR4_VMXE );/* FIXME: not cpu hotplug safe */ +cr4_set_bits (X86_CR4_VMXE );if (vmm_exclusive) {kvm_cpu_vmxon (phys_addr);
@@ -2775,7 +2775,7 @@ static void hardware_disable(void *garbage)vmclear_local_loaded_vmcss ();kvm_cpu_vmxoff (); } -write_cr4 (read_cr4 () & ~X86_CR4_VMXE ); +cr4_clear_bits (X86_CR4_VMXE ); } static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
arch/x86/kvm/x86.c +2 -1
@@ -688,7 +688,8 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)return 1 ;/* PCID can not be enabled when cr3[11:0]!=000H or EFER.LMA=0 */ -if ((kvm_read_cr3 (vcpu) &X86_CR3_PCID_MASK ) || !is_long_mode (vcpu)) +if ((kvm_read_cr3 (vcpu) &X86_CR3_PCID_ASID_MASK ) || + !is_long_mode (vcpu))return 1 ; }
arch/x86/lib/clear_page_64.S +2 -2
@@ -67,7 +67,7 @@ ENDPROC(clear_page) .previous .section .altinstructions,"a" altinstruction_entry clear_page,1b,X86_FEATURE_REP_GOOD,\ - .Lclear_page_end-clear_page, 2b-1b + .Lclear_page_end-clear_page, 2b-1b, 0 altinstruction_entry clear_page,2b,X86_FEATURE_ERMS, \ - .Lclear_page_end-clear_page,3b-2b + .Lclear_page_end-clear_page,3b-2b, 0 .previous
arch/x86/lib/cmdline.c +148 -17
192 lines not on this page · raw message
arch/x86/lib/copy_page_64.S +1 -1
@@ -106,5 +106,5 @@ ENDPROC(copy_page) .previous .section .altinstructions,"a" altinstruction_entry copy_page, 1b, X86_FEATURE_REP_GOOD, \ - .Lcopy_page_end-copy_page, 2b-1b + .Lcopy_page_end-copy_page, 2b-1b, 0 .previous
arch/x86/lib/copy_user_64.S +7 -8
@@ -28,19 +28,18 @@ */ .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2 0: - .byte 0xe9 /* 32bit jump */ - .long \orig-1f /* by default jump to orig */ + jmp \orig 1: .section .altinstr_replacement,"ax" -2: .byte 0xe9 /* near jump with 32bit immediate */ - .long \alt1-1b /* offset */ /* or alternatively to alt1 */ -3: .byte 0xe9 /* near jump with 32bit immediate */ - .long \alt2-1b /* offset */ /* or alternatively to alt2 */ +2: + jmp \alt1 +3: + jmp \alt2 .previous .section .altinstructions,"a" - altinstruction_entry 0b,2b,\feature1,5,5 - altinstruction_entry 0b,3b,\feature2,5,5 + altinstruction_entry 0b,2b,\feature1,5,5,0 + altinstruction_entry 0b,3b,\feature2,5,5,0 .previous .endm
arch/x86/lib/memcpy_64.S +4 -4
@@ -199,8 +199,8 @@ ENDPROC(__memcpy) * only outcome... */ .section .altinstructions, "a" - altinstruction_entry memcpy,.Lmemcpy_c,X86_FEATURE_REP_GOOD,\ - .Lmemcpy_e-.Lmemcpy_c,.Lmemcpy_e-.Lmemcpy_c - altinstruction_entry memcpy,.Lmemcpy_c_e,X86_FEATURE_ERMS, \ - .Lmemcpy_e_e-.Lmemcpy_c_e,.Lmemcpy_e_e-.Lmemcpy_c_e + altinstruction_entry __memcpy,.Lmemcpy_c,X86_FEATURE_REP_GOOD,\ + .Lmemcpy_e-.Lmemcpy_c,.Lmemcpy_e-.Lmemcpy_c,0 + altinstruction_entry __memcpy,.Lmemcpy_c_e,X86_FEATURE_ERMS, \ + .Lmemcpy_e_e-.Lmemcpy_c_e,.Lmemcpy_e_e-.Lmemcpy_c_e,0 .previous
arch/x86/lib/memmove_64.S +1 -1
@@ -218,6 +218,6 @@ ENTRY(memmove) altinstruction_entry .Lmemmove_begin_forward, \ .Lmemmove_begin_forward_efs,X86_FEATURE_ERMS, \ .Lmemmove_end_forward-.Lmemmove_begin_forward, \ - .Lmemmove_end_forward_efs-.Lmemmove_begin_forward_efs + .Lmemmove_end_forward_efs-.Lmemmove_begin_forward_efs,0 .previous ENDPROC(memmove)
arch/x86/lib/memset_64.S +4 -4
@@ -147,8 +147,8 @@ ENDPROC(__memset) * feature to implement the right patch order. */ .section .altinstructions,"a" - altinstruction_entry memset,.Lmemset_c,X86_FEATURE_REP_GOOD,\ - .Lfinal-memset,.Lmemset_e-.Lmemset_c - altinstruction_entry memset,.Lmemset_c_e,X86_FEATURE_ERMS, \ - .Lfinal-memset,.Lmemset_e_e-.Lmemset_c_e + altinstruction_entry __memset,.Lmemset_c,X86_FEATURE_REP_GOOD,\ + .Lfinal-__memset,.Lmemset_e-.Lmemset_c,0 + altinstruction_entry __memset,.Lmemset_c_e,X86_FEATURE_ERMS, \ + .Lfinal-__memset,.Lmemset_e_e-.Lmemset_c_e,0 .previous
arch/x86/mm/Makefile +2 -2
@@ -1,5 +1,5 @@ obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ - pat.o pgtable.o physaddr.o gup.o setup_nx.o + pat.o pgtable.o physaddr.o gup.o setup_nx.o tlb.o # Make sure __phys_addr has no stackprotector nostackp := $(call cc-option, -fno-stack-protector)
@@ -9,7 +9,6 @@ CFLAGS_setup_nx.o := $(nostackp) CFLAGS_fault.o := -I$(src)/../include/asm/trace obj-$(CONFIG_X86_PAT) += pat_rbtree.o -obj-$(CONFIG_SMP) += tlb.o obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o
@@ -30,3 +29,4 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o obj-$(CONFIG_NUMA_EMU) += numa_emulation.o obj-$(CONFIG_MEMTEST) += memtest.o +obj-$(CONFIG_PAGE_TABLE_ISOLATION) += kaiser.o
arch/x86/mm/init.c +3 -3
@@ -137,11 +137,11 @@ static void __init probe_page_size_mask(void)/* Enable PSE if available */ if (cpu_has_pse) -set_in_cr4 (X86_CR4_PSE ); +cr4_set_bits_and_update_boot (X86_CR4_PSE );/* Enable PGE if available */ -if (cpu_has_pge) { -set_in_cr4 (X86_CR4_PGE ); +if (cpu_has_pge && !kaiser_enabled) { +cr4_set_bits_and_update_boot (X86_CR4_PGE ); __supported_pte_mask |= _PAGE_GLOBAL; } }
arch/x86/mm/init_64.c +10 -0
@@ -396,6 +396,16 @@ void __init cleanup_highmap(void)continue ;if (vaddr < (unsigned long ) _text || vaddr > end)set_pmd (pmd,__pmd (0 )); +else if (kaiser_enabled) { +/* +* level2_kernel_pgt is initialized with _PAGE_GLOBAL: +* clear that now. This is not important, so long as +* CR4.PGE remains clear, but it removes an anomaly. +* Physical mapping setup below avoids _PAGE_GLOBAL +* by use of massage_pgprot() inside pfn_pte() etc. +*/ +set_pmd (pmd,pmd_clear_flags (*pmd, _PAGE_GLOBAL)); + } } }
arch/x86/mm/kaiser.c new file +469 -0
57 lines not on this page · raw message
arch/x86/mm/pageattr.c +47 -16
63 lines not on this page · raw message
arch/x86/mm/tlb.c +160 -95
255 lines not on this page · raw message
include/linux/kaiser.h new file +52 -0
52 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.