From: Avi Kivity <[EMAIL PROTECTED]>

This gives better traces when something goes wrong.

Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/kernel/Kbuild b/kernel/Kbuild
index e3e97ab..cabfc75 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,11 +1,11 @@
 EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h
 obj-m := kvm.o kvm-intel.o kvm-amd.o
 kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o i8259.o \
-        lapic.o ioapic.o preempt.o i8254.o
+        lapic.o ioapic.o preempt.o i8254.o external-module-compat.o
 ifeq ($(CONFIG_KVM_TRACE),y)
 kvm-objs += kvm_trace.o
 endif
-kvm-intel-objs := vmx.o vmx-debug.o
-kvm-amd-objs := svm.o
+kvm-intel-objs := vmx.o vmx-debug.o external-module-compat.o
+kvm-amd-objs := svm.o external-module-compat.o
 
 CFLAGS_kvm_main.o = -DKVM_MAIN
diff --git a/kernel/external-module-compat.c b/kernel/external-module-compat.c
new file mode 100644
index 0000000..7b0b983
--- /dev/null
+++ b/kernel/external-module-compat.c
@@ -0,0 +1,79 @@
+
+/*
+ * smp_call_function_single() is not exported below 2.6.20.
+ */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+
+#undef smp_call_function_single
+
+#include <linux/spinlock.h>
+#include <linux/smp.h>
+
+struct scfs_thunk_info {
+       int cpu;
+       void (*func)(void *info);
+       void *info;
+};
+
+static void scfs_thunk(void *_thunk)
+{
+       struct scfs_thunk_info *thunk = _thunk;
+
+       if (raw_smp_processor_id() == thunk->cpu)
+               thunk->func(thunk->info);
+}
+
+int kvm_smp_call_function_single(int cpu, void (*func)(void *info),
+                                void *info, int nonatomic, int wait)
+{
+       int r, this_cpu;
+       struct scfs_thunk_info thunk;
+
+       this_cpu = get_cpu();
+       if (cpu == this_cpu) {
+               r = 0;
+               local_irq_disable();
+               func(info);
+               local_irq_enable();
+       } else {
+               thunk.cpu = cpu;
+               thunk.func = func;
+               thunk.info = info;
+               r = smp_call_function(scfs_thunk, &thunk, 0, 1);
+       }
+       put_cpu();
+       return r;
+}
+
+#define smp_call_function_single kvm_smp_call_function_single
+
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+/*
+ * pre 2.6.23 doesn't handle smp_call_function_single on current cpu
+ */
+
+#undef smp_call_function_single
+
+#include <linux/smp.h>
+
+int kvm_smp_call_function_single(int cpu, void (*func)(void *info),
+                                void *info, int nonatomic, int wait)
+{
+       int this_cpu, r;
+
+       this_cpu = get_cpu();
+       if (cpu == this_cpu) {
+               r = 0;
+               local_irq_disable();
+               func(info);
+               local_irq_enable();
+       } else
+               r = smp_call_function_single(cpu, func, info, nonatomic, wait);
+       put_cpu();
+       return r;
+}
+
+#define smp_call_function_single kvm_smp_call_function_single
+
+#endif
diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h
index 5fc2479..acc7a03 100644
--- a/kernel/external-module-compat.h
+++ b/kernel/external-module-compat.h
@@ -39,76 +39,15 @@
 #endif
 
 /*
- * smp_call_function_single() is not exported below 2.6.20
+ * smp_call_function_single() is not exported below 2.6.20, and has different
+ * semantics below 2.6.23.
  */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-
-#include <linux/spinlock.h>
-#include <linux/smp.h>
-
-struct scfs_thunk_info {
-       int cpu;
-       void (*func)(void *info);
-       void *info;
-};
-
-static inline void scfs_thunk(void *_thunk)
-{
-       struct scfs_thunk_info *thunk = _thunk;
-
-       if (raw_smp_processor_id() == thunk->cpu)
-               thunk->func(thunk->info);
-}
-
-static inline int smp_call_function_single1(int cpu, void (*func)(void *info),
-                                          void *info, int nonatomic, int wait)
-{
-       int r, this_cpu;
-       struct scfs_thunk_info thunk;
-
-       this_cpu = get_cpu();
-       if (cpu == this_cpu) {
-               r = 0;
-               local_irq_disable();
-               func(info);
-               local_irq_enable();
-       } else {
-               thunk.cpu = cpu;
-               thunk.func = func;
-               thunk.info = info;
-               r = smp_call_function(scfs_thunk, &thunk, 0, 1);
-       }
-       put_cpu();
-       return r;
-}
-
-#define smp_call_function_single smp_call_function_single1
-
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-/*
- * pre 2.6.23 doesn't handle smp_call_function_single on current cpu
- */
-
-#include <linux/smp.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
 
-static inline int smp_call_function_single2(int cpu, void (*func)(void *info),
-                                           void *info, int nonatomic, int wait)
-{
-       int this_cpu, r;
-
-       this_cpu = get_cpu();
-       if (cpu == this_cpu) {
-               r = 0;
-               local_irq_disable();
-               func(info);
-               local_irq_enable();
-       } else
-               r = smp_call_function_single(cpu, func, info, nonatomic, wait);
-       put_cpu();
-       return r;
-}
+int kvm_smp_call_function_single(int cpu, void (*func)(void *info),
+                                void *info, int nonatomic, int wait);
 
-#define smp_call_function_single smp_call_function_single2
+#define smp_call_function_single kvm_smp_call_function_single
 
 #endif
 

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to