[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v10 04/11] x86/hvm: Introduce hvm_save_cpu_xsave_states_one



> -----Original Message-----
> From: Alexandru Isaila [mailto:aisaila@xxxxxxxxxxxxxxx]
> Sent: 04 July 2018 14:32
> To: xen-devel@xxxxxxxxxxxxx
> Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxx>; Wei Liu <wei.liu2@xxxxxxxxxx>;
> jbeulich@xxxxxxxx; Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>; Paul
> Durrant <Paul.Durrant@xxxxxxxxxx>; Alexandru Isaila
> <aisaila@xxxxxxxxxxxxxxx>
> Subject: [PATCH v10 04/11] x86/hvm: Introduce
> hvm_save_cpu_xsave_states_one
> 
> This is used to save data from a single instance.
> 
> Signed-off-by: Alexandru Isaila <aisaila@xxxxxxxxxxxxxxx>
> 
> ---
> Changes since V9:
>       - Move continue out of save_one func.
> ---
>  xen/arch/x86/hvm/hvm.c | 34 +++++++++++++++++++++-------------
>  1 file changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index c343ba8..495abe5 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -1188,30 +1188,38 @@ HVM_REGISTER_SAVE_RESTORE(CPU,
> hvm_save_cpu_ctxt, hvm_load_cpu_ctxt,
>                                             save_area) + \
>                                    xstate_ctxt_size(xcr0))
> 
> -static int hvm_save_cpu_xsave_states(struct domain *d,
> hvm_domain_context_t *h)
> +static int hvm_save_cpu_xsave_states_one(struct vcpu *v,
> hvm_domain_context_t *h)
>  {
> -    struct vcpu *v;
>      struct hvm_hw_cpu_xsave *ctxt;
> +    unsigned int size = HVM_CPU_XSAVE_SIZE(v->arch.xcr0_accum);
> 
>      if ( !cpu_has_xsave )
>          return 0;   /* do nothing */
> 

Since this function should not be called if !xsave_enabled(v) it would seem 
reasonable to ASSERT that here.

  Paul

> +    if ( _hvm_init_entry(h, CPU_XSAVE_CODE, v->vcpu_id, size) )
> +        return 1;
> +    ctxt = (struct hvm_hw_cpu_xsave *)&h->data[h->cur];
> +    h->cur += size;
> +    ctxt->xfeature_mask = xfeature_mask;
> +    ctxt->xcr0 = v->arch.xcr0;
> +    ctxt->xcr0_accum = v->arch.xcr0_accum;
> +
> +    expand_xsave_states(v, &ctxt->save_area,
> +                        size - offsetof(typeof(*ctxt), save_area));
> +    return 0;
> + }
> +
> +static int hvm_save_cpu_xsave_states(struct domain *d,
> hvm_domain_context_t *h)
> +{
> +    struct vcpu *v;
> +
>      for_each_vcpu ( d, v )
>      {
> -        unsigned int size = HVM_CPU_XSAVE_SIZE(v->arch.xcr0_accum);
> -
>          if ( !xsave_enabled(v) )
>              continue;
> -        if ( _hvm_init_entry(h, CPU_XSAVE_CODE, v->vcpu_id, size) )
> +
> +        if ( hvm_save_cpu_xsave_states_one(v, h) != 0 )
>              return 1;
> -        ctxt = (struct hvm_hw_cpu_xsave *)&h->data[h->cur];
> -        h->cur += size;
> -
> -        ctxt->xfeature_mask = xfeature_mask;
> -        ctxt->xcr0 = v->arch.xcr0;
> -        ctxt->xcr0_accum = v->arch.xcr0_accum;
> -        expand_xsave_states(v, &ctxt->save_area,
> -                            size - offsetof(typeof(*ctxt), save_area));
>      }
> 
>      return 0;
> --
> 2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.