rpms/kernel-xen-2.6/devel linux-2.6-xen-sleazy-fpu-i386.patch, NONE, 1.1 linux-2.6-xen-sleazy-fpu-x86_64.patch, NONE, 1.1 kernel-xen.spec, 1.57, 1.58
Eduardo Habkost (ehabkost)
fedora-extras-commits at redhat.com
Thu Sep 20 21:39:15 UTC 2007
Author: ehabkost
Update of /cvs/pkgs/rpms/kernel-xen-2.6/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv16354
Modified Files:
kernel-xen.spec
Added Files:
linux-2.6-xen-sleazy-fpu-i386.patch
linux-2.6-xen-sleazy-fpu-x86_64.patch
Log Message:
Fix sleazy-fpu on i386 and x86_64 under Xen
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)
Index: kernel-xen.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel-xen-2.6/devel/kernel-xen.spec,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- kernel-xen.spec 20 Sep 2007 18:18:24 -0000 1.57
+++ kernel-xen.spec 20 Sep 2007 21:38:43 -0000 1.58
@@ -471,6 +471,10 @@
Patch961: linux-2.6-xen-backwards-time.patch
Patch962: linux-2.6-xen-irq_vector-uninitialize.patch
+# Fix sleazy-FPU implementation
+Patch963: linux-2.6-xen-sleazy-fpu-i386.patch
+Patch964: linux-2.6-xen-sleazy-fpu-x86_64.patch
+
#
# Patches 1000 to 5000 are reserved for bugfixes to drivers and filesystems
#
@@ -963,6 +967,8 @@
%patch960 -p1
%patch961 -p1
%patch962 -p1
+%patch963 -p1
+%patch964 -p1
%endif
@@ -2376,6 +2382,10 @@
%changelog
* Thu Sep 20 2007 Eduardo Habkost <ehabkost at redhat.com>
+- Fix sleazy-fpu implementation to actually avoid on fpu-intensive
+ programs
+
+* Thu Sep 20 2007 Eduardo Habkost <ehabkost at redhat.com>
- Add fix for bug #294011 (floating point corruption)
(changeset 8c24767501ff from Xen 3.1.1)
More information about the fedora-extras-commits
mailing list