From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Subject: Re: [PATCH v6 1/2] xen/hvm: introduce a flags field in the CPU save record Date: Tue, 12 Jan 2016 18:49:40 +0100 Message-ID: <56953CB4.6030806@citrix.com> References: <1452615153-67387-1-git-send-email-roger.pau@citrix.com> <1452615153-67387-2-git-send-email-roger.pau@citrix.com> <5695388802000078000C6062@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJ34k-0002B0-Dm for xen-devel@lists.xenproject.org; Tue, 12 Jan 2016 17:49:46 +0000 In-Reply-To: <5695388802000078000C6062@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Andrew Cooper , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org El 12/01/16 a les 17.31, Jan Beulich ha escrit: >>>> On 12.01.16 at 17:12, wrote: >> @@ -2087,19 +2100,21 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) >> seg.attr.bytes = ctxt.ldtr_arbytes; >> hvm_set_segment_register(v, x86_seg_ldtr, &seg); >> >> - /* In case xsave-absent save file is restored on a xsave-capable host */ >> - if ( cpu_has_xsave && !xsave_enabled(v) ) >> + v->fpu_initialised = !!(ctxt.flags & XEN_X86_FPU_INITIALISED); >> + if ( v->fpu_initialised ) >> { >> - struct xsave_struct *xsave_area = v->arch.xsave_area; >> + memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); >> + /* In case xsave-absent save file is restored on a xsave-capable host */ >> + if ( cpu_has_xsave && !xsave_enabled(v) ) >> + { >> + struct xsave_struct *xsave_area = v->arch.xsave_area; >> >> - memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); >> - xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; >> - if ( cpu_has_xsaves || cpu_has_xsavec ) >> - xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | >> - XSTATE_COMPACTION_ENABLED; >> + xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE; >> + if ( cpu_has_xsaves || cpu_has_xsavec ) >> + xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE | >> + XSTATE_COMPACTION_ENABLED; >> + } >> } >> - else >> - memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); >> > > I would have expected this to simply be re-indentation, yet > you changed from if/else to just if with the else code done > ahead of it. If this really is intended, the commit message should > explain it. Right, sorry. AFAICT v->arch.fpu_ctxt points to the xsave_area (as set by vcpu_init_fpu), so I though it was simpler to just do one memcpy for both cases, since v->arch.fpu_ctxt always points to the right area for either cases (and I was already modifying the code in question). I can see that this might be seen as an unrelated change, so if you want I can split it into a separate patch, or add the following to the commit message: "While modifying the FPU restore part of hvm_load_cpu_ctxt remove the memcpy branching, since v->arch.fpu_ctxt will always point to the right area for hosts with XSAVE or without it." Thanks, Roger.