ia64/xen-unstable

annotate xen/arch/x86/i387.c @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents d6e6ba8a72bf
children
rev   line source
kaf24@1452 1 /*
kaf24@1452 2 * linux/arch/i386/kernel/i387.c
kaf24@1452 3 *
kaf24@1452 4 * Copyright (C) 1994 Linus Torvalds
kaf24@1452 5 *
kaf24@1452 6 * Pentium III FXSR, SSE support
kaf24@1452 7 * General FPU state handling cleanups
kfraser@11204 8 * Gareth Hughes <gareth@valinux.com>, May 2000
kaf24@1452 9 */
kaf24@1452 10
kaf24@1452 11 #include <xen/config.h>
kaf24@1452 12 #include <xen/sched.h>
cl349@5287 13 #include <asm/current.h>
kaf24@1452 14 #include <asm/processor.h>
kaf24@8708 15 #include <asm/hvm/support.h>
kaf24@1452 16 #include <asm/i387.h>
kfraser@11859 17 #include <asm/asm_defns.h>
kaf24@1452 18
kaf24@1452 19 void init_fpu(void)
kaf24@1452 20 {
keir@17182 21 asm volatile ( "fninit" );
kaf24@3896 22 if ( cpu_has_xmm )
kaf24@3896 23 load_mxcsr(0x1f80);
kfraser@14657 24 current->fpu_initialised = 1;
kaf24@1452 25 }
kaf24@1452 26
kaf24@8851 27 void save_init_fpu(struct vcpu *v)
kaf24@1452 28 {
kaf24@8851 29 unsigned long cr0 = read_cr0();
kaf24@9867 30 char *fpu_ctxt = v->arch.guest_context.fpu_ctxt.x;
kaf24@8851 31
kaf24@8851 32 /* This can happen, if a paravirtualised guest OS has set its CR0.TS. */
kaf24@8851 33 if ( cr0 & X86_CR0_TS )
kaf24@3896 34 clts();
kaf24@3896 35
kaf24@3896 36 if ( cpu_has_fxsr )
kaf24@9867 37 {
kaf24@9867 38 #ifdef __i386__
keir@17182 39 asm volatile (
kaf24@9867 40 "fxsave %0"
kaf24@9867 41 : "=m" (*fpu_ctxt) );
kaf24@9867 42 #else /* __x86_64__ */
kaf24@9867 43 /*
kaf24@9867 44 * The only way to force fxsaveq on a wide range of gas versions. On
kfraser@11859 45 * older versions the rex64 prefix works only if we force an
kfraser@11859 46 * addressing mode that doesn't require extended registers.
kaf24@9867 47 */
keir@17182 48 asm volatile (
kfraser@11859 49 REX64_PREFIX "fxsave (%1)"
kaf24@9867 50 : "=m" (*fpu_ctxt) : "cdaSDb" (fpu_ctxt) );
kaf24@9867 51 #endif
kaf24@9867 52
kaf24@9867 53 /* Clear exception flags if FSW.ES is set. */
kaf24@9867 54 if ( unlikely(fpu_ctxt[2] & 0x80) )
keir@17182 55 asm volatile ("fnclex");
kaf24@9867 56
kaf24@9867 57 /*
kaf24@9867 58 * AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
kaf24@9867 59 * is pending. Clear the x87 state here by setting it to fixed
kaf24@9867 60 * values. The hypervisor data segment can be sometimes 0 and
kaf24@9867 61 * sometimes new user value. Both should be ok. Use the FPU saved
kaf24@9867 62 * data block as a safe address because it should be in L1.
kaf24@9867 63 */
kaf24@9867 64 if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD )
kaf24@9867 65 {
keir@17182 66 asm volatile (
kaf24@9867 67 "emms\n\t" /* clear stack tags */
kaf24@9867 68 "fildl %0" /* load to clear state */
kaf24@9867 69 : : "m" (*fpu_ctxt) );
kaf24@9867 70 }
kaf24@9867 71 }
kaf24@3896 72 else
kaf24@9867 73 {
keir@17182 74 /* FWAIT is required to make FNSAVE synchronous. */
keir@17182 75 asm volatile ( "fnsave %0 ; fwait" : "=m" (*fpu_ctxt) );
kaf24@9867 76 }
kaf24@3896 77
kfraser@14657 78 v->fpu_dirtied = 0;
kaf24@8851 79 write_cr0(cr0|X86_CR0_TS);
kaf24@1452 80 }
kaf24@1452 81
kaf24@8851 82 void restore_fpu(struct vcpu *v)
kaf24@1452 83 {
kaf24@9867 84 char *fpu_ctxt = v->arch.guest_context.fpu_ctxt.x;
kaf24@9867 85
kaf24@4690 86 /*
kaf24@4690 87 * FXRSTOR can fault if passed a corrupted data block. We handle this
kaf24@4690 88 * possibility, which may occur if the block was passed to us by control
kaf24@4690 89 * tools, by silently clearing the block.
kaf24@4690 90 */
kaf24@3896 91 if ( cpu_has_fxsr )
kaf24@9867 92 {
keir@17182 93 asm volatile (
kaf24@9867 94 #ifdef __i386__
kaf24@4690 95 "1: fxrstor %0 \n"
kaf24@9867 96 #else /* __x86_64__ */
kaf24@9867 97 /* See above for why the operands/constraints are this way. */
kfraser@11859 98 "1: " REX64_PREFIX "fxrstor (%2)\n"
kaf24@9867 99 #endif
kaf24@4690 100 ".section .fixup,\"ax\" \n"
kaf24@4690 101 "2: push %%"__OP"ax \n"
kaf24@4690 102 " push %%"__OP"cx \n"
kaf24@4690 103 " push %%"__OP"di \n"
kaf24@4690 104 " lea %0,%%"__OP"di \n"
kaf24@4690 105 " mov %1,%%ecx \n"
kaf24@4690 106 " xor %%eax,%%eax \n"
kaf24@4690 107 " rep ; stosl \n"
kaf24@4690 108 " pop %%"__OP"di \n"
kaf24@4690 109 " pop %%"__OP"cx \n"
kaf24@4690 110 " pop %%"__OP"ax \n"
kaf24@4690 111 " jmp 1b \n"
kaf24@4690 112 ".previous \n"
kaf24@4690 113 ".section __ex_table,\"a\"\n"
kaf24@4690 114 " "__FIXUP_ALIGN" \n"
kaf24@4690 115 " "__FIXUP_WORD" 1b,2b \n"
kaf24@4690 116 ".previous \n"
kaf24@4690 117 :
kaf24@9867 118 : "m" (*fpu_ctxt),
kaf24@9867 119 "i" (sizeof(v->arch.guest_context.fpu_ctxt)/4)
kaf24@9867 120 #ifdef __x86_64__
kaf24@9867 121 ,"cdaSDb" (fpu_ctxt)
kaf24@9867 122 #endif
kaf24@9867 123 );
kaf24@9867 124 }
kaf24@3896 125 else
kaf24@9867 126 {
keir@17182 127 asm volatile ( "frstor %0" : : "m" (v->arch.guest_context.fpu_ctxt) );
kaf24@9867 128 }
kaf24@1452 129 }
kaf24@3914 130
kaf24@3914 131 /*
kaf24@3914 132 * Local variables:
kaf24@3914 133 * mode: C
kaf24@3914 134 * c-set-style: "BSD"
kaf24@3914 135 * c-basic-offset: 4
kaf24@3914 136 * tab-width: 4
kaf24@3914 137 * indent-tabs-mode: nil
kaf24@3988 138 * End:
kaf24@3914 139 */