ia64/xen-unstable
changeset 17182:d6e6ba8a72bf
x86: Clean up FPU code style and add a comment about FNSAVE/FWAIT
instruction pair.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
instruction pair.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Mar 04 11:20:22 2008 +0000 (2008-03-04) |
parents | 017927162815 |
children | 96453af916b9 |
files | xen/arch/x86/i387.c |
line diff
1.1 --- a/xen/arch/x86/i387.c Tue Mar 04 10:33:50 2008 +0000 1.2 +++ b/xen/arch/x86/i387.c Tue Mar 04 11:20:22 2008 +0000 1.3 @@ -18,7 +18,7 @@ 1.4 1.5 void init_fpu(void) 1.6 { 1.7 - __asm__ __volatile__ ( "fninit" ); 1.8 + asm volatile ( "fninit" ); 1.9 if ( cpu_has_xmm ) 1.10 load_mxcsr(0x1f80); 1.11 current->fpu_initialised = 1; 1.12 @@ -36,7 +36,7 @@ void save_init_fpu(struct vcpu *v) 1.13 if ( cpu_has_fxsr ) 1.14 { 1.15 #ifdef __i386__ 1.16 - __asm__ __volatile__ ( 1.17 + asm volatile ( 1.18 "fxsave %0" 1.19 : "=m" (*fpu_ctxt) ); 1.20 #else /* __x86_64__ */ 1.21 @@ -45,14 +45,14 @@ void save_init_fpu(struct vcpu *v) 1.22 * older versions the rex64 prefix works only if we force an 1.23 * addressing mode that doesn't require extended registers. 1.24 */ 1.25 - __asm__ __volatile__ ( 1.26 + asm volatile ( 1.27 REX64_PREFIX "fxsave (%1)" 1.28 : "=m" (*fpu_ctxt) : "cdaSDb" (fpu_ctxt) ); 1.29 #endif 1.30 1.31 /* Clear exception flags if FSW.ES is set. */ 1.32 if ( unlikely(fpu_ctxt[2] & 0x80) ) 1.33 - __asm__ __volatile__ ("fnclex"); 1.34 + asm volatile ("fnclex"); 1.35 1.36 /* 1.37 * AMD CPUs don't save/restore FDP/FIP/FOP unless an exception 1.38 @@ -63,7 +63,7 @@ void save_init_fpu(struct vcpu *v) 1.39 */ 1.40 if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD ) 1.41 { 1.42 - __asm__ __volatile__ ( 1.43 + asm volatile ( 1.44 "emms\n\t" /* clear stack tags */ 1.45 "fildl %0" /* load to clear state */ 1.46 : : "m" (*fpu_ctxt) ); 1.47 @@ -71,9 +71,8 @@ void save_init_fpu(struct vcpu *v) 1.48 } 1.49 else 1.50 { 1.51 - __asm__ __volatile__ ( 1.52 - "fnsave %0 ; fwait" 1.53 - : "=m" (*fpu_ctxt) ); 1.54 + /* FWAIT is required to make FNSAVE synchronous. */ 1.55 + asm volatile ( "fnsave %0 ; fwait" : "=m" (*fpu_ctxt) ); 1.56 } 1.57 1.58 v->fpu_dirtied = 0; 1.59 @@ -91,7 +90,7 @@ void restore_fpu(struct vcpu *v) 1.60 */ 1.61 if ( cpu_has_fxsr ) 1.62 { 1.63 - __asm__ __volatile__ ( 1.64 + asm volatile ( 1.65 #ifdef __i386__ 1.66 "1: fxrstor %0 \n" 1.67 #else /* __x86_64__ */ 1.68 @@ -125,9 +124,7 @@ void restore_fpu(struct vcpu *v) 1.69 } 1.70 else 1.71 { 1.72 - __asm__ __volatile__ ( 1.73 - "frstor %0" 1.74 - : : "m" (v->arch.guest_context.fpu_ctxt) ); 1.75 + asm volatile ( "frstor %0" : : "m" (v->arch.guest_context.fpu_ctxt) ); 1.76 } 1.77 } 1.78