linux-stable/arch/x86/kernel
Frederic Weisbecker 24f1e32c60 hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events
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 <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>
2009-11-08 15:34:42 +01:00
..
acpi x86: linker script syntax nits 2009-10-14 14:16:38 -07:00
apic sysctl: remove "struct file *" argument of ->proc_handler 2009-09-24 07:21:04 -07:00
cpu Merge commit 'v2.6.32-rc4' into perf/core 2009-10-13 09:31:34 +02:00
.gitignore
alternative.c Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-14 07:57:32 -07:00
amd_iommu.c Merge branch 'amd-iommu/pagetable' into amd-iommu/2.6.32 2009-09-03 17:14:57 +02:00
amd_iommu_init.c Merge branch 'amd-iommu/passthrough' into amd-iommu/2.6.32 2009-09-03 16:34:23 +02:00
aperture_64.c kmemleak: Ignore the aperture memory hole on x86_64 2009-09-01 11:12:32 +01:00
apm_32.c Merge commit 'origin/x86/urgent' into x86/asm 2009-08-25 15:40:29 -07:00
asm-offsets.c
asm-offsets_32.c lguest: optimize by coding restore_flags and irq_enable in assembler. 2009-06-12 22:27:03 +09:30
asm-offsets_64.c tracing: Define NR_syscalls for x86_64 2009-08-26 21:29:58 +02:00
audit_64.c
bios_uv.c x86, UV: system table in bios accessed after unmap 2009-04-03 19:25:57 +02:00
bootflag.c
check.c x86: fix 64k corruption-check 2009-03-15 07:03:15 +01:00
cpuid.c Driver-Core: extend devnode callbacks to provide permissions 2009-09-19 12:50:38 -07:00
crash.c x86: disable IOMMUs on kernel crash 2009-06-15 15:20:40 +02:00
crash_dump_32.c
crash_dump_64.c
doublefault_32.c x86: Use get_desc_base() 2009-07-19 18:27:51 +02:00
ds.c x86: ds.c fix invalid assignment 2009-06-20 17:53:13 +02:00
ds_selftest.c x86, ds: fix buffer alignment in debug store selftest 2009-04-24 10:18:51 +02:00
ds_selftest.h x86, bts: cleanups 2009-03-13 11:57:22 +01:00
dumpstack.c x86: Remove duplicated #include 2009-07-11 10:17:08 +02:00
dumpstack.h x86: avoid multiple declaration of kstack_depth_to_print 2009-04-14 11:45:33 +02:00
dumpstack_32.c headers: utsname.h redux 2009-09-23 18:13:10 -07:00
dumpstack_64.c headers: utsname.h redux 2009-09-23 18:13:10 -07:00
e820.c pci: increase alignment to make more space for hidden code 2009-10-11 14:43:36 -07:00
early-quirks.c x86 early quirks: eliminate unused function 2009-04-08 14:16:32 +02:00
early_printk.c x86: earlyprintk: Fix regression to handle serial,ttySn as 1 arg 2009-10-01 10:34:16 +02:00
efi.c x86: Move get/set_wallclock to x86_platform_ops 2009-09-16 14:34:50 +02:00
efi_32.c
efi_64.c x86: Make 64-bit efi_ioremap use ioremap on MMIO regions 2009-08-03 13:34:25 -07:00
efi_stub_32.S Merge branch 'x86/asm' into x86/mm 2009-02-25 08:27:46 +01:00
efi_stub_64.S x86: efi_stub_32,64 - add missing ENDPROCs 2009-02-24 18:08:40 +01:00
entry_32.S function-graph/x86: Replace unbalanced ret with jmp 2009-10-14 08:13:53 +02:00
entry_64.S function-graph/x86: Replace unbalanced ret with jmp 2009-10-14 08:13:53 +02:00
ftrace.c tracing: Move syscalls metadata handling from arch to core 2009-10-14 09:53:56 +02:00
geode_32.c
head.c
head32.c x86: Add Moorestown early detection 2009-08-31 11:09:40 +02:00
head64.c x86: Add early platform detection 2009-08-31 11:09:40 +02:00
head_32.S Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-26 10:13:35 -07:00
head_64.S Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-26 10:13:35 -07:00
hpet.c x86: hpet: Mark per cpu interrupts IRQF_TIMER to prevent resume failure 2009-06-14 18:24:29 +02:00
hw_breakpoint.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
i386_ksyms_32.c x86: Don't generate cmpxchg8b_emu if CONFIG_X86_CMPXCHG64=y 2009-10-01 08:42:24 +02:00
i387.c x86, math-emu: fix init_fpu for task != current 2009-03-04 20:33:16 +01:00
i8237.c
i8253.c x86: Do not unregister PIT clocksource on PIT oneshot setup/shutdown 2009-08-21 21:13:37 +02:00
i8259.c x86: refactor x86_quirks support 2009-02-23 00:08:11 +01:00
init_task.c Use new __init_task_data macro in arch init_task.c files. 2009-09-21 06:27:08 +02:00
io_delay.c x86: io_delay.c cleanup 2009-03-21 16:57:04 +05:30
ioport.c x86-32: use non-lazy io bitmap context switching 2009-03-02 12:07:48 +01:00
irq.c Revert "x86, timers: Check for pending timers after (device) interrupts" 2009-10-09 15:58:20 +02:00
irq_32.c x86: Use printk_once() 2009-08-09 22:28:34 +02:00
irq_64.c
irqinit.c perf: Do the big rename: Performance Counters -> Performance Events 2009-09-21 14:28:04 +02:00
k8.c
kdebugfs.c x86: kdebugfs.c cleanup 2009-03-21 16:55:45 +05:30
kgdb.c Merge branch 'linus' into tracing/hw-breakpoints 2009-06-17 12:56:49 +02:00
kprobes.c hw-breakpoints: reset bits in dr6 after the corresponding exception is handled 2009-06-02 22:47:00 +02:00
kvm.c KVM guest: do not batch pte updates from interrupt context 2009-09-10 18:10:50 +03:00
kvmclock.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-18 14:05:47 -07:00
ldt.c cpumask: use mm_cpumask() wrapper: x86 2009-09-24 09:34:52 +09:30
machine_kexec_32.c hw-breakpoints: cleanup HW Breakpoint registers before kexec 2009-06-02 22:47:00 +02:00
machine_kexec_64.c hw-breakpoints: cleanup HW Breakpoint registers before kexec 2009-06-02 22:47:00 +02:00
Makefile Merge commit 'perf/core' into perf/hw-breakpoint 2009-10-18 01:12:33 +02:00
mca_32.c x86: refactor x86_quirks support 2009-02-23 00:08:11 +01:00
mfgpt_32.c x86: geode: Mark mfgpt irq IRQF_TIMER to prevent resume failure 2009-07-24 08:42:52 +02:00
microcode_amd.c x86, microcode: Simplify vfree() use 2009-06-07 16:35:11 +02:00
microcode_core.c mm: replace various uses of num_physpages by totalram_pages 2009-09-22 07:17:38 -07:00
microcode_intel.c x86: microcode: use smp_call_function_single instead of set_cpus_allowed, cleanup of synchronization logic 2009-05-12 10:36:44 +02:00
mmconf-fam10h_64.c x86: move various CPU initialization objects into .cpuinit.rodata 2009-03-12 13:13:07 +01:00
module.c module: cleanup FIXME comments about trimming exception table entries. 2009-06-12 21:47:05 +09:30
mpparse.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-18 14:05:47 -07:00
mrst.c x86: Add Moorestown early detection 2009-08-31 11:09:40 +02:00
msr.c Driver-Core: extend devnode callbacks to provide permissions 2009-09-19 12:50:38 -07:00
olpc.c x86, olpc: fix model detection without OFW 2009-02-14 23:05:25 +01:00
paravirt-spinlocks.c
paravirt.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-18 14:05:47 -07:00
paravirt_patch_32.c
paravirt_patch_64.c
pci-calgary_64.c x86: calgary: remove IOMMU_DEBUG 2009-04-14 13:03:36 +02:00
pci-dma.c Merge git://git.infradead.org/~dwmw2/iommu-2.6.32 2009-10-13 10:04:40 -07:00
pci-gart_64.c headers: remove sched.h from interrupt.h 2009-10-11 11:20:58 -07:00
pci-nommu.c dma-ops: Remove flush_write_buffers() in dma-mapping-common.h 2009-08-10 09:34:57 +02:00
pci-swiotlb.c Merge git://git.infradead.org/iommu-2.6 2009-09-23 10:06:10 -07:00
pcspeaker.c
pmtimer_64.c
probe_roms_32.c
process.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
process_32.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
process_64.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
ptrace.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
pvclock.c x86: Fix warning in pvclock.c 2009-07-14 16:25:05 +02:00
quirks.c x86/PCI: pci quirks, fix pci refcounting 2009-09-09 14:11:02 -07:00
reboot.c headers: remove sched.h from interrupt.h 2009-10-11 11:20:58 -07:00
reboot_fixups_32.c
relocate_kernel_32.S x86, kexec: fix kexec x86 coding style 2009-03-10 18:13:25 -07:00
relocate_kernel_64.S x86, kexec: x86_64: add kexec jump support for x86_64 2009-03-10 18:13:25 -07:00
rtc.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-18 14:05:47 -07:00
scx200_32.c
setup.c Merge branch 'sfi-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-sfi-2.6 2009-09-23 09:34:07 -07:00
setup_percpu.c x86,percpu: use embedding for 64bit NUMA and page for 32bit NUMA 2009-08-14 15:00:52 +09:00
sfi.c SFI: remove unneeded includes 2009-09-15 15:08:40 -04:00
signal.c Merge commit 'perf/core' into perf/hw-breakpoint 2009-10-18 01:12:33 +02:00
smp.c Revert "x86, timers: Check for pending timers after (device) interrupts" 2009-10-09 15:58:20 +02:00
smpboot.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
stacktrace.c x86: add save_stack_trace_bp() for tracing from a specific stack frame 2009-06-12 23:01:05 +02:00
step.c x86: Use get_desc_base() 2009-07-19 18:27:51 +02:00
sys_i386_32.c
sys_x86_64.c tracing: Convert x86_64 mmap and uname to use DEFINE_SYSCALL 2009-08-11 20:35:29 +02:00
syscall_64.c
syscall_table_32.S perf: Do the big rename: Performance Counters -> Performance Events 2009-09-21 14:28:04 +02:00
tboot.c x86, intel_txt: clean up the impact on generic code, unbreak non-x86 2009-09-01 18:25:07 -07:00
tce_64.c
test_nx.c
test_rodata.c
time.c x86: fix kernel panic on 32 bits when profiling 2009-10-12 11:53:51 -07:00
tlb_uv.c x86: uv: Clean up uv_ptc_init(), use proc_create() 2009-08-24 12:26:46 +02:00
tls.c
tls.h
topology.c x86: topology.c cleanup 2009-03-21 16:55:24 +05:30
trampoline.c x86: Fix Suspend to RAM freeze on Acer Aspire 1511Lmi laptop 2009-10-12 18:06:48 +02:00
trampoline_32.S x86: cpuinit-annotate SMP boot trampolines properly 2009-09-20 20:23:37 +02:00
trampoline_64.S x86: Fix Suspend to RAM freeze on Acer Aspire 1511Lmi laptop 2009-10-12 18:06:48 +02:00
traps.c Merge commit 'perf/core' into perf/hw-breakpoint 2009-10-18 01:12:33 +02:00
tsc.c Merge branch 'linus' into x86/urgent 2009-09-20 20:25:03 +02:00
tsc_sync.c x86: Reduce verbosity of "TSC is reliable" message 2009-09-24 11:35:19 +02:00
uv_irq.c x86, apic: remove genapic.h 2009-02-17 17:52:44 +01:00
uv_sysfs.c x86: prevent /sys/firmware/sgi_uv from being created on non-uv systems 2009-04-08 14:58:10 +02:00
uv_time.c uv_time: add parameter to uv_read_rtc() 2009-04-22 17:41:25 +02:00
verify_cpu_64.S
visws_quirks.c x86: Add timer_init to x86_init_ops 2009-08-31 09:35:46 +02:00
vm86_32.c Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 16:15:14 -07:00
vmi_32.c x86, vmi: Mark VMI deprecated and schedule it for removal 2009-10-08 22:27:55 +02:00
vmiclock_32.c x86: Move tsc_calibration to x86_init_ops 2009-08-31 09:35:47 +02:00
vmlinux.lds.S x86: linker script syntax nits 2009-10-14 14:16:38 -07:00
vsmp_64.c Revert "x86: don't compile vsmp_64 for 32bit" 2009-03-25 21:34:28 +01:00
vsyscall_64.c sysctl: remove "struct file *" argument of ->proc_handler 2009-09-24 07:21:04 -07:00
x86_init.c x86: Move get/set_wallclock to x86_platform_ops 2009-09-16 14:34:50 +02:00
x8664_ksyms_64.c
xsave.c x86-64: fix FPU corruption with signals and preemption 2009-04-20 14:33:00 -07:00