xcp-1.6-updates/xen-4.1.hg

changeset 23248:b0bf2fc4eff9

x86/xsave: provide guests with finit-like environment

Without the use of xsave, guests get their initial floating point
environment set up with finit. At least NetWare actually depends on
this (in particular on all exceptions being masked), so to be
consistent set the same environment also when using xsave. This is
also in line with all SSE exceptions getting masked initially.

To avoid further fragile casts in xstate_alloc_save_area() the patch
also changes xsave_struct's fpu_see member to have actually usable
fields.

The patch was tested in its technically identical, but modified-file-
wise different 4.1.2 version.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Charles Arnold <carnold@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24157:7b5e1cb94bfa
xen-unstable date: Fri Nov 18 09:22:45 2011 +0100
author Jan Beulich <jbeulich@suse.com>
date Wed Mar 07 08:43:28 2012 +0000 (2012-03-07)
parents e03aa3794cff
children b5051d40e1cc
files xen/arch/x86/i387.c xen/include/asm-x86/i387.h
line diff
     1.1 --- a/xen/arch/x86/i387.c	Wed Mar 07 08:39:21 2012 +0000
     1.2 +++ b/xen/arch/x86/i387.c	Wed Mar 07 08:43:28 2012 +0000
     1.3 @@ -287,7 +287,7 @@ void xsave_init(void)
     1.4  
     1.5  int xsave_alloc_save_area(struct vcpu *v)
     1.6  {
     1.7 -    void *save_area;
     1.8 +    struct xsave_struct *save_area;
     1.9  
    1.10      if ( !cpu_has_xsave || is_idle_vcpu(v) )
    1.11          return 0;
    1.12 @@ -300,8 +300,9 @@ int xsave_alloc_save_area(struct vcpu *v
    1.13          return -ENOMEM;
    1.14  
    1.15      memset(save_area, 0, xsave_cntxt_size);
    1.16 -    ((u32 *)save_area)[6] = 0x1f80;  /* MXCSR */
    1.17 -    *(uint64_t *)(save_area + 512) = XSTATE_FP_SSE;  /* XSETBV */
    1.18 +    save_area->fpu_sse.fcw = FCW_DEFAULT;
    1.19 +    save_area->fpu_sse.mxcsr = MXCSR_DEFAULT;
    1.20 +    save_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE;
    1.21  
    1.22      v->arch.xsave_area = save_area;
    1.23      v->arch.xcr0 = XSTATE_FP_SSE;
     2.1 --- a/xen/include/asm-x86/i387.h	Wed Mar 07 08:39:21 2012 +0000
     2.2 +++ b/xen/include/asm-x86/i387.h	Wed Mar 07 08:43:28 2012 +0000
     2.3 @@ -35,9 +35,34 @@ bool_t xsave_enabled(const struct vcpu *
     2.4  #define XSTATE_YMM_SIZE    256
     2.5  #define XSAVEOPT        (1 << 0)
     2.6  
     2.7 +#define FCW_DEFAULT               0x037f
     2.8 +#define MXCSR_DEFAULT             0x1f80
     2.9 +
    2.10  struct xsave_struct
    2.11  {
    2.12 -    struct { char x[512]; } fpu_sse;         /* FPU/MMX, SSE */
    2.13 +    union {                                  /* FPU/MMX, SSE */
    2.14 +        char x[512];
    2.15 +        struct {
    2.16 +            uint16_t fcw;
    2.17 +            uint16_t fsw;
    2.18 +            uint8_t ftw;
    2.19 +            uint8_t rsvd1;
    2.20 +            uint16_t fop;
    2.21 +            union {
    2.22 +#ifdef __x86_64__
    2.23 +                uint64_t addr;
    2.24 +#endif
    2.25 +                struct {
    2.26 +                    uint32_t offs;
    2.27 +                    uint16_t sel;
    2.28 +                    uint16_t rsvd;
    2.29 +                };
    2.30 +            } fip, fdp;
    2.31 +            uint32_t mxcsr;
    2.32 +            uint32_t mxcsr_mask;
    2.33 +            /* data registers follow here */
    2.34 +        };
    2.35 +    } fpu_sse;
    2.36  
    2.37      struct {
    2.38          u64 xstate_bv;