1. 24 4月, 2014 1 次提交
  2. 07 1月, 2014 1 次提交
  3. 10 7月, 2013 1 次提交
    • O
      ptrace/x86: flush_ptrace_hw_breakpoint() shoule clear the virtual debug registers · f7da04c9
      Oleg Nesterov 提交于
      flush_ptrace_hw_breakpoint() destroys the counters set by ptrace, but
      "leaks" ->debugreg6 and ->ptrace_dr7.
      
      The problem is minor, but still it doesn't look right and flush_thread()
      did this until commit 66cb5917 ("hw-breakpoints: use the new wrapper
      routines to access debug registers in process/thread code").  Now that
      PTRACE_DETACH does flush_ too this makes even more sense.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
      Cc: Michael Neuling <mikey@neuling.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f7da04c9
  4. 30 12月, 2010 1 次提交
  5. 12 11月, 2010 1 次提交
    • F
      x86: Ignore trap bits on single step exceptions · 6c0aca28
      Frederic Weisbecker 提交于
      When a single step exception fires, the trap bits, used to
      signal hardware breakpoints, are in a random state.
      
      These trap bits might be set if another exception will follow,
      like a breakpoint in the next instruction, or a watchpoint in the
      previous one. Or there can be any junk there.
      
      So if we handle these trap bits during the single step exception,
      we are going to handle an exception twice, or we are going to
      handle junk.
      
      Just ignore them in this case.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=21332Reported-by: NMichael Stefaniuc <mstefani@redhat.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Rafael J. Wysocki <rjw@sisk.pl>
      Cc: Maciej Rutecki <maciej.rutecki@gmail.com>
      Cc: Alexandre Julliard <julliard@winehq.org>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: All since 2.6.33.x <stable@kernel.org>
      6c0aca28
  6. 17 9月, 2010 1 次提交
    • F
      x86: Fix instruction breakpoint encoding · 89e45aac
      Frederic Weisbecker 提交于
      Lengths and types of breakpoints are encoded in a half byte
      into CPU registers. However when we extract these values
      and store them, we add a high half byte part to them: 0x40 to the
      length and 0x80 to the type.
      When that gets reloaded to the CPU registers, the high part
      is masked.
      
      While making the instruction breakpoints available for perf,
      I zapped that high part on instruction breakpoint encoding
      and that broke the arch -> generic translation used by ptrace
      instruction breakpoints. Writing dr7 to set an inst breakpoint
      was then failing.
      
      There is no apparent reason for these high parts so we could get
      rid of them altogether. That's an invasive change though so let's
      do that later and for now fix the problem by restoring that inst
      breakpoint high part encoding in this sole patch.
      Reported-by: NKelvie Wong <kelvie@ieee.org>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      89e45aac
  7. 25 6月, 2010 2 次提交
    • F
      x86: Support for instruction breakpoints · f7809daf
      Frederic Weisbecker 提交于
      Instruction breakpoints need to have a specific length of 0 to
      be working. Bring this support but also take care the user is not
      trying to set an unsupported length, like a range breakpoint for
      example.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      f7809daf
    • F
      x86: Set resume bit before returning from breakpoint exception · 0c4519e8
      Frederic Weisbecker 提交于
      Instruction breakpoints trigger before the instruction executes,
      and returning back from the breakpoint handler brings us again
      to the instruction that breakpointed. This naturally bring to
      a breakpoint recursion.
      
      To solve this, x86 has the Resume Bit trick. When the cpu flags
      have the RF flag set, the next instruction won't trigger any
      instruction breakpoint, and once this instruction is executed,
      RF is cleared back.
      
      This let's us jump back to the instruction that triggered the
      breakpoint without recursion.
      
      Use this when an instruction breakpoint triggers.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      0c4519e8
  8. 01 5月, 2010 1 次提交
    • F
      hw-breakpoints: Change/Enforce some breakpoints policies · b2812d03
      Frederic Weisbecker 提交于
      The current policies of breakpoints in x86 and SH are the following:
      
      - task bound breakpoints can only break on userspace addresses
      - cpu wide breakpoints can only break on kernel addresses
      
      The former rule prevents ptrace breakpoints to be set to trigger on
      kernel addresses, which is good. But as a side effect, we can't
      breakpoint on kernel addresses for task bound breakpoints.
      
      The latter rule simply makes no sense, there is no reason why we
      can't set breakpoints on userspace while performing cpu bound
      profiles.
      
      We want the following new policies:
      
      - task bound breakpoint can set userspace address breakpoints, with
      no particular privilege required.
      - task bound breakpoints can set kernelspace address breakpoints but
      must be privileged to do that.
      - cpu bound breakpoints can do what they want as they are privileged
      already.
      
      To implement these new policies, this patch checks if we are dealing
      with a kernel address breakpoint, if so and if the exclude_kernel
      parameter is set, we tell the user that the breakpoint is invalid,
      which makes a good generic ptrace protection.
      If we don't have exclude_kernel, ensure the user has the right
      privileges as kernel breakpoints are quite sensitive (risk of
      trap recursion attacks and global performance impacts).
      
      [ Paul Mundt: keep addr space check for sh signal delivery and fix
        double function declaration]
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
      Cc: K. Prasad <prasad@linux.vnet.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NPaul Mundt <lethal@linux-sh.org>
      b2812d03
  9. 01 3月, 2010 1 次提交
    • F
      hw-breakpoints: Remove stub unthrottle callback · 1e259e0a
      Frederic Weisbecker 提交于
      We support event unthrottling in breakpoint events. It means
      that if we have more than sysctl_perf_event_sample_rate/HZ,
      perf will throttle, ignoring subsequent events until the next
      tick.
      
      So if ptrace exceeds this max rate, it will omit events, which
      breaks the ptrace determinism that is supposed to report every
      triggered breakpoints. This is likely to happen if we set
      sysctl_perf_event_sample_rate to 1.
      
      This patch removes support for unthrottling in breakpoint
      events to break throttling and restore ptrace determinism.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: 2.6.33.x <stable@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: K.Prasad <prasad@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      1e259e0a
  10. 28 2月, 2010 1 次提交
  11. 20 2月, 2010 1 次提交
  12. 29 1月, 2010 1 次提交
    • K
      x86/hw-breakpoints: Optimize return code from notifier chain in hw_breakpoint_handler · e0e53db6
      K.Prasad 提交于
      Processing of debug exceptions in do_debug() can stop if it
      originated from a hw-breakpoint exception by returning NOTIFY_STOP
      in most cases.
      
      But for certain cases such as:
      
      a) user-space breakpoints with pending SIGTRAP signal delivery (as
      in the case of ptrace induced breakpoints).
      
      b) exceptions due to other causes than breakpoints
      
      We will continue to process the exception by returning NOTIFY_DONE.
      Signed-off-by: NK.Prasad <prasad@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Roland McGrath <roland@redhat.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      LKML-Reference: <20100128111415.GC13935@in.ibm.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      e0e53db6
  13. 06 12月, 2009 1 次提交
  14. 26 11月, 2009 1 次提交
  15. 25 11月, 2009 1 次提交
    • T
      x86: Rename global percpu symbol dr7 to cpu_dr7 · 28b4e0d8
      Tejun Heo 提交于
      Percpu symbols now occupy the same namespace as other global
      symbols and as such short global symbols without subsystem
      prefix tend to collide with local variables.  dr7 percpu
      variable used by x86 was hit by this. Rename it to cpu_dr7.
      
      The rename also makes it more consistent with its fellow
      cpu_debugreg percpu variable.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>,
      Cc: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <20091125115856.GA17856@elte.hu>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      28b4e0d8
  16. 24 11月, 2009 1 次提交
  17. 14 11月, 2009 1 次提交
    • I
      hw-breakpoints, x86: Fix modular KVM build · 68efa37d
      Ingo Molnar 提交于
      This build error:
      
      arch/x86/kvm/x86.c:3655: error: implicit declaration of function 'hw_breakpoint_restore'
      
      Happens because in the CONFIG_KVM=m case there's no 'CONFIG_KVM' define
      in the kernel - it's CONFIG_KVM_MODULE in that case.
      
      Make the prototype available unconditionally.
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      LKML-Reference: <1258114575-32655-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      68efa37d
  18. 10 11月, 2009 1 次提交
  19. 08 11月, 2009 1 次提交
    • F
      hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events · 24f1e32c
      Frederic Weisbecker 提交于
      This patch rebase the implementation of the breakpoints API on top of
      perf events instances.
      
      Each breakpoints are now perf events that handle the
      register scheduling, thread/cpu attachment, etc..
      
      The new layering is now made as follows:
      
             ptrace       kgdb      ftrace   perf syscall
                \          |          /         /
                 \         |         /         /
                                              /
                  Core breakpoint API        /
                                            /
                           |               /
                           |              /
      
                    Breakpoints perf events
      
                           |
                           |
      
                     Breakpoints PMU ---- Debug Register constraints handling
                                          (Part of core breakpoint API)
                           |
                           |
      
                   Hardware debug registers
      
      Reasons of this rewrite:
      
      - Use the centralized/optimized pmu registers scheduling,
        implying an easier arch integration
      - More powerful register handling: perf attributes (pinned/flexible
        events, exclusive/non-exclusive, tunable period, etc...)
      
      Impact:
      
      - New perf ABI: the hardware breakpoints counters
      - Ptrace breakpoints setting remains tricky and still needs some per
        thread breakpoints references.
      
      Todo (in the order):
      
      - Support breakpoints perf counter events for perf tools (ie: implement
        perf_bpcounter_event())
      - Support from perf tools
      
      Changes in v2:
      
      - Follow the perf "event " rename
      - The ptrace regression have been fixed (ptrace breakpoint perf events
        weren't released when a task ended)
      - Drop the struct hw_breakpoint and store generic fields in
        perf_event_attr.
      - Separate core and arch specific headers, drop
        asm-generic/hw_breakpoint.h and create linux/hw_breakpoint.h
      - Use new generic len/type for breakpoint
      - Handle off case: when breakpoints api is not supported by an arch
      
      Changes in v3:
      
      - Fix broken CONFIG_KVM, we need to propagate the breakpoint api
        changes to kvm when we exit the guest and restore the bp registers
        to the host.
      
      Changes in v4:
      
      - Drop the hw_breakpoint_restore() stub as it is only used by KVM
      - EXPORT_SYMBOL_GPL hw_breakpoint_restore() as KVM can be built as a
        module
      - Restore the breakpoints unconditionally on kvm guest exit:
        TIF_DEBUG_THREAD doesn't anymore cover every cases of running
        breakpoints and vcpu->arch.switch_db_regs might not always be
        set when the guest used debug registers.
        (Waiting for a reliable optimization)
      
      Changes in v5:
      
      - Split-up the asm-generic/hw-breakpoint.h moving to
        linux/hw_breakpoint.h into a separate patch
      - Optimize the breakpoints restoring while switching from kvm guest
        to host. We only want to restore the state if we have active
        breakpoints to the host, otherwise we don't care about messed-up
        address registers.
      - Add asm/hw_breakpoint.h to Kbuild
      - Fix bad breakpoint type in trace_selftest.c
      
      Changes in v6:
      
      - Fix wrong header inclusion in trace.h (triggered a build
        error with CONFIG_FTRACE_SELFTEST
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Prasad <prasad@linux.vnet.ibm.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jan Kiszka <jan.kiszka@web.de>
      Cc: Jiri Slaby <jirislaby@gmail.com>
      Cc: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Avi Kivity <avi@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Masami Hiramatsu <mhiramat@redhat.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      24f1e32c
  20. 18 6月, 2009 1 次提交
    • J
      x86: hw_breakpoint.c arch_check_va_in_kernelspace and hw_breakpoint_handler should be static · 4555835b
      Jaswinder Singh Rajput 提交于
      arch_check_va_in_kernelspace() and hw_breakpoint_handler() is used only by same file so it should be static.
      
      Also fixed non-ANSI function declaration of function 'arch_uninstall_thread_hw_breakpoint'
      
      Fixed following sparse warnings :
        arch/x86/kernel/hw_breakpoint.c:124:42: warning: non-ANSI function declaration of function 'arch_uninstall_thread_hw_breakpoint'
        arch/x86/kernel/hw_breakpoint.c:169:5: warning: symbol 'arch_check_va_in_kernelspace' was not declared. Should it be static?
        arch/x86/kernel/hw_breakpoint.c:313:15: warning: symbol 'hw_breakpoint_handler' was not declared. Should it be static?
      Signed-off-by: NJaswinder Singh Rajput <jaswinderrajput@gmail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: "K.Prasad" <prasad@linux.vnet.ibm.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1245230059.2662.4.camel@ht.satnam>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      4555835b
  21. 03 6月, 2009 2 次提交