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

Re: [PATCH 2/2] x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 27 Mar 2026 16:21:58 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ycr6zfo8t9VZ5q0vHSI77f2ZyV3kSnoqeHgKcKxwuOc=; b=ZqpiVJ2lzyNbDqGrlvfnAgjP/Z1CAFG216DJN67WV/Qn0yqerxGPemWGiX/BpzrjQn033euh87Y/T8+ls5gfGPkMKMQUKJuaiEvuvapX0iVZ+0CdVulI2jBw3RDuv33Pa4XEX2morwR/lS4HK41XevZgpuCPMP9MtxyKGpGAog9ipJRKW8a1OX7qArKCGxiRzMspU6YWtvK2OuF0/mHg2JTuo0Zr7Yd4jSEZYVYIX89/7ZFWUbioescXtE1sZK2p/zc7CDJKlGztwljvgexyl471hWSHbZeUV0BsjBoq2dniySwEiD4yACOtQgbTXQhG6pvElu59bnOV/Nz/eL0/+w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ik//9bHvcWrHBt1BMAHrnPzozTLzUzs7QO2PypnzROisQpoaRVq6E+ZNokEiWBWIg9b/H8dkwP0AZCV7oA9R7Ocgs1UvqBgfXuWceF4HVvFaB99XW2idD9PAHDLkKAAyexzj6rnJSV9nm4q4LJjnsTfUcM7GlCMkMtXxICrtK9gwTjEJiDdGmsnKEiohUl+AWCAxB8AKwCr2p3gmjTf3OA7uVaE3N8r92Jn/Q44VJcopE/FR4FOh/YQDrszNi0vgwYAdGJKZQ1OLrhhCtmz1C3hwzYc9kkXIAUZsXyTWluH59KKcc4JwFDgYiiFc4WBkc/3z8DHQE25wscOIxIgzEg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 27 Mar 2026 16:22:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27/03/2026 10:17 am, Jan Beulich wrote:
> On 27.03.2026 11:04, Ross Lagerwall wrote:
>> On 3/26/26 7:04 PM, Andrew Cooper wrote:
>>> xstate_alloc_save_area() configures FCW and MXCSR to #RESET values but 
>>> misses
>>> FTW.  Fixing this means that the backing memory always has an 
>>> architecturally
>>> correct value.
>>>
>>> Adjust the comment to state that it's the #RESET values which we care about.
>>>
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>> ---
>>> CC: Jan Beulich <JBeulich@xxxxxxxx>
>>> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>>> CC: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
>>>
>>> I don't understand what the rest of the comment is trying to say, so have 
>>> left
>>> it alone.  There's still a lot of cleanup to be done to merge i387 and 
>>> xstate.
>>> ---
>>>   xen/arch/x86/xstate.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
>>> index e990abc9d18c..747df0b2e9a9 100644
>>> --- a/xen/arch/x86/xstate.c
>>> +++ b/xen/arch/x86/xstate.c
>>> @@ -550,11 +550,12 @@ int xstate_alloc_save_area(struct vcpu *v)
>>>           return -ENOMEM;
>>>   
>>>       /*
>>> -     * Set the memory image to default values, but don't force the context
>>> +     * Set the memory image to #RESET values, but don't force the context
>>>        * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv
>>>        * clear).
>>>        */
>>>       save_area->fpu_sse.fcw = FCW_DEFAULT;
>>> +    save_area->fpu_sse.ftw = FXSAVE_FTW_RESET;
>>>       save_area->fpu_sse.mxcsr = MXCSR_DEFAULT;
>>>   
>>>       v->arch.xsave_area = save_area;
>> Is this comment correct given that it is initializing FCW to FCW_DEFAULT
>> which is different from FCW_RESET?
> Is the goal here to represent XSAVE init-state in memory, or do we truly mean
> #RESET state (in which case FCW_RESET would need using, and in which case
> leaving xstate_bv bit 0 clear would be wrong).

We're creating the vCPU, so conceptually I think #RESET state is what we
want.

But, I'd forgotten that #RESET and #INIT FCW are different.  Also, we
don't really want to be taking the overhead of keeping this properly at
the #RESET state until the guest executes an FNINIT/etc.

I think it's better to keep using DEFAULT here.  I'll rework the comment
and commit message.

This also suggests that we want to rethink vcpu_reset_fpu(), but we can
leave that for later.

~Andrew



 


Rackspace

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