rpms/kernel-xen-2.6/F-7 linux-2.6-xen-sleazy-fpu-i386.patch, NONE, 1.1 linux-2.6-xen-sleazy-fpu-x86_64.patch, NONE, 1.1 xen-vmx-fpu-ts-fix.patch, NONE, 1.1 kernel-xen.spec, 1.47, 1.48

Eduardo Habkost (ehabkost) fedora-extras-commits at redhat.com
Fri Sep 21 15:14:14 UTC 2007


Author: ehabkost

Update of /cvs/pkgs/rpms/kernel-xen-2.6/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11474

Modified Files:
	kernel-xen.spec 
Added Files:
	linux-2.6-xen-sleazy-fpu-i386.patch 
	linux-2.6-xen-sleazy-fpu-x86_64.patch xen-vmx-fpu-ts-fix.patch 
Log Message:
Floating point fixes

- Fix for bug #294011 (floating point corruption)
  (changeset 8c24767501ff from Xen 3.1.1)
- Fix sleazy-fpu implementation to actually avoid on fpu-intensive
  programs



linux-2.6-xen-sleazy-fpu-i386.patch:

--- NEW FILE linux-2.6-xen-sleazy-fpu-i386.patch ---
# HG changeset patch
# User "Eduardo Habkost <ehabkost at redhat.com>"
# Date 1190313016 10800
# Node ID 8792a16b6dd531cad0ed28d9bef86e3e597ea8db
# Parent  35983eae211a531bd50bcd177a9da77d48631e2c
Fix sleazy-fpu under Xen

- Make it reset fpu_counter when needed (like __unlazy_fpu() does)
- Make it call clts() before restoring the fpu state during task switch
  (clts() will still not be called during the device_not_available trap,
  because it is not needed under Xen)

diff -r 35983eae211a -r 8792a16b6dd5 arch/i386/kernel/entry-xen.S
--- a/arch/i386/kernel/entry-xen.S	Wed Aug 08 16:15:30 2007 -0300
+++ b/arch/i386/kernel/entry-xen.S	Thu Sep 20 15:30:16 2007 -0300
@@ -950,7 +950,9 @@ device_available_emulate:
 device_available_emulate:
 #endif
 	preempt_stop(CLBR_ANY)
-	call math_state_restore
+	# 'clts' is done by Xen during virtual trap, so we can call
+	# __math_state_restore instead of math_state_restore
+	call __math_state_restore
 	jmp ret_from_exception
 	CFI_ENDPROC
 
diff -r 35983eae211a -r 8792a16b6dd5 arch/i386/kernel/process-xen.c
--- a/arch/i386/kernel/process-xen.c	Wed Aug 08 16:15:30 2007 -0300
+++ b/arch/i386/kernel/process-xen.c	Thu Sep 20 15:30:16 2007 -0300
@@ -597,7 +597,9 @@ struct task_struct fastcall * __switch_t
 		mcl->op      = __HYPERVISOR_fpu_taskswitch;
 		mcl->args[0] = 1;
 		mcl++;
-	}
+	} else
+		prev_p->fpu_counter = 0;
+
 #if 0 /* lazy fpu sanity check */
 	else BUG_ON(!(read_cr0() & 8));
 #endif
diff -r 35983eae211a -r 8792a16b6dd5 arch/i386/kernel/traps-xen.c
--- a/arch/i386/kernel/traps-xen.c	Wed Aug 08 16:15:30 2007 -0300
+++ b/arch/i386/kernel/traps-xen.c	Thu Sep 20 15:30:16 2007 -0300
@@ -1012,17 +1012,22 @@ fastcall unsigned long patch_espfix_desc
  * Must be called with kernel preemption disabled (in this case,
  * local interrupts are disabled at the call-site in entry.S).
  */
-asmlinkage void math_state_restore(void)
+asmlinkage void __math_state_restore(void)
 {
 	struct thread_info *thread = current_thread_info();
 	struct task_struct *tsk = thread->task;
 
-	/* NB. 'clts' is done for us by Xen during virtual trap. */
 	if (!tsk_used_math(tsk))
 		init_fpu(tsk);
 	restore_fpu(tsk);
 	thread->status |= TS_USEDFPU;	/* So we fnsave on switch_to() */
 	tsk->fpu_counter++;
+}
+
+asmlinkage void math_state_restore(void)
+{
+	clts();		/* Allow maths ops (or we recurse) */
+	__math_state_restore();
 }
 
 #ifndef CONFIG_MATH_EMULATION
diff -r 35983eae211a -r 8792a16b6dd5 arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c	Wed Aug 08 16:15:30 2007 -0300
+++ b/arch/i386/kernel/traps.c	Thu Sep 20 15:30:16 2007 -0300
@@ -1041,17 +1041,22 @@ fastcall unsigned long patch_espfix_desc
  * Must be called with kernel preemption disabled (in this case,
  * local interrupts are disabled at the call-site in entry.S).
  */
-asmlinkage void math_state_restore(void)
+asmlinkage void __math_state_restore(void)
 {
 	struct thread_info *thread = current_thread_info();
 	struct task_struct *tsk = thread->task;
 
-	clts();		/* Allow maths ops (or we recurse) */
 	if (!tsk_used_math(tsk))
 		init_fpu(tsk);
 	restore_fpu(tsk);
 	thread->status |= TS_USEDFPU;	/* So we fnsave on switch_to() */
 	tsk->fpu_counter++;
+}
+
+asmlinkage void math_state_restore(void)
+{
+	clts();		/* Allow maths ops (or we recurse) */
+	__math_state_restore();
 }
 
 #ifndef CONFIG_MATH_EMULATION

linux-2.6-xen-sleazy-fpu-x86_64.patch:

--- NEW FILE linux-2.6-xen-sleazy-fpu-x86_64.patch ---
# HG changeset patch
# User "Eduardo Habkost <ehabkost at redhat.com>"
# Date 1190317568 10800
# Node ID ab958de6e67d1b4f6c321cd46d2793d2409b91fd
# Parent  8792a16b6dd531cad0ed28d9bef86e3e597ea8db
x86_64: Fix sleazy-fpu under Xen

- Make it reset fpu_counter when needed (like __unlazy_fpu() does)
- Make it call clts() before restoring the fpu state during task switch
  (clts() will still not be called during the device_not_available trap,
  because it is not needed under Xen)

diff -r 8792a16b6dd5 -r ab958de6e67d arch/x86_64/kernel/entry-xen.S
--- a/arch/x86_64/kernel/entry-xen.S	Thu Sep 20 15:30:16 2007 -0300
+++ b/arch/x86_64/kernel/entry-xen.S	Thu Sep 20 16:46:08 2007 -0300
@@ -1071,7 +1071,9 @@ END(simd_coprocessor_error)
 END(simd_coprocessor_error)
 
 ENTRY(device_not_available)
-	zeroentry math_state_restore
+	# 'clts' is done by Xen during virtual trap, so we can call
+	# __math_state_restore instead of math_state_restore
+	zeroentry __math_state_restore
 END(device_not_available)
 
 	/* runs on exception stack */
diff -r 8792a16b6dd5 -r ab958de6e67d arch/x86_64/kernel/process-xen.c
--- a/arch/x86_64/kernel/process-xen.c	Thu Sep 20 15:30:16 2007 -0300
+++ b/arch/x86_64/kernel/process-xen.c	Thu Sep 20 16:46:08 2007 -0300
@@ -637,7 +637,8 @@ __switch_to(struct task_struct *prev_p, 
 	if (prev_p->thread_info->status & TS_USEDFPU) {
 		__save_init_fpu(prev_p); /* _not_ save_init_fpu() */
 		HYPERVISOR_fpu_taskswitch(1);
-	}
+	} else
+		prev_p->fpu_counter = 0;
 
 	/* 
 	 * Switch the PDA context.
diff -r 8792a16b6dd5 -r ab958de6e67d arch/x86_64/kernel/traps-xen.c
--- a/arch/x86_64/kernel/traps-xen.c	Thu Sep 20 15:30:16 2007 -0300
+++ b/arch/x86_64/kernel/traps-xen.c	Thu Sep 20 16:46:08 2007 -0300
@@ -1064,16 +1064,21 @@ asmlinkage void __attribute__((weak)) mc
  * Careful.. There are problems with IBM-designed IRQ13 behaviour.
  * Don't touch unless you *really* know how it works.
  */
-asmlinkage void math_state_restore(void)
+asmlinkage void __math_state_restore(void)
 {
 	struct task_struct *me = current;
-        /* clts(); */ /* 'clts' is done for us by Xen during virtual trap. */
 
 	if (!used_math())
 		init_fpu(me);
 	restore_fpu_checking(&me->thread.i387.fxsave);
 	task_thread_info(me)->status |= TS_USEDFPU;
 	me->fpu_counter++;
+}
+
+asmlinkage void math_state_restore(void)
+{
+	clts();			/* Allow maths ops (or we recurse) */
+	__math_state_restore();
 }
 
 
diff -r 8792a16b6dd5 -r ab958de6e67d arch/x86_64/kernel/traps.c
--- a/arch/x86_64/kernel/traps.c	Thu Sep 20 15:30:16 2007 -0300
+++ b/arch/x86_64/kernel/traps.c	Thu Sep 20 16:46:08 2007 -0300
@@ -1056,16 +1056,21 @@ asmlinkage void __attribute__((weak)) mc
  * Careful.. There are problems with IBM-designed IRQ13 behaviour.
  * Don't touch unless you *really* know how it works.
  */
-asmlinkage void math_state_restore(void)
+asmlinkage void __math_state_restore(void)
 {
 	struct task_struct *me = current;
-	clts();			/* Allow maths ops (or we recurse) */
 
 	if (!used_math())
 		init_fpu(me);
 	restore_fpu_checking(&me->thread.i387.fxsave);
 	task_thread_info(me)->status |= TS_USEDFPU;
 	me->fpu_counter++;
+}
+
+asmlinkage void math_state_restore(void)
+{
+	clts();			/* Allow maths ops (or we recurse) */
+	__math_state_restore();
 }
 
 void __init trap_init(void)

xen-vmx-fpu-ts-fix.patch:

--- NEW FILE xen-vmx-fpu-ts-fix.patch ---
# HG changeset patch
# User Steven Hand <steven at xensource.com>
# Date 1189784017 -3600
# Node ID 8c24767501ff25f28a0dab638116b560de294da7
# Parent  eec47edb2a25fde7075e2e17dee638216d2e5582
Ensure CR0.TS is set for VMX domains regardless of the current
state of the real TS bit. This fixes a number of subtle FP
corruption issues within PV domains when running alongside VMX ones.

Signed-off-by: Steven Hand <steven at xensource.com>
xen-unstable changeset: 15216:6f13c3be08fa4c044868144672783f7b1341999a
xen-unstable date: Mon Jun 04 16:47:48 2007 +0100

diff -r eec47edb2a25 -r 8c24767501ff xen/arch/x86/hvm/vmx/vmcs.c
--- xen/arch/x86/hvm/vmx/vmcs.c	Fri Sep 14 16:33:37 2007 +0100
+++ xen/arch/x86/hvm/vmx/vmcs.c	Fri Sep 14 16:33:37 2007 +0100
@@ -338,7 +338,7 @@ static void construct_vmcs(struct vcpu *
 #endif
 
     /* Host control registers. */
-    __vmwrite(HOST_CR0, read_cr0());
+    __vmwrite(HOST_CR0, read_cr0() | X86_CR0_TS);
     __vmwrite(HOST_CR4, read_cr4());
 
     /* Host CS:RIP. */


Index: kernel-xen.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/F-7/kernel-xen.spec,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- kernel-xen.spec	13 Sep 2007 19:57:59 -0000	1.47
+++ kernel-xen.spec	21 Sep 2007 15:13:42 -0000	1.48
@@ -408,6 +408,11 @@
 Patch963: linux-2.6-xen-add-packet_auxdata-cmsg-2.patch
 Patch964: linux-2.6-xen-af_packet-no-skb_checksum_setup.patch
 
+# Fix sleazy-FPU implementation
+Patch965: linux-2.6-xen-sleazy-fpu-i386.patch
+Patch966: linux-2.6-xen-sleazy-fpu-x86_64.patch
+
+
 
 #
 # Patches 1000 to 5000 are reserved for bugfixes to drivers and filesystems
@@ -522,6 +527,12 @@
 # Fix graphical boot (e.g. F7 DVD booting) under Full Virtualization
 Patch20002: xen-vpic-irqbase-mode.patch
 
+# Fix bz#294011: floating point corruption issues
+# changeset 8c24767501ff from Xen 3.1.1
+Patch20003: xen-vmx-fpu-ts-fix.patch
+
+
+
 # END OF PATCH DEFINITIONS
 
 BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root-%{_target_cpu}
@@ -939,6 +950,8 @@
 %patch962 -p1
 %patch963 -p1
 %patch964 -p1
+%patch965 -p1
+%patch966 -p1
 %endif
 
 #
@@ -1168,6 +1181,7 @@
 %patch20000 -p1
 %patch20001 -p1
 %patch20002 -p1
+%patch20003 -p1
 
 # Update the Makefile version strings
 sed -i -e 's/\(^export XEN_BUILDER.*$\)/\1'%{?dist}'/' Makefile
@@ -2058,6 +2072,12 @@
 #  - tux.
 
 %changelog
+* Fri Sep 21 2007 Eduardo Habkost <ehabkost at redhat.com>
+- Add fix for bug #294011 (floating point corruption)
+  (changeset 8c24767501ff from Xen 3.1.1)
+- Fix sleazy-fpu implementation to actually avoid on fpu-intensive
+  programs
+
 * Thu Sep 13 2007 Eduardo Habkost <ehabkost at redhat.com>
 - Hypervisor-side of fix for bug #248398: HVM domain hangs during (F-7)
   install. Backport of fix from xen-unstable: 15239:656b8175f4f2.




More information about the scm-commits mailing list