xref: /linux/arch/s390/include/asm/perf_event.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Performance event support - s390 specific definitions.
4  *
5  * Copyright IBM Corp. 2009, 2017
6  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7  *	      Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
8  */
9 
10 #ifndef _ASM_S390_PERF_EVENT_H
11 #define _ASM_S390_PERF_EVENT_H
12 
13 #include <linux/perf_event.h>
14 #include <linux/device.h>
15 #include <asm/stacktrace.h>
16 
17 /* Per-CPU flags for PMU states */
18 #define PMU_F_RESERVED			0x1000
19 #define PMU_F_ENABLED			0x2000
20 #define PMU_F_IN_USE			0x4000
21 #define PMU_F_ERR_IBE			0x0100
22 #define PMU_F_ERR_LSDA			0x0200
23 #define PMU_F_ERR_MASK			(PMU_F_ERR_IBE|PMU_F_ERR_LSDA)
24 
25 /* Perf definitions for PMU event attributes in sysfs */
26 extern __init const struct attribute_group **cpumf_cf_event_group(void);
27 extern ssize_t cpumf_events_sysfs_show(struct device *dev,
28 				       struct device_attribute *attr,
29 				       char *page);
30 #define EVENT_VAR(_cat, _name)		event_attr_##_cat##_##_name
31 #define EVENT_PTR(_cat, _name)		(&EVENT_VAR(_cat, _name).attr.attr)
32 
33 #define CPUMF_EVENT_ATTR(cat, name, id)			\
34 	PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show)
35 #define CPUMF_EVENT_PTR(cat, name)	EVENT_PTR(cat, name)
36 
37 
38 /* Perf callbacks */
39 struct pt_regs;
40 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
41 extern unsigned long perf_misc_flags(struct pt_regs *regs);
42 #define perf_misc_flags(regs) perf_misc_flags(regs)
43 #define perf_arch_bpf_user_pt_regs(regs) &regs->user_regs
44 
45 /* Perf pt_regs extension for sample-data-entry indicators */
46 struct perf_sf_sde_regs {
47 	unsigned char in_guest:1;	  /* guest sample */
48 	unsigned long reserved:63;	  /* reserved */
49 };
50 
51 #define perf_arch_fetch_caller_regs(regs, __ip) do {			\
52 	(regs)->psw.mask = 0;						\
53 	(regs)->psw.addr = (__ip);					\
54 	(regs)->gprs[15] = (unsigned long)__builtin_frame_address(0) -	\
55 		offsetof(struct stack_frame, back_chain);		\
56 } while (0)
57 
58 #endif /* _ASM_S390_PERF_EVENT_H */
59