ia64/xen-unstable

changeset 8851:ee6f025fb264

Clean up save_init_fpu().

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 14 23:30:59 2006 +0100 (2006-02-14)
parents 646edff07475
children 7d89f672aa49
files xen/arch/x86/i387.c
line diff
     1.1 --- a/xen/arch/x86/i387.c	Tue Feb 14 22:36:22 2006 +0100
     1.2 +++ b/xen/arch/x86/i387.c	Tue Feb 14 23:30:59 2006 +0100
     1.3 @@ -23,30 +23,28 @@ void init_fpu(void)
     1.4      set_bit(_VCPUF_fpu_initialised, &current->vcpu_flags);
     1.5  }
     1.6  
     1.7 -void save_init_fpu(struct vcpu *tsk)
     1.8 +void save_init_fpu(struct vcpu *v)
     1.9  {
    1.10 -    /*
    1.11 -     * The guest OS may have set the 'virtual STTS' flag.
    1.12 -     * This causes us to set the real flag, so we'll need
    1.13 -     * to temporarily clear it while saving f-p state.
    1.14 -     */
    1.15 -    if ( HVM_DOMAIN(tsk) || (tsk->arch.guest_context.ctrlreg[0] & X86_CR0_TS) )
    1.16 +    unsigned long cr0 = read_cr0();
    1.17 +
    1.18 +    /* This can happen, if a paravirtualised guest OS has set its CR0.TS. */
    1.19 +    if ( cr0 & X86_CR0_TS )
    1.20          clts();
    1.21  
    1.22      if ( cpu_has_fxsr )
    1.23          __asm__ __volatile__ (
    1.24              "fxsave %0 ; fnclex"
    1.25 -            : "=m" (tsk->arch.guest_context.fpu_ctxt) );
    1.26 +            : "=m" (v->arch.guest_context.fpu_ctxt) );
    1.27      else
    1.28          __asm__ __volatile__ (
    1.29              "fnsave %0 ; fwait"
    1.30 -            : "=m" (tsk->arch.guest_context.fpu_ctxt) );
    1.31 +            : "=m" (v->arch.guest_context.fpu_ctxt) );
    1.32  
    1.33 -    clear_bit(_VCPUF_fpu_dirtied, &tsk->vcpu_flags);
    1.34 -    stts();
    1.35 +    clear_bit(_VCPUF_fpu_dirtied, &v->vcpu_flags);
    1.36 +    write_cr0(cr0|X86_CR0_TS);
    1.37  }
    1.38  
    1.39 -void restore_fpu(struct vcpu *tsk)
    1.40 +void restore_fpu(struct vcpu *v)
    1.41  {
    1.42      /*
    1.43       * FXRSTOR can fault if passed a corrupted data block. We handle this
    1.44 @@ -74,12 +72,12 @@ void restore_fpu(struct vcpu *tsk)
    1.45              "   "__FIXUP_WORD" 1b,2b  \n"
    1.46              ".previous                \n"
    1.47              : 
    1.48 -            : "m" (tsk->arch.guest_context.fpu_ctxt),
    1.49 -              "i" (sizeof(tsk->arch.guest_context.fpu_ctxt)/4) );
    1.50 +            : "m" (v->arch.guest_context.fpu_ctxt),
    1.51 +              "i" (sizeof(v->arch.guest_context.fpu_ctxt)/4) );
    1.52      else
    1.53          __asm__ __volatile__ (
    1.54              "frstor %0"
    1.55 -            : : "m" (tsk->arch.guest_context.fpu_ctxt) );
    1.56 +            : : "m" (v->arch.guest_context.fpu_ctxt) );
    1.57  }
    1.58  
    1.59  /*