• Chang S. Bae's avatar
    x86/fpu/xstate: Add fpstate_realloc()/free() · 500afbf6
    Chang S. Bae authored
    The fpstate embedded in struct fpu is the default state for storing the FPU
    registers. It's sized so that the default supported features can be stored.
    For dynamically enabled features the register buffer is too small.
    
    The #NM handler detects first use of a feature which is disabled in the
    XFD MSR. After handling permission checks it recalculates the size for
    kernel space and user space state and invokes fpstate_realloc() which
    tries to reallocate fpstate and install it.
    
    Provide the allocator function which checks whether the current buffer size
    is sufficient and if not allocates one. If allocation is successful the new
    fpstate is initialized with the new features and sizes and the now enabled
    features is removed from the task's XFD mask.
    
    realloc_fpstate() uses vzalloc(). If use of this mechanism grows to
    re-allocate buffers larger than 64KB, a more sophisticated allocation
    scheme that includes purpose-built reclaim capability might be justified.
    Signed-off-by: default avatarChang S. Bae <chang.seok.bae@intel.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/20211021225527.10184-19-chang.seok.bae@intel.com
    500afbf6
api.h 4.92 KB