Skip to content

x86: Memory Protection Keys

Dave Hansen linux-api linux-arch linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest25 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/25x86, fpu: add placeholder for Processor Trace XSAVE statearch/x86/include/asm/fpu/types.h arch/x86/kernel/fpu/xstate.c+9 -21 reply
2/25x86, pkeys: Add Kconfig optionarch/x86/Kconfig+4 -01 reply
3/25x86, pkeys: cpuid bit definitionarch/x86/include/asm/cpufeature.h arch/x86/include/asm/disabled-features.h arch/x86/include/asm/required-features.h +1 more+50 -211 reply
4/25x86, pku: define new CR4 bitarch/x86/include/uapi/asm/processor-flags.h+2 -01 reply
5/25x86, pkey: add PKRU xsave fields and data structure(s)arch/x86/include/asm/fpu/types.h arch/x86/include/asm/fpu/xstate.h arch/x86/kernel/fpu/xstate.c+25 -22 replies
6/25x86, pkeys: PTE bits for storing protection keyarch/x86/include/asm/pgtable_types.h+16 -11 reply
7/25x86, pkeys: new page fault error code bit: PF_PKarch/x86/mm/fault.c+6 -12 replies
8/25x86, pkeys: store protection in high VMA flagsarch/x86/Kconfig include/linux/mm.h mm/Kconfig+11 -00 replies
9/25x86, pkeys: arch-specific protection bitsarch/x86/include/asm/mmu_context.h arch/x86/include/asm/pgtable_types.h arch/x86/include/uapi/asm/mman.h +1 more+52 -20 replies
10/25x86, pkeys: pass VMA down in to fault signal generation codearch/x86/mm/fault.c+28 -220 replies
11/25x86, pkeys: notify userspace about protection key faultsarch/x86/include/asm/pgtable_types.h arch/x86/mm/fault.c include/uapi/asm-generic/siginfo.h +1 more+79 -60 replies
12/25x86, pkeys: add functions to fetch PKRUarch/x86/include/asm/pgtable.h arch/x86/include/asm/special_insns.h+28 -00 replies
13/25mm: factor out VMA fault permission checkingmm/gup.c+12 -30 replies
14/25mm: simplify get_user_pages() PTE bit handlingarch/x86/mm/gup.c+17 -170 replies
15/25x86, pkeys: check VMAs and PTEs for protection keysarch/powerpc/include/asm/mmu_context.h arch/s390/include/asm/mmu_context.h arch/unicore32/include/asm/mmu_context.h +7 more+165 -44 replies
16/25x86, pkeys: optimize fault handling in access_error()arch/x86/mm/fault.c+10 -00 replies
17/25x86, pkeys: dump PKRU with other kernel registersarch/x86/kernel/process_64.c+2 -00 replies
18/25x86, pkeys: dump PTE pkey in /proc/pid/smapsarch/x86/kernel/setup.c fs/proc/task_mmu.c+14 -00 replies
19/25x86, pkeys: add Kconfig prompt to existing config optionarch/x86/Kconfig+10 -00 replies
20/25mm, multi-arch: pass a protection key in to calc_vm_flag_bits()arch/powerpc/include/asm/mman.h drivers/char/agp/frontend.c drivers/staging/android/ashmem.c +4 more+15 -130 replies
21/25mm: implement new mprotect_key() system callmm/Kconfig mm/mprotect.c+24 -32 replies
22/25x86: wire up mprotect_key() system callarch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_64.tbl arch/x86/include/uapi/asm/mman.h +1 more+10 -00 replies
23/25x86, pkeys: actually enable Memory Protection Keys in CPUDocumentation/kernel-parameters.txt arch/x86/kernel/cpu/common.c+44 -00 replies
24/25x86, pkeys: add self-teststools/testing/selftests/x86/Makefile tools/testing/selftests/x86/pkey-helpers.h tools/testing/selftests/x86/protection_keys.c+1011 -10 replies
25/25x86, pkeys: DocumentationDocumentation/x86/protection-keys.txt+54 -02 replies

Reviews trailers per patch

6 of 25 patches have a Reviewed-by or Acked-by.

PatchDave HansenThomas Gleixner
1/25R-b
2/25R-b
3/25R-b
4/25R-b
5/25
6/25R-b
7/25R-b
8/25
9/25
10/25
11/25
12/25eigned-off-by
13/25
14/25
15/25
16/25
17/25
18/25
19/25
20/25
21/25
22/25
23/25
24/25
25/25

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/25] x86: Memory Protection Keys

I have addressed all known issues and review comments. I believe they are ready to be pulled in to the x86 tree. Note that this is also the first time anyone has seen the new 'selftests' code. If there are issues limited to it, I'd prefer to fix those up separately post-merge.

Changes from RFCv2 (Thanks Ingo and Thomas for most of these):

* few minor compile warnings
* changed 'nopku' interaction with cpuid bits. Now, we do not clear the PKU cpuid bit, we just skip enabling it.
* changed __pkru_allows_write() to also check access disable bit
* removed the unused write_pkru()
* made si_pkey a u64 and added some patch description details. Also made it share space in siginfo with MPX and clarified comments.
* give some real text for the Processor Trace xsave state
* made vma_pkey() less ugly (and much more optimized actually)
* added SEGV_PKUERR to copy_siginfo_to_user()
* remove page table walk when filling in si_pkey, added some big fat comments about it being inherently racy.
* added self test code

MM reviewers, if you are going to look at one thing, please look at patch 14 which adds a bunch of additional vma/pte permission checks.

This code contains a new system call: mprotect_key(), This needs the usual amount of rigor around new interfaces. Review there would be much appreciated.

This code is not runnable to anyone outside of Intel unless they have some special hardware or a fancy simulator. If you are interested in running this for real, please get in touch with me. Hardware is available to a very small but nonzero number of people.

This set is also available here (with the new syscall):

	git://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-pkeys.git pkeys-v006

=== diffstat ===

(note that over half of this is kselftests)

 Documentation/kernel-parameters.txt           |    3 
 Documentation/x86/protection-keys.txt         |   54 +
 arch/powerpc/include/asm/mman.h               |    5 
 arch/powerpc/include/asm/mmu_context.h        |   11 
 arch/s390/include/asm/mmu_context.h           |   11 
 arch/unicore32/include/asm/mmu_context.h      |   11 
 arch/x86/Kconfig                              |   15 
 arch/x86/entry/syscalls/syscall_32.tbl        |    1 
 arch/x86/entry/syscalls/syscall_64.tbl        |    1 
 arch/x86/include/asm/cpufeature.h             |   54 +
 arch/x86/include/asm/disabled-features.h      |   12 
 arch/x86/include/asm/fpu/types.h              |   16 
 arch/x86/include/asm/fpu/xstate.h             |    4 
 arch/x86/include/asm/mmu_context.h            |   71 ++
 arch/x86/include/asm/pgtable.h                |   45 +
 arch/x86/include/asm/pgtable_types.h          |   34 -
 arch/x86/include/asm/required-features.h      |    4 
 arch/x86/include/asm/special_insns.h          |   32 +
 arch/x86/include/uapi/asm/mman.h              |   23 
 arch/x86/include/uapi/asm/processor-flags.h   |    2 
 arch/x86/kernel/cpu/common.c                  |   42 +
 arch/x86/kernel/fpu/xstate.c                  |    7 
 arch/x86/kernel/process_64.c                  |    2 
 arch/x86/kernel/setup.c                       |    9 
 arch/x86/mm/fault.c                           |  143 +++-
 arch/x86/mm/gup.c                             |   37 -
 drivers/char/agp/frontend.c                   |    2 
 drivers/staging/android/ashmem.c              |    9 
 fs/proc/task_mmu.c                            |    5 
 include/asm-generic/mm_hooks.h                |   11 
 include/linux/mm.h                            |   13 
 include/linux/mman.h                          |    6 
 include/uapi/asm-generic/siginfo.h            |   17 
 kernel/signal.c                               |    4 
 mm/Kconfig                                    |   11 
 mm/gup.c                                      |   28 
 mm/memory.c                                   |    4 
 mm/mmap.c                                     |    2 
 mm/mprotect.c                                 |   20 
 mm/nommu.c                                    |    2 
 tools/testing/selftests/x86/Makefile          |    3 
 tools/testing/selftests/x86/pkey-helpers.h    |  182 +++++
 tools/testing/selftests/x86/protection_keys.c |  828 ++++++++++++++++++++++++++
 43 files changed, 1705 insertions(+), 91 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>