linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yao, Yuan" <yuan.yao@intel.com>
To: "Bae, Chang Seok" <chang.seok.bae@intel.com>,
	"Hansen, Dave" <dave.hansen@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "x86@kernel.org" <x86@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Subject: RE: [PATCH] x86/fpu: Remove dynamic features from xcomp_bv for init_fpstate
Date: Fri, 14 Oct 2022 04:10:43 +0000	[thread overview]
Message-ID: <BYAPR11MB3717D733EC448197D0321FF695249@BYAPR11MB3717.namprd11.prod.outlook.com> (raw)
In-Reply-To: <084b98d1-1021-14fd-0d7b-3b85ffee3035@intel.com>

>-----Original Message-----
>From: Bae, Chang Seok <chang.seok.bae@intel.com>
>Sent: Friday, October 14, 2022 11:54
>To: Hansen, Dave <dave.hansen@intel.com>; Yao, Yuan <yuan.yao@intel.com>; Dave Hansen <dave.hansen@linux.intel.com>;
>linux-kernel@vger.kernel.org
>Cc: x86@kernel.org; Thomas Gleixner <tglx@linutronix.de>
>Subject: Re: [PATCH] x86/fpu: Remove dynamic features from xcomp_bv for init_fpstate
>
>On 10/13/2022 10:44 AM, Dave Hansen wrote:
>>
>> A better comment for that would be:
>>
>> 	 * Some user_xfeatures may not be present in the fpstate.
>> 	 * Remove those from 'mask' to zero those features in the
>> 	 * user buffer instead of retrieving them from fpstate.
>
>Yes, indeed!
>
>Also this xstate copy routine looks to need some updates.
>
>If an xfeature is present in fpstate, and in init state, the value is
>retrieved from init_fpstate via copy_feature(). But, it has no space for
>dynamic states. Also, for extended states, the init state is known to be
>zero.
>
>Then, perhaps, init_fpstate is better not to be accessed in the
>for_each_extended_xfeature loop; instead of using copy_feature(), the
>feature can be zeroed like this:
>
>diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
>index 13b83b11b3d8..0fdfd03938b6 100644
>--- a/arch/x86/kernel/fpu/xstate.c
>+++ b/arch/x86/kernel/fpu/xstate.c
>@@ -1150,11 +1150,11 @@ void __copy_xstate_to_uabi_buf(struct membuf to,
>struct fpstate *fpstate,
>                          */
>                         pkru.pkru = pkru_val;
>                         membuf_write(&to, &pkru, sizeof(pkru));
>-               } else {
>-                       copy_feature(header.xfeatures & BIT_ULL(i), &to,
>-                                    __raw_xsave_addr(xsave, i),
>-                                    __raw_xsave_addr(xinit, i),
>+               } else if (header.xfeatures & BIT_ULL(i)) {
>+                       membuf_write(&to, __raw_xsave_addr(xsave, i),
>                                      xstate_sizes[i]);
>+               } else {
>+                       membuf_zero(&to, xstate_sizes[i]);

Ah, I didn’t aware your reply before sent mine :- ) 

Does init_fpstate saves the "init" state for all non-dynamic components in its buffer ? if no than 
this change is better, else read from init_fpstate for allocated buffer and only zero the not exist buffer is preferred to me.
The head.xfeatures is 0 before the guest fpu is used to xsaves at least once.

>                 }
>
>Thanks,
>Chang

  reply	other threads:[~2022-10-14  4:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 22:24 [PATCH] x86/fpu: Remove dynamic features from xcomp_bv for init_fpstate Dave Hansen
2022-10-11 22:47 ` Chang S. Bae
2022-10-13  1:33 ` Yao, Yuan
2022-10-13  1:47 ` Chang S. Bae
2022-10-13  3:35 ` Yao, Yuan
2022-10-13 16:23   ` Chang S. Bae
2022-10-13 17:21     ` Dave Hansen
2022-10-13 17:33       ` Chang S. Bae
2022-10-13 17:44         ` Dave Hansen
2022-10-14  3:53           ` Chang S. Bae
2022-10-14  4:10             ` Yao, Yuan [this message]
2022-10-14  4:26               ` Chang S. Bae
2022-10-14  4:03     ` Yao, Yuan
2022-10-13 18:04   ` Dave Hansen
2022-10-17 22:39 ` Chang S. Bae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR11MB3717D733EC448197D0321FF695249@BYAPR11MB3717.namprd11.prod.outlook.com \
    --to=yuan.yao@intel.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).