Skip to content

Use hugepages to map kernel mem on 8xx

Christophe Leroy linuxppc-dev lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest46 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/46powerpc/kasan: Fix shadow memory protection with CONFIG_KASAN_VMALLOCarch/powerpc/mm/kasan/kasan_init_32.c+2 -70 replies
2/46powerpc/kasan: Fix error detection on memory allocationarch/powerpc/mm/kasan/kasan_init_32.c+2 -30 replies
3/46powerpc/kasan: Fix issues by lowering KASAN_SHADOW_ENDarch/powerpc/include/asm/kasan.h+1 -30 replies
4/46powerpc/kasan: Fix shadow pages allocation failurearch/powerpc/include/asm/kasan.h arch/powerpc/mm/init_32.c arch/powerpc/mm/kasan/kasan_init_32.c+3 -50 replies
5/46powerpc/kasan: Remove unnecessary page table lockingarch/powerpc/mm/kasan/kasan_init_32.c+4 -150 replies
6/46powerpc/kasan: Refactor update of early shadow mappingsarch/powerpc/mm/kasan/kasan_init_32.c+18 -211 reply
7/46powerpc/kasan: Declare kasan_init_region() weakarch/powerpc/include/asm/kasan.h arch/powerpc/mm/kasan/kasan_init_32.c+14 -100 replies
8/46powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32arch/powerpc/mm/ptdump/8xx.c arch/powerpc/mm/ptdump/shared.c+35 -330 replies
9/46powerpc/ptdump: Reorder flagsarch/powerpc/mm/ptdump/8xx.c arch/powerpc/mm/ptdump/shared.c+30 -300 replies
10/46powerpc/ptdump: Add _PAGE_COHERENT flagarch/powerpc/mm/ptdump/shared.c+5 -00 replies
11/46powerpc/ptdump: Display size of BATsarch/powerpc/mm/ptdump/bats.c arch/powerpc/mm/ptdump/ptdump.c arch/powerpc/mm/ptdump/ptdump.h+20 -90 replies
12/46powerpc/ptdump: Standardise display of BAT flagsarch/powerpc/mm/ptdump/bats.c+15 -220 replies
13/46powerpc/ptdump: Properly handle non standard page sizearch/powerpc/mm/ptdump/ptdump.c+13 -90 replies
14/46powerpc/ptdump: Handle hugepd at PGD levelarch/powerpc/mm/ptdump/ptdump.c+26 -30 replies
15/46powerpc/32s: Don't warn when mapping RO data ROX.arch/powerpc/mm/book3s32/mmu.c+4 -20 replies
16/46powerpc/mm: Allocate static page tables for fixmaparch/powerpc/include/asm/fixmap.h arch/powerpc/kernel/setup_32.c arch/powerpc/mm/pgtable_32.c+21 -12 replies
17/46powerpc/mm: Fix conditions to perform MMU specific management by blocks on PPC32.arch/powerpc/mm/pgtable_32.c+2 -20 replies
18/46powerpc/mm: PTE_ATOMIC_UPDATES is only for 40xarch/powerpc/include/asm/nohash/32/pgtable.h arch/powerpc/include/asm/nohash/64/pgtable.h+1 -440 replies
19/46powerpc/mm: Refactor pte_update() on nohash/32arch/powerpc/include/asm/nohash/32/pgtable.h+4 -220 replies
20/46powerpc/mm: Refactor pte_update() on book3s/32arch/powerpc/include/asm/book3s/32/pgtable.h+20 -380 replies
21/46powerpc/mm: Standardise __ptep_test_and_clear_young() params between PPC32 and PPC64arch/powerpc/include/asm/book3s/32/pgtable.h arch/powerpc/include/asm/nohash/32/pgtable.h+7 -50 replies
22/46powerpc/mm: Standardise pte_update() prototype between PPC32 and PPC64arch/powerpc/include/asm/book3s/32/pgtable.h arch/powerpc/include/asm/hugetlb.h arch/powerpc/include/asm/nohash/32/pgtable.h+15 -170 replies
23/46powerpc/mm: Create a dedicated pte_update() for 8xxarch/powerpc/include/asm/nohash/32/pgtable.h+25 -40 replies
24/46powerpc/mm: Reduce hugepd size for 8M hugepages on 8xxarch/powerpc/include/asm/nohash/32/hugetlb-8xx.h arch/powerpc/include/asm/nohash/32/pgtable.h arch/powerpc/mm/hugetlbpage.c +1 more+46 -60 replies
25/46powerpc/8xx: Drop CONFIG_8xx_COPYBACK optionarch/powerpc/configs/adder875_defconfig arch/powerpc/configs/ep88xc_defconfig arch/powerpc/configs/mpc866_ads_defconfig +5 more+1 -300 replies
26/46powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages.arch/powerpc/include/asm/nohash/32/pgtable.h arch/powerpc/kernel/head_8xx.S+15 -130 replies
27/46powerpc/8xx: Manage 512k huge pages as standard pages.arch/powerpc/include/asm/nohash/32/pgtable.h arch/powerpc/include/asm/nohash/32/pte-8xx.h arch/powerpc/include/asm/nohash/pgtable.h +3 more+44 -160 replies
28/46powerpc/8xx: Only 8M pages are hugepte pages nowarch/powerpc/include/asm/nohash/32/hugetlb-8xx.h arch/powerpc/mm/hugetlbpage.c+6 -170 replies
29/46powerpc/8xx: MM_SLICE is not needed anymorearch/powerpc/include/asm/nohash/32/mmu-8xx.h arch/powerpc/include/asm/nohash/32/slice.h arch/powerpc/include/asm/slice.h +1 more+0 -870 replies
30/46powerpc/8xx: Move PPC_PIN_TLB options into 8xx Kconfigarch/powerpc/Kconfig arch/powerpc/platforms/8xx/Kconfig+41 -200 replies
31/46powerpc/8xx: Add function to update pinned TLBsarch/powerpc/include/asm/nohash/32/mmu-8xx.h arch/powerpc/kernel/head_8xx.S+47 -00 replies
32/46powerpc/8xx: Don't set IMMR map anymore at bootarch/powerpc/kernel/head_8xx.S arch/powerpc/mm/mmu_decl.h arch/powerpc/mm/nohash/8xx.c +2 more+32 -270 replies
33/46powerpc/8xx: Always pin TLBs at startup.arch/powerpc/kernel/head_8xx.S arch/powerpc/mm/nohash/8xx.c+18 -320 replies
34/46powerpc/8xx: Drop special handling of Linear and IMMR mappings in I/D TLB handlersarch/powerpc/kernel/head_8xx.S arch/powerpc/mm/nohash/8xx.c+3 -1290 replies
35/46powerpc/8xx: Remove now unused TLB miss functionsarch/powerpc/include/asm/nohash/32/mmu-8xx.h arch/powerpc/kernel/head_8xx.S arch/powerpc/perf/8xx-pmu.c+1 -1000 replies
36/46powerpc/8xx: Move DTLB perf handling closer.arch/powerpc/kernel/head_8xx.S+11 -120 replies
37/46powerpc/mm: Don't be too strict with _etext alignment on PPC32arch/powerpc/Kconfig arch/powerpc/kernel/vmlinux.lds.S+1 -280 replies
38/46powerpc/8xx: Refactor kernel address boundary comparisonarch/powerpc/kernel/head_8xx.S+8 -140 replies
39/46powerpc/8xx: Add a function to early map kernel via huge pagesarch/powerpc/include/asm/hugetlb.h arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h arch/powerpc/include/asm/pgtable.h +5 more+68 -32 replies
40/46powerpc/8xx: Map IMMR with a huge pagearch/powerpc/mm/nohash/8xx.c+2 -60 replies
41/46powerpc/8xx: Map linear memory with huge pagesarch/powerpc/kernel/head_8xx.S arch/powerpc/mm/nohash/8xx.c+51 -30 replies
42/46powerpc/8xx: Allow STRICT_KERNEL_RwX with pinned TLBarch/powerpc/Kconfig arch/powerpc/mm/nohash/8xx.c arch/powerpc/platforms/8xx/Kconfig+38 -40 replies
43/46powerpc/8xx: Allow large TLBs with DEBUG_PAGEALLOCarch/powerpc/Kconfig arch/powerpc/mm/init_32.c arch/powerpc/mm/nohash/8xx.c +1 more+20 -90 replies
44/46powerpc/8xx: Implement dedicated kasan_init_region()arch/powerpc/mm/kasan/8xx.c arch/powerpc/mm/kasan/Makefile+75 -00 replies
45/46powerpc/32s: Allow mapping with BATs with DEBUG_PAGEALLOCarch/powerpc/Kconfig arch/powerpc/mm/book3s32/mmu.c arch/powerpc/mm/init_32.c+9 -30 replies
46/46powerpc/32s: Implement dedicated kasan_init_region()arch/powerpc/include/asm/kasan.h arch/powerpc/mm/kasan/Makefile arch/powerpc/mm/kasan/book3s_32.c +1 more+60 -11 reply

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH v1 00/46] Use hugepages to map kernel mem on 8xx

The main purpose of this big series is to:
- reorganise huge page handling to avoid using mm_slices.
- use huge pages to map kernel memory on the 8xx.

The 8xx supports 4 page sizes: 4k, 16k, 512k and 8M.
It uses 2 Level page tables, PGD having 1024 entries, each entry covering 4M address space. Then each page table has 1024 entries.

At the time being, page sizes are managed in PGD entries, implying the use of mm_slices as it can't mix several pages of the same size in one page table.

The first purpose of this series is to reorganise things so that standard page tables can also handle 512k pages. This is done by adding a new _PAGE_HUGE flag which will be copied into the Level 1 entry in the TLB miss handler. That done, we have 2 types of pages:
- PGD entries to regular page tables handling 4k/16k and 512k pages
- PGD entries to hugepd tables handling 8M pages.

There is no need to mix 8M pages with other sizes, because a 8M page will use more than what a single PGD covers.

Then comes the second purpose of this series. At the time being, the 8xx has implemented special handling in the TLB miss handlers in order to transparently map kernel linear address space and the IMMR using huge pages by building the TLB entries in assembly at the time of the exception.

As mm_slices is only for user space pages, and also because it would anyway not be convenient to slice kernel address space, it was not possible to use huge pages for kernel address space. But after step one of the series, it is now more flexible to use huge pages.

This series drop all assembly 'just in time' handling of huge pages and use huge pages in page tables instead.

Once the above is done, then comes the cherry on cake:
- Use huge pages for KASAN shadow mapping
- Allow pinned TLBs with strict kernel rwx
- Allow pinned TLBs with debug pagealloc

Then, last but not least, those modifications for the 8xx allows the following improvement on book3s/32:
- Mapping KASAN shadow with BATs
- Allowing BATs with debug pagealloc

All this allows to considerably simplify TLB miss handlers and associated initialisation. The overhead of reading page tables is negligible compared to the reduction of the miss handlers.

While we were at touching pte_update(), some cleanup was done there too.

Tested widely on 8xx and 832x. Boot tested on QEMU MAC99.

Christophe Leroy (46):
powerpc/kasan: Fix shadow memory protection with CONFIG_KASAN_VMALLOC powerpc/kasan: Fix error detection on memory allocation powerpc/kasan: Fix issues by lowering KASAN_SHADOW_END powerpc/kasan: Fix shadow pages allocation failure powerpc/kasan: Remove unnecessary page table locking powerpc/kasan: Refactor update of early shadow mappings powerpc/kasan: Declare kasan_init_region() weak powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32 powerpc/ptdump: Reorder flags
powerpc/ptdump: Add _PAGE_COHERENT flag
powerpc/ptdump: Display size of BATs
powerpc/ptdump: Standardise display of BAT flags powerpc/ptdump: Properly handle non standard page size powerpc/ptdump: Handle hugepd at PGD level
powerpc/32s: Don't warn when mapping RO data ROX. powerpc/mm: Allocate static page tables for fixmap powerpc/mm: Fix conditions to perform MMU specific management by
blocks on PPC32.
powerpc/mm: PTE_ATOMIC_UPDATES is only for 40x
powerpc/mm: Refactor pte_update() on nohash/32
powerpc/mm: Refactor pte_update() on book3s/32
powerpc/mm: Standardise __ptep_test_and_clear_young() params between

    PPC32 and PPC64

powerpc/mm: Standardise pte_update() prototype between PPC32 and PPC64 powerpc/mm: Create a dedicated pte_update() for 8xx powerpc/mm: Reduce hugepd size for 8M hugepages on 8xx powerpc/8xx: Drop CONFIG_8xx_COPYBACK option
powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages. powerpc/8xx: Manage 512k huge pages as standard pages. powerpc/8xx: Only 8M pages are hugepte pages now powerpc/8xx: MM_SLICE is not needed anymore
powerpc/8xx: Move PPC_PIN_TLB options into 8xx Kconfig powerpc/8xx: Add function to update pinned TLBs powerpc/8xx: Don't set IMMR map anymore at boot powerpc/8xx: Always pin TLBs at startup.
powerpc/8xx: Drop special handling of Linear and IMMR mappings in I/D
TLB handlers
powerpc/8xx: Remove now unused TLB miss functions powerpc/8xx: Move DTLB perf handling closer.
powerpc/mm: Don't be too strict with _etext alignment on PPC32 powerpc/8xx: Refactor kernel address boundary comparison powerpc/8xx: Add a function to early map kernel via huge pages powerpc/8xx: Map IMMR with a huge page
powerpc/8xx: Map linear memory with huge pages powerpc/8xx: Allow STRICT_KERNEL_RwX with pinned TLB powerpc/8xx: Allow large TLBs with DEBUG_PAGEALLOC powerpc/8xx: Implement dedicated kasan_init_region() powerpc/32s: Allow mapping with BATs with DEBUG_PAGEALLOC powerpc/32s: Implement dedicated kasan_init_region()

 arch/powerpc/Kconfig                          |  62 +---
 arch/powerpc/configs/adder875_defconfig       |   1 -
 arch/powerpc/configs/ep88xc_defconfig         |   1 -
 arch/powerpc/configs/mpc866_ads_defconfig     |   1 -
 arch/powerpc/configs/mpc885_ads_defconfig     |   1 -
 arch/powerpc/configs/tqm8xx_defconfig         |   1 -
 arch/powerpc/include/asm/book3s/32/pgtable.h  |  78 ++---
 arch/powerpc/include/asm/fixmap.h             |   4 +
 arch/powerpc/include/asm/hugetlb.h            |   6 +-
 arch/powerpc/include/asm/kasan.h              |  10 +-
 .../include/asm/nohash/32/hugetlb-8xx.h       |  32 +-
 arch/powerpc/include/asm/nohash/32/mmu-8xx.h  |  75 +----
 arch/powerpc/include/asm/nohash/32/pgtable.h  | 104 +++----
 arch/powerpc/include/asm/nohash/32/pte-8xx.h  |   4 +-
 arch/powerpc/include/asm/nohash/32/slice.h    |  20 --
 arch/powerpc/include/asm/nohash/64/pgtable.h  |  28 +-
 arch/powerpc/include/asm/nohash/pgtable.h     |   2 +-
 arch/powerpc/include/asm/pgtable.h            |   2 +
 arch/powerpc/include/asm/slice.h              |   2 -
 arch/powerpc/kernel/head_8xx.S                | 292 ++++++------------
 arch/powerpc/kernel/setup_32.c                |   2 +-
 arch/powerpc/kernel/vmlinux.lds.S             |   3 +-
 arch/powerpc/mm/book3s32/mmu.c                |  12 +-
 arch/powerpc/mm/hugetlbpage.c                 |  43 +--
 arch/powerpc/mm/init_32.c                     |  12 +-
 arch/powerpc/mm/kasan/8xx.c                   |  74 +++++
 arch/powerpc/mm/kasan/Makefile                |   2 +
 arch/powerpc/mm/kasan/book3s_32.c             |  57 ++++
 arch/powerpc/mm/kasan/kasan_init_32.c         |  91 +++---
 arch/powerpc/mm/mmu_decl.h                    |   4 +
 arch/powerpc/mm/nohash/8xx.c                  | 250 ++++++++-------
 arch/powerpc/mm/pgtable.c                     |  34 +-
 arch/powerpc/mm/pgtable_32.c                  |  22 +-
 arch/powerpc/mm/ptdump/8xx.c                  |  52 ++--
 arch/powerpc/mm/ptdump/bats.c                 |  41 ++-
 arch/powerpc/mm/ptdump/ptdump.c               |  72 +++--
 arch/powerpc/mm/ptdump/ptdump.h               |   2 +
 arch/powerpc/mm/ptdump/shared.c               |  58 ++--
 arch/powerpc/perf/8xx-pmu.c                   |  10 -
 arch/powerpc/platforms/8xx/Kconfig            |  50 ++-
 arch/powerpc/platforms/Kconfig.cputype        |   2 +-
 arch/powerpc/sysdev/cpm_common.c              |   2 +
 42 files changed, 820 insertions(+), 801 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/nohash/32/slice.h
 create mode 100644 arch/powerpc/mm/kasan/8xx.c
 create mode 100644 arch/powerpc/mm/kasan/book3s_32.c
Signature · 1 line
2.25.0