ia64/xen-unstable

changeset 4690:57dcb8c9f1d8

bitkeeper revision 1.1389.1.5 (42712ad1Qoo2MSKU_8_-kkJWHY9E9g)

Handle the possibility that FXRSTOR may fault by silently clearing
the data area that it is restoring from. This may occur if control
tools reload a saved VM image without adequate checking, for example.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 28 18:26:25 2005 +0000 (2005-04-28)
parents cd690b71434a
children f23e5c9c3f1b e686528abbfc
files xen/arch/x86/i387.c
line diff
     1.1 --- a/xen/arch/x86/i387.c	Thu Apr 28 18:04:45 2005 +0000
     1.2 +++ b/xen/arch/x86/i387.c	Thu Apr 28 18:26:25 2005 +0000
     1.3 @@ -46,10 +46,34 @@ void save_init_fpu(struct exec_domain *t
     1.4  
     1.5  void restore_fpu(struct exec_domain *tsk)
     1.6  {
     1.7 +    /*
     1.8 +     * FXRSTOR can fault if passed a corrupted data block. We handle this
     1.9 +     * possibility, which may occur if the block was passed to us by control
    1.10 +     * tools, by silently clearing the block.
    1.11 +     */
    1.12      if ( cpu_has_fxsr )
    1.13          __asm__ __volatile__ (
    1.14 -            "fxrstor %0"
    1.15 -            : : "m" (tsk->arch.guest_context.fpu_ctxt) );
    1.16 +            "1: fxrstor %0            \n"
    1.17 +            ".section .fixup,\"ax\"   \n"
    1.18 +            "2: push %%"__OP"ax       \n"
    1.19 +            "   push %%"__OP"cx       \n"
    1.20 +            "   push %%"__OP"di       \n"
    1.21 +            "   lea  %0,%%"__OP"di    \n"
    1.22 +            "   mov  %1,%%ecx         \n"
    1.23 +            "   xor  %%eax,%%eax      \n"
    1.24 +            "   rep ; stosl           \n"
    1.25 +            "   pop  %%"__OP"di       \n"
    1.26 +            "   pop  %%"__OP"cx       \n"
    1.27 +            "   pop  %%"__OP"ax       \n"
    1.28 +            "   jmp  1b               \n"
    1.29 +            ".previous                \n"
    1.30 +            ".section __ex_table,\"a\"\n"
    1.31 +            "   "__FIXUP_ALIGN"       \n"
    1.32 +            "   "__FIXUP_WORD" 1b,2b  \n"
    1.33 +            ".previous                \n"
    1.34 +            : 
    1.35 +            : "m" (tsk->arch.guest_context.fpu_ctxt),
    1.36 +              "i" (sizeof(tsk->arch.guest_context.fpu_ctxt)/4) );
    1.37      else
    1.38          __asm__ __volatile__ (
    1.39              "frstor %0"