linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/23] Kernel userspace access/execution prevention with hash translation
@ 2020-08-27  4:09 Aneesh Kumar K.V
  2020-08-27  4:09 ` [PATCH v5 01/23] powerpc: Add new macro to handle NESTED_IFCLR Aneesh Kumar K.V
                   ` (22 more replies)
  0 siblings, 23 replies; 36+ messages in thread
From: Aneesh Kumar K.V @ 2020-08-27  4:09 UTC (permalink / raw)
  To: linuxppc-dev, mpe; +Cc: Aneesh Kumar K.V

This patch series implements KUAP and KUEP with hash translation mode using
memory keys. The kernel now uses memory protection key 3 to control access
to the kernel. Kernel page table entries are now configured with key 3.
Access to locations configured with any other key value is denied when in
kernel mode (MSR_PR=0). This includes userspace which is by default configured
with key 0.

null-syscall benchmark results:

With smap/smep disabled:
Without patch:
	845.29 ns    2451.44 cycles
With patch series:
	858.38 ns    2489.30 cycles

With smap/smep enabled:
Without patch:
	NA
With patch series:
	1021.51 ns    2962.44 cycles

Changes from v4:
* Repost with other pkey related changes split out as a separate series.
* Improve null-syscall benchmark by optimizing SPRN save and restore.

Changes from v3:
* Fix build error reported by kernel test robot <lkp@intel.com>

Changes from v2:
* Rebase to the latest kernel.
* Fixed a bug with disabling KUEP/KUAP on kernel command line
* Added a patch to make kup key dynamic.

Changes from V1:
* Rebased on latest kernel

Aneesh Kumar K.V (23):
  powerpc: Add new macro to handle NESTED_IFCLR
  KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR
  powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of
    PPC_MEM_KEYS
  powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init
  powerpc/book3s64/kuap: Move KUAP related function outside radix
  powerpc/book3s64/kup: Use the correct #ifdef when including headers
  powerpc/book3s64/kuep: Move KUEP related function outside radix
  powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP
  powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash
    translation
  powerpc/exec: Set thread.regs early during exec
  powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on
    entry and exit from kernel
  powerpc/book3s64/pkeys: Inherit correctly on fork.
  powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec
  powerpc/ptrace-view: Use pt_regs values instead of thread_struct based
    one.
  powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode.
  powerpc/book3s64/kuap: Restrict access to userspace based on userspace
    AMR
  powerpc/book3s64/kuap: Improve error reporting with KUAP
  powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash
    translation.
  powerpc/book3s64/kuep: Use Key 3 to implement KUEP with hash
    translation.
  powerpc/book3s64/hash/kuap: Enable kuap on hash
  powerpc/book3s64/hash/kuep: Enable KUEP on hash
  powerpc/book3s64/hash/kup: Don't hardcode kup key
  powerpc/book3s64/pkeys: Optimize FTR_KUAP and FTR_KUEP disabled case

 arch/powerpc/include/asm/book3s/32/kup.h      |   4 +-
 .../powerpc/include/asm/book3s/64/hash-pkey.h |  10 +-
 arch/powerpc/include/asm/book3s/64/hash.h     |   2 +-
 .../powerpc/include/asm/book3s/64/kup-radix.h | 185 --------
 arch/powerpc/include/asm/book3s/64/kup.h      | 409 ++++++++++++++++++
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |   1 +
 arch/powerpc/include/asm/book3s/64/mmu.h      |   2 +-
 arch/powerpc/include/asm/book3s/64/pkeys.h    |   3 +
 arch/powerpc/include/asm/feature-fixups.h     |   3 +
 arch/powerpc/include/asm/kup.h                |  14 +-
 arch/powerpc/include/asm/mmu.h                |  16 +-
 arch/powerpc/include/asm/mmu_context.h        |   2 +-
 arch/powerpc/include/asm/nohash/32/kup-8xx.h  |   4 +-
 arch/powerpc/include/asm/processor.h          |   4 -
 arch/powerpc/include/asm/ptrace.h             |   6 +-
 arch/powerpc/include/asm/thread_info.h        |   2 -
 arch/powerpc/kernel/asm-offsets.c             |   4 +-
 arch/powerpc/kernel/entry_64.S                |   6 +-
 arch/powerpc/kernel/exceptions-64s.S          |   4 +-
 arch/powerpc/kernel/process.c                 |  56 ++-
 arch/powerpc/kernel/ptrace/ptrace-view.c      |   7 +-
 arch/powerpc/kernel/syscall_64.c              |  38 +-
 arch/powerpc/kernel/traps.c                   |   6 -
 arch/powerpc/kvm/book3s_emulate.c             |   6 +
 arch/powerpc/mm/book3s64/Makefile             |   2 +-
 arch/powerpc/mm/book3s64/hash_4k.c            |   2 +-
 arch/powerpc/mm/book3s64/hash_64k.c           |   4 +-
 arch/powerpc/mm/book3s64/hash_hugepage.c      |   2 +-
 arch/powerpc/mm/book3s64/hash_hugetlbpage.c   |   2 +-
 arch/powerpc/mm/book3s64/hash_pgtable.c       |   2 +-
 arch/powerpc/mm/book3s64/hash_utils.c         |  10 +-
 arch/powerpc/mm/book3s64/pkeys.c              | 177 +++++---
 arch/powerpc/mm/book3s64/radix_pgtable.c      |  47 +-
 arch/powerpc/mm/fault.c                       |   2 +-
 arch/powerpc/platforms/Kconfig.cputype        |   4 +
 35 files changed, 679 insertions(+), 369 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/book3s/64/kup-radix.h
 create mode 100644 arch/powerpc/include/asm/book3s/64/kup.h

-- 
2.26.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2020-10-18  4:09 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27  4:09 [PATCH v5 00/23] Kernel userspace access/execution prevention with hash translation Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 01/23] powerpc: Add new macro to handle NESTED_IFCLR Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 02/23] KVM: PPC: BOOK3S: PR: Ignore UAMOR SPR Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 03/23] powerpc/book3s64/kuap/kuep: Make KUAP and KUEP a subfeature of PPC_MEM_KEYS Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 04/23] powerpc/book3s64/kuap/kuep: Move uamor setup to pkey init Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 05/23] powerpc/book3s64/kuap: Move KUAP related function outside radix Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 06/23] powerpc/book3s64/kup: Use the correct #ifdef when including headers Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 07/23] powerpc/book3s64/kuep: Move KUEP related function outside radix Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 08/23] powerpc/book3s64/kuap: Rename MMU_FTR_RADIX_KUAP to MMU_FTR_KUAP Aneesh Kumar K.V
2020-08-27  4:57   ` Christophe Leroy
2020-08-27  4:09 ` [PATCH v5 09/23] powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation Aneesh Kumar K.V
2020-10-18  3:46   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 10/23] powerpc/exec: Set thread.regs early during exec Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 11/23] powerpc/book3s64/pkeys: Store/restore userspace AMR/IAMR correctly on entry and exit from kernel Aneesh Kumar K.V
2020-10-18  3:49   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 12/23] powerpc/book3s64/pkeys: Inherit correctly on fork Aneesh Kumar K.V
2020-10-18  3:50   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 13/23] powerpc/book3s64/pkeys: Reset userspace AMR correctly on exec Aneesh Kumar K.V
2020-10-18  3:50   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 14/23] powerpc/ptrace-view: Use pt_regs values instead of thread_struct based one Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 15/23] powerpc/book3s64/pkeys: Don't update SPRN_AMR when in kernel mode Aneesh Kumar K.V
2020-10-18  3:52   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 16/23] powerpc/book3s64/kuap: Restrict access to userspace based on userspace AMR Aneesh Kumar K.V
2020-10-18  4:00   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 17/23] powerpc/book3s64/kuap: Improve error reporting with KUAP Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 18/23] powerpc/book3s64/kuap: Use Key 3 to implement KUAP with hash translation Aneesh Kumar K.V
2020-10-18  4:00   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 19/23] powerpc/book3s64/kuep: Use Key 3 to implement KUEP " Aneesh Kumar K.V
2020-10-18  4:01   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 20/23] powerpc/book3s64/hash/kuap: Enable kuap on hash Aneesh Kumar K.V
2020-09-12 11:54   ` Michael Ellerman
2020-10-18  4:02   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 21/23] powerpc/book3s64/hash/kuep: Enable KUEP " Aneesh Kumar K.V
2020-10-18  4:03   ` Sandipan Das
2020-08-27  4:09 ` [PATCH v5 22/23] powerpc/book3s64/hash/kup: Don't hardcode kup key Aneesh Kumar K.V
2020-08-27  4:09 ` [PATCH v5 23/23] powerpc/book3s64/pkeys: Optimize FTR_KUAP and FTR_KUEP disabled case Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).