linux-kernel-test/arch/x86/kvm
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
..
emulate.c KVM: x86 emulator: Add adc and sbb missing decoder flags 2009-09-10 10:46:51 +03:00
i8254.c KVM: remove superfluous NULL pointer check in kvm_inject_pit_timer_irqs() 2009-09-10 08:33:19 +03:00
i8254.h KVM: PIT support for HPET legacy mode 2009-09-10 08:33:12 +03:00
i8259.c KVM: Replace pic_lock()/pic_unlock() with direct call to spinlock functions 2009-09-10 08:33:22 +03:00
irq.c KVM: Remove irq_pending bitmap 2009-06-10 11:48:57 +03:00
irq.h KVM: Call kvm_vcpu_kick() inside pic spinlock 2009-09-10 08:33:21 +03:00
Kconfig KVM: remove old KVMTRACE support code 2009-09-10 08:33:03 +03:00
kvm_cache_regs.h KVM: Cache pdptrs 2009-09-10 08:32:46 +03:00
kvm_timer.h KVM: Use pointer to vcpu instead of vcpu_id in timer code. 2009-09-10 08:32:52 +03:00
lapic.c KVM: fix LAPIC timer period overflow 2009-10-04 13:57:23 +02:00
lapic.h KVM: x2apic interface to lapic 2009-09-10 08:33:08 +03:00
Makefile KVM: Rename x86_emulate.c to emulate.c 2009-09-10 10:46:45 +03:00
mmu.c KVM: add support for change_pte mmu notifiers 2009-10-04 17:04:53 +02:00
mmu.h KVM: MMU: add kvm_mmu_get_spte_hierarchy helper 2009-09-10 08:32:56 +03:00
mmutrace.h KVM: Trace shadow page lifecycle 2009-09-10 08:33:10 +03:00
paging_tmpl.h KVM: MMU: add SPTE_HOST_WRITEABLE flag to the shadow ptes 2009-10-04 17:04:50 +02:00
svm.c KVM: SVM: Handle tsc in svm_get_msr/svm_set_msr correctly 2009-10-04 13:57:23 +02:00
timer.c KVM: Drop useless atomic test from timer function 2009-09-10 08:32:57 +03:00
trace.h KVM: Add trace points in irqchip code 2009-09-10 08:33:11 +03:00
tss.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
vmx.c KVM: VMX: flush TLB with INVEPT on cpu migration 2009-10-04 13:57:24 +02:00
x86.c hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events 2009-11-08 15:34:42 +01:00
x86.h KVM: Add Directed EOI support to APIC emulation 2009-09-10 08:33:07 +03:00