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;
static void fpu_init(void)
{
- unsigned long val;
-
+ uint32_t val = MXCSR_DEFAULT;
+
asm volatile ( "fninit" );
- if ( cpu_has_xmm )
- {
- /* load default value into MXCSR control/status register */
- val = MXCSR_DEFAULT;
- asm volatile ( "ldmxcsr %0" : : "m" (val) );
- }
+
+ /* load default value into MXCSR control/status register */
+ asm volatile ( "ldmxcsr %0" : : "m" (val) );
}
/*******************************/
}
}
-/* Restore x87 extended state */
-static inline void fpu_frstor(struct vcpu *v)
-{
- const char *fpu_ctxt = v->arch.fpu_ctxt;
-
- asm volatile ( "frstor %0" : : "m" (*fpu_ctxt) );
-}
-
/*******************************/
/* FPU Save Functions */
/*******************************/
fpu_ctxt->x[FPU_WORD_SIZE_OFFSET] = word_size;
}
-/* Save x87 FPU state */
-static inline void fpu_fsave(struct vcpu *v)
-{
- char *fpu_ctxt = v->arch.fpu_ctxt;
-
- /* FWAIT is required to make FNSAVE synchronous. */
- asm volatile ( "fnsave %0 ; fwait" : "=m" (*fpu_ctxt) );
-}
-
/*******************************/
/* VCPU FPU Functions */
/*******************************/
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();
if ( cpu_has_xsave )
fpu_xsave(v);
- else if ( cpu_has_fxsr )
- fpu_fxsave(v);
else
- fpu_fsave(v);
+ fpu_fxsave(v);
v->fpu_dirtied = 0;
identify_cpu(&boot_cpu_data);
- 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 | X86_CR4_OSXMMEXCPT);
if ( disable_smep )
setup_clear_cpu_cap(X86_FEATURE_SMEP);
#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
/* Byte offset of the stored word size within the FXSAVE area/portion. */
#define FPU_WORD_SIZE_OFFSET 511
-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;
};
void vcpu_restore_fpu_eager(struct vcpu *v);
#define pagetable_null() pagetable_from_pfn(0)
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)
/* Convert between Xen-heap virtual addresses and machine addresses. */
#define __pa(x) (virt_to_maddr(x))