]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86: relocate get/set debugreg fcns to include/asm/debugreg.
authorPaul Gortmaker <paul.gortmaker@windriver.com>
Fri, 20 Jan 2012 21:24:09 +0000 (16:24 -0500)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Tue, 28 Feb 2012 22:48:04 +0000 (17:48 -0500)
Since we already have a debugreg.h header file, move the
assoc. get/set functions to it.  In addition to it being the
logical home for them, it has a secondary advantage.  The
functions that are moved use BUG().  So we really need to
have linux/bug.h in scope.  But asm/processor.h is used about
600 times, vs. only about 15 for debugreg.h -- so adding bug.h
to the latter reduces the amount of time we'll be processing
it during a compile.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
arch/x86/include/asm/debugreg.h
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c

index b903d5ea394111edc965c351103953a62b5357a6..2d91580bf2288d46076a5a22beb96895ee31836d 100644 (file)
  */
 #ifdef __KERNEL__
 
+#include <linux/bug.h>
+
 DECLARE_PER_CPU(unsigned long, cpu_dr7);
 
+#ifndef CONFIG_PARAVIRT
+/*
+ * These special macros can be used to get or set a debugging register
+ */
+#define get_debugreg(var, register)                            \
+       (var) = native_get_debugreg(register)
+#define set_debugreg(value, register)                          \
+       native_set_debugreg(register, value)
+#endif
+
+static inline unsigned long native_get_debugreg(int regno)
+{
+       unsigned long val = 0;  /* Damn you, gcc! */
+
+       switch (regno) {
+       case 0:
+               asm("mov %%db0, %0" :"=r" (val));
+               break;
+       case 1:
+               asm("mov %%db1, %0" :"=r" (val));
+               break;
+       case 2:
+               asm("mov %%db2, %0" :"=r" (val));
+               break;
+       case 3:
+               asm("mov %%db3, %0" :"=r" (val));
+               break;
+       case 6:
+               asm("mov %%db6, %0" :"=r" (val));
+               break;
+       case 7:
+               asm("mov %%db7, %0" :"=r" (val));
+               break;
+       default:
+               BUG();
+       }
+       return val;
+}
+
+static inline void native_set_debugreg(int regno, unsigned long value)
+{
+       switch (regno) {
+       case 0:
+               asm("mov %0, %%db0"     ::"r" (value));
+               break;
+       case 1:
+               asm("mov %0, %%db1"     ::"r" (value));
+               break;
+       case 2:
+               asm("mov %0, %%db2"     ::"r" (value));
+               break;
+       case 3:
+               asm("mov %0, %%db3"     ::"r" (value));
+               break;
+       case 6:
+               asm("mov %0, %%db6"     ::"r" (value));
+               break;
+       case 7:
+               asm("mov %0, %%db7"     ::"r" (value));
+               break;
+       default:
+               BUG();
+       }
+}
+
 static inline void hw_breakpoint_disable(void)
 {
        /* Zero the control register for HW Breakpoint */
index 58545c97d071c84dba4a05b59bad7be5d0b69b01..30aa6e95f8147f86f9c5ee4adbe78977605b332e 100644 (file)
@@ -474,61 +474,6 @@ struct thread_struct {
        unsigned                io_bitmap_max;
 };
 
-static inline unsigned long native_get_debugreg(int regno)
-{
-       unsigned long val = 0;  /* Damn you, gcc! */
-
-       switch (regno) {
-       case 0:
-               asm("mov %%db0, %0" :"=r" (val));
-               break;
-       case 1:
-               asm("mov %%db1, %0" :"=r" (val));
-               break;
-       case 2:
-               asm("mov %%db2, %0" :"=r" (val));
-               break;
-       case 3:
-               asm("mov %%db3, %0" :"=r" (val));
-               break;
-       case 6:
-               asm("mov %%db6, %0" :"=r" (val));
-               break;
-       case 7:
-               asm("mov %%db7, %0" :"=r" (val));
-               break;
-       default:
-               BUG();
-       }
-       return val;
-}
-
-static inline void native_set_debugreg(int regno, unsigned long value)
-{
-       switch (regno) {
-       case 0:
-               asm("mov %0, %%db0"     ::"r" (value));
-               break;
-       case 1:
-               asm("mov %0, %%db1"     ::"r" (value));
-               break;
-       case 2:
-               asm("mov %0, %%db2"     ::"r" (value));
-               break;
-       case 3:
-               asm("mov %0, %%db3"     ::"r" (value));
-               break;
-       case 6:
-               asm("mov %0, %%db6"     ::"r" (value));
-               break;
-       case 7:
-               asm("mov %0, %%db7"     ::"r" (value));
-               break;
-       default:
-               BUG();
-       }
-}
-
 /*
  * Set IOPL bits in EFLAGS from given mask
  */
@@ -574,14 +519,6 @@ static inline void native_swapgs(void)
 #define __cpuid                        native_cpuid
 #define paravirt_enabled()     0
 
-/*
- * These special macros can be used to get or set a debugging register
- */
-#define get_debugreg(var, register)                            \
-       (var) = native_get_debugreg(register)
-#define set_debugreg(value, register)                          \
-       native_set_debugreg(register, value)
-
 static inline void load_sp0(struct tss_struct *tss,
                            struct thread_struct *thread)
 {
index c0f7d68d318f1b7a8a6a27f798250b53c778d50f..0d676dd923ac20a4180114b17de5fdcdd4693ba1 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/archrandom.h>
 #include <asm/hypervisor.h>
 #include <asm/processor.h>
+#include <asm/debugreg.h>
 #include <asm/sections.h>
 #include <linux/topology.h>
 #include <linux/cpumask.h>