diff options
Diffstat (limited to 'arch/x86/include/asm/debugreg.h')
-rw-r--r-- | arch/x86/include/asm/debugreg.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h index b903d5ea3941..2d91580bf228 100644 --- a/arch/x86/include/asm/debugreg.h +++ b/arch/x86/include/asm/debugreg.h | |||
@@ -78,8 +78,75 @@ | |||
78 | */ | 78 | */ |
79 | #ifdef __KERNEL__ | 79 | #ifdef __KERNEL__ |
80 | 80 | ||
81 | #include <linux/bug.h> | ||
82 | |||
81 | DECLARE_PER_CPU(unsigned long, cpu_dr7); | 83 | DECLARE_PER_CPU(unsigned long, cpu_dr7); |
82 | 84 | ||
85 | #ifndef CONFIG_PARAVIRT | ||
86 | /* | ||
87 | * These special macros can be used to get or set a debugging register | ||
88 | */ | ||
89 | #define get_debugreg(var, register) \ | ||
90 | (var) = native_get_debugreg(register) | ||
91 | #define set_debugreg(value, register) \ | ||
92 | native_set_debugreg(register, value) | ||
93 | #endif | ||
94 | |||
95 | static inline unsigned long native_get_debugreg(int regno) | ||
96 | { | ||
97 | unsigned long val = 0; /* Damn you, gcc! */ | ||
98 | |||
99 | switch (regno) { | ||
100 | case 0: | ||
101 | asm("mov %%db0, %0" :"=r" (val)); | ||
102 | break; | ||
103 | case 1: | ||
104 | asm("mov %%db1, %0" :"=r" (val)); | ||
105 | break; | ||
106 | case 2: | ||
107 | asm("mov %%db2, %0" :"=r" (val)); | ||
108 | break; | ||
109 | case 3: | ||
110 | asm("mov %%db3, %0" :"=r" (val)); | ||
111 | break; | ||
112 | case 6: | ||
113 | asm("mov %%db6, %0" :"=r" (val)); | ||
114 | break; | ||
115 | case 7: | ||
116 | asm("mov %%db7, %0" :"=r" (val)); | ||
117 | break; | ||
118 | default: | ||
119 | BUG(); | ||
120 | } | ||
121 | return val; | ||
122 | } | ||
123 | |||
124 | static inline void native_set_debugreg(int regno, unsigned long value) | ||
125 | { | ||
126 | switch (regno) { | ||
127 | case 0: | ||
128 | asm("mov %0, %%db0" ::"r" (value)); | ||
129 | break; | ||
130 | case 1: | ||
131 | asm("mov %0, %%db1" ::"r" (value)); | ||
132 | break; | ||
133 | case 2: | ||
134 | asm("mov %0, %%db2" ::"r" (value)); | ||
135 | break; | ||
136 | case 3: | ||
137 | asm("mov %0, %%db3" ::"r" (value)); | ||
138 | break; | ||
139 | case 6: | ||
140 | asm("mov %0, %%db6" ::"r" (value)); | ||
141 | break; | ||
142 | case 7: | ||
143 | asm("mov %0, %%db7" ::"r" (value)); | ||
144 | break; | ||
145 | default: | ||
146 | BUG(); | ||
147 | } | ||
148 | } | ||
149 | |||
83 | static inline void hw_breakpoint_disable(void) | 150 | static inline void hw_breakpoint_disable(void) |
84 | { | 151 | { |
85 | /* Zero the control register for HW Breakpoint */ | 152 | /* Zero the control register for HW Breakpoint */ |