From: Jan Kiszka <[email protected]>

preempt.c already has one, now x86.c need it too. Generalize it and make
it more robust against potential naming conflicts.

Signed-off-by: Jan Kiszka <[email protected]>

diff --git a/sync b/sync
index 8868e6d..da5c218 100755
--- a/sync
+++ b/sync
@@ -133,6 +133,8 @@ def __hack(data):
             line = '\t{ struct page *mapped_page;\n' + sub(r'\);', ', 
&mapped_page);', line)
         if match('nested_svm_unmap(.*);'):
             line = sub(r'\);', ', mapped_page); }', line)
+        if match(r'->thread.debugreg[0-7]'):
+            line = sub(r'->thread.debugreg([0-7])', 
r'->thread.kvm_compat_debugreg(\1)', line)
         w(line)
         if match(r'\tkvm_init_debug'):
             w('\thrtimer_kallsyms_resolve();')
diff --git a/x86/external-module-compat.h b/x86/external-module-compat.h
index 7056aa1..b32e68e 100644
--- a/x86/external-module-compat.h
+++ b/x86/external-module-compat.h
@@ -571,6 +571,12 @@ static inline unsigned long kvm_get_desc_limit(const 
struct kvm_desc_struct *des
 
 #endif
 
+#if !defined(CONFIG_X86_64) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+#define kvm_compat_debugreg(x) debugreg[x]
+#else
+#define kvm_compat_debugreg(x) debugreg##x
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
 
 struct mtrr_var_range {
diff --git a/x86/preempt.c b/x86/preempt.c
index 3112879..440060b 100644
--- a/x86/preempt.c
+++ b/x86/preempt.c
@@ -13,17 +13,11 @@ static LIST_HEAD(pn_list);
                               current->pid, raw_smp_processor_id());   \
        } while (0)
 
-#if !defined(CONFIG_X86_64) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
-#define debugreg(x) debugreg[x]
-#else
-#define debugreg(x) debugreg##x
-#endif
-
 static void preempt_enable_sched_out_notifiers(void)
 {
        asm volatile ("mov %0, %%db0" : : "r"(schedule));
        asm volatile ("mov %0, %%db7" : : "r"(0x701ul));
-       current->thread.debugreg(7) = 0ul;
+       current->thread.kvm_compat_debugreg(7) = 0ul;
 #ifdef TIF_DEBUG
        clear_tsk_thread_flag(current, TIF_DEBUG);
 #endif
@@ -33,8 +27,8 @@ static void preempt_enable_sched_in_notifiers(void * addr)
 {
        asm volatile ("mov %0, %%db0" : : "r"(addr));
        asm volatile ("mov %0, %%db7" : : "r"(0x701ul));
-       current->thread.debugreg(0) = (unsigned long) addr;
-       current->thread.debugreg(7) = 0x701ul;
+       current->thread.kvm_compat_debugreg(0) = (unsigned long) addr;
+       current->thread.kvm_compat_debugreg(7) = 0x701ul;
 #ifdef TIF_DEBUG
        set_tsk_thread_flag(current, TIF_DEBUG);
 #endif
@@ -48,7 +42,7 @@ static void __preempt_disable_notifiers(void)
 static void preempt_disable_notifiers(void)
 {
        __preempt_disable_notifiers();
-       current->thread.debugreg(7) = 0ul;
+       current->thread.kvm_compat_debugreg(7) = 0ul;
 #ifdef TIF_DEBUG
        clear_tsk_thread_flag(current, TIF_DEBUG);
 #endif
@@ -235,7 +229,7 @@ static void do_disable(void *blah)
 #ifdef TIF_DEBUG
        if (!test_tsk_thread_flag(current, TIF_DEBUG))
 #else
-       if (!current->thread.debugreg(7))
+       if (!current->thread.kvm_compat_debugreg(7))
 #endif
                __preempt_disable_notifiers();
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to