From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Subject: Re: [PATCH v4 3/4] xen/hvm: introduce a flags field in the CPU save record Date: Fri, 27 Nov 2015 17:15:02 +0100 Message-ID: <56588186.4080405@citrix.com> References: <1448464684-5597-1-git-send-email-roger.pau@citrix.com> <1448464684-5597-4-git-send-email-roger.pau@citrix.com> <565725F402000078000B96A9@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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a2Lfx-0003V1-Ku for xen-devel@lists.xenproject.org; Fri, 27 Nov 2015 16:15:09 +0000 In-Reply-To: <565725F402000078000B96A9@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 26/11/15 a les 15.32, Jan Beulich ha escrit: >>>> On 25.11.15 at 16:18, wrote: >> --- a/xen/arch/x86/hvm/hvm.c >> +++ b/xen/arch/x86/hvm/hvm.c >> @@ -2085,16 +2091,17 @@ 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); >> >> + v->fpu_initialised = !!(ctxt.flags & XEN_X86_FPU_INITIALISED); >> /* In case xsave-absent save file is restored on a xsave-capable host */ >> - if ( cpu_has_xsave && !xsave_enabled(v) ) >> + if ( cpu_has_xsave && !xsave_enabled(v) && v->fpu_initialised ) > > Hmm, didn't I pretty explicitly ask for this to become > > if ( !v->fpu_initialised ) > memset(); I don't think this is possible with the current code. Sadly the XSTATE stuff is kind of messy IMHO. vcpu_init_fpu calls xstate_alloc_save_area which on a XSAVE capable CPUs allocates _and_ initializes the FPU registers, while on non-XSAVE capable CPUs vcpu_init_fpu just allocates the FPU memory, but doesn't initialize the registers. So either xstate_alloc_save_area also sets v->fpu_initialised = 1 (this is the simplest solution), or xstate_alloc_save_area is reworked so it only allocates the XSAVE area, but doesn't initialize it. Then XSAVE area initialization should be done in vcpu_restore_fpu_lazy. Roger.