1. 07 8月, 2018 1 次提交
    • M
      powerpc/asm: Add a patch_site macro & helpers for patching instructions · 06d0bbc6
      Michael Ellerman 提交于
      Add a macro and some helper C functions for patching single asm
      instructions.
      
      The gas macro means we can do something like:
      
        1:	nop
        	patch_site 1b, patch__foo
      
      Which is less visually distracting than defining a GLOBAL symbol at 1,
      and also doesn't pollute the symbol table which can confuse eg. perf.
      
      These are obviously similar to our existing feature sections, but are
      not automatically patched based on CPU/MMU features, rather they are
      designed to be manually patched by C code at some arbitrary point.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      06d0bbc6
  2. 21 1月, 2018 2 次提交
  3. 11 12月, 2017 1 次提交
  4. 22 11月, 2017 1 次提交
  5. 03 7月, 2017 1 次提交
    • B
      powerpc/lib/code-patching: Use alternate map for patch_instruction() · 37bc3e5f
      Balbir Singh 提交于
      This patch creates the window using text_poke_area, allocated via
      get_vm_area(). text_poke_area is per CPU to avoid locking.
      text_poke_area for each cpu is setup using late_initcall, prior to
      setup of these alternate mapping areas, we continue to use direct
      write to change/modify kernel text. With the ability to use alternate
      mappings to write to kernel text, it provides us the freedom to then
      turn text read-only and implement CONFIG_STRICT_KERNEL_RWX.
      
      This code is CPU hotplug aware to ensure that the we have mappings for
      any new cpus as they come online and tear down mappings for any CPUs
      that go offline.
      Signed-off-by: NBalbir Singh <bsingharora@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      37bc3e5f
  6. 23 4月, 2017 1 次提交
    • N
      powerpc/kprobes: Convert __kprobes to NOKPROBE_SYMBOL() · 71f6e58e
      Naveen N. Rao 提交于
      Along similar lines as commit 9326638c ("kprobes, x86: Use NOKPROBE_SYMBOL()
      instead of __kprobes annotation"), convert __kprobes annotation to either
      NOKPROBE_SYMBOL() or nokprobe_inline. The latter forces inlining, in which case
      the caller needs to be added to NOKPROBE_SYMBOL().
      
      Also:
       - blacklist arch_deref_entry_point(), and
       - convert a few regular inlines to nokprobe_inline in lib/sstep.c
      
      A key benefit is the ability to detect such symbols as being
      blacklisted. Before this patch:
      
        $ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
        $ perf probe read_mem
        Failed to write event: Invalid argument
          Error: Failed to add events.
        $ dmesg | tail -1
        [ 3736.112815] Could not insert probe at _text+10014968: -22
      
      After patch:
        $ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
        0xc000000000072b50-0xc000000000072d20	read_mem
        $ perf probe read_mem
        read_mem is blacklisted function, skip it.
        Added new events:
          (null):(null)        (on read_mem)
          probe:read_mem       (on read_mem)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe:read_mem -aR sleep 1
      
        $ grep " read_mem" /proc/kallsyms
        c000000000072b50 t read_mem
        c0000000005f3b40 t read_mem
        $ cat /sys/kernel/debug/kprobes/list
        c0000000005f3b48  k  read_mem+0x8    [DISABLED]
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      [mpe: Minor change log formatting, fix up some conflicts]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      71f6e58e
  7. 28 2月, 2017 1 次提交
    • L
      kprobes: move kprobe declarations to asm-generic/kprobes.h · 7d134b2c
      Luis R. Rodriguez 提交于
      Often all is needed is these small helpers, instead of compiler.h or a
      full kprobes.h.  This is important for asm helpers, in fact even some
      asm/kprobes.h make use of these helpers...  instead just keep a generic
      asm file with helpers useful for asm code with the least amount of
      clutter as possible.
      
      Likewise we need now to also address what to do about this file for both
      when architectures have CONFIG_HAVE_KPROBES, and when they do not.  Then
      for when architectures have CONFIG_HAVE_KPROBES but have disabled
      CONFIG_KPROBES.
      
      Right now most asm/kprobes.h do not have guards against CONFIG_KPROBES,
      this means most architecture code cannot include asm/kprobes.h safely.
      Correct this and add guards for architectures missing them.
      Additionally provide architectures that not have kprobes support with
      the default asm-generic solution.  This lets us force asm/kprobes.h on
      the header include/linux/kprobes.h always, but most importantly we can
      now safely include just asm/kprobes.h on architecture code without
      bringing the full kitchen sink of header files.
      
      Two architectures already provided a guard against CONFIG_KPROBES on its
      kprobes.h: sh, arch.  The rest of the architectures needed gaurds added.
      We avoid including any not-needed headers on asm/kprobes.h unless
      kprobes have been enabled.
      
      In a subsequent atomic change we can try now to remove compiler.h from
      include/linux/kprobes.h.
      
      During this sweep I've also identified a few architectures defining a
      common macro needed for both kprobes and ftrace, that of the definition
      of the breakput instruction up.  Some refer to this as
      BREAKPOINT_INSTRUCTION.  This must be kept outside of the #ifdef
      CONFIG_KPROBES guard.
      
      [mcgrof@kernel.org: fix arm64 build]
        Link: http://lkml.kernel.org/r/CAB=NE6X1WMByuARS4mZ1g9+W=LuVBnMDnh_5zyN0CLADaVh=Jw@mail.gmail.com
      [sfr@canb.auug.org.au: fixup for kprobes declarations moving]
        Link: http://lkml.kernel.org/r/20170214165933.13ebd4f4@canb.auug.org.au
      Link: http://lkml.kernel.org/r/20170203233139.32682-1-mcgrof@kernel.orgSigned-off-by: NLuis R. Rodriguez <mcgrof@kernel.org>
      Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7d134b2c
  8. 10 2月, 2017 2 次提交
    • A
      powerpc/kprobes: Implement Optprobes · 51c9c084
      Anju T 提交于
      Current infrastructure of kprobe uses the unconditional trap instruction
      to probe a running kernel. Optprobe allows kprobe to replace the trap
      with a branch instruction to a detour buffer. Detour buffer contains
      instructions to create an in memory pt_regs. Detour buffer also has a
      call to optimized_callback() which in turn call the pre_handler(). After
      the execution of the pre-handler, a call is made for instruction
      emulation. The NIP is determined in advanced through dummy instruction
      emulation and a branch instruction is created to the NIP at the end of
      the trampoline.
      
      To address the limitation of branch instruction in POWER architecture,
      detour buffer slot is allocated from a reserved area. For the time
      being, 64KB is reserved in memory for this purpose.
      
      Instructions which can be emulated using analyse_instr() are the
      candidates for optimization. Before optimization ensure that the address
      range between the detour buffer allocated and the instruction being
      probed is within +/- 32MB.
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      51c9c084
    • A
      powerpc: Add helper to check if offset is within relative branch range · ebfa50df
      Anju T 提交于
      To permit the use of relative branch instruction in powerpc, the target
      address has to be relatively nearby, since the address is specified in an
      immediate field (24 bit filed) in the instruction opcode itself. Here
      nearby refers to 32MB on either side of the current instruction.
      
      This patch verifies whether the target address is within +/- 32MB
      range or not.
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ebfa50df
  9. 25 12月, 2016 1 次提交
  10. 02 12月, 2013 1 次提交
  11. 05 9月, 2012 1 次提交
  12. 03 7月, 2012 1 次提交
  13. 25 7月, 2008 1 次提交
    • A
      PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures · 27ac792c
      Andrea Righi 提交于
      On 32-bit architectures PAGE_ALIGN() truncates 64-bit values to the 32-bit
      boundary. For example:
      
      	u64 val = PAGE_ALIGN(size);
      
      always returns a value < 4GB even if size is greater than 4GB.
      
      The problem resides in PAGE_MASK definition (from include/asm-x86/page.h for
      example):
      
      #define PAGE_SHIFT      12
      #define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
      #define PAGE_MASK       (~(PAGE_SIZE-1))
      ...
      #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
      
      The "~" is performed on a 32-bit value, so everything in "and" with
      PAGE_MASK greater than 4GB will be truncated to the 32-bit boundary.
      Using the ALIGN() macro seems to be the right way, because it uses
      typeof(addr) for the mask.
      
      Also move the PAGE_ALIGN() definitions out of include/asm-*/page.h in
      include/linux/mm.h.
      
      See also lkml discussion: http://lkml.org/lkml/2008/6/11/237
      
      [akpm@linux-foundation.org: fix drivers/media/video/uvc/uvc_queue.c]
      [akpm@linux-foundation.org: fix v850]
      [akpm@linux-foundation.org: fix powerpc]
      [akpm@linux-foundation.org: fix arm]
      [akpm@linux-foundation.org: fix mips]
      [akpm@linux-foundation.org: fix drivers/media/video/pvrusb2/pvrusb2-dvb.c]
      [akpm@linux-foundation.org: fix drivers/mtd/maps/uclinux.c]
      [akpm@linux-foundation.org: fix powerpc]
      Signed-off-by: NAndrea Righi <righi.andrea@gmail.com>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      27ac792c
  14. 01 7月, 2008 5 次提交