Skip to content

Commit 5f07aa7

Browse files
committed
Merge commit 'paulus-perf/master' into next
2 parents e467e10 + d09ec73 commit 5f07aa7

File tree

18 files changed

+2408
-52
lines changed

18 files changed

+2408
-52
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ config PPC
141141
select GENERIC_ATOMIC64 if PPC32
142142
select HAVE_PERF_EVENTS
143143
select HAVE_REGS_AND_STACK_ACCESS_API
144+
select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
144145

145146
config EARLY_PRINTK
146147
bool

arch/powerpc/include/asm/asm-compat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define PPC_STLCX stringify_in_c(stdcx.)
3131
#define PPC_CNTLZL stringify_in_c(cntlzd)
3232
#define PPC_LR_STKOFF 16
33+
#define PPC_MIN_STKFRM 112
3334

3435
/* Move to CR, single-entry optimized version. Only available
3536
* on POWER4 and later.
@@ -55,6 +56,7 @@
5556
#define PPC_CNTLZL stringify_in_c(cntlzw)
5657
#define PPC_MTOCRF stringify_in_c(mtcrf)
5758
#define PPC_LR_STKOFF 4
59+
#define PPC_MIN_STKFRM 16
5860

5961
#endif
6062

arch/powerpc/include/asm/cputable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ static inline int cpu_has_feature(unsigned long feature)
517517
& feature);
518518
}
519519

520+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
521+
#define HBP_NUM 1
522+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
523+
520524
#endif /* !__ASSEMBLY__ */
521525

522526
#endif /* __KERNEL__ */
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* PowerPC BookIII S hardware breakpoint definitions
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17+
*
18+
* Copyright 2010, IBM Corporation.
19+
* Author: K.Prasad <prasad@linux.vnet.ibm.com>
20+
*
21+
*/
22+
23+
#ifndef _PPC_BOOK3S_64_HW_BREAKPOINT_H
24+
#define _PPC_BOOK3S_64_HW_BREAKPOINT_H
25+
26+
#ifdef __KERNEL__
27+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
28+
29+
struct arch_hw_breakpoint {
30+
bool extraneous_interrupt;
31+
u8 len; /* length of the target data symbol */
32+
int type;
33+
unsigned long address;
34+
};
35+
36+
#include <linux/kdebug.h>
37+
#include <asm/reg.h>
38+
#include <asm/system.h>
39+
40+
struct perf_event;
41+
struct pmu;
42+
struct perf_sample_data;
43+
44+
#define HW_BREAKPOINT_ALIGN 0x7
45+
/* Maximum permissible length of any HW Breakpoint */
46+
#define HW_BREAKPOINT_LEN 0x8
47+
48+
extern int hw_breakpoint_slots(int type);
49+
extern int arch_bp_generic_fields(int type, int *gen_bp_type);
50+
extern int arch_check_bp_in_kernelspace(struct perf_event *bp);
51+
extern int arch_validate_hwbkpt_settings(struct perf_event *bp);
52+
extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
53+
unsigned long val, void *data);
54+
int arch_install_hw_breakpoint(struct perf_event *bp);
55+
void arch_uninstall_hw_breakpoint(struct perf_event *bp);
56+
void hw_breakpoint_pmu_read(struct perf_event *bp);
57+
extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
58+
59+
extern struct pmu perf_ops_bp;
60+
extern void ptrace_triggered(struct perf_event *bp, int nmi,
61+
struct perf_sample_data *data, struct pt_regs *regs);
62+
static inline void hw_breakpoint_disable(void)
63+
{
64+
set_dabr(0);
65+
}
66+
extern void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs);
67+
68+
#else /* CONFIG_HAVE_HW_BREAKPOINT */
69+
static inline void hw_breakpoint_disable(void) { }
70+
static inline void thread_change_pc(struct task_struct *tsk,
71+
struct pt_regs *regs) { }
72+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
73+
#endif /* __KERNEL__ */
74+
#endif /* _PPC_BOOK3S_64_HW_BREAKPOINT_H */

arch/powerpc/include/asm/ppc-opcode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@
5252
#define PPC_INST_WAIT 0x7c00007c
5353
#define PPC_INST_TLBIVAX 0x7c000624
5454
#define PPC_INST_TLBSRX_DOT 0x7c0006a5
55+
#define PPC_INST_XXLOR 0xf0000510
5556

5657
/* macros to insert fields into opcodes */
5758
#define __PPC_RA(a) (((a) & 0x1f) << 16)
5859
#define __PPC_RB(b) (((b) & 0x1f) << 11)
5960
#define __PPC_RS(s) (((s) & 0x1f) << 21)
6061
#define __PPC_RT(s) __PPC_RS(s)
62+
#define __PPC_XA(a) ((((a) & 0x1f) << 16) | (((a) & 0x20) >> 3))
63+
#define __PPC_XB(b) ((((b) & 0x1f) << 11) | (((b) & 0x20) >> 4))
6164
#define __PPC_XS(s) ((((s) & 0x1f) << 21) | (((s) & 0x20) >> 5))
65+
#define __PPC_XT(s) __PPC_XS(s)
6266
#define __PPC_T_TLB(t) (((t) & 0x3) << 21)
6367
#define __PPC_WC(w) (((w) & 0x3) << 21)
6468
/*
@@ -106,9 +110,12 @@
106110
* the 128 bit load store instructions based on that.
107111
*/
108112
#define VSX_XX1(s, a, b) (__PPC_XS(s) | __PPC_RA(a) | __PPC_RB(b))
113+
#define VSX_XX3(t, a, b) (__PPC_XT(t) | __PPC_XA(a) | __PPC_XB(b))
109114
#define STXVD2X(s, a, b) stringify_in_c(.long PPC_INST_STXVD2X | \
110115
VSX_XX1((s), (a), (b)))
111116
#define LXVD2X(s, a, b) stringify_in_c(.long PPC_INST_LXVD2X | \
112117
VSX_XX1((s), (a), (b)))
118+
#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \
119+
VSX_XX3((t), (a), (b)))
113120

114121
#endif /* _ASM_POWERPC_PPC_OPCODE_H */

arch/powerpc/include/asm/processor.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ struct thread_struct {
209209
#ifdef CONFIG_PPC64
210210
unsigned long start_tb; /* Start purr when proc switched in */
211211
unsigned long accum_tb; /* Total accumilated purr for process */
212+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
213+
struct perf_event *ptrace_bps[HBP_NUM];
214+
/*
215+
* Helps identify source of single-step exception and subsequent
216+
* hw-breakpoint enablement
217+
*/
218+
struct perf_event *last_hit_ubp;
219+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
212220
#endif
213221
unsigned long dabr; /* Data address breakpoint register */
214222
#ifdef CONFIG_ALTIVEC

arch/powerpc/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ obj-y += vdso32/
3434
obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
3535
signal_64.o ptrace32.o \
3636
paca.o nvram_64.o firmware.o
37+
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
3738
obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o
3839
obj64-$(CONFIG_RELOCATABLE) += reloc_64.o
3940
obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
828828

829829
/* We have a data breakpoint exception - handle it */
830830
handle_dabr_fault:
831+
bl .save_nvgprs
831832
ld r4,_DAR(r1)
832833
ld r5,_DSISR(r1)
833834
addi r3,r1,STACK_FRAME_OVERHEAD

0 commit comments

Comments
 (0)