linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 00/22] powerpc: Add KUAP support for BOOKE and 40x
Date: Tue, 19 Oct 2021 09:29:11 +0200	[thread overview]
Message-ID: <cover.1634627931.git.christophe.leroy@csgroup.eu> (raw)

On booke/40x we don't have segments like book3s/32.
On booke/40x we don't have access protection groups like 8xx.

Use the PID register to provide user access protection.
Kernel address space can be accessed with any PID.
User address space has to be accessed with the PID of the user.
User PID is always not null.

Everytime the kernel is entered, set PID register to 0 and
restore PID register when returning to user.

Everytime kernel needs to access user data, PID is restored
for the access.

In TLB miss handlers, check the PID and bail out to data storage
exception when PID is 0 and accessed address is in user space.

Note that also forbids execution of user text by kernel except
when user access is unlocked. But this shouldn't be a problem
as the kernel is not supposed to ever run user text.

This series has:
- First five patches remove the complexity due to too much configurability of KUEP (ref https://github.com/linuxppc/issues/issues/379)
- Two following patches have already been submitted and are not directly related to KUAP but would conflict otherwise
- Patch 8 removes 'nosmep' kernel parameter.
- Following patches aim at refactoring the KUAP interface to reduce redundant platform specific code.
- Then comes patches 14 and 15 that add generic support frame for booke type processors
- Followed by the assembly modification for each of the 4 booke family types 
- Last patch removes CONFIG_PPC_HAVE_KUAP and CONFIG_PPC_HAVE_KUEP now that all powerpc platforms have KUAP and KUEP.

Changes in v3:
- Added the first five patches plus patch 8 to reduce the configurability of KUEP
- Patch 4 also adds missing KUEP support to book3e in 32 bits PTE mode.
- Modified 6 and 7 to also remove configurability of KUEP
- Patch 19 links KUEP to KUAP
- Last patch now removes both CONFIG_PPC_HAVE_KUAP and CONFIG_PPC_HAVE_KUEP

Changes in v2:
- Rebased on top of today's merge (trivial conflict with d93f9e23744b ("powerpc/32s: Fix kuap_kernel_restore()"))
- Fix missing check in bad_kuap_fault() which led to KUAP fault on platforms where KUAP was disabled (CI g5_defconfig)
- New patch to fix PPC_KUAP_DEBUG dependency

Christophe Leroy (22):
  Revert "powerpc: Inline setup_kup()"
  powerpc/8xx: Activate KUEP at all time
  powerpc/44x: Activate KUEP at all time
  powerpc/book3e: Activate KUEP at all time
  powerpc/32s: Remove capability to disable KUEP at boottime
  powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly
  powerpc/32s: Save content of sr0 to avoid 'mfsr'
  powerpc/kuep: Remove 'nosmep' boot time parameter except for book3s/64
  powerpc/kuap: Add a generic intermediate layer
  powerpc/kuap: Check KUAP activation in generic functions
  powerpc/kuap: Remove __kuap_assert_locked()
  powerpc/kuap: Add kuap_lock()
  powerpc/nohash: Move setup_kuap out of 8xx.c
  powerpc/config: Add CONFIG_BOOKE_OR_40x
  powerpc/kuap: Prepare for supporting KUAP on BOOK3E/64
  powerpc/kuap: Make PPC_KUAP_DEBUG depend on PPC_KUAP only
  powerpc: Add KUAP support for BOOKE and 40x
  powerpc/kuap: Wire-up KUAP on 44x
  powerpc/kuap: Wire-up KUAP on 40x
  powerpc/kuap: Wire-up KUAP on 85xx in 32 bits mode.
  powerpc/kuap: Wire-up KUAP on book3e/64
  powerpc: Remove CONFIG_PPC_HAVE_KUAP and CONFIG_PPC_HAVE_KUEP

 .../admin-guide/kernel-parameters.txt         |   2 +-
 arch/powerpc/include/asm/book3s/32/kup.h      | 108 ++++------------
 arch/powerpc/include/asm/book3s/32/mmu-hash.h |  82 +++++++++++-
 arch/powerpc/include/asm/book3s/64/kup.h      |  56 ++++----
 arch/powerpc/include/asm/hw_irq.h             |   8 +-
 arch/powerpc/include/asm/interrupt.h          |  13 +-
 arch/powerpc/include/asm/irq.h                |   2 +-
 arch/powerpc/include/asm/kup.h                | 122 ++++++++++++++----
 arch/powerpc/include/asm/nohash/32/kup-8xx.h  |  50 ++-----
 arch/powerpc/include/asm/nohash/32/mmu-44x.h  |   1 -
 arch/powerpc/include/asm/nohash/32/mmu-8xx.h  |   6 +-
 arch/powerpc/include/asm/nohash/kup-booke.h   | 110 ++++++++++++++++
 arch/powerpc/include/asm/processor.h          |  12 ++
 arch/powerpc/include/asm/ptrace.h             |   2 +-
 arch/powerpc/include/asm/reg.h                |   4 +-
 arch/powerpc/kernel/asm-offsets.c             |   3 +-
 arch/powerpc/kernel/entry_32.S                |  31 ++++-
 arch/powerpc/kernel/head_32.h                 |   6 +
 arch/powerpc/kernel/head_40x.S                |   8 ++
 arch/powerpc/kernel/head_44x.S                |  26 ++--
 arch/powerpc/kernel/head_book3s_32.S          |   4 +
 arch/powerpc/kernel/head_fsl_booke.S          |  13 ++
 arch/powerpc/kernel/interrupt.c               |   3 +-
 arch/powerpc/kernel/irq.c                     |   2 +-
 arch/powerpc/kernel/kgdb.c                    |   4 +-
 arch/powerpc/kernel/process.c                 |   9 +-
 arch/powerpc/kernel/setup.h                   |   2 +-
 arch/powerpc/kernel/setup_32.c                |   2 +-
 arch/powerpc/kernel/time.c                    |   2 +-
 arch/powerpc/mm/book3s32/Makefile             |   1 -
 arch/powerpc/mm/book3s32/kuap.c               |   5 +-
 arch/powerpc/mm/book3s32/kuep.c               |  20 ---
 arch/powerpc/mm/book3s32/mmu_context.c        |  15 +--
 arch/powerpc/mm/init-common.c                 |  21 +++
 arch/powerpc/mm/mmu_context.c                 |   9 ++
 arch/powerpc/mm/nohash/44x.c                  |  16 ---
 arch/powerpc/mm/nohash/8xx.c                  |  33 -----
 arch/powerpc/mm/nohash/Makefile               |   2 +-
 arch/powerpc/mm/nohash/kup.c                  |  33 +++++
 arch/powerpc/mm/nohash/mmu_context.c          |   6 +-
 arch/powerpc/mm/nohash/tlb_low_64e.S          |  40 +++++-
 arch/powerpc/platforms/Kconfig.cputype        |  30 ++---
 42 files changed, 606 insertions(+), 318 deletions(-)
 create mode 100644 arch/powerpc/include/asm/nohash/kup-booke.h
 delete mode 100644 arch/powerpc/mm/book3s32/kuep.c
 create mode 100644 arch/powerpc/mm/nohash/kup.c

-- 
2.31.1


             reply	other threads:[~2021-10-19  7:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19  7:29 Christophe Leroy [this message]
2021-10-19  7:29 ` [PATCH v3 01/22] Revert "powerpc: Inline setup_kup()" Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 02/22] powerpc/8xx: Activate KUEP at all time Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 03/22] powerpc/44x: " Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 04/22] powerpc/book3e: " Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 05/22] powerpc/32s: Remove capability to disable KUEP at boottime Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 06/22] powerpc/32s: Do kuep_lock() and kuep_unlock() in assembly Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 07/22] powerpc/32s: Save content of sr0 to avoid 'mfsr' Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 08/22] powerpc/kuep: Remove 'nosmep' boot time parameter except for book3s/64 Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 09/22] powerpc/kuap: Add a generic intermediate layer Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 10/22] powerpc/kuap: Check KUAP activation in generic functions Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 11/22] powerpc/kuap: Remove __kuap_assert_locked() Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 12/22] powerpc/kuap: Add kuap_lock() Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 13/22] powerpc/nohash: Move setup_kuap out of 8xx.c Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 14/22] powerpc/config: Add CONFIG_BOOKE_OR_40x Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 15/22] powerpc/kuap: Prepare for supporting KUAP on BOOK3E/64 Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 16/22] powerpc/kuap: Make PPC_KUAP_DEBUG depend on PPC_KUAP only Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 17/22] powerpc: Add KUAP support for BOOKE and 40x Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 18/22] powerpc/kuap: Wire-up KUAP on 44x Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 19/22] powerpc/kuap: Wire-up KUAP on 40x Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 20/22] powerpc/kuap: Wire-up KUAP on 85xx in 32 bits mode Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 21/22] powerpc/kuap: Wire-up KUAP on book3e/64 Christophe Leroy
2021-10-19  7:29 ` [PATCH v3 22/22] powerpc: Remove CONFIG_PPC_HAVE_KUAP and CONFIG_PPC_HAVE_KUEP Christophe Leroy
2021-12-15  0:24 ` [PATCH v3 00/22] powerpc: Add KUAP support for BOOKE and 40x Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1634627931.git.christophe.leroy@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).