ia64/xen-unstable

changeset 17:8d92e87aa174

bitkeeper revision 1.7.1.6 (3df08cc8US1aforRcF-D7KIyM9F8Bw)

traps.c, setup.c, i387.c:
Fix floating-point ctxt-switch code
author kaf24@labyrinth.cl.cam.ac.uk
date Fri Dec 06 11:40:56 2002 +0000 (2002-12-06)
parents 9011ca198220
children 78ce779f901c 1a7b9ea4cb94
files BitKeeper/etc/logging_ok xen-2.4.16/arch/i386/i387.c xen-2.4.16/arch/i386/setup.c xen-2.4.16/arch/i386/traps.c
line diff
     1.1 --- a/BitKeeper/etc/logging_ok	Thu Dec 05 14:14:44 2002 +0000
     1.2 +++ b/BitKeeper/etc/logging_ok	Fri Dec 06 11:40:56 2002 +0000
     1.3 @@ -1,4 +1,5 @@
     1.4  akw27@boulderdash.cl.cam.ac.uk
     1.5 +kaf24@labyrinth.cl.cam.ac.uk
     1.6  kaf24@plym.cl.cam.ac.uk
     1.7  kaf24@striker.cl.cam.ac.uk
     1.8  smh22@boulderdash.cl.cam.ac.uk
     2.1 --- a/xen-2.4.16/arch/i386/i387.c	Thu Dec 05 14:14:44 2002 +0000
     2.2 +++ b/xen-2.4.16/arch/i386/i387.c	Fri Dec 06 11:40:56 2002 +0000
     2.3 @@ -22,20 +22,26 @@ void init_fpu(void)
     2.4  
     2.5  static inline void __save_init_fpu( struct task_struct *tsk )
     2.6  {
     2.7 -	if ( cpu_has_fxsr ) {
     2.8 -		asm volatile( "fxsave %0 ; fnclex"
     2.9 -			      : "=m" (tsk->thread.i387.fxsave) );
    2.10 -	} else {
    2.11 -		asm volatile( "fnsave %0 ; fwait"
    2.12 -			      : "=m" (tsk->thread.i387.fsave) );
    2.13 -	}
    2.14 -	tsk->flags &= ~PF_USEDFPU;
    2.15 +    if ( cpu_has_fxsr ) {
    2.16 +        asm volatile( "fxsave %0 ; fnclex"
    2.17 +                      : "=m" (tsk->thread.i387.fxsave) );
    2.18 +    } else {
    2.19 +        asm volatile( "fnsave %0 ; fwait"
    2.20 +                      : "=m" (tsk->thread.i387.fsave) );
    2.21 +    }
    2.22 +    tsk->flags &= ~PF_USEDFPU;
    2.23  }
    2.24  
    2.25  void save_init_fpu( struct task_struct *tsk )
    2.26  {
    2.27 -	__save_init_fpu(tsk);
    2.28 -	stts();
    2.29 +    /*
    2.30 +     * The guest OS may have set the 'virtual STTS' flag.
    2.31 +     * This causes us to set the real flag, so we'll need
    2.32 +     * to temporarily clear it while saving f-p state.
    2.33 +     */
    2.34 +    if ( tsk->flags & PF_GUEST_STTS ) clts();
    2.35 +    __save_init_fpu(tsk);
    2.36 +    stts();
    2.37  }
    2.38  
    2.39  void restore_fpu( struct task_struct *tsk )
     3.1 --- a/xen-2.4.16/arch/i386/setup.c	Thu Dec 05 14:14:44 2002 +0000
     3.2 +++ b/xen-2.4.16/arch/i386/setup.c	Fri Dec 06 11:40:56 2002 +0000
     3.3 @@ -193,6 +193,9 @@ void __init cpu_init(void)
     3.4      /* No nested task. */
     3.5      __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl");
     3.6  
     3.7 +    /* Ensure FPU gets initialised for each domain. */
     3.8 +    stts();
     3.9 +
    3.10      /* Set up and load the per-CPU TSS and LDT. */
    3.11      t->ss0  = __HYPERVISOR_DS;
    3.12      t->esp0 = current->thread.esp0;
     4.1 --- a/xen-2.4.16/arch/i386/traps.c	Thu Dec 05 14:14:44 2002 +0000
     4.2 +++ b/xen-2.4.16/arch/i386/traps.c	Fri Dec 06 11:40:56 2002 +0000
     4.3 @@ -362,7 +362,8 @@ asmlinkage void do_nmi(struct pt_regs * 
     4.4  
     4.5  asmlinkage void math_state_restore(struct pt_regs *regs, long error_code)
     4.6  {
     4.7 -    __asm__ __volatile__("clts");
     4.8 +    /* Prevent recursion. */
     4.9 +    clts();
    4.10  
    4.11      if ( !(current->flags & PF_USEDFPU) )
    4.12      {