From: "Jan Beulich" Subject: [PATCH 1/4] x86: remove unused x87 remnants of 32-bit days Date: Wed, 14 Oct 2015 07:29:16 -0600 Message-ID: <561E74CC02000078000AAEE0@prv-mh.provo.novell.com> References: <561E734D02000078000AAEC5@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC4F381BC.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZmM7N-0005x6-Pt for xen-devel@lists.xenproject.org; Wed, 14 Oct 2015 13:29:22 +0000 In-Reply-To: <561E734D02000078000AAEC5@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC4F381BC.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline x86-64 requires FXSR, XMM, and XMM2, so there's no point in hiding respective code behind conditionals. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1542,8 +1542,7 @@ static int hvmemul_get_fpu( return X86EMUL_UNHANDLEABLE; break; case X86EMUL_FPU_xmm: - if ( !cpu_has_xmm || - (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) || + if ( (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) || !(curr->arch.hvm_vcpu.guest_cr[4] & X86_CR4_OSFXSR) ) return X86EMUL_UNHANDLEABLE; break; --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -19,15 +19,12 @@ =20 static void fpu_init(void) { - unsigned long val; + uint32_t val =3D MXCSR_DEFAULT; =20 asm volatile ( "fninit" ); - if ( cpu_has_xmm ) - { - /* load default value into MXCSR control/status register */ - val =3D MXCSR_DEFAULT; - asm volatile ( "ldmxcsr %0" : : "m" (val) ); - } + + /* load default value into MXCSR control/status register */ + asm volatile ( "ldmxcsr %0" : : "m" (val) ); } =20 /*******************************/ @@ -122,14 +119,6 @@ static inline void fpu_fxrstor(struct vc } } =20 -/* Restore x87 extended state */ -static inline void fpu_frstor(struct vcpu *v) -{ - const char *fpu_ctxt =3D v->arch.fpu_ctxt; - - asm volatile ( "frstor %0" : : "m" (*fpu_ctxt) ); -} - /*******************************/ /* FPU Save Functions */ /*******************************/ @@ -206,15 +195,6 @@ static inline void fpu_fxsave(struct vcp fpu_ctxt->x[FPU_WORD_SIZE_OFFSET] =3D word_size; } =20 -/* Save x87 FPU state */ -static inline void fpu_fsave(struct vcpu *v) -{ - char *fpu_ctxt =3D v->arch.fpu_ctxt; - - /* FWAIT is required to make FNSAVE synchronous. */ - asm volatile ( "fnsave %0 ; fwait" : "=3Dm" (*fpu_ctxt) ); -} - /*******************************/ /* VCPU FPU Functions */ /*******************************/ @@ -249,12 +229,7 @@ void vcpu_restore_fpu_lazy(struct vcpu * if ( cpu_has_xsave ) fpu_xrstor(v, XSTATE_LAZY); else if ( v->fpu_initialised ) - { - if ( cpu_has_fxsr ) - fpu_fxrstor(v); - else - fpu_frstor(v); - } + fpu_fxrstor(v); else fpu_init(); =20 @@ -278,10 +253,8 @@ static bool_t _vcpu_save_fpu(struct vcpu =20 if ( cpu_has_xsave ) fpu_xsave(v); - else if ( cpu_has_fxsr ) - fpu_fxsave(v); else - fpu_fsave(v); + fpu_fxsave(v); =20 v->fpu_dirtied =3D 0; =20 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1295,10 +1295,8 @@ void __init noreturn __start_xen(unsigne =20 identify_cpu(&boot_cpu_data); =20 - if ( cpu_has_fxsr ) - set_in_cr4(X86_CR4_OSFXSR); - if ( cpu_has_xmm ) - set_in_cr4(X86_CR4_OSXMMEXCPT); + set_in_cr4(X86_CR4_OSFXSR); + set_in_cr4(X86_CR4_OSXMMEXCPT); =20 if ( disable_smep ) setup_clear_cpu_cap(X86_FEATURE_SMEP); --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -184,9 +184,6 @@ #define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP) #define cpu_has_mtrr 1 #define cpu_has_mmx 1 -#define cpu_has_fxsr 1 -#define cpu_has_xmm 1 -#define cpu_has_xmm2 1 #define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3) #define cpu_has_ht boot_cpu_has(X86_FEATURE_HT) #define cpu_has_syscall 1 --- a/xen/include/asm-x86/i387.h +++ b/xen/include/asm-x86/i387.h @@ -17,22 +17,15 @@ /* Byte offset of the stored word size within the FXSAVE area/portion. */ #define FPU_WORD_SIZE_OFFSET 511 =20 -struct ix87_state { - struct ix87_env { - uint16_t fcw, _res0; - uint16_t fsw, _res1; - uint16_t ftw, _res2; - uint32_t fip; - uint16_t fcs; - uint16_t fop; - uint32_t fdp; - uint16_t fds, _res6; - } env; - struct __packed ix87_reg { - uint64_t mantissa; - uint16_t exponent:15; - uint16_t sign:1; - } r[8]; +struct ix87_env { + uint16_t fcw, _res0; + uint16_t fsw, _res1; + uint16_t ftw, _res2; + uint32_t fip; + uint16_t fcs; + uint16_t fop; + uint32_t fdp; + uint16_t fds, _res6; }; =20 void vcpu_restore_fpu_eager(struct vcpu *v); --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t; #define pagetable_null() pagetable_from_pfn(0) =20 void clear_page_sse2(void *); -#define clear_page(_p) (cpu_has_xmm2 ? \ - clear_page_sse2((void *)(_p)) : \ - (void)memset((void *)(_p), 0, PAGE_SIZE)) void copy_page_sse2(void *, const void *); -#define copy_page(_t,_f) (cpu_has_xmm2 ? \ - copy_page_sse2(_t, _f) : \ - (void)memcpy(_t, _f, PAGE_SIZE)) + +#define clear_page(_p) clear_page_sse2(_p) +#define copy_page(_t,_f) copy_page_sse2(_t, _f) =20 /* Convert between Xen-heap virtual addresses and machine addresses. */ #define __pa(x) (virt_to_maddr(x)) --=__PartC4F381BC.1__= Content-Type: text/plain; name="x86-remove-x87.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-remove-x87.patch" x86: remove unused x87 remnants of 32-bit days=0A=0Ax86-64 requires FXSR, = XMM, and XMM2, so there's no point in hiding=0Arespective code behind = conditionals.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/hvm/emulate.c=0A+++ b/xen/arch/x86/hvm/emulate.c=0A@@ = -1542,8 +1542,7 @@ static int hvmemul_get_fpu(=0A return = X86EMUL_UNHANDLEABLE;=0A break;=0A case X86EMUL_FPU_xmm:=0A- = if ( !cpu_has_xmm ||=0A- (curr->arch.hvm_vcpu.guest_cr[0] = & X86_CR0_EM) ||=0A+ if ( (curr->arch.hvm_vcpu.guest_cr[0] & = X86_CR0_EM) ||=0A !(curr->arch.hvm_vcpu.guest_cr[4] & = X86_CR4_OSFXSR) )=0A return X86EMUL_UNHANDLEABLE;=0A = break;=0A--- a/xen/arch/x86/i387.c=0A+++ b/xen/arch/x86/i387.c=0A@@ -19,15 = +19,12 @@=0A =0A static void fpu_init(void)=0A {=0A- unsigned long = val;=0A+ uint32_t val =3D MXCSR_DEFAULT;=0A =0A asm volatile ( = "fninit" );=0A- if ( cpu_has_xmm )=0A- {=0A- /* load default = value into MXCSR control/status register */=0A- val =3D MXCSR_DEFAUL= T;=0A- asm volatile ( "ldmxcsr %0" : : "m" (val) );=0A- = }=0A+=0A+ /* load default value into MXCSR control/status register = */=0A+ asm volatile ( "ldmxcsr %0" : : "m" (val) );=0A }=0A =0A = /*******************************/=0A@@ -122,14 +119,6 @@ static inline = void fpu_fxrstor(struct vc=0A }=0A }=0A =0A-/* Restore x87 extended = state */=0A-static inline void fpu_frstor(struct vcpu *v)=0A-{=0A- = const char *fpu_ctxt =3D v->arch.fpu_ctxt;=0A-=0A- asm volatile ( = "frstor %0" : : "m" (*fpu_ctxt) );=0A-}=0A-=0A /***************************= ****/=0A /* FPU Save Functions */=0A /****************************= ***/=0A@@ -206,15 +195,6 @@ static inline void fpu_fxsave(struct vcp=0A = fpu_ctxt->x[FPU_WORD_SIZE_OFFSET] =3D word_size;=0A }=0A =0A-/* Save = x87 FPU state */=0A-static inline void fpu_fsave(struct vcpu *v)=0A-{=0A- = char *fpu_ctxt =3D v->arch.fpu_ctxt;=0A-=0A- /* FWAIT is required to = make FNSAVE synchronous. */=0A- asm volatile ( "fnsave %0 ; fwait" : = "=3Dm" (*fpu_ctxt) );=0A-}=0A-=0A /*******************************/=0A /* = VCPU FPU Functions */=0A /*******************************/=0A@@ = -249,12 +229,7 @@ void vcpu_restore_fpu_lazy(struct vcpu *=0A if ( = cpu_has_xsave )=0A fpu_xrstor(v, XSTATE_LAZY);=0A else if ( = v->fpu_initialised )=0A- {=0A- if ( cpu_has_fxsr )=0A- = fpu_fxrstor(v);=0A- else=0A- fpu_frstor(v);=0A- = }=0A+ fpu_fxrstor(v);=0A else=0A fpu_init();=0A =0A@@ = -278,10 +253,8 @@ static bool_t _vcpu_save_fpu(struct vcpu=0A =0A if ( = cpu_has_xsave )=0A fpu_xsave(v);=0A- else if ( cpu_has_fxsr = )=0A- fpu_fxsave(v);=0A else=0A- fpu_fsave(v);=0A+ = fpu_fxsave(v);=0A =0A v->fpu_dirtied =3D 0;=0A =0A--- a/xen/arch/x86/s= etup.c=0A+++ b/xen/arch/x86/setup.c=0A@@ -1295,10 +1295,8 @@ void __init = noreturn __start_xen(unsigne=0A =0A identify_cpu(&boot_cpu_data);=0A = =0A- if ( cpu_has_fxsr )=0A- set_in_cr4(X86_CR4_OSFXSR);=0A- = if ( cpu_has_xmm )=0A- set_in_cr4(X86_CR4_OSXMMEXCPT);=0A+ = set_in_cr4(X86_CR4_OSFXSR);=0A+ set_in_cr4(X86_CR4_OSXMMEXCPT);=0A =0A = if ( disable_smep )=0A setup_clear_cpu_cap(X86_FEATURE_SMEP);=0A= --- a/xen/include/asm-x86/cpufeature.h=0A+++ b/xen/include/asm-x86/cpufeatu= re.h=0A@@ -184,9 +184,6 @@=0A #define cpu_has_sep boot_cpu_ha= s(X86_FEATURE_SEP)=0A #define cpu_has_mtrr 1=0A #define = cpu_has_mmx 1=0A-#define cpu_has_fxsr 1=0A-#defin= e cpu_has_xmm 1=0A-#define cpu_has_xmm2 1=0A = #define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)=0A #define = cpu_has_ht boot_cpu_has(X86_FEATURE_HT)=0A #define cpu_has_sys= call 1=0A--- a/xen/include/asm-x86/i387.h=0A+++ b/xen/include/as= m-x86/i387.h=0A@@ -17,22 +17,15 @@=0A /* Byte offset of the stored word = size within the FXSAVE area/portion. */=0A #define FPU_WORD_SIZE_OFFSET = 511=0A =0A-struct ix87_state {=0A- struct ix87_env {=0A- = uint16_t fcw, _res0;=0A- uint16_t fsw, _res1;=0A- uint16_t = ftw, _res2;=0A- uint32_t fip;=0A- uint16_t fcs;=0A- = uint16_t fop;=0A- uint32_t fdp;=0A- uint16_t fds, _res6;=0A- = } env;=0A- struct __packed ix87_reg {=0A- uint64_t = mantissa;=0A- uint16_t exponent:15;=0A- uint16_t sign:1;=0A- = } r[8];=0A+struct ix87_env {=0A+ uint16_t fcw, _res0;=0A+ = uint16_t fsw, _res1;=0A+ uint16_t ftw, _res2;=0A+ uint32_t fip;=0A+ = uint16_t fcs;=0A+ uint16_t fop;=0A+ uint32_t fdp;=0A+ uint16_t = fds, _res6;=0A };=0A =0A void vcpu_restore_fpu_eager(struct vcpu *v);=0A---= a/xen/include/asm-x86/page.h=0A+++ b/xen/include/asm-x86/page.h=0A@@ = -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t;=0A #define = pagetable_null() pagetable_from_pfn(0)=0A =0A void clear_page_sse2(v= oid *);=0A-#define clear_page(_p) (cpu_has_xmm2 ? = \=0A- clear_page_sse2((void *)(_p)) : = \=0A- (void)memset((void *)(_p), 0, = PAGE_SIZE))=0A void copy_page_sse2(void *, const void *);=0A-#define = copy_page(_t,_f) (cpu_has_xmm2 ? \=0A- = copy_page_sse2(_t, _f) : \=0A- = (void)memcpy(_t, _f, PAGE_SIZE))=0A+=0A+#define = clear_page(_p) clear_page_sse2(_p)=0A+#define copy_page(_t,_f) = copy_page_sse2(_t, _f)=0A =0A /* Convert between Xen-heap virtual = addresses and machine addresses. */=0A #define __pa(x) = (virt_to_maddr(x))=0A --=__PartC4F381BC.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartC4F381BC.1__=--