lkml.org 
[lkml]   [2017]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH v2] x86/fpu: copy MXCSR & MXCSR_FLAGS with SSE/YMM state
    From
    Date
    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)

    \
     
     \ /
      Last update: 2017-02-10 02:18    [W:7.116 / U:0.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site