• Chang S. Bae's avatar
    selftests/x86/amx: Add test cases for AMX state management · 6a3e0651
    Chang S. Bae authored
    AMX TILEDATA is a very large XSAVE feature.  It could have caused
    nasty XSAVE buffer space waste in two places:
    
     * Signal stacks
     * Kernel task_struct->fpu buffers
    
    To avoid this waste, neither of these buffers have AMX state by
    default.  The non-default features are called "dynamic" features.
    
    There is an arch_prctl(ARCH_REQ_XCOMP_PERM) which allows a task
    to declare that it wants to use AMX or other "dynamic" XSAVE
    features.  This arch_prctl() ensures that sufficient sigaltstack
    space is available before it will succeed.  It also expands the
    task_struct buffer.
    
    Functions of this test:
     * Test arch_prctl(ARCH_REQ_XCOMP_PERM).  Ensure that it checks for
       proper sigaltstack sizing and that the sizing is enforced for
       future sigaltstack calls.
     * Ensure that ARCH_REQ_XCOMP_PERM is inherited across fork()
     * Ensure that TILEDATA use before the prctl() is fatal
     * Ensure that TILEDATA is cleared across fork()
    
    Note: Generally, compiler support is needed to do something with
    AMX.  Instead, directly load AMX state from userspace with a
    plain XSAVE.  Do not depend on the compiler.
    
     [ dhansen: bunches of cleanups ]
    Signed-off-by: default avatarChang S. Bae <chang.seok.bae@intel.com>
    Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lkml.kernel.org/r/20211026122524.7BEDAA95@davehans-spike.ostc.intel.com
    6a3e0651
Makefile 3.43 KB