Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1578265
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state |
| Date | 2017-02-10 09:10 +0100 |
| Message-ID | <t9erf-Q0-1@gated-at.bofh.it> (permalink) |
| References | <t96N4-4gQ-23@gated-at.bofh.it> <t96WJ-4z7-5@gated-at.bofh.it> <t982u-5bz-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
* Rik van Riel <riel@redhat.com> wrote:
> On Fri, 2017-02-10 at 01:02 +0100, Borislav Petkov wrote:
> > On Thu, Feb 09, 2017 at 06:43:47PM -0500, Rik van Riel wrote:
> > > On Skylake CPUs I noticed that XRSTOR is unable to deal with xsave
> > > areas
> > > created by copyout_from_xsaves if the xstate has only SSE/YMM
> > > state, but
> > > no FP state. That is, xfeatures had XFEATURE_MASK_SSE set, but not
> > > XFEATURE_MASK_FP.
> > >
> > > The reason is that part of the SSE/YMM state lives in the MXCSR and
> > > MXCSR_FLAGS fields of the FP area.
> > >
> > > Ensure that whenever we copy SSE or YMM state around, the MXCSR and
> > > MXCSR_FLAGS fields are also copied around.
> > >
> > > Signed-off-by: Rik van Riel <riel@redhat.com>
> > > ---
> > > arch/x86/kernel/fpu/xstate.c | 44
> > > ++++++++++++++++++++++++++++++++++++++++++++
> > > 1 file changed, 44 insertions(+)
> >
> > ...
> >
> > > @@ -987,6 +1004,13 @@ int copy_xstate_to_kernel(void *kbuf, struct
> > > xregs_state *xsave, unsigned int of
> > >
> > > }
> > >
> > > + if (xfeatures_need_mxcsr_copy(header.xfeatures)) {
> > > + offset = offsetof(struct fxregs_state, mxcsr);
> > > + size = sizeof(u64); // copy mxcsr & mxcsr_flags
> >
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > We don't do // comments, do we?
> >
> > And side-line comments are always impairing the readability of the
> > code
> > unless it is a struct's members or asm or so ...
>
> Good point. OTOH, I don't really want to add an extra line
> to each of these blocks of code, either...
>
> Ingo, how would you like me to do these comments?
>
> Or should I have a magic #define with comment somewhere,
> like this?
>
> /* Copy both mxcsr & mxcsr_flags */
> #define MXCSR_AND_FLAGS_SIZE sizeof(u64)
Yeah, that define would make it pretty clear what's going on. Please make it a bit
more vebose:
/* Copy both mxcsr & mxcsr_flags with a single u64 memcpy: */
#define MXCSR_AND_FLAGS_SIZE sizeof(u64)
As for same-line comments, it can be the usual comment form:
size = sizeof(u64); /* Copy mxcsr & mxcsr_flags */
But MXCSR_AND_FLAGS_SIZE is more expressive.
BTW., you can also use a separate comment line in such cases:
/* Copy mxcsr & mxcsr_flags in one u64 step: */
size = sizeof(u64);
... as readability is more important than brevity.
It's the C++ comment style that is frowned upon, as it looks weird in Linux kernel
code.
Thanks,
Ingo
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Rik van Riel <riel@redhat.com> - 2017-02-10 01:00 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Borislav Petkov <bp@suse.de> - 2017-02-10 01:10 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Rik van Riel <riel@redhat.com> - 2017-02-10 02:20 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Ingo Molnar <mingo@kernel.org> - 2017-02-10 09:10 +0100
[PATCH v3] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Rik van Riel <riel@redhat.com> - 2017-02-10 15:30 +0100
Re: [PATCH v3] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Ingo Molnar <mingo@kernel.org> - 2017-02-11 11:10 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Rik van Riel <riel@redhat.com> - 2017-02-10 02:10 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Yu-cheng Yu <yu-cheng.yu@intel.com> - 2017-02-10 19:30 +0100
Re: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state Yu-cheng Yu <yu-cheng.yu@intel.com> - 2017-02-10 02:30 +0100
csiph-web