From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
<linux-kernel@vger.kernel.org>
Cc: <x86@kernel.org>, Yuan Yao <yuan.yao@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] x86/fpu: Remove dynamic features from xcomp_bv for init_fpstate
Date: Mon, 17 Oct 2022 15:39:39 -0700 [thread overview]
Message-ID: <1bb04108-a250-7cc7-e008-a227cbafdb15@intel.com> (raw)
In-Reply-To: <20221011222425.866137-1-dave.hansen@linux.intel.com>
On 10/11/2022 3:24 PM, Dave Hansen wrote:
>
> diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> index 3b28c5b25e12..4d64de34da12 100644
> --- a/arch/x86/kernel/fpu/core.c
> +++ b/arch/x86/kernel/fpu/core.c
> @@ -526,6 +526,9 @@ static void __fpstate_reset(struct fpstate *fpstate, u64 xfd)
> fpstate->xfeatures = fpu_kernel_cfg.default_features;
> fpstate->user_xfeatures = fpu_user_cfg.default_features;
> fpstate->xfd = xfd;
> +
> + /* Ensure that xcomp_bv matches ->xfeatures */
> + xstate_init_xcomp_bv(&fpstate->regs.xsave, fpstate->xfeatures);
> }
I have some difficulty understanding the problem without this. Maybe I'm
missing something here:
We have two call sites for this -- (a) one for the guest fpstate
allocation [1] and (b) the other for the reset [2].
(a) The former has a call chain to init xcomp_bv:
fpu_alloc_guest_fpstate()->fpstate_init_user()->xstate_init_xcomp_bv()
(b) And the latter picks up the default area:
void fpstate_reset(struct fpu *fpu)
{
/* Set the fpstate pointer to the default fpstate */
fpu->fpstate = &fpu->__fpstate;
__fpstate_reset(fpu->fpstate, init_fpstate.xfd);
...
}
Then, xcomp_bv looks to be subsequently written by XSAVE* or by copying
from init_fpstate.
There are three distinct call sites for fpstate_reset():
* fpu_clone() [3]: the child will either copy from init_fpstate or do
XSAVE* that will update xcomp_bv according to ->xfeatures.
* fpu__init_system_xstate() [4]: When the init task switches away,
xcomp_bv will be updated by XSAVE*.
* fpu_flush_thread() [5]: xcomp_bv will be copied from init_fpstate via
fpu_reset_fpregs().
Thanks,
Chang
[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/core.c#n229
[2]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/core.c#n535
[3]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/core.c#n567
[4]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/xstate.c#n869
[5]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/core.c#n744
prev parent reply other threads:[~2022-10-17 22:39 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
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 [this message]
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=1bb04108-a250-7cc7-e008-a227cbafdb15@intel.com \
--to=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 \
--cc=yuan.yao@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.