Pull x86 cleanups from Ingo Molnar: "Various cleanups and simplifications, none of them really stands out, they are all over the place" * 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/uaccess: Remove unused __addr_ok() macro x86/smpboot: Remove unused phys_id variable x86/mm/dump_pagetables: Remove the unused prev_pud variable x86/fpu: Move init_xstate_size() to __init section x86/cpu_entry_area: Move percpu_setup_debug_store() to __init section x86/mtrr: Remove unused variable x86/boot/compressed/64: Explain paging_prepare()'s return value x86/resctrl: Remove duplicate MSR_MISC_FEATURE_CONTROL definition x86/asm/suspend: Drop ENTRY from local data x86/hw_breakpoints, kprobes: Remove kprobes ifdeffery x86/boot: Save several bytes in decompressor x86/trap: Remove useless declaration x86/mm/tlb: Remove unused cpu variable x86/events: Mark expected switch-case fall-throughs x86/asm-prototypes: Remove duplicate include <asm/page.h> x86/kernel: Mark expected switch-case fall-throughs x86/insn-eval: Mark expected switch-case fall-through x86/platform/UV: Replace kmalloc() and memset() with k[cz]alloc() calls x86/e820: Replace kmalloc() + memcpy() with kmemdup()
Unified · Split
| @@ -358,8 +358,11 @@ ENTRY(startup_64) · 357 unmodified lines | ||
| 358 | 358 | * paging_prepare() sets up the trampoline and checks if we need to |
| 359 | 359 | * enable 5-level paging. |
| 360 | 360 | * |
| 361 | − * Address of the trampoline is returned in RAX. | |
| 362 | − * Non zero RDX on return means we need to enable 5-level paging. | |
| 361 | + * paging_prepare() returns a two-quadword structure which lands | |
| 362 | + * into RDX:RAX: | |
| 363 | + * - Address of the trampoline is returned in RAX. | |
| 364 | + * - Non zero RDX means trampoline needs to enable 5-level | |
| 365 | + * paging. | |
| 363 | 366 | * |
| 364 | 367 | * RSI holds real mode data and needs to be preserved across |
| 365 | 368 | * this function call. |
| @@ -565,7 +568,7 @@ adjust_got: · 199 unmodified lines | ||
| 565 | 568 | * |
| 566 | 569 | * RDI contains the return address (might be above 4G). |
| 567 | 570 | * ECX contains the base address of the trampoline memory. |
| 568 | − * Non zero RDX on return means we need to enable 5-level paging. | |
| 571 | + * Non zero RDX means trampoline needs to enable 5-level paging. | |
| 569 | 572 | */ |
| 570 | 573 | ENTRY(trampoline_32bit_src) |
| 571 | 574 | /* Set up data and stack segments */ |
| @@ -655,8 +658,6 @@ no_longmode: · 83 unmodified lines | ||
| 655 | 658 | .data |
| 656 | 659 | gdt64: |
| 657 | 660 | .word gdt_end - gdt |
| 658 | − .long 0 | |
| 659 | − .word 0 | |
| 660 | 661 | .quad 0 |
| 661 | 662 | gdt: |
| 662 | 663 | .word gdt_end - gdt |
| @@ -4220,6 +4220,8 @@ __init int intel_pmu_init(void) · 4219 unmodified lines | ||
| 4220 | 4220 | |
| 4221 | 4221 | case INTEL_FAM6_CORE2_MEROM: |
| 4222 | 4222 | x86_add_quirk(intel_clovertown_quirk); |
| 4223 | + /* fall through */ | |
| 4224 | + | |
| 4223 | 4225 | case INTEL_FAM6_CORE2_MEROM_L: |
| 4224 | 4226 | case INTEL_FAM6_CORE2_PENRYN: |
| 4225 | 4227 | case INTEL_FAM6_CORE2_DUNNINGTON: |
| @@ -931,6 +931,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort) · 930 unmodified lines | ||
| 931 | 931 | ret = X86_BR_ZERO_CALL; |
| 932 | 932 | break; |
| 933 | 933 | } |
| 934 | + /* fall through */ | |
| 934 | 935 | case 0x9a: /* call far absolute */ |
| 935 | 936 | ret = X86_BR_CALL; |
| 936 | 937 | break; |
| @@ -7,7 +7,6 @@ · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | #include <asm-generic/asm-prototypes.h> |
| 9 | 9 | |
| 10 | −#include <asm/page.h> | |
| 11 | 10 | #include <asm/pgtable.h> |
| 12 | 11 | #include <asm/special_insns.h> |
| 13 | 12 | #include <asm/preempt.h> |
| @@ -742,7 +742,6 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT, · 741 unmodified lines | ||
| 742 | 742 | extern void enable_sep_cpu(void); |
| 743 | 743 | extern int sysenter_setup(void); |
| 744 | 744 | |
| 745 | −void early_trap_pf_init(void); | |
| 746 | 745 | |
| 747 | 746 | /* Defined in head.S */ |
| 748 | 747 | extern struct desc_ptr early_gdt_descr; |
| @@ -34,10 +34,7 @@ static inline void set_fs(mm_segment_t fs) · 33 unmodified lines | ||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | #define segment_eq(a, b) ((a).seg == (b).seg) |
| 37 | − | |
| 38 | 37 | #define user_addr_max() (current->thread.addr_limit.seg) |
| 39 | −#define __addr_ok(addr) \ | |
| 40 | − ((unsigned long __force)(addr) < user_addr_max()) | |
| 41 | 38 | |
| 42 | 39 | /* |
| 43 | 40 | * Test whether a block of memory is a valid user space address. |
| @@ -90,7 +90,7 @@ ret_point: · 89 unmodified lines | ||
| 90 | 90 | .data |
| 91 | 91 | ALIGN |
| 92 | 92 | ENTRY(saved_magic) .long 0 |
| 93 | −ENTRY(saved_eip) .long 0 | |
| 93 | +saved_eip: .long 0 | |
| 94 | 94 | |
| 95 | 95 | # saved registers |
| 96 | 96 | saved_idt: .long 0,0 |
| @@ -125,12 +125,12 @@ ENTRY(do_suspend_lowlevel) · 124 unmodified lines | ||
| 125 | 125 | ENDPROC(do_suspend_lowlevel) |
| 126 | 126 | |
| 127 | 127 | .data |
| 128 | −ENTRY(saved_rbp) .quad 0 | |
| 129 | −ENTRY(saved_rsi) .quad 0 | |
| 130 | −ENTRY(saved_rdi) .quad 0 | |
| 131 | −ENTRY(saved_rbx) .quad 0 | |
| 128 | +saved_rbp: .quad 0 | |
| 129 | +saved_rsi: .quad 0 | |
| 130 | +saved_rdi: .quad 0 | |
| 131 | +saved_rbx: .quad 0 | |
| 132 | 132 | |
| 133 | −ENTRY(saved_rip) .quad 0 | |
| 134 | −ENTRY(saved_rsp) .quad 0 | |
| 133 | +saved_rip: .quad 0 | |
| 134 | +saved_rsp: .quad 0 | |
| 135 | 135 | |
| 136 | 136 | ENTRY(saved_magic) .quad 0 |
| @@ -812,6 +812,7 @@ static int irq_polarity(int idx) · 811 unmodified lines | ||
| 812 | 812 | return IOAPIC_POL_HIGH; |
| 813 | 813 | case MP_IRQPOL_RESERVED: |
| 814 | 814 | pr_warn("IOAPIC: Invalid polarity: 2, defaulting to low\n"); |
| 815 | + /* fall through */ | |
| 815 | 816 | case MP_IRQPOL_ACTIVE_LOW: |
| 816 | 817 | default: /* Pointless default required due to do gcc stupidity */ |
| 817 | 818 | return IOAPIC_POL_LOW; |
| @@ -859,6 +860,7 @@ static int irq_trigger(int idx) · 41 unmodified lines | ||
| 859 | 860 | return IOAPIC_EDGE; |
| 860 | 861 | case MP_IRQTRIG_RESERVED: |
| 861 | 862 | pr_warn("IOAPIC: Invalid trigger mode 2 defaulting to level\n"); |
| 863 | + /* fall through */ | |
| 862 | 864 | case MP_IRQTRIG_LEVEL: |
| 863 | 865 | default: /* Pointless default required due to do gcc stupidity */ |
| 864 | 866 | return IOAPIC_LEVEL; |
| @@ -248,6 +248,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, · 247 unmodified lines | ||
| 248 | 248 | switch (leaf) { |
| 249 | 249 | case 1: |
| 250 | 250 | l1 = &l1i; |
| 251 | + /* fall through */ | |
| 251 | 252 | case 0: |
| 252 | 253 | if (!l1->val) |
| 253 | 254 | return; |
| @@ -296,7 +296,7 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek, · 295 unmodified lines | ||
| 296 | 296 | unsigned long sizek) |
| 297 | 297 | { |
| 298 | 298 | unsigned long hole_basek, hole_sizek; |
| 299 | − unsigned long second_basek, second_sizek; | |
| 299 | + unsigned long second_sizek; | |
| 300 | 300 | unsigned long range0_basek, range0_sizek; |
| 301 | 301 | unsigned long range_basek, range_sizek; |
| 302 | 302 | unsigned long chunk_sizek; |
| @@ -304,7 +304,6 @@ range_to_mtrr_with_hole(struct var_mtrr_state *state, unsigned long basek, · 1 unmodified line | ||
| 304 | 304 | |
| 305 | 305 | hole_basek = 0; |
| 306 | 306 | hole_sizek = 0; |
| 307 | − second_basek = 0; | |
| 308 | 307 | second_sizek = 0; |
| 309 | 308 | chunk_sizek = state->chunk_sizek; |
| 310 | 309 | gran_sizek = state->gran_sizek; |
| @@ -33,13 +33,6 @@ · 32 unmodified lines | ||
| 33 | 33 | #define CREATE_TRACE_POINTS |
| 34 | 34 | #include "pseudo_lock_event.h" |
| 35 | 35 | |
| 36 | −/* | |
| 37 | − * MSR_MISC_FEATURE_CONTROL register enables the modification of hardware | |
| 38 | − * prefetcher state. Details about this register can be found in the MSR | |
| 39 | − * tables for specific platforms found in Intel's SDM. | |
| 40 | − */ | |
| 41 | −#define MSR_MISC_FEATURE_CONTROL 0x000001a4 | |
| 42 | − | |
| 43 | 36 | /* |
| 44 | 37 | * The bits needed to disable hardware prefetching varies based on the |
| 45 | 38 | * platform. During initialization we will discover which bits to use. |
| @@ -671,21 +671,18 @@ __init void e820__reallocate_tables(void) · 670 unmodified lines | ||
| 671 | 671 | int size; |
| 672 | 672 | |
| 673 | 673 | size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table->nr_entries; |
| 674 | − n = kmalloc(size, GFP_KERNEL); | |
| 674 | + n = kmemdup(e820_table, size, GFP_KERNEL); | |
| 675 | 675 | BUG_ON(!n); |
| 676 | − memcpy(n, e820_table, size); | |
| 677 | 676 | e820_table = n; |
| 678 | 677 | |
| 679 | 678 | size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table_kexec->nr_entries; |
| 680 | − n = kmalloc(size, GFP_KERNEL); | |
| 679 | + n = kmemdup(e820_table_kexec, size, GFP_KERNEL); | |
| 681 | 680 | BUG_ON(!n); |
| 682 | − memcpy(n, e820_table_kexec, size); | |
| 683 | 681 | e820_table_kexec = n; |
| 684 | 682 | |
| 685 | 683 | size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry)*e820_table_firmware->nr_entries; |
| 686 | − n = kmalloc(size, GFP_KERNEL); | |
| 684 | + n = kmemdup(e820_table_firmware, size, GFP_KERNEL); | |
| 687 | 685 | BUG_ON(!n); |
| 688 | − memcpy(n, e820_table_firmware, size); | |
| 689 | 686 | e820_table_firmware = n; |
| 690 | 687 | } |
| 691 | 688 | |
| @@ -669,7 +669,7 @@ static bool is_supported_xstate_size(unsigned int test_xstate_size) · 668 unmodified lines | ||
| 669 | 669 | return false; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | −static int init_xstate_size(void) | |
| 672 | +static int __init init_xstate_size(void) | |
| 673 | 673 | { |
| 674 | 674 | /* Recompute the context size for enabled features: */ |
| 675 | 675 | unsigned int possible_xstate_size; |
| @@ -261,12 +261,8 @@ static int arch_build_bp_info(struct perf_event *bp, · 260 unmodified lines | ||
| 261 | 261 | * allow kernel breakpoints at all. |
| 262 | 262 | */ |
| 263 | 263 | if (attr->bp_addr >= TASK_SIZE_MAX) { |
| 264 | −#ifdef CONFIG_KPROBES | |
| 265 | 264 | if (within_kprobe_blacklist(attr->bp_addr)) |
| 266 | 265 | return -EINVAL; |
| 267 | −#else | |
| 268 | − return -EINVAL; | |
| 269 | −#endif | |
| 270 | 266 | } |
| 271 | 267 | |
| 272 | 268 | hw->type = X86_BREAKPOINT_EXECUTE; |
| @@ -279,6 +275,7 @@ static int arch_build_bp_info(struct perf_event *bp, · 6 unmodified lines | ||
| 279 | 275 | hw->len = X86_BREAKPOINT_LEN_X; |
| 280 | 276 | return 0; |
| 281 | 277 | } |
| 278 | + /* fall through */ | |
| 282 | 279 | default: |
| 283 | 280 | return -EINVAL; |
| 284 | 281 | } |
| @@ -467,6 +467,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code, · 466 unmodified lines | ||
| 467 | 467 | ptr = &remcomInBuffer[1]; |
| 468 | 468 | if (kgdb_hex2long(&ptr, &addr)) |
| 469 | 469 | linux_regs->ip = addr; |
| 470 | + /* fall through */ | |
| 470 | 471 | case 'D': |
| 471 | 472 | case 'k': |
| 472 | 473 | /* clear the trace bit */ |
| @@ -150,7 +150,7 @@ static inline void smpboot_restore_warm_reset_vector(void) · 149 unmodified lines | ||
| 150 | 150 | */ |
| 151 | 151 | static void smp_callin(void) |
| 152 | 152 | { |
| 153 | − int cpuid, phys_id; | |
| 153 | + int cpuid; | |
| 154 | 154 | |
| 155 | 155 | /* |
| 156 | 156 | * If waken up by an INIT in an 82489DX configuration |
| @@ -160,11 +160,6 @@ static void smp_callin(void) · 3 unmodified lines | ||
| 160 | 160 | */ |
| 161 | 161 | cpuid = smp_processor_id(); |
| 162 | 162 | |
| 163 | − /* | |
| 164 | − * (This works even if the APIC is not enabled.) | |
| 165 | − */ | |
| 166 | − phys_id = read_apic_id(); | |
| 167 | − | |
| 168 | 163 | /* |
| 169 | 164 | * the boot CPU has finished the init stage and is spinning |
| 170 | 165 | * on callin_map until we finish. We are free to set up this |
| @@ -745,6 +745,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) · 744 unmodified lines | ||
| 745 | 745 | * OPCODE1() of the "short" jmp which checks the same condition. |
| 746 | 746 | */ |
| 747 | 747 | opc1 = OPCODE2(insn) - 0x10; |
| 748 | + /* fall through */ | |
| 748 | 749 | default: |
| 749 | 750 | if (!is_cond_jmp_opcode(opc1)) |
| 750 | 751 | return -ENOSYS; |
| @@ -179,6 +179,8 @@ static int resolve_default_seg(struct insn *insn, struct pt_regs *regs, int off) · 178 unmodified lines | ||
| 179 | 179 | if (insn->addr_bytes == 2) |
| 180 | 180 | return -EINVAL; |
| 181 | 181 | |
| 182 | + /* fall through */ | |
| 183 | + | |
| 182 | 184 | case -EDOM: |
| 183 | 185 | case offsetof(struct pt_regs, bx): |
| 184 | 186 | case offsetof(struct pt_regs, si): |
| @@ -52,7 +52,7 @@ cea_map_percpu_pages(void *cea_vaddr, void *ptr, int pages, pgprot_t prot) · 51 unmodified lines | ||
| 52 | 52 | cea_set_pte(cea_vaddr, per_cpu_ptr_to_phys(ptr), prot); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | −static void percpu_setup_debug_store(int cpu) | |
| 55 | +static void __init percpu_setup_debug_store(int cpu) | |
| 56 | 56 | { |
| 57 | 57 | #ifdef CONFIG_CPU_SUP_INTEL |
| 58 | 58 | int npages; |
| @@ -444,7 +444,6 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, · 443 unmodified lines | ||
| 444 | 444 | int i; |
| 445 | 445 | pud_t *start, *pud_start; |
| 446 | 446 | pgprotval_t prot, eff; |
| 447 | − pud_t *prev_pud = NULL; | |
| 448 | 447 | |
| 449 | 448 | pud_start = start = (pud_t *)p4d_page_vaddr(addr); |
| 450 | 449 | |
| @@ -462,7 +461,6 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr, · 11 unmodified lines | ||
| 462 | 461 | } else |
| 463 | 462 | note_page(m, st, __pgprot(0), 0, 3); |
| 464 | 463 | |
| 465 | − prev_pud = start; | |
| 466 | 464 | start++; |
| 467 | 465 | } |
| 468 | 466 | } |
| @@ -685,9 +685,6 @@ void native_flush_tlb_others(const struct cpumask *cpumask, · 684 unmodified lines | ||
| 685 | 685 | * that UV should be updated so that smp_call_function_many(), |
| 686 | 686 | * etc, are optimal on UV. |
| 687 | 687 | */ |
| 688 | − unsigned int cpu; | |
| 689 | − | |
| 690 | − cpu = smp_processor_id(); | |
| 691 | 688 | cpumask = uv_flush_tlb_others(cpumask, info); |
| 692 | 689 | if (cpumask) |
| 693 | 690 | smp_call_function_many(cpumask, flush_tlb_func_remote, |
| @@ -2010,8 +2010,7 @@ static void make_per_cpu_thp(struct bau_control *smaster) · 2009 unmodified lines | ||
| 2010 | 2010 | int cpu; |
| 2011 | 2011 | size_t hpsz = sizeof(struct hub_and_pnode) * num_possible_cpus(); |
| 2012 | 2012 | |
| 2013 | − smaster->thp = kmalloc_node(hpsz, GFP_KERNEL, smaster->osnode); | |
| 2014 | − memset(smaster->thp, 0, hpsz); | |
| 2013 | + smaster->thp = kzalloc_node(hpsz, GFP_KERNEL, smaster->osnode); | |
| 2015 | 2014 | for_each_present_cpu(cpu) { |
| 2016 | 2015 | smaster->thp[cpu].pnode = uv_cpu_hub_info(cpu)->pnode; |
| 2017 | 2016 | smaster->thp[cpu].uvhub = uv_cpu_hub_info(cpu)->numa_blade_id; |
| @@ -2135,15 +2134,12 @@ static int __init summarize_uvhub_sockets(int nuvhubs, · 117 unmodified lines | ||
| 2135 | 2134 | static int __init init_per_cpu(int nuvhubs, int base_part_pnode) |
| 2136 | 2135 | { |
| 2137 | 2136 | unsigned char *uvhub_mask; |
| 2138 | − void *vp; | |
| 2139 | 2137 | struct uvhub_desc *uvhub_descs; |
| 2140 | 2138 | |
| 2141 | 2139 | if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub()) |
| 2142 | 2140 | timeout_us = calculate_destination_timeout(); |
| 2143 | 2141 | |
| 2144 | − vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL); | |
| 2145 | − uvhub_descs = (struct uvhub_desc *)vp; | |
| 2146 | − memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); | |
| 2142 | + uvhub_descs = kcalloc(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL); | |
| 2147 | 2143 | uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); |
| 2148 | 2144 | |
| 2149 | 2145 | if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) |
| @@ -442,6 +442,11 @@ static inline int enable_kprobe(struct kprobe *kp) · 441 unmodified lines | ||
| 442 | 442 | { |
| 443 | 443 | return -ENOSYS; |
| 444 | 444 | } |
| 445 | + | |
| 446 | +static inline bool within_kprobe_blacklist(unsigned long addr) | |
| 447 | +{ | |
| 448 | + return true; | |
| 449 | +} | |
| 445 | 450 | #endif /* CONFIG_KPROBES */ |
| 446 | 451 | static inline int disable_kretprobe(struct kretprobe *rp) |
| 447 | 452 | { |