Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
perf_regs.c
Go to the documentation of this file.
1 #include <linux/errno.h>
2 #include <linux/kernel.h>
3 #include <linux/sched.h>
4 #include <linux/perf_event.h>
5 #include <linux/bug.h>
6 #include <linux/stddef.h>
7 #include <asm/perf_regs.h>
8 #include <asm/ptrace.h>
9 
10 #ifdef CONFIG_X86_32
11 #define PERF_REG_X86_MAX PERF_REG_X86_32_MAX
12 #else
13 #define PERF_REG_X86_MAX PERF_REG_X86_64_MAX
14 #endif
15 
16 #define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)
17 
18 static unsigned int pt_regs_offset[PERF_REG_X86_MAX] = {
31 #ifdef CONFIG_X86_32
36 #else
37  /*
38  * The pt_regs struct does not store
39  * ds, es, fs, gs in 64 bit mode.
40  */
41  (unsigned int) -1,
42  (unsigned int) -1,
43  (unsigned int) -1,
44  (unsigned int) -1,
45 #endif
46 #ifdef CONFIG_X86_64
55 #endif
56 };
57 
59 {
61  return 0;
62 
63  return regs_get_register(regs, pt_regs_offset[idx]);
64 }
65 
66 #define REG_RESERVED (~((1ULL << PERF_REG_X86_MAX) - 1ULL))
67 
68 #ifdef CONFIG_X86_32
70 {
71  if (!mask || mask & REG_RESERVED)
72  return -EINVAL;
73 
74  return 0;
75 }
76 
78 {
80 }
81 #else /* CONFIG_X86_64 */
82 #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
83  (1ULL << PERF_REG_X86_ES) | \
84  (1ULL << PERF_REG_X86_FS) | \
85  (1ULL << PERF_REG_X86_GS))
86 
88 {
89  if (!mask || mask & REG_RESERVED)
90  return -EINVAL;
91 
92  if (mask & REG_NOSUPPORT)
93  return -EINVAL;
94 
95  return 0;
96 }
97 
99 {
100  if (test_tsk_thread_flag(task, TIF_IA32))
102  else
104 }
105 #endif /* CONFIG_X86_32 */