Merge branch 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 asmlinkage (LTO) changes from Peter Anvin:
"This patchset adds more infrastructure for link time optimization
(LTO).

This patchset was pulled into my tree late because of a
miscommunication (part of the patchset was picked up by other
maintainers). However, the patchset is strictly build-related and
seems to be okay in testing"

* 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86, asmlinkage, xen: Fix type of NMI
x86, asmlinkage, xen, kvm: Make {xen,kvm}_lock_spinning global and visible
x86: Use inline assembler instead of global register variable to get sp
x86, asmlinkage, paravirt: Make paravirt thunks global
x86, asmlinkage, paravirt: Don't rely on local assembler labels
x86, asmlinkage, lguest: Fix C functions used by inline assembler

+37 -34
+1 -1
arch/x86/include/asm/paravirt.h
··· 781 */ 782 #define PV_CALLEE_SAVE_REGS_THUNK(func) \ 783 extern typeof(func) __raw_callee_save_##func; \ 784 - static void *__##func##__ __used = func; \ 785 \ 786 asm(".pushsection .text;" \ 787 "__raw_callee_save_" #func ": " \ 788 PV_SAVE_ALL_CALLER_REGS \ 789 "call " #func ";" \
··· 781 */ 782 #define PV_CALLEE_SAVE_REGS_THUNK(func) \ 783 extern typeof(func) __raw_callee_save_##func; \ 784 \ 785 asm(".pushsection .text;" \ 786 + ".globl __raw_callee_save_" #func " ; " \ 787 "__raw_callee_save_" #func ": " \ 788 PV_SAVE_ALL_CALLER_REGS \ 789 "call " #func ";" \
+5 -4
arch/x86/include/asm/paravirt_types.h
··· 388 _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") 389 390 /* Simple instruction patching code. */ 391 - #define DEF_NATIVE(ops, name, code) \ 392 - extern const char start_##ops##_##name[] __visible, \ 393 - end_##ops##_##name[] __visible; \ 394 - asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":") 395 396 unsigned paravirt_patch_nop(void); 397 unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len);
··· 388 _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") 389 390 /* Simple instruction patching code. */ 391 + #define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t" 392 + 393 + #define DEF_NATIVE(ops, name, code) \ 394 + __visible extern const char start_##ops##_##name[], end_##ops##_##name[]; \ 395 + asm(NATIVE_LABEL("start_", ops, name) code NATIVE_LABEL("end_", ops, name)) 396 397 unsigned paravirt_patch_nop(void); 398 unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len);
+5 -3
arch/x86/include/asm/thread_info.h
··· 163 */ 164 #ifndef __ASSEMBLY__ 165 166 - 167 - /* how to get the current stack pointer from C */ 168 - register unsigned long current_stack_pointer asm("esp") __used; 169 170 /* how to get the thread information struct from C */ 171 static inline struct thread_info *current_thread_info(void)
··· 163 */ 164 #ifndef __ASSEMBLY__ 165 166 + #define current_stack_pointer ({ \ 167 + unsigned long sp; \ 168 + asm("mov %%esp,%0" : "=g" (sp)); \ 169 + sp; \ 170 + }) 171 172 /* how to get the thread information struct from C */ 173 static inline struct thread_info *current_thread_info(void)
+1 -1
arch/x86/kernel/kvm.c
··· 673 /* Track spinlock on which a cpu is waiting */ 674 static DEFINE_PER_CPU(struct kvm_lock_waiting, klock_waiting); 675 676 - static void kvm_lock_spinning(struct arch_spinlock *lock, __ticket_t want) 677 { 678 struct kvm_lock_waiting *w; 679 int cpu;
··· 673 /* Track spinlock on which a cpu is waiting */ 674 static DEFINE_PER_CPU(struct kvm_lock_waiting, klock_waiting); 675 676 + __visible void kvm_lock_spinning(struct arch_spinlock *lock, __ticket_t want) 677 { 678 struct kvm_lock_waiting *w; 679 int cpu;
+4 -4
arch/x86/kernel/vsmp_64.c
··· 33 * and vice versa. 34 */ 35 36 - static unsigned long vsmp_save_fl(void) 37 { 38 unsigned long flags = native_save_fl(); 39 ··· 43 } 44 PV_CALLEE_SAVE_REGS_THUNK(vsmp_save_fl); 45 46 - static void vsmp_restore_fl(unsigned long flags) 47 { 48 if (flags & X86_EFLAGS_IF) 49 flags &= ~X86_EFLAGS_AC; ··· 53 } 54 PV_CALLEE_SAVE_REGS_THUNK(vsmp_restore_fl); 55 56 - static void vsmp_irq_disable(void) 57 { 58 unsigned long flags = native_save_fl(); 59 ··· 61 } 62 PV_CALLEE_SAVE_REGS_THUNK(vsmp_irq_disable); 63 64 - static void vsmp_irq_enable(void) 65 { 66 unsigned long flags = native_save_fl(); 67
··· 33 * and vice versa. 34 */ 35 36 + asmlinkage unsigned long vsmp_save_fl(void) 37 { 38 unsigned long flags = native_save_fl(); 39 ··· 43 } 44 PV_CALLEE_SAVE_REGS_THUNK(vsmp_save_fl); 45 46 + __visible void vsmp_restore_fl(unsigned long flags) 47 { 48 if (flags & X86_EFLAGS_IF) 49 flags &= ~X86_EFLAGS_AC; ··· 53 } 54 PV_CALLEE_SAVE_REGS_THUNK(vsmp_restore_fl); 55 56 + asmlinkage void vsmp_irq_disable(void) 57 { 58 unsigned long flags = native_save_fl(); 59 ··· 61 } 62 PV_CALLEE_SAVE_REGS_THUNK(vsmp_irq_disable); 63 64 + asmlinkage void vsmp_irq_enable(void) 65 { 66 unsigned long flags = native_save_fl(); 67
+6 -6
arch/x86/lguest/boot.c
··· 233 * flags word contains all kind of stuff, but in practice Linux only cares 234 * about the interrupt flag. Our "save_flags()" just returns that. 235 */ 236 - static unsigned long save_fl(void) 237 { 238 return lguest_data.irq_enabled; 239 } 240 241 /* Interrupts go off... */ 242 - static void irq_disable(void) 243 { 244 lguest_data.irq_enabled = 0; 245 } ··· 253 * PV_CALLEE_SAVE_REGS_THUNK(), which pushes %eax onto the stack, calls the 254 * C function, then restores it. 255 */ 256 - PV_CALLEE_SAVE_REGS_THUNK(save_fl); 257 - PV_CALLEE_SAVE_REGS_THUNK(irq_disable); 258 /*:*/ 259 260 /* These are in i386_head.S */ ··· 1291 */ 1292 1293 /* Interrupt-related operations */ 1294 - pv_irq_ops.save_fl = PV_CALLEE_SAVE(save_fl); 1295 pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(lg_restore_fl); 1296 - pv_irq_ops.irq_disable = PV_CALLEE_SAVE(irq_disable); 1297 pv_irq_ops.irq_enable = __PV_IS_CALLEE_SAVE(lg_irq_enable); 1298 pv_irq_ops.safe_halt = lguest_safe_halt; 1299
··· 233 * flags word contains all kind of stuff, but in practice Linux only cares 234 * about the interrupt flag. Our "save_flags()" just returns that. 235 */ 236 + asmlinkage unsigned long lguest_save_fl(void) 237 { 238 return lguest_data.irq_enabled; 239 } 240 241 /* Interrupts go off... */ 242 + asmlinkage void lguest_irq_disable(void) 243 { 244 lguest_data.irq_enabled = 0; 245 } ··· 253 * PV_CALLEE_SAVE_REGS_THUNK(), which pushes %eax onto the stack, calls the 254 * C function, then restores it. 255 */ 256 + PV_CALLEE_SAVE_REGS_THUNK(lguest_save_fl); 257 + PV_CALLEE_SAVE_REGS_THUNK(lguest_irq_disable); 258 /*:*/ 259 260 /* These are in i386_head.S */ ··· 1291 */ 1292 1293 /* Interrupt-related operations */ 1294 + pv_irq_ops.save_fl = PV_CALLEE_SAVE(lguest_save_fl); 1295 pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(lg_restore_fl); 1296 + pv_irq_ops.irq_disable = PV_CALLEE_SAVE(lguest_irq_disable); 1297 pv_irq_ops.irq_enable = __PV_IS_CALLEE_SAVE(lg_irq_enable); 1298 pv_irq_ops.safe_halt = lguest_safe_halt; 1299
+4 -4
arch/x86/xen/irq.c
··· 23 (void)HYPERVISOR_xen_version(0, NULL); 24 } 25 26 - static unsigned long xen_save_fl(void) 27 { 28 struct vcpu_info *vcpu; 29 unsigned long flags; ··· 41 } 42 PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl); 43 44 - static void xen_restore_fl(unsigned long flags) 45 { 46 struct vcpu_info *vcpu; 47 ··· 63 } 64 PV_CALLEE_SAVE_REGS_THUNK(xen_restore_fl); 65 66 - static void xen_irq_disable(void) 67 { 68 /* There's a one instruction preempt window here. We need to 69 make sure we're don't switch CPUs between getting the vcpu ··· 74 } 75 PV_CALLEE_SAVE_REGS_THUNK(xen_irq_disable); 76 77 - static void xen_irq_enable(void) 78 { 79 struct vcpu_info *vcpu; 80
··· 23 (void)HYPERVISOR_xen_version(0, NULL); 24 } 25 26 + asmlinkage unsigned long xen_save_fl(void) 27 { 28 struct vcpu_info *vcpu; 29 unsigned long flags; ··· 41 } 42 PV_CALLEE_SAVE_REGS_THUNK(xen_save_fl); 43 44 + __visible void xen_restore_fl(unsigned long flags) 45 { 46 struct vcpu_info *vcpu; 47 ··· 63 } 64 PV_CALLEE_SAVE_REGS_THUNK(xen_restore_fl); 65 66 + asmlinkage void xen_irq_disable(void) 67 { 68 /* There's a one instruction preempt window here. We need to 69 make sure we're don't switch CPUs between getting the vcpu ··· 74 } 75 PV_CALLEE_SAVE_REGS_THUNK(xen_irq_disable); 76 77 + asmlinkage void xen_irq_enable(void) 78 { 79 struct vcpu_info *vcpu; 80
+8 -8
arch/x86/xen/mmu.c
··· 431 return val; 432 } 433 434 - static pteval_t xen_pte_val(pte_t pte) 435 { 436 pteval_t pteval = pte.pte; 437 #if 0 ··· 448 } 449 PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); 450 451 - static pgdval_t xen_pgd_val(pgd_t pgd) 452 { 453 return pte_mfn_to_pfn(pgd.pgd); 454 } ··· 479 WARN_ON(pat != 0x0007010600070106ull); 480 } 481 482 - static pte_t xen_make_pte(pteval_t pte) 483 { 484 phys_addr_t addr = (pte & PTE_PFN_MASK); 485 #if 0 ··· 514 } 515 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte); 516 517 - static pgd_t xen_make_pgd(pgdval_t pgd) 518 { 519 pgd = pte_pfn_to_mfn(pgd); 520 return native_make_pgd(pgd); 521 } 522 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pgd); 523 524 - static pmdval_t xen_pmd_val(pmd_t pmd) 525 { 526 return pte_mfn_to_pfn(pmd.pmd); 527 } ··· 580 } 581 #endif /* CONFIG_X86_PAE */ 582 583 - static pmd_t xen_make_pmd(pmdval_t pmd) 584 { 585 pmd = pte_pfn_to_mfn(pmd); 586 return native_make_pmd(pmd); ··· 588 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pmd); 589 590 #if PAGETABLE_LEVELS == 4 591 - static pudval_t xen_pud_val(pud_t pud) 592 { 593 return pte_mfn_to_pfn(pud.pud); 594 } 595 PV_CALLEE_SAVE_REGS_THUNK(xen_pud_val); 596 597 - static pud_t xen_make_pud(pudval_t pud) 598 { 599 pud = pte_pfn_to_mfn(pud); 600
··· 431 return val; 432 } 433 434 + __visible pteval_t xen_pte_val(pte_t pte) 435 { 436 pteval_t pteval = pte.pte; 437 #if 0 ··· 448 } 449 PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); 450 451 + __visible pgdval_t xen_pgd_val(pgd_t pgd) 452 { 453 return pte_mfn_to_pfn(pgd.pgd); 454 } ··· 479 WARN_ON(pat != 0x0007010600070106ull); 480 } 481 482 + __visible pte_t xen_make_pte(pteval_t pte) 483 { 484 phys_addr_t addr = (pte & PTE_PFN_MASK); 485 #if 0 ··· 514 } 515 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte); 516 517 + __visible pgd_t xen_make_pgd(pgdval_t pgd) 518 { 519 pgd = pte_pfn_to_mfn(pgd); 520 return native_make_pgd(pgd); 521 } 522 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pgd); 523 524 + __visible pmdval_t xen_pmd_val(pmd_t pmd) 525 { 526 return pte_mfn_to_pfn(pmd.pmd); 527 } ··· 580 } 581 #endif /* CONFIG_X86_PAE */ 582 583 + __visible pmd_t xen_make_pmd(pmdval_t pmd) 584 { 585 pmd = pte_pfn_to_mfn(pmd); 586 return native_make_pmd(pmd); ··· 588 PV_CALLEE_SAVE_REGS_THUNK(xen_make_pmd); 589 590 #if PAGETABLE_LEVELS == 4 591 + __visible pudval_t xen_pud_val(pud_t pud) 592 { 593 return pte_mfn_to_pfn(pud.pud); 594 } 595 PV_CALLEE_SAVE_REGS_THUNK(xen_pud_val); 596 597 + __visible pud_t xen_make_pud(pudval_t pud) 598 { 599 pud = pte_pfn_to_mfn(pud); 600
+2 -2
arch/x86/xen/setup.c
··· 35 extern const char xen_hypervisor_callback[]; 36 extern const char xen_failsafe_callback[]; 37 #ifdef CONFIG_X86_64 38 - extern const char nmi[]; 39 #endif 40 extern void xen_sysenter_target(void); 41 extern void xen_syscall_target(void); ··· 577 void xen_enable_nmi(void) 578 { 579 #ifdef CONFIG_X86_64 580 - if (register_callback(CALLBACKTYPE_nmi, nmi)) 581 BUG(); 582 #endif 583 }
··· 35 extern const char xen_hypervisor_callback[]; 36 extern const char xen_failsafe_callback[]; 37 #ifdef CONFIG_X86_64 38 + extern asmlinkage void nmi(void); 39 #endif 40 extern void xen_sysenter_target(void); 41 extern void xen_syscall_target(void); ··· 577 void xen_enable_nmi(void) 578 { 579 #ifdef CONFIG_X86_64 580 + if (register_callback(CALLBACKTYPE_nmi, (char *)nmi)) 581 BUG(); 582 #endif 583 }
+1 -1
arch/x86/xen/spinlock.c
··· 106 static cpumask_t waiting_cpus; 107 108 static bool xen_pvspin = true; 109 - static void xen_lock_spinning(struct arch_spinlock *lock, __ticket_t want) 110 { 111 int irq = __this_cpu_read(lock_kicker_irq); 112 struct xen_lock_waiting *w = &__get_cpu_var(lock_waiting);
··· 106 static cpumask_t waiting_cpus; 107 108 static bool xen_pvspin = true; 109 + __visible void xen_lock_spinning(struct arch_spinlock *lock, __ticket_t want) 110 { 111 int irq = __this_cpu_read(lock_kicker_irq); 112 struct xen_lock_waiting *w = &__get_cpu_var(lock_waiting);