[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Fri, 27 Mar 2026 10:04:19 +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=lATMMXG+NWg2y3eQXyaSPwpqqFTx9NEydPGz3X1MHwM=; b=jveL7FQCCfNw9NXVUC6D2VfGLgEw4wr4Gh9mGuN6GypUz5sP7REXnQYwWjZtmW8kPglcpKELEKWHIlNp7gB1JI0WNjEffgov4HiMTscQ4dHbIsMw373Mdqo7VjFv0nbjqdT+k0pKGewJEiW4FdY2fgPyBr3Zl23ThfahF1h7befvwbJSzOjcxoo/qDFdWk6IiVu5AL7mZI463hYeOgdgWLpNEw0Ic37KnHX8rV3x5YWddFr5VCKu1qi9vKG2W7qnPI20GFdUs5yZr56peFGj0wjS5418ykGUS7dogWZNKCizQP7/EawNSLNtnfdkvQ5BcZHmo4lcfVJVkXGtiSXQnQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eYJvi0WdWgrIXkje5b8+OZC+4XAYx6lB30dueH3AclAUnhgItTwUi1tyR3wOtc2lG703D/VGjegUrvg3jbJSwD782P7/DMFBEv2qulQvCWOoxGm6hQwFnxHsTRflFjkECivAocQGGCu+7iemXtZ5jdZW0blYjZG1qaOXUp0ZL0LQZW7W6lnW2IQ+t1NeqEAm7XMyG+oBECAXZkdExrodRpa81aU7KGRtxN4EQ+a4cvVWj29pAmwxzpPqMN838CkqR+Hz94tpCzbQIubbGFO6NYs045K42wqpw5wczy7H2aD0eOtggAfYujU7ikAv41Sx3tw648ibeD7Ug7SG15HPkA==
  • 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: Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 27 Mar 2026 10:05:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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?

As they seem to be mostly doing the same thing, could we call
vcpu_reset_fpu() here instead?

Ross



 


Rackspace

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