From: Dave Hansen <dave.hansen@intel.com>
To: "Chang S. Bae" <chang.seok.bae@intel.com>, linux-kernel@vger.kernel.org
Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
yuan.yao@intel.com
Subject: Re: [PATCH 1/1] x86/fpu: Fix copy_xstate_to_uabi() to copy init states correctly
Date: Thu, 20 Oct 2022 09:57:28 -0700 [thread overview]
Message-ID: <f086b776-75ad-47b1-e87a-7fb07c1cee3b@intel.com> (raw)
In-Reply-To: <20221018221349.4196-2-chang.seok.bae@intel.com>
On 10/18/22 15:13, Chang S. Bae wrote:
> @@ -1141,10 +1141,14 @@ void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
> */
> pkru.pkru = pkru_val;
> membuf_write(&to, &pkru, sizeof(pkru));
> + } else if (!(header.xfeatures & BIT_ULL(i))) {
> + /*
> + * Every extended state component has an all zeros
> + * init state.
> + */
> + membuf_zero(&to, xstate_sizes[i]);
> } else {
> - copy_feature(header.xfeatures & BIT_ULL(i), &to,
> - __raw_xsave_addr(xsave, i),
> - __raw_xsave_addr(xinit, i),
> + membuf_write(&to, __raw_xsave_addr(xsave, i),
> xstate_sizes[i]);
> }
Just to add a bit more context, this is inside this loop:
mask = fpstate->user_xfeatures;
for_each_extended_xfeature(i, mask) {
if (zerofrom < xstate_offsets[i])
membuf_zero(&to, xstate_offsets[i] - zerofrom);
...
}
if (to.left)
membuf_zero(&to, to.left);
In other words, the loop and the surrounding code already know how to
membuf_zero() any gaps in the middle or the end of the user buffer.
Would it be simpler to just adjust the 'mask' over which the loop iterates?
I think that would end up being something like:
mask = fpstate->user_xfeatures &
(xsave->xfeatures | xinit->xfeatures);
Logically, that makes sense too. We're copying out of either 'xsave' or
'xinit'. If a feature isn't in either one of those we can't do the
copy_feature() on it.
next prev parent reply other threads:[~2022-10-20 16:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 19:12 [PATCH 0/3] x86/fpu: Improve the init_fpstate setup code Chang S. Bae
2022-08-24 19:12 ` [PATCH 1/3] x86/fpu: Configure init_fpstate attributes orderly Chang S. Bae
2022-10-03 21:18 ` Neel Natu
2022-10-17 13:47 ` [tip: x86/urgent] " tip-bot2 for Chang S. Bae
2022-08-24 19:12 ` [PATCH 2/3] x86/fpu: Fix the init_fpstate size check with the actual size Chang S. Bae
2022-10-17 13:47 ` [tip: x86/urgent] " tip-bot2 for Chang S. Bae
2022-08-24 19:12 ` [PATCH 3/3] x86/fpu: Exclude dynamic states from init_fpstate Chang S. Bae
2022-10-17 13:47 ` [tip: x86/urgent] " tip-bot2 for Chang S. Bae
2022-10-18 22:13 ` [PATCH 0/1] x86/fpu: Follow up on the init_fpstate fix Chang S. Bae
2022-10-18 22:13 ` [PATCH 1/1] x86/fpu: Fix copy_xstate_to_uabi() to copy init states correctly Chang S. Bae
2022-10-20 16:57 ` Dave Hansen [this message]
2022-10-20 18:52 ` Chang S. Bae
2022-10-21 18:58 ` [PATCH v2] " Chang S. Bae
2022-10-21 22:25 ` [tip: x86/urgent] " tip-bot2 for Chang S. Bae
2022-10-22 6:23 ` Ingo Molnar
2022-10-22 13:02 ` Chang S. Bae
2023-02-27 21:05 ` [PATCH 0/2] x86/fpu/xstate: Follow up on the init_fpstate fallout again Chang S. Bae
2023-02-27 21:05 ` [PATCH 1/2] x86/fpu/xstate: Prevent false-positive warning in __copy_xstate_uabi_buf() Chang S. Bae
2023-02-27 21:05 ` [PATCH 2/2] selftests/x86/amx: Add a ptrace test 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=f086b776-75ad-47b1-e87a-7fb07c1cee3b@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox