• Dave Hansen's avatar
    x86/pkeys: Add self-tests · 5f23f6d0
    Dave Hansen authored
    This code should be a good demonstration of how to use the new
    system calls as well as how to use protection keys in general.
    
    This code shows how to:
    1. Manipulate the Protection Keys Rights User (PKRU) register
    2. Set a protection key on memory
    3. Fetch and/or modify PKRU from the signal XSAVE state
    4. Read the kernel-provided protection key in the siginfo
    5. Set up an execute-only mapping
    
    There are currently 13 tests:
    
      test_read_of_write_disabled_region
      test_read_of_access_disabled_region
      test_write_of_write_disabled_region
      test_write_of_access_disabled_region
      test_kernel_write_of_access_disabled_region
      test_kernel_write_of_write_disabled_region
      test_kernel_gup_of_access_disabled_region
      test_kernel_gup_write_to_write_disabled_region
      test_executing_on_unreadable_memory
      test_ptrace_of_child
      test_pkey_syscalls_on_non_allocated_pkey
      test_pkey_syscalls_bad_args
      test_pkey_alloc_exhaust
    
    Each of the tests is run with plain memory (via mmap(MAP_ANON)),
    transparent huge pages, and hugetlb.
    Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
    Cc: linux-arch@vger.kernel.org
    Cc: Dave Hansen <dave@sr71.net>
    Cc: mgorman@techsingularity.net
    Cc: arnd@arndb.de
    Cc: linux-api@vger.kernel.org
    Cc: shuahkh@osg.samsung.com
    Cc: linux-mm@kvack.org
    Cc: luto@kernel.org
    Cc: akpm@linux-foundation.org
    Cc: torvalds@linux-foundation.org
    Link: http://lkml.kernel.org/r/20160729163024.FC5A0C2D@viggo.jf.intel.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    5f23f6d0
pkey-helpers.h 4.8 KB