01 May, 2010
3 commits
-
The breakpoint generic layer assumes that archs always know in advance
the static number of address registers available to host breakpoints
through the HBP_NUM macro.However this is not true for every archs. For example Arm needs to get
this information dynamically to handle the compatiblity between
different versions.To solve this, this patch proposes to drop the static HBP_NUM macro
and let the arch provide the number of available slots through a
new hw_breakpoint_slots() function. For archs that have
CONFIG_HAVE_MIXED_BREAKPOINTS_REGS selected, it will be called once
as the number of registers fits for instruction and data breakpoints
together.
For the others it will be called first to get the number of
instruction breakpoint registers and another time to get the
data breakpoint registers, the targeted type is given as a
parameter of hw_breakpoint_slots().Reported-by: Will Deacon
Signed-off-by: Frederic Weisbecker
Acked-by: Paul Mundt
Cc: Mahesh Salgaonkar
Cc: K. Prasad
Cc: Benjamin Herrenschmidt
Cc: Paul Mackerras
Cc: Jason Wessel
Cc: Ingo Molnar -
There are two outstanding fashions for archs to implement hardware
breakpoints.The first is to separate breakpoint address pattern definition
space between data and instruction breakpoints. We then have
typically distinct instruction address breakpoint registers
and data address breakpoint registers, delivered with
separate control registers for data and instruction breakpoints
as well. This is the case of PowerPc and ARM for example.The second consists in having merged breakpoint address space
definition between data and instruction breakpoint. Address
registers can host either instruction or data address and
the access mode for the breakpoint is defined in a control
register. This is the case of x86 and Super H.This patch adds a new CONFIG_HAVE_MIXED_BREAKPOINTS_REGS config
that archs can select if they belong to the second case. Those
will have their slot allocation merged for instructions and
data breakpoints.The others will have a separate slot tracking between data and
instruction breakpoints.Signed-off-by: Frederic Weisbecker
Acked-by: Paul Mundt
Cc: Will Deacon
Cc: Mahesh Salgaonkar
Cc: K. Prasad
Cc: Benjamin Herrenschmidt
Cc: Paul Mackerras
Cc: Ingo Molnar -
Tag ptrace breakpoints with the exclude_kernel attribute set. This
will make it easier to set generic policies on breakpoints, when it
comes to ensure nobody unpriviliged try to breakpoint on the kernel.Signed-off-by: Frederic Weisbecker
Acked-by: Paul Mundt
Cc: Will Deacon
Cc: Mahesh Salgaonkar
Cc: K. Prasad
Cc: Benjamin Herrenschmidt
Cc: Paul Mackerras
Cc: Ingo Molnar
27 Feb, 2010
1 commit
-
Add __percpu sparse annotations to hw_breakpoint.
These annotations are to make sparse consider percpu variables to be
in a different address space and warn if accessed without going
through percpu accessors. This patch doesn't affect normal builds.In kernel/hw_breakpoint.c, per_cpu(nr_task_bp_pinned, cpu)'s will
trigger spurious noderef related warnings from sparse. Changing it to
&per_cpu(nr_task_bp_pinned[0], cpu) will work around the problem but
deemed to ugly by the maintainer. Leave it alone until better
solution can be found.Signed-off-by: Tejun Heo
Cc: Stephen Rothwell
Cc: K.Prasad
LKML-Reference:
Signed-off-by: Frederic Weisbecker
04 Feb, 2010
1 commit
-
Change 'bp_len' type to __u64 to make it work across archs as
the s390 architecture watch point length can be upto 2^64.reference:
http://lkml.org/lkml/2010/1/25/212This is an ABI change that is not backward compatible with
the previous hardware breakpoint info layout integrated in this
development cycle, a rebuilt of perf tools is necessary for
versions based on 2.6.33-rc1 - 2.6.33-rc6 to work with a
kernel based on this patch.Signed-off-by: Mahesh Salgaonkar
Acked-by: Peter Zijlstra
Cc: Ananth N Mavinakayanahalli
Cc: "K. Prasad"
Cc: Maneesh Soni
Cc: Heiko Carstens
Cc: Martin
LKML-Reference:
Signed-off-by: Frederic Weisbecker
30 Jan, 2010
1 commit
-
This patch fixes the regression in functionality where the
kernel debugger and the perf API do not nicely share hw
breakpoint reservations.The kernel debugger cannot use any mutex_lock() calls because it
can start the kernel running from an invalid context.A mutex free version of the reservation API needed to get
created for the kernel debugger to safely update hw breakpoint
reservations.The possibility for a breakpoint reservation to be concurrently
processed at the time that kgdb interrupts the system is
improbable. Should this corner case occur the end user is
warned, and the kernel debugger will prohibit updating the
hardware breakpoint reservations.Any time the kernel debugger reserves a hardware breakpoint it
will be a system wide reservation.Signed-off-by: Jason Wessel
Acked-by: Frederic Weisbecker
Cc: kgdb-bugreport@lists.sourceforge.net
Cc: K.Prasad
Cc: Peter Zijlstra
Cc: Alan Stern
Cc: torvalds@linux-foundation.org
LKML-Reference:
Signed-off-by: Ingo Molnar
11 Dec, 2009
1 commit
-
While converting modify_user_hw_breakpoint() return value, we
forgot to handle the off-case. It's not returning a pointer
anymore.This solves the build warning reported by Stephen Rothwell against
linux-next.Reported-by: Stephen Rothwell
Signed-off-by: Frederic Weisbecker
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar
Cc: Prasad
09 Dec, 2009
1 commit
-
Currently, when ptrace needs to modify a breakpoint, like disabling
it, changing its address, type or len, it calls
modify_user_hw_breakpoint(). This latter will perform the heavy and
racy task of unregistering the old breakpoint and registering a new
one.This is racy as someone else might steal the reserved breakpoint
slot under us, which is undesired as the breakpoint is only
supposed to be modified, sometimes in the middle of a debugging
workflow. We don't want our slot to be stolen in the middle.So instead of unregistering/registering the breakpoint, just
disable it while we modify its breakpoint fields and re-enable it
after if necessary.Signed-off-by: Frederic Weisbecker
Cc: Peter Zijlstra
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar
07 Dec, 2009
1 commit
-
The perf attrs used to set up breakpoint parameters are often allocated
in the stack and not zeroed out before calling hw_breakpoint_init().
Handle it from this helper to avoid random attributes set by the stack.Signed-off-by: Frederic Weisbecker
Cc: Prasad
06 Dec, 2009
2 commits
-
struct perf_event::event callback was called when a breakpoint
triggers. But this is a rather opaque callback, pretty
tied-only to the breakpoint API and not really integrated into perf
as it triggers even when we don't overflow.We prefer to use overflow_handler() as it fits into the perf events
rules, being called only when we overflow.Reported-by: Peter Zijlstra
Signed-off-by: Frederic Weisbecker
Cc: Paul Mackerras
Cc: Arnaldo Carvalho de Melo
Cc: "K. Prasad" -
Drop the callback and task parameters from modify_user_hw_breakpoint().
For now we have no user that need to modify a breakpoint to the point
of changing its handler or its task context.Signed-off-by: Frederic Weisbecker
Cc: "K. Prasad"
27 Nov, 2009
2 commits
-
Kernel breakpoints are created using functions in which we pass
breakpoint parameters as individual variables: address, length
and type.Although it fits well for x86, this just does not scale across
architectures that may support this api later as these may have
more or different needs. Pass in a perf_event_attr structure
instead because it is meant to evolve as much as possible into
a generic hardware breakpoint parameter structure.Reported-by: K.Prasad
Signed-off-by: Frederic Weisbecker
LKML-Reference:
Signed-off-by: Ingo Molnar -
In-kernel user breakpoints are created using functions in which
we pass breakpoint parameters as individual variables: address,
length and type.Although it fits well for x86, this just does not scale across
archictectures that may support this api later as these may have
more or different needs. Pass in a perf_event_attr structure
instead because it is meant to evolve as much as possible into
a generic hardware breakpoint parameter structure.Reported-by: K.Prasad
Signed-off-by: Frederic Weisbecker
LKML-Reference:
Signed-off-by: Ingo Molnar
24 Nov, 2009
2 commits
-
Fix a misplaced ifdef. We need the perf event headers also in
off-case to avoid the following build error:include/linux/hw_breakpoint.h:94: error: expected declaration specifiers or '...' before 'perf_callback_t'
include/linux/hw_breakpoint.h:102: error: expected declaration specifiers or '...' before 'perf_callback_t'
include/linux/hw_breakpoint.h:109: error: expected declaration specifiers or '...' before 'perf_callback_t'
include/linux/hw_breakpoint.h:116: error: expected declaration specifiers or '...' before 'perf_callback_t'Reported-by: Kisskb-bot by Michael Ellerman
Signed-off-by: Frederic Weisbecker
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar -
As userspace only needs the breakpoints enum types from the
breakpoints headers.Signed-off-by: Frederic Weisbecker
Cc: Peter Zijlstra
Cc: Arnaldo Carvalho de Melo
Cc: Paul Mackerras
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar
22 Nov, 2009
1 commit
-
So that we can include this header from userspace tools, like
perf tools, to get the breakpoint types and len definitions.Signed-off-by: Frederic Weisbecker
Cc: Peter Zijlstra
Cc: Arnaldo Carvalho de Melo
Cc: Paul Mackerras
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar
14 Nov, 2009
2 commits
-
the arch/alpha build fails with:
In file included from tip/kernel/exit.c:52:
tip/include/linux/hw_breakpoint.h: In function 'hw_breakpoint_addr':
tip/include/linux/hw_breakpoint.h:21: error: 'struct perf_event' has no member named 'attr'
[...]Move these helper inlines inside the CONFIG_HAVE_HW_BREAKPOINT ifdef.
Cc: Frederic Weisbecker
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar -
If an arch doesn't support the hw breakpoints, counter_arch_bp()
has no off case to cover the missing breakpoint info structure
from the perf event. The result is a build error in non-x86
configs.Reported-by: Ingo Molnar
Signed-off-by: Frederic Weisbecker
Cc: Prasad
LKML-Reference:
Signed-off-by: Ingo Molnar
Cc: Prasad
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 toolsChanges 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 archChanges 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.cChanges in v6:
- Fix wrong header inclusion in trace.h (triggered a build
error with CONFIG_FTRACE_SELFTESTSigned-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
06 Nov, 2009
1 commit
-
We plan to make the breakpoints parameters generic among architectures.
For that it's better to move the asm-generic header to a generic linux
header.Signed-off-by: Frederic Weisbecker