22 Dec, 2011

1 commit

  • Mathieu Desnoyers pointed out a case that can cause issues with
    NMIs running on the debug stack:

    int3 -> interrupt -> NMI -> int3

    Because the interrupt changes the stack, the NMI will not see that
    it preempted the debug stack. Looking deeper at this case,
    interrupts only happen when the int3 is from userspace or in
    an a location in the exception table (fixup).

    userspace -> int3 -> interurpt -> NMI -> int3

    All other int3s that happen in the kernel should be processed
    without ever enabling interrupts, as the do_trap() call will
    panic the kernel if it is called to process any other location
    within the kernel.

    Adding a counter around the sections that enable interrupts while
    using the debug stack allows the NMI to also check that case.
    If the NMI sees that it either interrupted a task using the debug
    stack or the debug counter is non-zero, then it will have to
    change the IDT table to make the int3 not change stacks (which will
    corrupt the stack if it does).

    Note, I had to move the debug_usage functions out of processor.h
    and into debugreg.h because of the static inlined functions to
    inc and dec the debug_usage counter. __get_cpu_var() requires
    smp.h which includes processor.h, and would fail to build.

    Link: http://lkml.kernel.org/r/1323976535.23971.112.camel@gandalf.stny.rr.com

    Reported-by: Mathieu Desnoyers
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: H. Peter Anvin
    Cc: Thomas Gleixner
    Cc: Paul Turner
    Cc: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

30 Dec, 2010

1 commit

  • Go through x86 code and replace __get_cpu_var and get_cpu_var
    instances that refer to a scalar and are not used for address
    determinations.

    Cc: Yinghai Lu
    Cc: Ingo Molnar
    Acked-by: Tejun Heo
    Acked-by: "H. Peter Anvin"
    Signed-off-by: Christoph Lameter
    Signed-off-by: Tejun Heo

    Tejun Heo
     

29 Jan, 2010

1 commit

  • Clear the reserved bits from the stored copy of debug status
    register (DR6).
    This will help easy bitwise operations such as quick testing
    of a debug event origin.

    Signed-off-by: K.Prasad
    Cc: Roland McGrath
    Cc: Jan Kiszka
    Cc: Alan Stern
    Cc: Ingo Molnar
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    K.Prasad
     

25 Nov, 2009

1 commit

  • 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: Tejun Heo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Rusty Russell
    Cc: Christoph Lameter
    Cc: Linus Torvalds ,
    Cc: Andrew Morton
    LKML-Reference:
    Signed-off-by: Ingo Molnar
    Reported-by: Stephen Rothwell

    Tejun Heo
     

14 Nov, 2009

1 commit

  • 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
    Cc: Prasad
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

10 Nov, 2009

2 commits


08 Nov, 2009

1 commit

  • 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: Frederic Weisbecker
    Cc: Prasad
    Cc: Alan Stern
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Steven Rostedt
    Cc: Ingo Molnar
    Cc: Jan Kiszka
    Cc: Jiri Slaby
    Cc: Li Zefan
    Cc: Avi Kivity
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    Cc: Masami Hiramatsu
    Cc: Paul Mundt

    Frederic Weisbecker
     

03 Jun, 2009

1 commit

  • The generic hardware breakpoint interface provides an abstraction of
    hardware breakpoints in front of specific arch implementations for both kernel
    and user side breakpoints.
    This includes execution breakpoints and read/write breakpoints, also known as
    "watchpoints".

    This patch introduces header files containing constants, structure definitions
    and declaration of functions used by the hardware breakpoint core and x86
    specific code.
    It also introduces an array based storage for the debug-register values in
    'struct thread_struct', while modifying all users of debugreg member in the
    structure.

    [ Impact: add headers for new hardware breakpoint interface ]

    Original-patch-by: Alan Stern
    Signed-off-by: K.Prasad
    Reviewed-by: Alan Stern
    Signed-off-by: Frederic Weisbecker

    K.Prasad
     

23 Oct, 2008

2 commits