diff mbox

Work around xstate_size export for kvm-kmod

Message ID 4C6E2DF1.5080301@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zachary Amsden Aug. 20, 2010, 7:25 a.m. UTC
None
diff mbox

Patch

diff --git a/sync b/sync
index c124fc7..b644f4d 100755
--- a/sync
+++ b/sync
@@ -45,6 +45,7 @@  def hack_content(data):
         'set_desc_base set_desc_limit pvclock_vcpu_time_info tboot_enabled '
         'i387_fxsave_struct native_write_msr_safe xsave_struct '
         'fpu_alloc fpu_free fpu_restore_checking fpu_save_init fpu_finit '
+	'xstate_size '
         )
     kvm_init = kvm_exit = False
     mce = False
diff --git a/x86/external-module-compat.h b/x86/external-module-compat.h
index ead5b5a..464d6a8 100644
--- a/x86/external-module-compat.h
+++ b/x86/external-module-compat.h
@@ -883,6 +883,18 @@  union kvm_thread_xstate {
 	struct kvm_xsave_struct xsave;
 };
 
+static inline unsigned int kvm_xstate_size_cache(void)
+{
+	static unsigned int xstate_size = 0;
+	if (!xstate_size) {
+		unsigned int eax, ebx, ecx, edx;
+		cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+        	xstate_size = ebx;
+	}
+	return xstate_size;
+}
+#define kvm_xstate_size kvm_xstate_size_cache()
+
 #else /* >= 2.6.35 */
 
 #define kvm_i387_fxsave_struct	i387_fxsave_struct
@@ -956,6 +968,8 @@  static inline void kvm_fpu_save_init(struct kvm_compat_fpu *fpu)
 #define kvm_fpu_save_init		fpu_save_init
 #define kvm_fpu_finit			fpu_finit
 
+#define kvm_xstate_size			xstate_size
+
 #endif /* >= 2.6.36 */
 
 #ifndef XSTATE_FP