On Tue, 2015-10-13 at 15:32 +0200, Roger Pau Monne wrote:
> Xen always set the FPU as initialized when loading a HVM context, so
> libxc
> has to provide a valid FPU context when setting the CPU registers.
> 
> Signed-off-by: Roger Pau Monné <roger....@citrix.com>
> Cc: Jan Beulich <jbeul...@suse.com>
> Cc: Andrew Cooper <andrew.coop...@citrix.com>
> Cc: Ian Jackson <ian.jack...@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabell...@eu.citrix.com>
> Cc: Ian Campbell <ian.campb...@citrix.com>
> Cc: Wei Liu <wei.l...@citrix.com>
> ---
>  tools/libxc/xc_dom_x86.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index dd331bf..f8d580c 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -841,6 +841,23 @@ static int vcpu_hvm(struct xc_dom_image *dom)
>          struct hvm_save_descriptor end_d;
>          HVM_SAVE_TYPE(END) end;
>      } bsp_ctx;
> +    struct {
> +        uint16_t fcw;
> +        uint16_t fsw;
> +        uint8_t ftw;
> +        uint8_t rsvd1;
> +        uint16_t fop;
> +        union {
> +            uint64_t addr;
> +            struct {
> +                uint32_t offs;
> +                uint16_t sel;
> +                uint16_t rsvd;
> +            };
> +        } fip, fdp;
> +        uint32_t mxcsr;
> +        uint32_t mxcsr_mask;
> +    } *fpu_ctxt;
>      uint8_t *full_ctx = NULL;
>      int rc;
>  
> @@ -908,6 +925,23 @@ static int vcpu_hvm(struct xc_dom_image *dom)
>      /* Set the control registers. */
>      bsp_ctx.cpu.cr0 = X86_CR0_PE | X86_CR0_ET;
>  
> +    /*
> +     * XXX: Set initial FPU state.
> +     *
> +     * This should be removed once Xen is able to know if the
> +     * FPU state saved is valid or not, now Xen always sets
> +     * fpu_initialised to true regardless of the FPU state.

I suppose we aren't just doing that now because there is some complexity in
doing so? Can that be mentioned in the commit log please.

Other than that if the hypervisor folks are happy with a) the approach and
b) the specifics of fpu_ctxt described below then it's fine by me too.


> +     *
> +     * The code below mimics the FPU sate after executing
> +     * fninit
> +     * ldmxcsr 0x1f80
> +     */
> +    fpu_ctxt = (typeof(fpu_ctxt))bsp_ctx.cpu.fpu_regs;
> +
> +    fpu_ctxt->fcw = 0x37f;
> +    fpu_ctxt->ftw = 0xff;
> +    fpu_ctxt->mxcsr = 0x1f80;
> +
>      /* Set the IP. */
>      bsp_ctx.cpu.rip = dom->parms.phys_entry;
>  

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to