Skip to content

powerpc: Optimise KUAP on book3s/32

Christophe Leroy linuxppc-dev lkml 1 version Applied

Status from this message: Applied to powerpc/next.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest12 patches 2 repliesApplied

Changes in v2 from the cover letter

- Incorporated the conversion to C of switch_mmu_context()
- Converted initial KUAP/KUEP setup to C
- Added capability to disable KUAP and KUEP at boottime
- Enable KUAP and KUEP by default

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/12powerpc/32s: Move setup_{kuep/kuap}() into {kuep/kuap}.carch/powerpc/mm/book3s32/Makefile arch/powerpc/mm/book3s32/kuap.c arch/powerpc/mm/book3s32/kuep.c +1 more+20 -200 replies
2/12powerpc/32s: Refactor update of user segment registersarch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/include/asm/book3s/32/mmu-hash.h arch/powerpc/include/asm/kup.h +1 more+49 -410 replies
3/12powerpc/32s: move CTX_TO_VSID() into mmu-hash.harch/powerpc/include/asm/book3s/32/mmu-hash.h arch/powerpc/kvm/book3s_32_mmu_host.c arch/powerpc/mm/book3s32/mmu_context.c+10 -160 replies
4/12powerpc/32s: Convert switch_mmu_context() to Carch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/kernel/asm-offsets.c arch/powerpc/kernel/head_book3s_32.S +1 more+40 -630 replies
5/12powerpc/32s: Simplify calculation of segment register contentarch/powerpc/include/asm/book3s/32/mmu-hash.h+23 -190 replies
6/12powerpc/32s: Initialise KUAP and KUEP in Carch/powerpc/kernel/head_book3s_32.S arch/powerpc/kernel/smp.c arch/powerpc/mm/book3s32/kuap.c +1 more+16 -60 replies
7/12powerpc/32s: Allow disabling KUEP at boot timearch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/mm/book3s32/kuep.c+12 -50 replies
8/12powerpc/32s: Allow disabling KUAP at boot timearch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/mm/book3s32/kuap.c+33 -51 reply
9/12powerpc/32s: Rework Kernel Userspace Access Protectionarch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/include/asm/processor.h arch/powerpc/kernel/process.c +1 more+102 -730 replies
10/12powerpc/32s: Activate KUAP and KUEP by defaultarch/powerpc/platforms/Kconfig.cputype+2 -20 replies
11/12powerpc/kuap: Remove KUAP_CURRENT_XXXarch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/include/asm/kup.h+3 -120 replies
12/12powerpc/kuap: Remove to/from/size parameters of prevent_user_access()arch/powerpc/include/asm/book3s/32/kup.h arch/powerpc/include/asm/book3s/64/kup.h arch/powerpc/include/asm/kup.h +1 more+10 -140 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/12] powerpc: Optimise KUAP on book3s/32

This series is a rework of KUAP on book3s/32.

On book3s32, KUAP is heavier than on other platform because it can't be opened globaly at once, it must be done for each 256Mb segment.

Instead of opening access to all necessary segments via a heavy logic, only open access to the segment matching the start of the range.

99.999% of the time, the range doesn't cross segment limit so it is not worth checking and handling that corner case at the first place. If that happens, take a fault and do the additional segments opening in the fault handler. See patch 9 for details.

This series also adds the capability to disable KUAP and KUEP at boot time via the "nosmap" and "nosmep" kernel parameters as PPC64 does.

Last 2 patches are cleanup of generic KUAP code once book3s/32 has been simplified.

Changes in v2:
- Incorporated the conversion to C of switch_mmu_context()
- Converted initial KUAP/KUEP setup to C
- Added capability to disable KUAP and KUEP at boottime
- Enable KUAP and KUEP by default

Christophe Leroy (12):
powerpc/32s: Move setup_{kuep/kuap}() into {kuep/kuap}.c powerpc/32s: Refactor update of user segment registers powerpc/32s: move CTX_TO_VSID() into mmu-hash.h powerpc/32s: Convert switch_mmu_context() to C powerpc/32s: Simplify calculation of segment register content powerpc/32s: Initialise KUAP and KUEP in C
powerpc/32s: Allow disabling KUEP at boot time powerpc/32s: Allow disabling KUAP at boot time powerpc/32s: Rework Kernel Userspace Access Protection powerpc/32s: Activate KUAP and KUEP by default powerpc/kuap: Remove KUAP_CURRENT_XXX
powerpc/kuap: Remove to/from/size parameters of prevent_user_access()

 arch/powerpc/include/asm/book3s/32/kup.h      | 199 ++++++++++++------
 arch/powerpc/include/asm/book3s/32/mmu-hash.h |  41 ++++
 arch/powerpc/include/asm/book3s/64/kup.h      |   3 +-
 arch/powerpc/include/asm/kup.h                |  28 +--
 arch/powerpc/include/asm/nohash/32/kup-8xx.h  |   3 +-
 arch/powerpc/include/asm/processor.h          |  10 +-
 arch/powerpc/kernel/asm-offsets.c             |   5 -
 arch/powerpc/kernel/head_book3s_32.S          |  64 ------
 arch/powerpc/kernel/process.c                 |   3 +
 arch/powerpc/kernel/smp.c                     |   4 +
 arch/powerpc/kvm/book3s_32_mmu_host.c         |   3 -
 arch/powerpc/mm/book3s32/Makefile             |   1 +
 arch/powerpc/mm/book3s32/kuap.c               |  30 +++
 arch/powerpc/mm/book3s32/kuep.c               |  42 +---
 arch/powerpc/mm/book3s32/mmu.c                |  20 --
 arch/powerpc/mm/book3s32/mmu_context.c        |  48 +++--
 arch/powerpc/platforms/Kconfig.cputype        |   4 +-
 17 files changed, 276 insertions(+), 232 deletions(-)
 create mode 100644 arch/powerpc/mm/book3s32/kuap.c
Signature · 1 line
2.25.0