Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169695
b: refs/heads/master
c: 24f1e32
h: refs/heads/master
i:
  169693: 927eb3a
  169691: 91cc679
  169687: cadaa5b
  169679: 82d85aa
  169663: 77b98fa
v: v3
  • Loading branch information
Frederic Weisbecker committed Nov 8, 2009
1 parent b1f6328 commit 716a34d
Show file tree
Hide file tree
Showing 23 changed files with 886 additions and 751 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2da3e160cb3d226d87b907fab26850d838ed8d7c
refs/heads/master: 24f1e32c60c45c89a997c73395b69c8af6f0a84e
3 changes: 3 additions & 0 deletions trunk/arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ config HAVE_DEFAULT_NO_SPIN_MUTEXES

config HAVE_HW_BREAKPOINT
bool
depends on HAVE_PERF_EVENTS
select ANON_INODES
select PERF_EVENTS


source "kernel/gcov/Kconfig"
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ header-y += ptrace-abi.h
header-y += sigcontext32.h
header-y += ucontext.h
header-y += processor-flags.h
header-y += hw_breakpoint.h

unifdef-y += e820.h
unifdef-y += ist.h
Expand Down
11 changes: 5 additions & 6 deletions trunk/arch/x86/include/asm/debugreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,8 @@
*/
#ifdef __KERNEL__

/* For process management */
extern void flush_thread_hw_breakpoint(struct task_struct *tsk);
extern int copy_thread_hw_breakpoint(struct task_struct *tsk,
struct task_struct *child, unsigned long clone_flags);
DECLARE_PER_CPU(unsigned long, dr7);

/* For CPU management */
extern void load_debug_registers(void);
static inline void hw_breakpoint_disable(void)
{
/* Zero the control register for HW Breakpoint */
Expand All @@ -94,6 +89,10 @@ static inline void hw_breakpoint_disable(void)
set_debugreg(0UL, 3);
}

#ifdef CONFIG_KVM
extern void hw_breakpoint_restore(void);
#endif

#endif /* __KERNEL__ */

#endif /* _ASM_X86_DEBUGREG_H */
58 changes: 38 additions & 20 deletions trunk/arch/x86/include/asm/hw_breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#ifdef __KERNEL__
#define __ARCH_HW_BREAKPOINT_H

/*
* The name should probably be something dealt in
* a higher level. While dealing with the user
* (display/resolving)
*/
struct arch_hw_breakpoint {
char *name; /* Contains name of the symbol to set bkpt */
unsigned long address;
Expand All @@ -12,44 +17,57 @@ struct arch_hw_breakpoint {
};

#include <linux/kdebug.h>
#include <linux/hw_breakpoint.h>
#include <linux/percpu.h>
#include <linux/list.h>

/* Available HW breakpoint length encodings */
#define HW_BREAKPOINT_LEN_1 0x40
#define HW_BREAKPOINT_LEN_2 0x44
#define HW_BREAKPOINT_LEN_4 0x4c
#define HW_BREAKPOINT_LEN_EXECUTE 0x40
#define X86_BREAKPOINT_LEN_1 0x40
#define X86_BREAKPOINT_LEN_2 0x44
#define X86_BREAKPOINT_LEN_4 0x4c
#define X86_BREAKPOINT_LEN_EXECUTE 0x40

#ifdef CONFIG_X86_64
#define HW_BREAKPOINT_LEN_8 0x48
#define X86_BREAKPOINT_LEN_8 0x48
#endif

/* Available HW breakpoint type encodings */

/* trigger on instruction execute */
#define HW_BREAKPOINT_EXECUTE 0x80
#define X86_BREAKPOINT_EXECUTE 0x80
/* trigger on memory write */
#define HW_BREAKPOINT_WRITE 0x81
#define X86_BREAKPOINT_WRITE 0x81
/* trigger on memory read or write */
#define HW_BREAKPOINT_RW 0x83
#define X86_BREAKPOINT_RW 0x83

/* Total number of available HW breakpoint registers */
#define HBP_NUM 4

extern struct hw_breakpoint *hbp_kernel[HBP_NUM];
DECLARE_PER_CPU(struct hw_breakpoint*, this_hbp_kernel[HBP_NUM]);
extern unsigned int hbp_user_refcount[HBP_NUM];
struct perf_event;
struct pmu;

extern void arch_install_thread_hw_breakpoint(struct task_struct *tsk);
extern void arch_uninstall_thread_hw_breakpoint(void);
extern int arch_check_va_in_userspace(unsigned long va, u8 hbp_len);
extern int arch_validate_hwbkpt_settings(struct hw_breakpoint *bp,
struct task_struct *tsk);
extern void arch_update_user_hw_breakpoint(int pos, struct task_struct *tsk);
extern void arch_flush_thread_hw_breakpoint(struct task_struct *tsk);
extern void arch_update_kernel_hw_breakpoint(void *);
extern int arch_validate_hwbkpt_settings(struct perf_event *bp,
struct task_struct *tsk);
extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
unsigned long val, void *data);
unsigned long val, void *data);


int arch_install_hw_breakpoint(struct perf_event *bp);
void arch_uninstall_hw_breakpoint(struct perf_event *bp);
void hw_breakpoint_pmu_read(struct perf_event *bp);
void hw_breakpoint_pmu_unthrottle(struct perf_event *bp);

extern void
arch_fill_perf_breakpoint(struct perf_event *bp);

unsigned long encode_dr7(int drnum, unsigned int len, unsigned int type);
int decode_dr7(unsigned long dr7, int bpnum, unsigned *len, unsigned *type);

extern int arch_bp_generic_fields(int x86_len, int x86_type,
int *gen_len, int *gen_type);

extern struct pmu perf_ops_bp;

#endif /* __KERNEL__ */
#endif /* _I386_HW_BREAKPOINT_H */

12 changes: 6 additions & 6 deletions trunk/arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ extern unsigned int xstate_size;
extern void free_thread_xstate(struct task_struct *);
extern struct kmem_cache *task_xstate_cachep;

struct perf_event;

struct thread_struct {
/* Cached TLS descriptors: */
struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
Expand All @@ -444,12 +446,10 @@ struct thread_struct {
unsigned long fs;
#endif
unsigned long gs;
/* Hardware debugging registers: */
unsigned long debugreg[HBP_NUM];
unsigned long debugreg6;
unsigned long debugreg7;
/* Hardware breakpoint info */
struct hw_breakpoint *hbp[HBP_NUM];
/* Save middle states of ptrace breakpoints */
struct perf_event *ptrace_bps[HBP_NUM];
/* Debug status used for traps, single steps, etc... */
unsigned long debugreg6;
/* Fault info: */
unsigned long cr2;
unsigned long trap_no;
Expand Down
Loading

0 comments on commit 716a34d

Please sign in to comment.