• D
    x86/fpu: Allow setting of XSAVE state · b8b9b6ba
    Dave Hansen 提交于
    We want to modify the Protection Key rights inside the kernel, so
    we need to change PKRU's contents.  But, if we do a plain
    'wrpkru', when we return to userspace we might do an XRSTOR and
    wipe out the kernel's 'wrpkru'.  So, we need to go after PKRU in
    the xsave buffer.
    
    We do this by:
    
      1. Ensuring that we have the XSAVE registers (fpregs) in the
         kernel FPU buffer (fpstate)
      2. Looking up the location of a given state in the buffer
      3. Filling in the stat
      4. Ensuring that the hardware knows that state is present there
         (basically that the 'init optimization' is not in place).
      5. Copying the newly-modified state back to the registers if
         necessary.
    Signed-off-by: NDave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Dave Hansen <dave@sr71.net>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/20160212210235.5A3139BF@viggo.jf.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
    b8b9b6ba
internal.h 18.1 KB