]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 4 Sep 2013 15:42:44 +0000 (08:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 4 Sep 2013 15:42:44 +0000 (08:42 -0700)
Pull x86/asmlinkage changes from Ingo Molnar:
 "As a preparation for Andi Kleen's LTO patchset (link time
  optimizations using GCC's -flto which build time optimization has
  steadily increased in quality over the past few years and might
  eventually be usable for the kernel too) this tree includes a handful
  of preparatory patches that make function calling convention
  annotations consistent again:

   - Mark every function without arguments (or 64bit only) that is used
     by assembly code with asmlinkage()

   - Mark every function with parameters or variables that is used by
     assembly code as __visible.

  For the vanilla kernel this has documentation, consistency and
  debuggability advantages, for the time being"

* 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/asmlinkage: Fix warning in xen asmlinkage change
  x86, asmlinkage, vdso: Mark vdso variables __visible
  x86, asmlinkage, power: Make various symbols used by the suspend asm code visible
  x86, asmlinkage: Make dump_stack visible
  x86, asmlinkage: Make 64bit checksum functions visible
  x86, asmlinkage, paravirt: Add __visible/asmlinkage to xen paravirt ops
  x86, asmlinkage, apm: Make APM data structure used from assembler visible
  x86, asmlinkage: Make syscall tables visible
  x86, asmlinkage: Make several variables used from assembler/linker script visible
  x86, asmlinkage: Make kprobes code visible and fix assembler code
  x86, asmlinkage: Make various syscalls asmlinkage
  x86, asmlinkage: Make 32bit/64bit __switch_to visible
  x86, asmlinkage: Make _*_start_kernel visible
  x86, asmlinkage: Make all interrupt handlers asmlinkage / __visible
  x86, asmlinkage: Change dotraplinkage into __visible on 32bit
  x86: Fix sys_call_table type in asm/syscall.h

1  2 
arch/x86/include/asm/pgtable.h
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/kprobes/core.c
arch/x86/kernel/kprobes/opt.c

index 1c00631164c29c1d2d676f8c384141931483363b,4e4765908af5847f63bfd872950c722e0f06993c..8d16befdec88c671dcf29776a835435f9a946c2d
@@@ -22,7 -22,8 +22,8 @@@
   * ZERO_PAGE is a global shared page that is always zero: used
   * for zero-mapped memory areas etc..
   */
- extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
+ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
+       __visible;
  #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  
  extern spinlock_t pgd_lock;
@@@ -314,36 -315,6 +315,36 @@@ static inline pmd_t pmd_mksoft_dirty(pm
        return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
  }
  
 +static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
 +{
 +      return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
 +}
 +
 +static inline int pte_swp_soft_dirty(pte_t pte)
 +{
 +      return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
 +}
 +
 +static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
 +{
 +      return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
 +}
 +
 +static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
 +{
 +      return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
 +}
 +
 +static inline pte_t pte_file_mksoft_dirty(pte_t pte)
 +{
 +      return pte_set_flags(pte, _PAGE_SOFT_DIRTY);
 +}
 +
 +static inline int pte_file_soft_dirty(pte_t pte)
 +{
 +      return pte_flags(pte) & _PAGE_SOFT_DIRTY;
 +}
 +
  /*
   * Mask out unsupported bits in a present pgprot.  Non-present pgprots
   * can use those bits for other purposes, so leave them be.
index 4f4a3d98c170477caff77d71693f203ae9a6fb34,573c1ad4994eda4495cd59eff6bc59c67b238abd..4c2d31d941ea086aac9085500c28759af297828a
@@@ -412,7 -412,7 +412,7 @@@ union irq_stack_union 
        };
  };
  
- DECLARE_PER_CPU_FIRST(union irq_stack_union, irq_stack_union);
+ DECLARE_PER_CPU_FIRST(union irq_stack_union, irq_stack_union) __visible;
  DECLARE_INIT_PER_CPU(irq_stack_union);
  
  DECLARE_PER_CPU(char *, irq_stack_ptr);
@@@ -942,6 -942,35 +942,6 @@@ extern int set_tsc_mode(unsigned int va
  
  extern u16 amd_get_nb_id(int cpu);
  
 -struct aperfmperf {
 -      u64 aperf, mperf;
 -};
 -
 -static inline void get_aperfmperf(struct aperfmperf *am)
 -{
 -      WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_APERFMPERF));
 -
 -      rdmsrl(MSR_IA32_APERF, am->aperf);
 -      rdmsrl(MSR_IA32_MPERF, am->mperf);
 -}
 -
 -#define APERFMPERF_SHIFT 10
 -
 -static inline
 -unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
 -                                  struct aperfmperf *new)
 -{
 -      u64 aperf = new->aperf - old->aperf;
 -      u64 mperf = new->mperf - old->mperf;
 -      unsigned long ratio = aperf;
 -
 -      mperf >>= APERFMPERF_SHIFT;
 -      if (mperf)
 -              ratio = div64_u64(aperf, mperf);
 -
 -      return ratio;
 -}
 -
  extern unsigned long arch_align_stack(unsigned long sp);
  extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
  
index 08a089043ccfbb669c889ac034091a55aaa92b75,466e3d15de124789943a59974b8110195209daf4..903a264af981c5bf5991e03e0a428e9b7dd8773e
@@@ -66,8 -66,8 +66,8 @@@ static inline int wrmsrl_amd_safe(unsig
   *    performance at the same time..
   */
  
- extern void vide(void);
- __asm__(".align 4\nvide: ret");
+ extern __visible void vide(void);
+ __asm__(".globl vide\n\t.align 4\nvide: ret");
  
  static void init_amd_k5(struct cpuinfo_x86 *c)
  {
@@@ -512,7 -512,7 +512,7 @@@ static void early_init_amd(struct cpuin
  
  static const int amd_erratum_383[];
  static const int amd_erratum_400[];
 -static bool cpu_has_amd_erratum(const int *erratum);
 +static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
  
  static void init_amd(struct cpuinfo_x86 *c)
  {
                value &= ~(1ULL << 24);
                wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
  
 -              if (cpu_has_amd_erratum(amd_erratum_383))
 +              if (cpu_has_amd_erratum(c, amd_erratum_383))
                        set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
        }
  
 -      if (cpu_has_amd_erratum(amd_erratum_400))
 +      if (cpu_has_amd_erratum(c, amd_erratum_400))
                set_cpu_bug(c, X86_BUG_AMD_APIC_C1E);
  
        rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy);
@@@ -878,13 -878,23 +878,13 @@@ static const int amd_erratum_400[] 
  static const int amd_erratum_383[] =
        AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
  
 -static bool cpu_has_amd_erratum(const int *erratum)
 +
 +static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
  {
 -      struct cpuinfo_x86 *cpu = __this_cpu_ptr(&cpu_info);
        int osvw_id = *erratum++;
        u32 range;
        u32 ms;
  
 -      /*
 -       * If called early enough that current_cpu_data hasn't been initialized
 -       * yet, fall back to boot_cpu_data.
 -       */
 -      if (cpu->x86 == 0)
 -              cpu = &boot_cpu_data;
 -
 -      if (cpu->x86_vendor != X86_VENDOR_AMD)
 -              return false;
 -
        if (osvw_id >= 0 && osvw_id < 65536 &&
            cpu_has(cpu, X86_FEATURE_OSVW)) {
                u64 osvw_len;
index cd49b2c96d32f9ede4bc47fa2c67f04803a78db7,048852d064479748d05fa63294d3dda397049d82..79a3f9682871ae81d02e08cbd169d5ba96e175aa
@@@ -661,7 -661,7 +661,7 @@@ static void __used __kprobes kretprobe_
  /*
   * Called from kretprobe_trampoline
   */
static __used __kprobes void *trampoline_handler(struct pt_regs *regs)
__visible __used __kprobes void *trampoline_handler(struct pt_regs *regs)
  {
        struct kretprobe_instance *ri = NULL;
        struct hlist_head *head, empty_rp;
@@@ -1068,7 -1068,7 +1068,7 @@@ int __kprobes longjmp_break_handler(str
  
  int __init arch_init_kprobes(void)
  {
 -      return arch_init_optprobes();
 +      return 0;
  }
  
  int __kprobes arch_trampoline_kprobe(struct kprobe *p)
index d71e994393760bca98efb30663f6bb5082b213c8,2c1ac2893365dda8c55a61e5fc1b277680d10a94..898160b42e4392daddd224c55ab62fb467752dd7
@@@ -88,9 -88,7 +88,7 @@@ static void __kprobes synthesize_set_ar
        *(unsigned long *)addr = val;
  }
  
- static void __used __kprobes kprobes_optinsn_template_holder(void)
- {
-       asm volatile (
+ asm (
                        ".global optprobe_template_entry\n"
                        "optprobe_template_entry:\n"
  #ifdef CONFIG_X86_64
  #endif
                        ".global optprobe_template_end\n"
                        "optprobe_template_end:\n");
- }
  
  #define TMPL_MOVE_IDX \
        ((long)&optprobe_template_val - (long)&optprobe_template_entry)
@@@ -371,6 -368,31 +368,6 @@@ int __kprobes arch_prepare_optimized_kp
        return 0;
  }
  
 -#define MAX_OPTIMIZE_PROBES 256
 -static struct text_poke_param *jump_poke_params;
 -static struct jump_poke_buffer {
 -      u8 buf[RELATIVEJUMP_SIZE];
 -} *jump_poke_bufs;
 -
 -static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
 -                                          u8 *insn_buf,
 -                                          struct optimized_kprobe *op)
 -{
 -      s32 rel = (s32)((long)op->optinsn.insn -
 -                      ((long)op->kp.addr + RELATIVEJUMP_SIZE));
 -
 -      /* Backup instructions which will be replaced by jump address */
 -      memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
 -             RELATIVE_ADDR_SIZE);
 -
 -      insn_buf[0] = RELATIVEJUMP_OPCODE;
 -      *(s32 *)(&insn_buf[1]) = rel;
 -
 -      tprm->addr = op->kp.addr;
 -      tprm->opcode = insn_buf;
 -      tprm->len = RELATIVEJUMP_SIZE;
 -}
 -
  /*
   * Replace breakpoints (int3) with relative jumps.
   * Caller must call with locking kprobe_mutex and text_mutex.
  void __kprobes arch_optimize_kprobes(struct list_head *oplist)
  {
        struct optimized_kprobe *op, *tmp;
 -      int c = 0;
 +      u8 insn_buf[RELATIVEJUMP_SIZE];
  
        list_for_each_entry_safe(op, tmp, oplist, list) {
 +              s32 rel = (s32)((long)op->optinsn.insn -
 +                      ((long)op->kp.addr + RELATIVEJUMP_SIZE));
 +
                WARN_ON(kprobe_disabled(&op->kp));
 -              /* Setup param */
 -              setup_optimize_kprobe(&jump_poke_params[c],
 -                                    jump_poke_bufs[c].buf, op);
 +
 +              /* Backup instructions which will be replaced by jump address */
 +              memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
 +                     RELATIVE_ADDR_SIZE);
 +
 +              insn_buf[0] = RELATIVEJUMP_OPCODE;
 +              *(s32 *)(&insn_buf[1]) = rel;
 +
 +              text_poke_bp(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE,
 +                           op->optinsn.insn);
 +
                list_del_init(&op->list);
 -              if (++c >= MAX_OPTIMIZE_PROBES)
 -                      break;
        }
 -
 -      /*
 -       * text_poke_smp doesn't support NMI/MCE code modifying.
 -       * However, since kprobes itself also doesn't support NMI/MCE
 -       * code probing, it's not a problem.
 -       */
 -      text_poke_smp_batch(jump_poke_params, c);
  }
  
 -static void __kprobes setup_unoptimize_kprobe(struct text_poke_param *tprm,
 -                                            u8 *insn_buf,
 -                                            struct optimized_kprobe *op)
 +/* Replace a relative jump with a breakpoint (int3).  */
 +void __kprobes arch_unoptimize_kprobe(struct optimized_kprobe *op)
  {
 +      u8 insn_buf[RELATIVEJUMP_SIZE];
 +
        /* Set int3 to first byte for kprobes */
        insn_buf[0] = BREAKPOINT_INSTRUCTION;
        memcpy(insn_buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
 -
 -      tprm->addr = op->kp.addr;
 -      tprm->opcode = insn_buf;
 -      tprm->len = RELATIVEJUMP_SIZE;
 +      text_poke_bp(op->kp.addr, insn_buf, RELATIVEJUMP_SIZE,
 +                   op->optinsn.insn);
  }
  
  /*
@@@ -420,11 -441,34 +417,11 @@@ extern void arch_unoptimize_kprobes(str
                                    struct list_head *done_list)
  {
        struct optimized_kprobe *op, *tmp;
 -      int c = 0;
  
        list_for_each_entry_safe(op, tmp, oplist, list) {
 -              /* Setup param */
 -              setup_unoptimize_kprobe(&jump_poke_params[c],
 -                                      jump_poke_bufs[c].buf, op);
 +              arch_unoptimize_kprobe(op);
                list_move(&op->list, done_list);
 -              if (++c >= MAX_OPTIMIZE_PROBES)
 -                      break;
        }
 -
 -      /*
 -       * text_poke_smp doesn't support NMI/MCE code modifying.
 -       * However, since kprobes itself also doesn't support NMI/MCE
 -       * code probing, it's not a problem.
 -       */
 -      text_poke_smp_batch(jump_poke_params, c);
 -}
 -
 -/* Replace a relative jump with a breakpoint (int3).  */
 -void __kprobes arch_unoptimize_kprobe(struct optimized_kprobe *op)
 -{
 -      u8 buf[RELATIVEJUMP_SIZE];
 -
 -      /* Set int3 to first byte for kprobes */
 -      buf[0] = BREAKPOINT_INSTRUCTION;
 -      memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
 -      text_poke_smp(op->kp.addr, buf, RELATIVEJUMP_SIZE);
  }
  
  int  __kprobes
@@@ -444,3 -488,22 +441,3 @@@ setup_detour_execution(struct kprobe *p
        }
        return 0;
  }
 -
 -int __kprobes arch_init_optprobes(void)
 -{
 -      /* Allocate code buffer and parameter array */
 -      jump_poke_bufs = kmalloc(sizeof(struct jump_poke_buffer) *
 -                               MAX_OPTIMIZE_PROBES, GFP_KERNEL);
 -      if (!jump_poke_bufs)
 -              return -ENOMEM;
 -
 -      jump_poke_params = kmalloc(sizeof(struct text_poke_param) *
 -                                 MAX_OPTIMIZE_PROBES, GFP_KERNEL);
 -      if (!jump_poke_params) {
 -              kfree(jump_poke_bufs);
 -              jump_poke_bufs = NULL;
 -              return -ENOMEM;
 -      }
 -
 -      return 0;
 -}