Use hugepages to map kernel mem on 8xx
Subsystems (3)
v4 cover 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 icing on the 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.
Changes in v4:
- Rebased on top of powerpc/next following the merge of prefix instructions series.
Changes in v3:
- Fixed the handling of leaf pages page size which didn't build on PPC64 and was invisibily bogus on PPC32 (patch 12)
Changes in v2:
- Selecting HUGETLBFS instead of HUGETLB_PAGE which leads to link failure.
- Rebase on latest powerpc/merge branch
- Reworked the way TLB 28 to 31 are pinned because it was not working.
Christophe Leroy (45):
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 set 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 | 4 - arch/powerpc/include/asm/kasan.h | 10 +- .../include/asm/nohash/32/hugetlb-8xx.h | 32 +- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 74 +--- 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 | 354 ++++++++---------- 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 | 41 +- 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 | 88 ++--- arch/powerpc/mm/mmu_decl.h | 4 + arch/powerpc/mm/nohash/8xx.c | 226 ++++++----- 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 | 71 +++- arch/powerpc/mm/ptdump/ptdump.h | 3 + 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, 853 insertions(+), 798 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
PATCH v4 1/45 powerpc/kasan: Fix error detection on memory allocation
In case (k_start & PAGE_MASK) doesn't equal (kstart), 'va' will never be NULL allthough 'block' is NULL
Check the return of memblock_alloc() directly instead of the resulting address in the loop.
--- arch/powerpc/mm/kasan/kasan_init_32.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +2 -3
@@ -76,15 +76,14 @@ static int __init kasan_init_region(void *start, size_t size)return ret; block =memblock_alloc (k_end - k_start,PAGE_SIZE ); +if (!block) +return -ENOMEM ;for (k_cur = k_start &PAGE_MASK ; k_cur < k_end; k_cur +=PAGE_SIZE ) {pmd_t *pmd =pmd_ptr_k (k_cur);void *va = block + k_cur - k_start;pte_t pte =pfn_pte (PHYS_PFN (__pa (va)),PAGE_KERNEL ); -if (!va) -return -ENOMEM ; -__set_pte_at (&init_mm, k_cur,pte_offset_kernel (pmd, k_cur), pte,0 ); }flush_tlb_kernel_range (k_start, k_end);
Signature · 1 line
2.25.0
PATCH v4 2/45 powerpc/kasan: Fix issues by lowering KASAN_SHADOW_END
In reply to Christophe LeroyAt the time being, KASAN_SHADOW_END is 0x100000000, which is 0 in 32 bits representation.
This leads to a couple of issues:
- kasan_remap_early_shadow_ro() does nothing because the comparison k_cur < k_end is always false.
- In ptdump, address comparison for markers display fails and the marker's name is printed at the start of the KASAN area instead of being printed at the end.
However, there is no need to shadow the KASAN shadow area itself, so the KASAN shadow area can stop shadowing memory at the start of itself.
With a PAGE_OFFSET set to 0xc0000000, KASAN shadow area is then going from 0xf8000000 to 0xff000000.
--- arch/powerpc/include/asm/kasan.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/include/asm/kasan.h +1 -3
@@ -23,9 +23,7 @@#define KASAN_SHADOW_OFFSET ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET) -#define KASAN_SHADOW_END 0UL - -#define KASAN_SHADOW_SIZE (KASAN_SHADOW_END - KASAN_SHADOW_START) +#define KASAN_SHADOW_END (-(-KASAN_SHADOW_START >> KASAN_SHADOW_SCALE_SHIFT))#ifdef CONFIG_KASAN void kasan_early_init (void );
Signature · 1 line
2.25.0
PATCH v4 3/45 powerpc/kasan: Fix shadow pages allocation failure
In reply to Christophe LeroyDoing kasan pages allocation in MMU_init is too early, kernel doesn't have access yet to the entire memory space and memblock_alloc() fails when the kernel is a bit big.
Do it from kasan_init() instead.
--- arch/powerpc/include/asm/kasan.h | 2 -- arch/powerpc/mm/init_32.c | 2 -- arch/powerpc/mm/kasan/kasan_init_32.c | 4 +++- 3 files changed, 3 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/kasan.h +0 -2
@@ -27,12 +27,10 @@#ifdef CONFIG_KASAN void kasan_early_init (void ); -void kasan_mmu_init (void );void kasan_init (void );void kasan_late_init (void );#else static inline void kasan_init (void ) { } -static inline void kasan_mmu_init (void ) { }static inline void kasan_late_init (void ) { }#endif
arch/powerpc/mm/init_32.c +0 -2
@@ -170,8 +170,6 @@ void __init MMU_init(void)btext_unmap ();#endif -kasan_mmu_init (); -setup_kup ();/* Shortly after that, the entire linear mapping will be available */
arch/powerpc/mm/kasan/kasan_init_32.c +3 -1
@@ -131,7 +131,7 @@ static void __init kasan_unmap_early_shadow_vmalloc(void)flush_tlb_kernel_range (k_start, k_end); } -void __init kasan_mmu_init (void ) +static void __init kasan_mmu_init (void ) {int ret;struct memblock_region *reg;
@@ -159,6 +159,8 @@ void __init kasan_mmu_init(void)void __init kasan_init (void ) { +kasan_mmu_init (); +kasan_remap_early_shadow_ro ();clear_page (kasan_early_shadow_page);
Signature · 1 line
2.25.0
PATCH v4 4/45 powerpc/kasan: Remove unnecessary page table locking
In reply to Christophe LeroyCommit 45ff3c559585 ("powerpc/kasan: Fix parallel loading of modules.") added spinlocks to manage parallele module loading.
Since then commit 47febbeeec44 ("powerpc/32: Force KASAN_VMALLOC for modules") converted the module loading to KASAN_VMALLOC.
The spinlocking has then become unneeded and can be removed to simplify kasan_init_shadow_page_tables()
Also remove inclusion of linux/moduleloader.h and linux/vmalloc.h which are not needed anymore since the removal of modules management.
--- arch/powerpc/mm/kasan/kasan_init_32.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +4 -15
@@ -5,9 +5,7 @@#include <linux/kasan.h> #include <linux/printk.h> #include <linux/memblock.h> -#include <linux/moduleloader.h> #include <linux/sched/task.h> -#include <linux/vmalloc.h> #include <asm/pgalloc.h> #include <asm/code-patching.h> #include <mm/mmu_decl.h>
@@ -34,31 +32,22 @@ static int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned {pmd_t *pmd;unsigned long k_cur, k_next; -pte_t *new =NULL ; pmd =pmd_ptr_k (k_start);for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd++) { +pte_t *new; + k_next =pgd_addr_end (k_cur, k_end);if ((void *)pmd_page_vaddr (*pmd) != kasan_early_shadow_pte)continue ; -if (!new) - new =memblock_alloc (PTE_FRAG_SIZE ,PTE_FRAG_SIZE ); + new =memblock_alloc (PTE_FRAG_SIZE ,PTE_FRAG_SIZE );if (!new)return -ENOMEM ;kasan_populate_pte (new,PAGE_KERNEL ); - -smp_wmb ();/* See comment in __pte_alloc */ - -spin_lock (&init_mm.page_table_lock); -/* Has another populated it ? */ -if (likely ((void *)pmd_page_vaddr (*pmd) == kasan_early_shadow_pte)) { -pmd_populate_kernel (&init_mm, pmd, new); - new =NULL ; - } -spin_unlock (&init_mm.page_table_lock); +pmd_populate_kernel (&init_mm, pmd, new); }return 0 ; }
Signature · 1 line
2.25.0
PATCH v4 5/45 powerpc/kasan: Refactor update of early shadow mappings
In reply to Christophe Leroykasan_remap_early_shadow_ro() and kasan_unmap_early_shadow_vmalloc() are both updating the early shadow mapping: the first one sets the mapping read-only while the other clears the mapping.
Refactor and create kasan_update_early_region()
--- arch/powerpc/mm/kasan/kasan_init_32.c | 39 +++++++++++++-------------- 1 file changed, 18 insertions(+), 21 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +18 -21
@@ -79,45 +79,42 @@ static int __init kasan_init_region(void *start, size_t size)return 0 ; } -static void __init kasan_remap_early_shadow_ro (void ) +static void __init +kasan_update_early_region (unsigned long k_start,unsigned long k_end,pte_t pte) { -pgprot_t prot =kasan_prot_ro (); -unsigned long k_start =KASAN_SHADOW_START ; -unsigned long k_end =KASAN_SHADOW_END ;unsigned long k_cur;phys_addr_t pa =__pa (kasan_early_shadow_page); -kasan_populate_pte (kasan_early_shadow_pte, prot); - -for (k_cur = k_start &PAGE_MASK ; k_cur != k_end; k_cur +=PAGE_SIZE ) { +for (k_cur = k_start; k_cur != k_end; k_cur +=PAGE_SIZE ) {pmd_t *pmd =pmd_ptr_k (k_cur);pte_t *ptep =pte_offset_kernel (pmd, k_cur);if ((pte_val (*ptep) &PTE_RPN_MASK ) != pa)continue ; -__set_pte_at (&init_mm, k_cur, ptep,pfn_pte (PHYS_PFN (pa), prot),0 ); +__set_pte_at (&init_mm, k_cur, ptep, pte,0 ); } -flush_tlb_kernel_range (KASAN_SHADOW_START ,KASAN_SHADOW_END ); + +flush_tlb_kernel_range (k_start, k_end); } -static void __init kasan_unmap_early_shadow_vmalloc (void ) +static void __init kasan_remap_early_shadow_ro (void ) { -unsigned long k_start = (unsigned long )kasan_mem_to_shadow ((void *)VMALLOC_START ); -unsigned long k_end = (unsigned long )kasan_mem_to_shadow ((void *)VMALLOC_END ); -unsigned long k_cur; +pgprot_t prot =kasan_prot_ro ();phys_addr_t pa =__pa (kasan_early_shadow_page); -for (k_cur = k_start &PAGE_MASK ; k_cur < k_end; k_cur +=PAGE_SIZE ) { -pmd_t *pmd =pmd_offset (pud_offset (pgd_offset_k (k_cur), k_cur), k_cur); -pte_t *ptep =pte_offset_kernel (pmd, k_cur); +kasan_populate_pte (kasan_early_shadow_pte, prot); -if ((pte_val (*ptep) &PTE_RPN_MASK ) != pa) -continue ; +kasan_update_early_region (KASAN_SHADOW_START ,KASAN_SHADOW_END , +pfn_pte (PHYS_PFN (pa), prot)); +} -__set_pte_at (&init_mm, k_cur, ptep,__pte (0 ),0 ); - } -flush_tlb_kernel_range (k_start, k_end); +static void __init kasan_unmap_early_shadow_vmalloc (void ) +{ +unsigned long k_start = (unsigned long )kasan_mem_to_shadow ((void *)VMALLOC_START ); +unsigned long k_end = (unsigned long )kasan_mem_to_shadow ((void *)VMALLOC_END ); + +kasan_update_early_region (k_start, k_end,__pte (0 )); }static void __init kasan_mmu_init (void )
Signature · 1 line
2.25.0
PATCH v4 6/45 powerpc/kasan: Declare kasan_init_region() weak
In reply to Christophe LeroyIn order to alloc sub-arches to alloc KASAN regions using optimised methods (Huge pages on 8xx, BATs on BOOK3S, ...), declare kasan_init_region() weak.
Also make kasan_init_shadow_page_tables() accessible from outside, so that it can be called from the specific kasan_init_region() functions if needed.
And populate remaining KASAN address space only once performed the region mapping, to allow 8xx to allocate hugepd instead of standard page tables for mapping via 8M hugepages.
--- arch/powerpc/include/asm/kasan.h | 3 +++ arch/powerpc/mm/kasan/kasan_init_32.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/kasan.h +3 -0
@@ -34,5 +34,8 @@ static inline void kasan_init(void) { }static inline void kasan_late_init (void ) { }#endif +int kasan_init_shadow_page_tables (unsigned long k_start,unsigned long k_end); +int kasan_init_region (void *start,size_t size); +#endif /* __ASSEMBLY */ #endif
arch/powerpc/mm/kasan/kasan_init_32.c +11 -10
@@ -28,7 +28,7 @@ static void __init kasan_populate_pte(pte_t *ptep, pgprot_t prot)__set_pte_at (&init_mm, va, ptep,pfn_pte (PHYS_PFN (pa), prot),0 ); } -static int __init kasan_init_shadow_page_tables (unsigned long k_start,unsigned long k_end) +int __init kasan_init_shadow_page_tables (unsigned long k_start,unsigned long k_end) {pmd_t *pmd;unsigned long k_cur, k_next;
@@ -52,7 +52,7 @@ static int __init kasan_init_shadow_page_tables(unsigned long k_start, unsignedreturn 0 ; } -static int __init kasan_init_region (void *start,size_t size) +int __init __weak kasan_init_region (void *start,size_t size) {unsigned long k_start = (unsigned long )kasan_mem_to_shadow (start);unsigned long k_end = (unsigned long )kasan_mem_to_shadow (start + size);
@@ -122,14 +122,6 @@ static void __init kasan_mmu_init(void)int ret;struct memblock_region *reg; -if (early_mmu_has_feature (MMU_FTR_HPTE_TABLE ) || -IS_ENABLED (CONFIG_KASAN_VMALLOC )) { - ret =kasan_init_shadow_page_tables (KASAN_SHADOW_START ,KASAN_SHADOW_END ); - -if (ret) -panic ("kasan: kasan_init_shadow_page_tables() failed" ); - } -for_each_memblock (memory, reg) {phys_addr_t base = reg->base;phys_addr_t top =min (base + reg->size, total_lowmem);
@@ -141,6 +133,15 @@ static void __init kasan_mmu_init(void)if (ret)panic ("kasan: kasan_init_region() failed" ); } + +if (early_mmu_has_feature (MMU_FTR_HPTE_TABLE ) || +IS_ENABLED (CONFIG_KASAN_VMALLOC )) { + ret =kasan_init_shadow_page_tables (KASAN_SHADOW_START ,KASAN_SHADOW_END ); + +if (ret) +panic ("kasan: kasan_init_shadow_page_tables() failed" ); + } + }void __init kasan_init (void )
Signature · 1 line
2.25.0
PATCH v4 7/45 powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32
In reply to Christophe LeroyIn order to have all flags fit on a 80 chars wide screen, reduce the flags to 1 char (2 where ambiguous).
No cache is 'i'
User is 'ur' (Supervisor would be sr)
Shared (for 8xx) becomes 'sh' (it was 'user' when not shared but that was ambiguous because that's not entirely right)
--- arch/powerpc/mm/ptdump/8xx.c | 33 ++++++++++++++++--------------- arch/powerpc/mm/ptdump/shared.c | 35 +++++++++++++++++---------------- 2 files changed, 35 insertions(+), 33 deletions(-)
arch/powerpc/mm/ptdump/8xx.c +17 -16
@@ -12,9 +12,9 @@static const struct flag_info flag_array[] = { { .mask = _PAGE_SH, - .val =0 , - .set ="user" , - .clear =" " , + .val = _PAGE_SH, + .set ="sh" , + .clear =" " , }, { .mask = _PAGE_RO | _PAGE_NA, .val =0 ,
@@ -30,37 +30,38 @@ static const struct flag_info flag_array[] = { }, { .mask = _PAGE_EXEC, .val = _PAGE_EXEC, - .set = " X ", - .clear = " ", + .set = "x", + .clear = " ", }, { .mask = _PAGE_PRESENT, .val = _PAGE_PRESENT, - .set = "present", - .clear = " ", + .set = "p", + .clear = " ", }, { .mask = _PAGE_GUARDED, .val = _PAGE_GUARDED, - .set = "guarded", - .clear = " ", + .set = "g", + .clear = " ", }, { .mask = _PAGE_DIRTY, .val = _PAGE_DIRTY, - .set = "dirty", - .clear = " ", + .set = "d", + .clear = " ", }, { .mask = _PAGE_ACCESSED, .val = _PAGE_ACCESSED, - .set = "accessed", - .clear = " ", + .set = "a", + .clear = " ", }, { .mask = _PAGE_NO_CACHE, .val = _PAGE_NO_CACHE, - .set = "no cache", - .clear = " ", + .set = "i", + .clear = " ", }, { .mask = _PAGE_SPECIAL, .val = _PAGE_SPECIAL, - .set = "special", + .set = "s", + .clear = " ", } };
arch/powerpc/mm/ptdump/shared.c +18 -17
@@ -13,8 +13,8 @@ static const struct flag_info flag_array[] = { { .mask = _PAGE_USER, .val = _PAGE_USER, - .set = "user", - .clear = " ", + .set = "ur", + .clear = " ", }, { .mask = _PAGE_RW, .val = _PAGE_RW,
@@ -23,42 +23,43 @@ static const struct flag_info flag_array[] = { }, { .mask = _PAGE_EXEC, .val = _PAGE_EXEC, - .set = " X ", - .clear = " ", + .set = "x", + .clear = " ", }, { .mask = _PAGE_PRESENT, .val = _PAGE_PRESENT, - .set = "present", - .clear = " ", + .set = "p", + .clear = " ", }, { .mask = _PAGE_GUARDED, .val = _PAGE_GUARDED, - .set = "guarded", - .clear = " ", + .set = "g", + .clear = " ", }, { .mask = _PAGE_DIRTY, .val = _PAGE_DIRTY, - .set = "dirty", - .clear = " ", + .set = "d", + .clear = " ", }, { .mask = _PAGE_ACCESSED, .val = _PAGE_ACCESSED, - .set = "accessed", - .clear = " ", + .set = "a", + .clear = " ", }, { .mask = _PAGE_WRITETHRU, .val = _PAGE_WRITETHRU, - .set = "write through", - .clear = " ", + .set = "w", + .clear = " ", }, { .mask = _PAGE_NO_CACHE, .val = _PAGE_NO_CACHE, - .set = "no cache", - .clear = " ", + .set = "i", + .clear = " ", }, { .mask = _PAGE_SPECIAL, .val = _PAGE_SPECIAL, - .set = "special", + .set = "s", + .clear = " ", } };
Signature · 1 line
2.25.0
Michael Ellerman
reviewerRe: [PATCH v4 07/45] powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32
Quoted 2 lines · Christophe Leroy
In order to have all flags fit on a 80 chars wide screen, reduce the flags to 1 char (2 where ambiguous).
I don't love this, the output is less readable. Is fitting on an 80 char screen a real issue for you? I just make my terminal window bigger.
cheers
Quoted 10 lines
No cache is 'i'
User is 'ur' (Supervisor would be sr)
Shared (for 8xx) becomes 'sh' (it was 'user' when not shared but that was ambiguous because that's not entirely right)Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/ptdump/8xx.c | 33 ++++++++++++++++--------------- arch/powerpc/mm/ptdump/shared.c | 35 +++++++++++++++++---------------- 2 files changed, 35 insertions(+), 33 deletions(-)
Re: [PATCH v4 07/45] powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32
Le 25/05/2020 à 07:15, Michael Ellerman a écrit :
Quoted 6 lines
Quoted 2 lines · Christophe Leroy
In order to have all flags fit on a 80 chars wide screen, reduce the flags to 1 char (2 where ambiguous).
I don't love this, the output is less readable. Is fitting on an 80 char screen a real issue for you? I just make my terminal window bigger.
I don't have strong opinion about that, and the terminal can be made bigger.
I just don't like how messy it is, some flags are so big that they hide other ones and getting it more ordered and more compact helped me during all the verifications I did with this series, but we can leave it as is if you prefer.
Would you like a v5 without patches 7 and 8 ? Or I can just resend the patches that will be impacted, that is 9 and 38 ?
Without the changes I get:
---[ Start of kernel VM ]---
0xc0000000-0xc0ffffff 0x00000000 16M huge shared r X present accessed 0xc1000000-0xc7ffffff 0x01000000 112M huge shared rw present dirty accessed ---[ vmalloc() Area ]--- 0xc9000000-0xc9003fff 0x050e4000 16K shared rw present dirty accessed 0xc9008000-0xc900bfff 0x050ec000 16K shared rw present dirty accessed 0xc9010000-0xc9013fff 0xd0000000 16K shared rw present guarded dirty accessed no cache 0xc9018000-0xc901bfff 0x050f0000 16K shared rw present dirty accessed
---[ Fixmap start ]---
0xf7f00000-0xf7f7ffff 0xff000000 512K huge shared rw present guarded dirty accessed no cache
---[ Fixmap end ]---
---[ kasan shadow mem start ]---
0xf8000000-0xf8ffffff 0x07000000 16M huge shared rw present dirty accessed 0xf9000000-0xf91fffff [0x01288000] 16K shared r present accessed 0xf9200000-0xf9203fff 0x050e0000 16K shared rw present dirty accessed
With the change I get.
---[ Start of kernel VM ]---
0xc0000000-0xc0ffffff 0x00000000 16M h r x p sh
a
0xc1000000-0xc7ffffff 0x01000000 112M h rw p sh d a
---[ vmalloc() Area ]---
0xc9000000-0xc9003fff 0x050e4000 16K rw p sh d a 0xc9008000-0xc900bfff 0x050ec000 16K rw p sh d a 0xc9010000-0xc9013fff 0xd0000000 16K rw p i g sh d a 0xc9018000-0xc901bfff 0x050f0000 16K rw p sh d a
---[ Fixmap start ]---
0xf7f00000-0xf7f7ffff 0xff000000 512K h rw p i g sh d a
---[ Fixmap end ]---
---[ kasan shadow mem start ]---
0xf8000000-0xf8ffffff 0x07000000 16M h rw p sh d a 0xf9000000-0xf91fffff [0x01288000] 16K r p sh
a
0xf9200000-0xf9203fff 0x050e0000 16K rw p sh d a
Christophe
Quoted 14 lines
cheers
Quoted 10 lines
No cache is 'i'
User is 'ur' (Supervisor would be sr)
Shared (for 8xx) becomes 'sh' (it was 'user' when not shared but that was ambiguous because that's not entirely right)Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/ptdump/8xx.c | 33 ++++++++++++++++--------------- arch/powerpc/mm/ptdump/shared.c | 35 +++++++++++++++++---------------- 2 files changed, 35 insertions(+), 33 deletions(-)
Michael Ellerman
reviewerRe: [PATCH v4 07/45] powerpc/ptdump: Limit size of flags text to 1/2 chars on PPC32
Quoted 5 lines · Christophe Leroy
Le 25/05/2020 à 07:15, Michael Ellerman a écrit :
Quoted 4 lines
Quoted 2 lines · Christophe Leroy
In order to have all flags fit on a 80 chars wide screen, reduce the flags to 1 char (2 where ambiguous).
Quoted 8 lines
Quoted 2 lines
I don't love this, the output is less readable. Is fitting on an 80 char screen a real issue for you? I just make my terminal window bigger.
I don't have strong opinion about that, and the terminal can be made bigger. I just don't like how messy it is, some flags are so big that they hide other ones and getting it more ordered and more compact helped me during all the verifications I did with this series, but we can leave it as is if you prefer.
I think I do.
Quoted 2 lines
Would you like a v5 without patches 7 and 8 ? Or I can just resend the patches that will be impacted, that is 9 and 38 ?
I dropped 7 and 8 and then fixed up 9 and 38, it was easy enough.
I used "coherent" and "huge".
Quoted 10 lines
With the change I get.
---[ Start of kernel VM ]---
0xc0000000-0xc0ffffff 0x00000000 16M h r x p sh a 0xc1000000-0xc7ffffff 0x01000000 112M h rw p sh d a ---[ vmalloc() Area ]--- 0xc9000000-0xc9003fff 0x050e4000 16K rw p sh d a 0xc9008000-0xc900bfff 0x050ec000 16K rw p sh d a 0xc9010000-0xc9013fff 0xd0000000 16K rw p i g sh d a 0xc9018000-0xc901bfff 0x050f0000 16K rw p sh d a
It's definitely more compact :)
But I worry no one other than you will be able to decipher it, without constantly referring back to the source code.
cheers
PATCH v4 8/45 powerpc/ptdump: Reorder flags
In reply to Christophe LeroyReorder flags in a more logical way:
- Page size (huge) first
- User
- RWX
- Present
- WIMG
- Special
- Dirty and Accessed
--- arch/powerpc/mm/ptdump/8xx.c | 30 +++++++++++++++--------------- arch/powerpc/mm/ptdump/shared.c | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-)
arch/powerpc/mm/ptdump/8xx.c +15 -15
@@ -11,11 +11,6 @@static const struct flag_info flag_array[] = { { - .mask = _PAGE_SH, - .val = _PAGE_SH, - .set ="sh" , - .clear =" " , - }, { .mask = _PAGE_RO | _PAGE_NA, .val =0 , .set ="rw" ,
@@ -37,11 +32,26 @@ static const struct flag_info flag_array[] = { .val = _PAGE_PRESENT, .set = "p", .clear = " ", + }, { + .mask = _PAGE_NO_CACHE, + .val = _PAGE_NO_CACHE, + .set = "i", + .clear = " ", }, { .mask = _PAGE_GUARDED, .val = _PAGE_GUARDED, .set = "g", .clear = " ", + }, { + .mask = _PAGE_SH, + .val = _PAGE_SH, + .set = "sh", + .clear = " ", + }, { + .mask = _PAGE_SPECIAL, + .val = _PAGE_SPECIAL, + .set = "s", + .clear = " ", }, { .mask = _PAGE_DIRTY, .val = _PAGE_DIRTY,
@@ -52,16 +62,6 @@ static const struct flag_info flag_array[] = { .val = _PAGE_ACCESSED, .set = "a", .clear = " ", - }, { - .mask = _PAGE_NO_CACHE, - .val = _PAGE_NO_CACHE, - .set = "i", - .clear = " ", - }, { - .mask = _PAGE_SPECIAL, - .val = _PAGE_SPECIAL, - .set = "s", - .clear = " ", } };
arch/powerpc/mm/ptdump/shared.c +15 -15
@@ -30,21 +30,6 @@ static const struct flag_info flag_array[] = { .val = _PAGE_PRESENT, .set = "p", .clear = " ", - }, { - .mask = _PAGE_GUARDED, - .val = _PAGE_GUARDED, - .set = "g", - .clear = " ", - }, { - .mask = _PAGE_DIRTY, - .val = _PAGE_DIRTY, - .set = "d", - .clear = " ", - }, { - .mask = _PAGE_ACCESSED, - .val = _PAGE_ACCESSED, - .set = "a", - .clear = " ", }, { .mask = _PAGE_WRITETHRU, .val = _PAGE_WRITETHRU,
@@ -55,11 +40,26 @@ static const struct flag_info flag_array[] = { .val = _PAGE_NO_CACHE, .set = "i", .clear = " ", + }, { + .mask = _PAGE_GUARDED, + .val = _PAGE_GUARDED, + .set = "g", + .clear = " ", }, { .mask = _PAGE_SPECIAL, .val = _PAGE_SPECIAL, .set = "s", .clear = " ", + }, { + .mask = _PAGE_DIRTY, + .val = _PAGE_DIRTY, + .set = "d", + .clear = " ", + }, { + .mask = _PAGE_ACCESSED, + .val = _PAGE_ACCESSED, + .set = "a", + .clear = " ", } };
Signature · 1 line
2.25.0
PATCH v4 9/45 powerpc/ptdump: Add _PAGE_COHERENT flag
In reply to Christophe LeroyFor platforms using shared.c (4xx, Book3e, Book3s/32), also handle the _PAGE_COHERENT flag with corresponds to the M bit of the WIMG flags.
--- arch/powerpc/mm/ptdump/shared.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/mm/ptdump/shared.c +5 -0
@@ -40,6 +40,11 @@ static const struct flag_info flag_array[] = { .val = _PAGE_NO_CACHE, .set = "i", .clear = " ", + }, { + .mask = _PAGE_COHERENT, + .val = _PAGE_COHERENT, + .set = "m", + .clear = " ", }, { .mask = _PAGE_GUARDED, .val = _PAGE_GUARDED,
Signature · 1 line
2.25.0
PATCH v4 10/45 powerpc/ptdump: Display size of BATs
In reply to Christophe LeroyDisplay the size of areas mapped with BATs.
For that, the size display for pages is refactorised.
---
v2: Add missing include of linux/seq_file.h (Thanks to kbuild test robot)
--- arch/powerpc/mm/ptdump/bats.c | 4 ++++ arch/powerpc/mm/ptdump/ptdump.c | 23 ++++++++++++++--------- arch/powerpc/mm/ptdump/ptdump.h | 3 +++ 3 files changed, 21 insertions(+), 9 deletions(-)
arch/powerpc/mm/ptdump/bats.c +4 -0
@@ -10,6 +10,8 @@#include <asm/pgtable.h> #include <asm/cpu_has_feature.h> +#include "ptdump.h" +static char *pp_601 (int k,int pp) {if (pp ==0 )
@@ -42,6 +44,7 @@ static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper)#else seq_printf (m,"0x%08x " , pbn);#endif +pt_dump_size (m, size);seq_printf (m,"Kernel %s User %s" ,pp_601 (k &2 , pp),pp_601 (k &1 , pp));
@@ -88,6 +91,7 @@ static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, bool#else seq_printf (m,"0x%08x " , brpn);#endif +pt_dump_size (m, size);if (k ==1 )seq_puts (m,"User " );
arch/powerpc/mm/ptdump/ptdump.c +14 -9
@@ -112,6 +112,19 @@ static struct addr_marker address_markers[] = {seq_putc (m, c); \ }) +void pt_dump_size (struct seq_file *m,unsigned long size) +{ +static const char units[] ="KMGTPE" ; +const char *unit = units; + +/* Work out what appropriate unit to use */ +while (!(size &1023 ) && unit[1 ]) { + size >>=10 ; + unit++; + } +pt_dump_seq_printf (m,"%9lu%c " , size, *unit); +} +static void dump_flag_info (struct pg_state *st,const struct flag_info *flag,u64 pte,int num) {
@@ -146,8 +159,6 @@ static void dump_flag_info(struct pg_state *st, const struct flag_infostatic void dump_addr (struct pg_state *st,unsigned long addr) { -static const char units[] ="KMGTPE" ; -const char *unit = units;unsigned long delta;#ifdef CONFIG_PPC64
@@ -164,13 +175,7 @@ static void dump_addr(struct pg_state *st, unsigned long addr)pt_dump_seq_printf (st->seq," " REG " " , st->start_pa); delta = (addr - st->start_address) >>10 ; } -/* Work out what appropriate unit to use */ -while (!(delta &1023 ) && unit[1 ]) { - delta >>=10 ; - unit++; - } -pt_dump_seq_printf (st->seq,"%9lu%c" , delta, *unit); - +pt_dump_size (st->seq, delta); }static void note_prot_wx (struct pg_state *st,unsigned long addr)
arch/powerpc/mm/ptdump/ptdump.h +3 -0
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ #include <linux/types.h> +#include <linux/seq_file.h> struct flag_info {u64 mask;
@@ -17,3 +18,5 @@ struct pgtable_level { };extern struct pgtable_level pg_level[5 ]; + +void pt_dump_size (struct seq_file *m,unsigned long delta);
Signature · 1 line
2.25.0
PATCH v4 11/45 powerpc/ptdump: Standardise display of BAT flags
In reply to Christophe LeroyDisplay BAT flags the same way as page flags: rwx and wimg
--- arch/powerpc/mm/ptdump/bats.c | 37 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
arch/powerpc/mm/ptdump/bats.c +15 -22
@@ -15,12 +15,12 @@static char *pp_601 (int k,int pp) {if (pp ==0 ) -return k ?"NA" :"RWX" ; +return k ?" " :"rwx" ;if (pp ==1 ) -return k ?"ROX" :"RWX" ; +return k ?"r x" :"rwx" ;if (pp ==2 ) -return k ?"RWX" :"RWX" ; -return k ?"ROX" :"ROX" ; +return "rwx" ; +return "r x" ; }static void bat_show_601 (struct seq_file *m,int idx,u32 lower,u32 upper)
@@ -48,12 +48,9 @@ static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper)seq_printf (m,"Kernel %s User %s" ,pp_601 (k &2 , pp),pp_601 (k &1 , pp)); -if (lower & _PAGE_WRITETHRU) -seq_puts (m,"write through " ); -if (lower & _PAGE_NO_CACHE) -seq_puts (m,"no cache " ); -if (lower & _PAGE_COHERENT) -seq_puts (m,"coherent " ); +seq_puts (m, lower & _PAGE_WRITETHRU ?"w " :" " ); +seq_puts (m, lower & _PAGE_NO_CACHE ?"i " :" " ); +seq_puts (m, lower & _PAGE_COHERENT ?"m " :" " );seq_puts (m,"\n" ); }
@@ -101,20 +98,16 @@ static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, boolseq_puts (m,"Kernel/User " );if (lower &BPP_RX ) -seq_puts (m, is_d ?"RO " :"EXEC " ); +seq_puts (m, is_d ?"r " :" x " );else if (lower &BPP_RW ) -seq_puts (m, is_d ?"RW " :"EXEC " ); +seq_puts (m, is_d ?"rw " :" x " );else -seq_puts (m, is_d ?"NA " :"NX " ); - -if (lower & _PAGE_WRITETHRU) -seq_puts (m,"write through " ); -if (lower & _PAGE_NO_CACHE) -seq_puts (m,"no cache " ); -if (lower & _PAGE_COHERENT) -seq_puts (m,"coherent " ); -if (lower & _PAGE_GUARDED) -seq_puts (m,"guarded " ); +seq_puts (m, is_d ?" " :" " ); + +seq_puts (m, lower & _PAGE_WRITETHRU ?"w " :" " ); +seq_puts (m, lower & _PAGE_NO_CACHE ?"i " :" " ); +seq_puts (m, lower & _PAGE_COHERENT ?"m " :" " ); +seq_puts (m, lower & _PAGE_GUARDED ?"g " :" " );seq_puts (m,"\n" ); }
Signature · 1 line
2.25.0
PATCH v4 12/45 powerpc/ptdump: Properly handle non standard page size
In reply to Christophe LeroyIn order to properly display information regardless of the page size, it is necessary to take into account real page size.
---
v3: Fixed sizes which were shifted one level (went unoticed on PPC32 as PMD and PUD level don't exist)
--- arch/powerpc/mm/ptdump/ptdump.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
arch/powerpc/mm/ptdump/ptdump.c +12 -9
@@ -60,6 +60,7 @@ struct pg_state {unsigned long start_address;unsigned long start_pa;unsigned long last_pa; +unsigned long page_size;unsigned int level;u64 current_flags;bool check_wx;
@@ -168,9 +169,9 @@ static void dump_addr(struct pg_state *st, unsigned long addr)#endif pt_dump_seq_printf (st->seq,REG "-" REG " " , st->start_address, addr -1 ); -if (st->start_pa == st->last_pa && st->start_address +PAGE_SIZE != addr) { +if (st->start_pa == st->last_pa && st->start_address + st->page_size != addr) {pt_dump_seq_printf (st->seq,"[" REG "]" , st->start_pa); - delta =PAGE_SIZE >>10 ; + delta = st->page_size >>10 ; }else {pt_dump_seq_printf (st->seq," " REG " " , st->start_pa); delta = (addr - st->start_address) >>10 ;
@@ -195,7 +196,7 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) }static void note_page (struct pg_state *st,unsigned long addr, -unsigned int level,u64 val) +unsigned int level,u64 val,unsigned long page_size) {u64 flag = val & pg_level[level].mask;u64 pa = val &PTE_RPN_MASK ;
@@ -207,6 +208,7 @@ static void note_page(struct pg_state *st, unsigned long addr, st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size;pt_dump_seq_printf (st->seq,"---[ %s ]---\n" , st->marker->name);/* * Dump the section of virtual memory when:
@@ -218,7 +220,7 @@ static void note_page(struct pg_state *st, unsigned long addr,*/ }else if (flag != st->current_flags || level != st->level || addr >= st->marker[1 ].start_address || - (pa != st->last_pa +PAGE_SIZE && + (pa != st->last_pa + st->page_size && (pa != st->start_pa || st->start_pa != st->last_pa))) {/* Check the PTE flags */
@@ -246,6 +248,7 @@ static void note_page(struct pg_state *st, unsigned long addr, st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size; st->current_flags = flag; st->level = level; }else {
@@ -261,7 +264,7 @@ static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start)for (i =0 ; i <PTRS_PER_PTE ; i++, pte++) { addr = start + i *PAGE_SIZE ; -note_page (st, addr,4 ,pte_val (*pte)); +note_page (st, addr,4 ,pte_val (*pte),PAGE_SIZE ); } }
@@ -278,7 +281,7 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)/* pmd exists */ walk_pte (st, pmd, addr); else - note_page(st, addr, 3, pmd_val(*pmd)); + note_page(st, addr, 3, pmd_val(*pmd), PMD_SIZE); } }
@@ -294,7 +297,7 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)/* pud exists */ walk_pmd (st, pud, addr); else - note_page(st, addr, 2, pud_val(*pud)); + note_page(st, addr, 2, pud_val(*pud), PUD_SIZE); } }
@@ -313,7 +316,7 @@ static void walk_pagetables(struct pg_state *st)/* pgd exists */ walk_pud (st, pgd, addr); else - note_page(st, addr, 1, pgd_val(*pgd)); + note_page(st, addr, 1, pgd_val(*pgd), PGDIR_SIZE); } }
@@ -368,7 +371,7 @@ static int ptdump_show(struct seq_file *m, void *v)/* Traverse kernel page tables */ walk_pagetables (&st); -note_page (&st,0 ,0 ,0 ); +note_page (&st,0 ,0 ,0 ,0 );return 0 ; }
Signature · 1 line
2.25.0
PATCH v4 13/45 powerpc/ptdump: Handle hugepd at PGD level
In reply to Christophe LeroyThe 8xx is about to map kernel linear space and IMMR using huge pages.
In order to display those pages properly, ptdump needs to handle hugepd tables at PGD level.
For the time being do it only at PGD level. Further patches may add handling of hugepd tables at lower level for other platforms when needed in the future.
---
v3: notepage() now takes page size instead of page shift
--- arch/powerpc/mm/ptdump/ptdump.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
arch/powerpc/mm/ptdump/ptdump.c +26 -3
@@ -23,6 +23,7 @@#include <linux/const.h> #include <asm/page.h> #include <asm/pgalloc.h> +#include <asm/hugetlb.h> #include <mm/mmu_decl.h>
@@ -269,6 +270,26 @@ static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start) } } +static void walk_hugepd (struct pg_state *st,hugepd_t *phpd,unsigned long start, +int pdshift,int level) +{ +#ifdef CONFIG_ARCH_HAS_HUGEPD +unsigned int i; +int shift =hugepd_shift (*phpd); +int ptrs_per_hpd = pdshift - shift >0 ?1 << (pdshift - shift) :1 ; + +if (start & ((1 << shift) -1 )) +return ; + +for (i =0 ; i < ptrs_per_hpd; i++) { +unsigned long addr = start + (i << shift); +pte_t *pte =hugepte_offset (*phpd, addr, pdshift); + +note_page (st, addr, level +1 ,pte_val (*pte),1 << shift); + } +#endif +} +static void walk_pmd (struct pg_state *st,pud_t *pud,unsigned long start) {pmd_t *pmd =pmd_offset (pud,0 );
@@ -312,11 +333,13 @@ static void walk_pagetables(struct pg_state *st)* the hash pagetable. */ for (i =pgd_index (addr); i <PTRS_PER_PGD ; i++, pgd++, addr +=PGDIR_SIZE ) { -if (!pgd_none (*pgd) && !pgd_is_leaf (*pgd)) +if (pgd_none (*pgd) ||pgd_is_leaf (*pgd)) +note_page (st, addr,1 ,pgd_val (*pgd),PGDIR_SIZE ); +else if (is_hugepd (__hugepd (pgd_val (*pgd)))) +walk_hugepd (st, (hugepd_t *)pgd, addr,PGDIR_SHIFT ,1 ); +else /* pgd exists */ walk_pud (st, pgd, addr); -else -note_page (st, addr,1 ,pgd_val (*pgd),PGDIR_SIZE ); } }
Signature · 1 line
2.25.0
PATCH v4 14/45 powerpc/32s: Don't warn when mapping RO data ROX.
In reply to Christophe LeroyMapping RO data as ROX is not an issue since that data cannot be modified to introduce an exploit.
PPC64 accepts to have RO data mapped ROX, as a trade off between kernel size and strictness of protection.
On PPC32, kernel size is even more critical as amount of memory is usually small.
Depending on the number of available IBATs, the last IBATs might overflow the end of text. Only warn if it crosses the end of RO data.
--- arch/powerpc/mm/book3s32/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/mm/book3s32/mmu.c +4 -2
@@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void)int i;unsigned long base = (unsigned long )_stext -PAGE_OFFSET ;unsigned long top = (unsigned long )_etext -PAGE_OFFSET ; +unsigned long border = (unsigned long )__init_begin -PAGE_OFFSET ;unsigned long size;if (IS_ENABLED (CONFIG_PPC_BOOK3S_601 ))
@@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void) size =block_size (base, top); size =max (size,128UL <<10 );if ((top - base) > size) { -if (strict_kernel_rwx_enabled ()) -pr_warn ("Kernel _etext not properly aligned\n" ); size <<=1 ; +if (strict_kernel_rwx_enabled () && base + size > border) +pr_warn ("Some RW data is getting mapped X. " +"Adjust CONFIG_DATA_SHIFT to avoid that.\n" ); }setibat (i++,PAGE_OFFSET + base, base, size,PAGE_KERNEL_TEXT ); base += size;
Signature · 1 line
2.25.0
Michael Ellerman
reviewerRe: [PATCH v4 14/45] powerpc/32s: Don't warn when mapping RO data ROX.
Quoted 2 lines · Christophe Leroy
Mapping RO data as ROX is not an issue since that data cannot be modified to introduce an exploit.
Being pedantic: it is still an issue, in that it means there's more targets for a code-reuse attack.
But given the entire kernel text is also available for code-reuse attacks, the RO data is unlikely to contain any useful sequences that aren't also in the kernel text.
Quoted 5 lines
PPC64 accepts to have RO data mapped ROX, as a trade off between kernel size and strictness of protection.
On PPC32, kernel size is even more critical as amount of memory is usually small.
Yep, I think it's a reasonable trade off to make.
cheers
Quoted 36 lines
Depending on the number of available IBATs, the last IBATs might overflow the end of text. Only warn if it crosses the end of RO data.
Signed-off-by Christophe Leroy <[email protected]>--- arch/powerpc/mm/book3s32/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/powerpc/mm/book3s32/mmu.c +4
-2@@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void)int i;unsigned long base = (unsigned long )_stext -PAGE_OFFSET ;unsigned long top = (unsigned long )_etext -PAGE_OFFSET ; +unsigned long border = (unsigned long )__init_begin -PAGE_OFFSET ;unsigned long size;if (IS_ENABLED (CONFIG_PPC_BOOK3S_601 ))@@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void) size =block_size (base, top); size =max (size,128UL <<10 );if ((top - base) > size) { -if (strict_kernel_rwx_enabled ()) -pr_warn ("Kernel _etext not properly aligned\n" ); size <<=1 ; +if (strict_kernel_rwx_enabled () && base + size > border) +pr_warn ("Some RW data is getting mapped X. " +"Adjust CONFIG_DATA_SHIFT to avoid that.\n" ); }setibat (i++,PAGE_OFFSET + base, base, size,PAGE_KERNEL_TEXT ); base += size;Signature · 1 line
2.25.0
PATCH v4 15/45 powerpc/mm: Allocate static page tables for fixmap
In reply to Christophe LeroyAllocate static page tables for the fixmap area. This allows setting mappings through page tables before memblock is ready. That's needed to use early_ioremap() early and to use standard page mappings with fixmap.
--- arch/powerpc/include/asm/fixmap.h | 4 ++++ arch/powerpc/kernel/setup_32.c | 2 +- arch/powerpc/mm/pgtable_32.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/fixmap.h +4 -0
@@ -86,6 +86,10 @@ enum fixed_addresses {#define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE) +#define FIXMAP_ALIGNED_SIZE (ALIGN(FIXADDR_TOP, PGDIR_SIZE) - \ + ALIGN_DOWN(FIXADDR_START, PGDIR_SIZE)) +#define FIXMAP_PTE_SIZE (FIXMAP_ALIGNED_SIZE / PGDIR_SIZE * PTE_TABLE_SIZE) +#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG#define FIXMAP_PAGE_IO PAGE_KERNEL_NCG
arch/powerpc/kernel/setup_32.c +1 -1
@@ -80,7 +80,7 @@ notrace void __init machine_init(u64 dt_ptr)/* Configure static keys first, now that we're relocated. */ setup_feature_keys (); -early_ioremap_setup (); +early_ioremap_init ();/* Enable early debugging if any specified (see udbg.h) */ udbg_early_init ();
arch/powerpc/mm/pgtable_32.c +16 -0
@@ -29,11 +29,27 @@#include <asm/fixmap.h> #include <asm/setup.h> #include <asm/sections.h> +#include <asm/early_ioremap.h> #include <mm/mmu_decl.h> extern char etext[], _stext[], _sinittext[], _einittext[]; +static u8 early_fixmap_pagetable[FIXMAP_PTE_SIZE] __page_aligned_data; + +notrace void __init early_ioremap_init(void) +{ +unsigned long addr =ALIGN_DOWN (FIXADDR_START ,PGDIR_SIZE ); +pte_t *ptep = (pte_t *)early_fixmap_pagetable; +pmd_t *pmdp =pmd_ptr_k (addr); + +for (; (s32)(FIXADDR_TOP - addr) >0 ; + addr +=PGDIR_SIZE , ptep +=PTRS_PER_PTE , pmdp++) +pmd_populate_kernel (&init_mm, pmdp, ptep); + +early_ioremap_setup (); +} +static void __init *early_alloc_pgtable (unsigned long size) {void *ptr =memblock_alloc (size, size);
Signature · 1 line
2.25.0
PATCH v4 16/45 powerpc/mm: Fix conditions to perform MMU specific management by blocks on PPC32.
In reply to Christophe LeroySetting init mem to NX shall depend on sinittext being mapped by block, not on stext being mapped by block.
Setting text and rodata to RO shall depend on stext being mapped by block, not on sinittext being mapped by block.
--- arch/powerpc/mm/pgtable_32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/pgtable_32.c +2 -2
@@ -185,7 +185,7 @@ void mark_initmem_nx(void)unsigned long numpages =PFN_UP ((unsigned long )_einittext) -PFN_DOWN ((unsigned long )_sinittext); -if (v_block_mapped ((unsigned long )_stext +1 )) +if (v_block_mapped ((unsigned long )_sinittext))mmu_mark_initmem_nx ();else change_page_attr (page, numpages,PAGE_KERNEL );
@@ -197,7 +197,7 @@ void mark_rodata_ro(void)struct page *page;unsigned long numpages; -if (v_block_mapped ((unsigned long )_sinittext)) { +if (v_block_mapped ((unsigned long )_stext +1 )) {mmu_mark_rodata_ro ();ptdump_check_wx ();return ;
Signature · 1 line
2.25.0
PATCH v4 17/45 powerpc/mm: PTE_ATOMIC_UPDATES is only for 40x
In reply to Christophe LeroyOnly 40x still uses PTE_ATOMIC_UPDATES.
40x cannot not select CONFIG_PTE64_BIT.
Drop handling of PTE_ATOMIC_UPDATES:
- In nohash/64
- In nohash/32 for CONFIG_PTE_64BIT
Keep PTE_ATOMIC_UPDATES only for nohash/32 for !CONFIG_PTE_64BIT
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 17 ------------ arch/powerpc/include/asm/nohash/64/pgtable.h | 28 +------------------- 2 files changed, 1 insertion(+), 44 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -17
@@ -262,25 +262,8 @@ static inline unsigned long long pte_update(pte_t *p, unsigned long clr, unsigned long set) { -#ifdef PTE_ATOMIC_UPDATES -unsigned long long old; -unsigned long tmp; - - __asm__ __volatile__("\ -1: lwarx %L0,0,%4\n\ -lwzx %0,0,%3\n\ -andc %1,%L0,%5\n\ -or %1,%1,%6\n" - PPC405_ERR77(0,%3) -" stwcx. %1,0,%4\n\ - bne- 1b" - : "=&r" (old), "=&r" (tmp), "=m" (*p) - : "r" (p), "r" ((unsigned long)(p) + 4), "r" (clr), "r" (set), "m" (*p) - : "cc" ); -#else /* PTE_ATOMIC_UPDATES */ unsigned long long old =pte_val (*p); *p =__pte ((old & ~(unsigned long long )clr) | set); -#endif /* !PTE_ATOMIC_UPDATES */ #ifdef CONFIG_44xif ((old & _PAGE_USER) && (old & _PAGE_EXEC))
arch/powerpc/include/asm/nohash/64/pgtable.h +1 -27
@@ -211,22 +211,9 @@ static inline unsigned long pte_update(struct mm_struct *mm, unsigned long set, int huge) { -#ifdef PTE_ATOMIC_UPDATES -unsigned long old, tmp; - - __asm__ __volatile__( -"1: ldarx %0,0,%3 # pte_update\n\ -andc %1,%0,%4 \n\ -or %1,%1,%6\n\ -stdcx. %1,0,%3 \n\ -bne- 1b" - :"=&r" (old),"=&r" (tmp),"=m" (*ptep) - :"r" (ptep),"r" (clr),"m" (*ptep),"r" (set) - :"cc" ); -#else unsigned long old =pte_val (*ptep); *ptep =__pte ((old & ~clr) | set); -#endif +/* huge pages use the old page table lock */ if (!huge)assert_pte_locked (mm, addr);
@@ -310,21 +297,8 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,unsigned long bits =pte_val (entry) & (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); -#ifdef PTE_ATOMIC_UPDATES -unsigned long old, tmp; - - __asm__ __volatile__( -"1: ldarx %0,0,%4\n\ -or %0,%3,%0\n\ -stdcx. %0,0,%4\n\ -bne- 1b" - :"=&r" (old),"=&r" (tmp),"=m" (*ptep) - :"r" (bits),"r" (ptep),"m" (*ptep) - :"cc" ); -#else unsigned long old =pte_val (*ptep); *ptep =__pte (old | bits); -#endif flush_tlb_page (vma, address); }
Signature · 1 line
2.25.0
PATCH v4 18/45 powerpc/mm: Refactor pte_update() on nohash/32
In reply to Christophe LeroyWhen CONFIG_PTE_64BIT is set, pte_update() operates on 'unsigned long long'
When CONFIG_PTE_64BIT is not set, pte_update() operates on 'unsigned long'
In asm/page.h, we have pte_basic_t which is 'unsigned long long' when CONFIG_PTE_64BIT is set and 'unsigned long' otherwise.
Refactor pte_update() using pte_basic_t.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 26 +++----------------- 1 file changed, 4 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +4 -22
@@ -222,12 +222,9 @@ static inline void pmd_clear(pmd_t *pmdp)* to properly flush the virtually tagged instruction cache of * those implementations. */ -#ifndef CONFIG_PTE_64BIT -static inline unsigned long pte_update (pte_t *p, -unsigned long clr, -unsigned long set) +static inline pte_basic_t pte_update (pte_t *p,unsigned long clr,unsigned long set) { -#ifdef PTE_ATOMIC_UPDATES +#if defined(PTE_ATOMIC_UPDATES ) && !defined(CONFIG_PTE_64BIT )unsigned long old, tmp; __asm__ __volatile__("\
@@ -241,8 +238,8 @@ static inline unsigned long pte_update(pte_t *p, : "r" (p), "r" (clr), "r" (set), "m" (*p) : "cc" );#else /* PTE_ATOMIC_UPDATES */ -unsigned long old =pte_val (*p); -unsigned long new = (old & ~clr) | set; +pte_basic_t old =pte_val (*p); +pte_basic_t new = (old & ~(pte_basic_t )clr) | set;#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES ) p->pte = p->pte1 = p->pte2 = p->pte3 = new;
@@ -257,21 +254,6 @@ static inline unsigned long pte_update(pte_t *p,#endif return old; } -#else /* CONFIG_PTE_64BIT */ -static inline unsigned long long pte_update (pte_t *p, -unsigned long clr, -unsigned long set) -{ -unsigned long long old =pte_val (*p); - *p =__pte ((old & ~(unsigned long long )clr) | set); - -#ifdef CONFIG_44x -if ((old & _PAGE_USER) && (old & _PAGE_EXEC)) - icache_44x_need_flush =1 ; -#endif -return old; -} -#endif /* CONFIG_PTE_64BIT */ #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNGstatic inline int __ptep_test_and_clear_young (unsigned int context,unsigned long addr,pte_t *ptep)
Signature · 1 line
2.25.0
PATCH v4 19/45 powerpc/mm: Refactor pte_update() on book3s/32
In reply to Christophe LeroyWhen CONFIG_PTE_64BIT is set, pte_update() operates on 'unsigned long long'
When CONFIG_PTE_64BIT is not set, pte_update() operates on 'unsigned long'
In asm/page.h, we have pte_basic_t which is 'unsigned long long' when CONFIG_PTE_64BIT is set and 'unsigned long' otherwise.
Refactor pte_update() using pte_basic_t.
While we are at it, drop the comment on 44x which is not applicable to book3s version of pte_update().
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 58 +++++++------------- 1 file changed, 20 insertions(+), 38 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +20 -38
@@ -253,53 +253,35 @@ extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep,* and the PTE may be either 32 or 64 bit wide. In the later case, * when using atomic updates, only the low part of the PTE is * accessed atomically. -* -* In addition, on 44x, we also maintain a global flag indicating -* that an executable user mapping was modified, which is needed -* to properly flush the virtually tagged instruction cache of -* those implementations. */ -#ifndef CONFIG_PTE_64BIT -static inline unsigned long pte_update (pte_t *p, -unsigned long clr, -unsigned long set) +static inline pte_basic_t pte_update (pte_t *p,unsigned long clr,unsigned long set) { -unsigned long old, tmp; - - __asm__ __volatile__("\ -1: lwarx %0,0,%3\n\ -andc %1,%0,%4\n\ -or %1,%1,%5\n" -" stwcx. %1,0,%3\n\ -bne- 1b" - :"=&r" (old),"=&r" (tmp),"=m" (*p) - :"r" (p),"r" (clr),"r" (set),"m" (*p) - :"cc" ); - -return old; -} -#else /* CONFIG_PTE_64BIT */ -static inline unsigned long long pte_update (pte_t *p, -unsigned long clr, -unsigned long set) -{ -unsigned long long old; +pte_basic_t old;unsigned long tmp; - __asm__ __volatile__("\ -1: lwarx %L0,0,%4\n\ -lwzx %0,0,%3\n\ -andc %1,%L0,%5\n\ -or %1,%1,%6\n" -" stwcx. %1,0,%4\n\ -bne- 1b" + __asm__ __volatile__( +#ifndef CONFIG_PTE_64BIT +"1: lwarx %0, 0, %3\n" +" andc %1, %0, %4\n" +#else +"1: lwarx %L0, 0, %3\n" +" lwz %0, -4(%3)\n" +" andc %1, %L0, %4\n" +#endif +" or %1, %1, %5\n" +" stwcx. %1, 0, %3\n" +" bne- 1b" : "=&r" (old), "=&r" (tmp), "=m" (*p) - :"r" (p),"r" ((unsigned long )(p) +4 ),"r" (clr),"r" (set),"m" (*p) +#ifndef CONFIG_PTE_64BIT + : "r" (p), +#else + : "b" ((unsigned long)(p) + 4), +#endif +"r" (clr),"r" (set),"m" (*p) : "cc" );return old; } -#endif /* CONFIG_PTE_64BIT */ /* * 2.6 calls this without flushing the TLB entry; this is wrong
Signature · 1 line
2.25.0
PATCH v4 20/45 powerpc/mm: Standardise __ptep_test_and_clear_young() params between PPC32 and PPC64
In reply to Christophe LeroyOn PPC32, __ptep_test_and_clear_young() takes the mm->context.id
In preparation of standardising pte_update() params between PPC32 and PPC64, __ptep_test_and_clear_young() need mm instead of mm->context.id
Replace context param by mm.
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 7 ++++--- arch/powerpc/include/asm/nohash/32/pgtable.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +4 -3
@@ -288,18 +288,19 @@ static inline pte_basic_t pte_update(pte_t *p, unsigned long clr, unsigned long* for our hash-based implementation, we fix that up here. */ #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -static inline int __ptep_test_and_clear_young (unsigned int context,unsigned long addr,pte_t *ptep) +static inline int __ptep_test_and_clear_young (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) {unsigned long old; old =pte_update (ptep, _PAGE_ACCESSED,0 );if (old & _PAGE_HASHPTE) {unsigned long ptephys =__pa (ptep) &PAGE_MASK ; -flush_hash_pages (context, addr, ptephys,1 ); +flush_hash_pages (mm->context.id, addr, ptephys,1 ); }return (old & _PAGE_ACCESSED) !=0 ; }#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ - __ptep_test_and_clear_young((__vma)->vm_mm->context.id, __addr, __ptep) + __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep)#define __HAVE_ARCH_PTEP_GET_AND_CLEAR static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
arch/powerpc/include/asm/nohash/32/pgtable.h +3 -2
@@ -256,14 +256,15 @@ static inline pte_basic_t pte_update(pte_t *p, unsigned long clr, unsigned long }#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -static inline int __ptep_test_and_clear_young (unsigned int context,unsigned long addr,pte_t *ptep) +static inline int __ptep_test_and_clear_young (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) {unsigned long old; old =pte_update (ptep, _PAGE_ACCESSED,0 );return (old & _PAGE_ACCESSED) !=0 ; }#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ - __ptep_test_and_clear_young((__vma)->vm_mm->context.id, __addr, __ptep) + __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep)#define __HAVE_ARCH_PTEP_GET_AND_CLEAR static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
Signature · 1 line
2.25.0
PATCH v4 21/45 powerpc/mm: Standardise pte_update() prototype between PPC32 and PPC64
In reply to Christophe LeroyPPC64 takes 3 additional parameters compared to PPC32:
- mm
- address
- huge
These 3 parameters will be needed in order to perform different action depending on the page size on the 8xx.
Make pte_update() prototype identical for PPC32 and PPC64.
This allows dropping an #ifdef in huge_ptep_get_and_clear().
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 15 ++++++++------- arch/powerpc/include/asm/hugetlb.h | 4 ---- arch/powerpc/include/asm/nohash/32/pgtable.h | 13 +++++++------ 3 files changed, 15 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +8 -7
@@ -218,7 +218,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);*/ #define pte_clear (mm, addr, ptep) \ - do { pte_update(ptep, ~_PAGE_HASHPTE, 0); } while (0) + do { pte_update(mm, addr, ptep, ~_PAGE_HASHPTE, 0, 0); } while (0)#define pmd_none (pmd) (!pmd_val(pmd))#define pmd_bad (pmd) (pmd_val(pmd) & _PMD_BAD)
@@ -254,7 +254,8 @@ extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep,* when using atomic updates, only the low part of the PTE is * accessed atomically. */ -static inline pte_basic_t pte_update (pte_t *p,unsigned long clr,unsigned long set) +static inline pte_basic_t pte_update (struct mm_struct *mm,unsigned long addr,pte_t *p, +unsigned long clr,unsigned long set,int huge) {pte_basic_t old;unsigned long tmp;
@@ -292,7 +293,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { unsigned long old; - old =pte_update (ptep, _PAGE_ACCESSED,0 ); + old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 );if (old & _PAGE_HASHPTE) {unsigned long ptephys =__pa (ptep) &PAGE_MASK ;flush_hash_pages (mm->context.id, addr, ptephys,1 );
@@ -306,14 +307,14 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -return __pte (pte_update (ptep, ~_PAGE_HASHPTE,0 )); +return __pte (pte_update (mm, addr, ptep, ~_PAGE_HASHPTE,0 ,0 )); }#define __HAVE_ARCH_PTEP_SET_WRPROTECTstatic inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -pte_update (ptep, _PAGE_RW,0 ); +pte_update (mm, addr, ptep, _PAGE_RW,0 ,0 ); } static inline void __ptep_set_access_flags(struct vm_area_struct *vma,
@@ -324,7 +325,7 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,unsigned long set =pte_val (entry) & (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); -pte_update (ptep,0 , set); +pte_update (vma->vm_mm, address, ptep,0 , set,0 );flush_tlb_page (vma, address); }
@@ -522,7 +523,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, *ptep =__pte ((pte_val (*ptep) & _PAGE_HASHPTE) | (pte_val (pte) & ~_PAGE_HASHPTE)); else - pte_update(ptep, ~_PAGE_HASHPTE, pte_val(pte)); + pte_update(mm, addr, ptep, ~_PAGE_HASHPTE, pte_val(pte), 0);#elif defined(CONFIG_PTE_64BIT )/* Second case is 32-bit with 64-bit PTE. In this case, we
arch/powerpc/include/asm/hugetlb.h +0 -4
@@ -40,11 +40,7 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,static inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -#ifdef CONFIG_PPC64 return __pte (pte_update (mm, addr, ptep, ~0UL ,0 ,1 )); -#else -return __pte (pte_update (ptep, ~0UL ,0 )); -#endif }#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
arch/powerpc/include/asm/nohash/32/pgtable.h +7 -6
@@ -166,7 +166,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);#ifndef __ASSEMBLY__#define pte_clear (mm, addr, ptep) \ - do { pte_update(ptep, ~0, 0); } while (0) + do { pte_update(mm, addr, ptep, ~0, 0, 0); } while (0)#ifndef pte_mkwritestatic inline pte_t pte_mkwrite (pte_t pte)
@@ -222,7 +222,8 @@ static inline void pmd_clear(pmd_t *pmdp)* to properly flush the virtually tagged instruction cache of * those implementations. */ -static inline pte_basic_t pte_update (pte_t *p,unsigned long clr,unsigned long set) +static inline pte_basic_t pte_update (struct mm_struct *mm,unsigned long addr,pte_t *p, +unsigned long clr,unsigned long set,int huge) {#if defined(PTE_ATOMIC_UPDATES ) && !defined(CONFIG_PTE_64BIT )unsigned long old, tmp;
@@ -260,7 +261,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { unsigned long old; - old =pte_update (ptep, _PAGE_ACCESSED,0 ); + old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 );return (old & _PAGE_ACCESSED) !=0 ; }#define ptep_test_and_clear_young (__vma, __addr, __ptep) \
@@ -270,7 +271,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -return __pte (pte_update (ptep, ~0 ,0 )); +return __pte (pte_update (mm, addr, ptep, ~0 ,0 ,0 )); }#define __HAVE_ARCH_PTEP_SET_WRPROTECT
@@ -280,7 +281,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,unsigned long clr = ~pte_val (pte_wrprotect (__pte (~0 )));unsigned long set =pte_val (pte_wrprotect (__pte (0 ))); -pte_update (ptep, clr, set); +pte_update (mm, addr, ptep, clr, set,0 ); } static inline void __ptep_set_access_flags(struct vm_area_struct *vma,
@@ -293,7 +294,7 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,unsigned long set =pte_val (entry) &pte_val (pte_set);unsigned long clr = ~pte_val (entry) & ~pte_val (pte_clr); -pte_update (ptep, clr, set); +pte_update (vma->vm_mm, address, ptep, clr, set,0 );flush_tlb_page (vma, address); }
Signature · 1 line
2.25.0
PATCH v4 22/45 powerpc/mm: Create a dedicated pte_update() for 8xx
In reply to Christophe Leroypte_update() is a bit special for the 8xx. At the time being, that's an #ifdef inside the nohash/32 pte_update().
As we are going to make it even more special in the coming patches, create a dedicated version for pte_update() for 8xx.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 29 +++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +25 -4
@@ -221,7 +221,31 @@ static inline void pmd_clear(pmd_t *pmdp)* that an executable user mapping was modified, which is needed * to properly flush the virtually tagged instruction cache of * those implementations. +* +* On the 8xx, the page tables are a bit special. For 16k pages, we have +* 4 identical entries. For other page sizes, we have a single entry in the +* table. */ +#ifdef CONFIG_PPC_8xx +static inline pte_basic_t pte_update (struct mm_struct *mm,unsigned long addr,pte_t *p, +unsigned long clr,unsigned long set,int huge) +{ +pte_basic_t *entry = &p->pte; +pte_basic_t old =pte_val (*p); +pte_basic_t new = (old & ~(pte_basic_t )clr) | set; +int num, i; + +if (!huge) + num =PAGE_SIZE /SZ_4K ; +else + num =1 ; + +for (i =0 ; i < num; i++, entry++) + *entry = new; + +return old; +} +#else static inline pte_basic_t pte_update (struct mm_struct *mm,unsigned long addr,pte_t *p,unsigned long clr,unsigned long set,int huge) {
@@ -242,11 +266,7 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, ppte_basic_t old =pte_val (*p);pte_basic_t new = (old & ~(pte_basic_t )clr) | set; -#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES ) - p->pte = p->pte1 = p->pte2 = p->pte3 = new; -#else *p =__pte (new); -#endif #endif /* !PTE_ATOMIC_UPDATES */ #ifdef CONFIG_44x
@@ -255,6 +275,7 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p#endif return old; } +#endif #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
Signature · 1 line
2.25.0
PATCH v4 23/45 powerpc/mm: Reduce hugepd size for 8M hugepages on 8xx
In reply to Christophe LeroyCommit 55c8fc3f4930 ("powerpc/8xx: reintroduce 16K pages with HW assistance") redefined pte_t as a struct of 4 pte_basic_t, because in 16K pages mode there are four identical entries in the page table. But hugepd entries for 8M pages require only one entry of size pte_basic_t. So there is no point in creating a cache for 4 entries page tables.
Calculate PTE_T_ORDER using the size of pte_basic_t instead of pte_t.
Define specific huge_pte helpers (set_huge_pte_at(), huge_pte_clear(), huge_ptep_set_wrprotect()) to write the pte in a single entry instead of using set_pte_at() which writes 4 identical entries in 16k pages mode. Also make sure that __ptep_set_access_flags() properly handle the huge_pte case.
Define set_pte_filter() inline otherwise GCC doesn't inline it anymore because it is now used twice, and that gives a pretty suboptimal code because of pte_t being a struct of 4 entries.
Those functions are also used for 512k pages which only require one entry as well allthough replicating it four times was harmless as 512k pages entries are spread every 128 bytes in the table.
--- .../include/asm/nohash/32/hugetlb-8xx.h | 20 ++++++++++++++ arch/powerpc/include/asm/nohash/32/pgtable.h | 3 ++- arch/powerpc/mm/hugetlbpage.c | 3 ++- arch/powerpc/mm/pgtable.c | 26 ++++++++++++++++--- 4 files changed, 46 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +20 -0
@@ -41,4 +41,24 @@ static inline int check_and_get_huge_psize(int shift)return shift_to_mmu_psize (shift); } +#define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT +void set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte); + +#define __HAVE_ARCH_HUGE_PTE_CLEAR +static inline void huge_pte_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz) +{ +pte_update (mm, addr, ptep, ~0UL ,0 ,1 ); +} + +#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT +static inline void huge_ptep_set_wrprotect (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) +{ +unsigned long clr = ~pte_val (pte_wrprotect (__pte (~0 ))); +unsigned long set =pte_val (pte_wrprotect (__pte (0 ))); + +pte_update (mm, addr, ptep, clr, set,1 ); +} +#endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */
arch/powerpc/include/asm/nohash/32/pgtable.h +2 -1
@@ -314,8 +314,9 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,pte_t pte_clr =pte_mkyoung (pte_mkdirty (pte_mkwrite (pte_mkexec (__pte (~0 )))));unsigned long set =pte_val (entry) &pte_val (pte_set);unsigned long clr = ~pte_val (entry) & ~pte_val (pte_clr); +int huge = psize > mmu_virtual_psize ?1 :0 ; -pte_update (vma->vm_mm, address, ptep, clr, set,0 ); +pte_update (vma->vm_mm, address, ptep, clr, set, huge);flush_tlb_page (vma, address); }
arch/powerpc/mm/hugetlbpage.c +2 -1
@@ -30,7 +30,8 @@ bool hugetlb_disabled = false;#define hugepd_none (hpd) (hpd_val(hpd) == 0) -#define PTE_T_ORDER (__builtin_ffs(sizeof(pte_t)) - __builtin_ffs(sizeof(void *))) +#define PTE_T_ORDER (__builtin_ffs(sizeof(pte_basic_t)) - \ + __builtin_ffs(sizeof(void *)))pte_t *huge_pte_offset (struct mm_struct *mm,unsigned long addr,unsigned long sz) {
arch/powerpc/mm/pgtable.c +22 -4
@@ -100,7 +100,7 @@ static pte_t set_pte_filter_hash(pte_t pte) { return pte; }* as we don't have two bits to spare for _PAGE_EXEC and _PAGE_HWEXEC so * instead we "filter out" the exec permission for non clean pages. */ -static pte_t set_pte_filter (pte_t pte) +static inline pte_t set_pte_filter (pte_t pte) {struct page *pg;
@@ -249,16 +249,34 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,#else /* -* Not used on non book3s64 platforms. But 8xx -* can possibly use tsize derived from hstate. +* Not used on non book3s64 platforms. +* 8xx compares it with mmu_virtual_psize to +* know if it is a huge page or not. */ - psize =0 ; + psize =MMU_PAGE_COUNT ;#endif __ptep_set_access_flags (vma, ptep, pte, addr, psize); }return changed;#endif } + +#if defined(CONFIG_PPC_8xx) +void set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte) +{ +/* +* Make sure hardware valid bit is not set. We don't do +* tlb flush for this update. +*/ +VM_WARN_ON (pte_hw_valid (*ptep) && !pte_protnone (*ptep)); + + pte =pte_mkpte (pte); + + pte =set_pte_filter (pte); + + ptep->pte =pte_val (pte); +} +#endif #endif /* CONFIG_HUGETLB_PAGE */ #ifdef CONFIG_DEBUG_VM
Signature · 1 line
2.25.0
PATCH v4 24/45 powerpc/8xx: Drop CONFIG_8xx_COPYBACK option
In reply to Christophe LeroyCONFIG_8xx_COPYBACK was there to help disabling copyback cache mode for debuging hardware. But nobody will design new boards with 8xx now.
All 8xx platforms select it, so make it the default and remove the option.
Also remove the Mx_RESETVAL values which are pretty useless and hide the real value while reading code.
--- 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/nohash/32/mmu-8xx.h | 2 -- arch/powerpc/kernel/head_8xx.S | 15 +-------------- arch/powerpc/platforms/8xx/Kconfig | 9 --------- 8 files changed, 1 insertion(+), 30 deletions(-)
arch/powerpc/configs/adder875_defconfig +0 -1
@@ -10,7 +10,6 @@ CONFIG_EXPERT=y # CONFIG_BLK_DEV_BSG is not set CONFIG_PARTITION_ADVANCED=y CONFIG_PPC_ADDER875=y -CONFIG_8xx_COPYBACK=y CONFIG_GEN_RTC=y CONFIG_HZ_1000=y # CONFIG_SECCOMP is not set
arch/powerpc/configs/ep88xc_defconfig +0 -1
@@ -12,7 +12,6 @@ CONFIG_EXPERT=y # CONFIG_BLK_DEV_BSG is not set CONFIG_PARTITION_ADVANCED=y CONFIG_PPC_EP88XC=y -CONFIG_8xx_COPYBACK=y CONFIG_GEN_RTC=y CONFIG_HZ_100=y # CONFIG_SECCOMP is not set
arch/powerpc/configs/mpc866_ads_defconfig +0 -1
@@ -12,7 +12,6 @@ CONFIG_EXPERT=y # CONFIG_BLK_DEV_BSG is not set CONFIG_PARTITION_ADVANCED=y CONFIG_MPC86XADS=y -CONFIG_8xx_COPYBACK=y CONFIG_GEN_RTC=y CONFIG_HZ_1000=y CONFIG_MATH_EMULATION=y
arch/powerpc/configs/mpc885_ads_defconfig +0 -1
@@ -11,7 +11,6 @@ CONFIG_EXPERT=y # CONFIG_VM_EVENT_COUNTERS is not set # CONFIG_BLK_DEV_BSG is not set CONFIG_PARTITION_ADVANCED=y -CONFIG_8xx_COPYBACK=y CONFIG_GEN_RTC=y CONFIG_HZ_100=y # CONFIG_SECCOMP is not set
arch/powerpc/configs/tqm8xx_defconfig +0 -1
@@ -15,7 +15,6 @@ CONFIG_MODULE_SRCVERSION_ALL=y # CONFIG_BLK_DEV_BSG is not set CONFIG_PARTITION_ADVANCED=y CONFIG_TQM8XX=y -CONFIG_8xx_COPYBACK=y # CONFIG_8xx_CPU15 is not set CONFIG_GEN_RTC=y CONFIG_HZ_100=y
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0 -2
@@ -19,7 +19,6 @@#define MI_RSV4I 0x08000000/* Reserve 4 TLB entries */ #define MI_PPCS 0x02000000/* Use MI_RPN prob/priv state */ #define MI_IDXMASK 0x00001f00/* TLB index to be loaded */ -#define MI_RESETVAL 0x00000000/* Value of register at reset */ /* These are the Ks and Kp from the PowerPC books. For proper operation, * Ks = 0, Kp = 1.
@@ -95,7 +94,6 @@#define MD_TWAM 0x04000000/* Use 4K page hardware assist */ #define MD_PPCS 0x02000000/* Use MI_RPN prob/priv state */ #define MD_IDXMASK 0x00001f00/* TLB index to be loaded */ -#define MD_RESETVAL 0x04000000/* Value of register at reset */ #define SPRN_M_CASID 793/* Address space ID (context) to match */ #define MC_ASIDMASK 0x0000000f/* Bits used for ASID value */
arch/powerpc/kernel/head_8xx.S +1 -14
@@ -779,10 +779,7 @@ start_here: initial_mmu: li r8, 0 mtspr SPRN_MI_CTR, r8 /* remove PINNED ITLB entries */ - lis r10, MD_RESETVAL@h -#ifndef CONFIG_8xx_COPYBACK - oris r10, r10, MD_WTDEF@h -#endif + lis r10, MD_TWAM@h mtspr SPRN_MD_CTR, r10 /* remove PINNED DTLB entries */ tlbia /* Invalidate all TLB entries */
@@ -857,17 +854,7 @@ initial_mmu: mtspr SPRN_DC_CST, r8 lis r8, IDC_ENABLE@h mtspr SPRN_IC_CST, r8 -#ifdef CONFIG_8xx_COPYBACK - mtspr SPRN_DC_CST, r8 -#else - /* For a debug option, I left this here to easily enable - * the write through cache mode - */ - lis r8, DC_SFWT@h mtspr SPRN_DC_CST, r8 - lis r8, IDC_ENABLE@h - mtspr SPRN_DC_CST, r8 -#endif /* Disable debug mode entry on breakpoints */ mfspr r8, SPRN_DER #ifdef CONFIG_PERF_EVENTS
arch/powerpc/platforms/8xx/Kconfig +0 -9
@@ -98,15 +98,6 @@ menu "MPC8xx CPM Options" # 8xx specific questions. comment "Generic MPC8xx Options" -config 8xx_COPYBACK - bool "Copy-Back Data Cache (else Writethrough)" - help - Saying Y here will cause the cache on an MPC8xx processor to be used - in Copy-Back mode. If you say N here, it is used in Writethrough - mode. - - If in doubt, say Y here. - config 8xx_GPIO bool "GPIO API Support" select GPIOLIB
Signature · 1 line
2.25.0
PATCH v4 25/45 powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages.
In reply to Christophe LeroyPrepare ITLB handler to handle _PAGE_HUGE when CONFIG_HUGETLBFS is enabled. This means that the L1 entry has to be kept in r11 until L2 entry is read, in order to insert _PAGE_HUGE into it.
Also move pgd_offset helpers before pte_update() as they will be needed there in next patch.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 13 ++++++------- arch/powerpc/kernel/head_8xx.S | 15 +++++++++------ 2 files changed, 15 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +6 -7
@@ -206,6 +206,12 @@ static inline void pmd_clear(pmd_t *pmdp) } +/* to find an entry in a kernel page-table-directory */ +#define pgd_offset_k (address) pgd_offset(&init_mm, address) + +/* to find an entry in a page-table-directory */ +#define pgd_index (address) ((address) >> PGDIR_SHIFT) +#define pgd_offset (mm, address) ((mm)->pgd + pgd_index(address))/* * PTE updates. This function is called whenever an existing
@@ -348,13 +354,6 @@ static inline int pte_young(pte_t pte) pfn_to_page((__pa(pmd_val(pmd)) >> PAGE_SHIFT))#endif -/* to find an entry in a kernel page-table-directory */ -#define pgd_offset_k (address) pgd_offset(&init_mm, address) - -/* to find an entry in a page-table-directory */ -#define pgd_index (address) ((address) >> PGDIR_SHIFT) -#define pgd_offset (mm, address) ((mm)->pgd + pgd_index(address)) -/* Find an entry in the third-level page table.. */ #define pte_index (address) \ (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
arch/powerpc/kernel/head_8xx.S +9 -6
@@ -196,7 +196,7 @@ SystemCall: InstructionTLBMiss: mtspr SPRN_SPRG_SCRATCH0, r10 -#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) +#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS) mtspr SPRN_SPRG_SCRATCH1, r11 #endif
@@ -235,16 +235,19 @@ InstructionTLBMiss: rlwinm r10, r10, 0, 20, 31 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha 3: + mtcr r11 #endif +#ifdef CONFIG_HUGETLBFS + lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */ + mtspr SPRN_MI_TWC, r11 /* Set segment attributes */ + mtspr SPRN_MD_TWC, r11 +#else lwz r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */ mtspr SPRN_MI_TWC, r10 /* Set segment attributes */ - mtspr SPRN_MD_TWC, r10 +#endif mfspr r10, SPRN_MD_TWC lwz r10, 0(r10) /* Get the pte */ -#ifdef ITLB_MISS_KERNEL - mtcr r11 -#endif #ifdef CONFIG_SWAP rlwinm r11, r10, 32-5, _PAGE_PRESENT and r11, r11, r10
@@ -263,7 +266,7 @@ InstructionTLBMiss: /* Restore registers */ 0: mfspr r10, SPRN_SPRG_SCRATCH0 -#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) +#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS) mfspr r11, SPRN_SPRG_SCRATCH1 #endif rfi
Signature · 1 line
2.25.0
PATCH v4 26/45 powerpc/8xx: Manage 512k huge pages as standard pages.
In reply to Christophe LeroyAt the time being, 512k huge pages are handled through hugepd page tables. The PMD entry is flagged as a hugepd pointer and it means that only 512k hugepages can be managed in that 4M block. However, the hugepd table has the same size as a normal page table, and 512k entries can therefore be nested with normal pages.
On the 8xx, TLB loading is performed by software and allthough the page tables are organised to match the L1 and L2 level defined by the HW, all TLB entries have both L1 and L2 independent entries. It means that even if two TLB entries are associated with the same PMD entry, they can be loaded with different values in L1 part.
The L1 entry contains the page size (PS field):
- 00 for 4k and 16 pages
- 01 for 512k pages
- 11 for 8M pages
By adding a flag for hugepages in the PTE (_PAGE_HUGE) and copying it into the lower bit of PS, we can then manage 512k pages with normal page tables:
- PMD entry has PS=11 for 8M pages
- PMD entry has PS=00 for other pages.
As a PMD entry covers 4M areas, a PMD will either point to a hugepd table having a single entry to an 8M page, or the PMD will point to a standard page table which will have either entries to 4k or 16k or 512k pages. For 512k pages, as the L1 entry will not know it is a 512k page before the PTE is read, there will be 128 entries in the PTE as if it was 4k pages. But when loading the TLB, it will be flagged as a 512k page.
Note that we can't use pmd_ptr() in asm/nohash/32/pgtable.h because it is not defined yet.
In ITLB miss, we keep the possibility to opt it out as when kernel text is pinned and no user hugepages are used, we can save several instruction by not using r11.
In DTLB miss, that's just one instruction so it's not worth bothering with it.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 10 ++++++--- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 4 +++- arch/powerpc/include/asm/nohash/pgtable.h | 2 +- arch/powerpc/kernel/head_8xx.S | 12 +++++------ arch/powerpc/mm/hugetlbpage.c | 22 +++++++++++++++++--- arch/powerpc/mm/pgtable.c | 10 ++++++++- 6 files changed, 44 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +7 -3
@@ -229,8 +229,9 @@ static inline void pmd_clear(pmd_t *pmdp)* those implementations. * * On the 8xx, the page tables are a bit special. For 16k pages, we have -* 4 identical entries. For other page sizes, we have a single entry in the -* table. +* 4 identical entries. For 512k pages, we have 128 entries as if it was +* 4k pages, but they are flagged as 512k pages for the hardware. +* For other page sizes, we have a single entry in the table. */ #ifdef CONFIG_PPC_8xx static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, pte_t *p,
@@ -240,13 +241,16 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, ppte_basic_t old =pte_val (*p);pte_basic_t new = (old & ~(pte_basic_t )clr) | set;int num, i; +pmd_t *pmd =pmd_offset (pud_offset (pgd_offset (mm, addr), addr), addr);if (!huge) num =PAGE_SIZE /SZ_4K ; +else if ((pmd_val (*pmd) & _PMD_PAGE_MASK) != _PMD_PAGE_8M) + num =SZ_512K /SZ_4K ;else num =1 ; -for (i =0 ; i < num; i++, entry++) +for (i =0 ; i < num; i++, entry++, new +=SZ_4K ) *entry = new;return old;
arch/powerpc/include/asm/nohash/32/pte-8xx.h +3 -1
@@ -46,6 +46,8 @@#define _PAGE_NA 0x0200/* Supervisor NA, User no access */ #define _PAGE_RO 0x0600/* Supervisor RO, User no access */ +#define _PAGE_HUGE 0x0800/* Copied to L1 PS bit 29 */ +/* cache related flags non existing on 8xx */ #define _PAGE_COHERENT 0#define _PAGE_WRITETHRU 0
@@ -128,7 +130,7 @@ static inline pte_t pte_mkuser(pte_t pte)static inline pte_t pte_mkhuge (pte_t pte) { -return __pte (pte_val (pte) | _PAGE_SPS); +return __pte (pte_val (pte) | _PAGE_SPS | _PAGE_HUGE); }#define pte_mkhuge pte_mkhuge
arch/powerpc/include/asm/nohash/pgtable.h +1 -1
@@ -267,7 +267,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,static inline int hugepd_ok (hugepd_t hpd) {#ifdef CONFIG_PPC_8xx -return ((hpd_val (hpd) &0x4 ) !=0 ); +return ((hpd_val (hpd) & _PMD_PAGE_MASK) == _PMD_PAGE_8M);#else /* We clear the top bit to indicate hugepd */ return (hpd_val (hpd) && (hpd_val (hpd) &PD_HUGE ) ==0 );
arch/powerpc/kernel/head_8xx.S +5 -7
@@ -239,7 +239,6 @@ InstructionTLBMiss: #endif #ifdef CONFIG_HUGETLBFS lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */ - mtspr SPRN_MI_TWC, r11 /* Set segment attributes */ mtspr SPRN_MD_TWC, r11 #else lwz r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */
@@ -248,6 +247,10 @@ InstructionTLBMiss: #endif mfspr r10, SPRN_MD_TWC lwz r10, 0(r10) /* Get the pte */ +#ifdef CONFIG_HUGETLBFS + rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K + mtspr SPRN_MI_TWC, r11 +#endif #ifdef CONFIG_SWAP rlwinm r11, r10, 32-5, _PAGE_PRESENT and r11, r11, r10
@@ -353,6 +356,7 @@ DataStoreTLBMiss: * above. */ rlwimi r11, r10, 0, _PAGE_GUARDED + rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K mtspr SPRN_MD_TWC, r11 /* Both _PAGE_ACCESSED and _PAGE_PRESENT has to be set.
@@ -584,7 +588,6 @@ FixupDAR:/* Entry point for dcbx workaround. */ mfspr r11, SPRN_MD_TWC lwz r11, 0(r11) /* Get the pte */ bt 28,200f /* bit 28 = Large page (8M) */ - bt 29,202f /* bit 29 = Large page (8M or 512K) */ /* concat physical page address(r11) and page offset(r10) */ rlwimi r11, r10, 0, 32 - PAGE_SHIFT, 31 201: lwz r11,0(r11)
@@ -611,11 +614,6 @@ FixupDAR:/* Entry point for dcbx workaround. */ rlwimi r11, r10, 0, 32 - PAGE_SHIFT_8M, 31 b 201b -202: - /* concat physical page address(r11) and page offset(r10) */ - rlwimi r11, r10, 0, 32 - PAGE_SHIFT_512K, 31 - b 201b - 144: mfspr r10, SPRN_DSISR rlwinm r10, r10,0,7,5 /* Clear store bit for buggy dcbst insn */ mtspr SPRN_DSISR, r10
arch/powerpc/mm/hugetlbpage.c +19 -3
@@ -189,6 +189,9 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long szif (!hpdp)return NULL ; +if (IS_ENABLED (CONFIG_PPC_8xx) && sz ==SZ_512K ) +return pte_alloc_map (mm, (pmd_t *)hpdp, addr); +BUG_ON (!hugepd_none (*hpdp) && !hugepd_ok (*hpdp)); if (hugepd_none(*hpdp) && __hugepte_alloc(mm, hpdp, addr,
@@ -331,13 +334,20 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshifif (shift >= pdshift)hugepd_free (tlb, hugepte); -else if (IS_ENABLED (CONFIG_PPC_8xx)) -pgtable_free_tlb (tlb, hugepte,0 );else pgtable_free_tlb (tlb, hugepte,get_hugepd_cache_index (pdshift - shift)); } +static void hugetlb_free_pte_range (struct mmu_gather *tlb,pmd_t *pmd,unsigned long addr) +{ +pgtable_t token =pmd_pgtable (*pmd); + +pmd_clear (pmd); +pte_free_tlb (tlb, token, addr); +mm_dec_nr_ptes (tlb->mm); +} +static void hugetlb_free_pmd_range (struct mmu_gather *tlb,pud_t *pud,unsigned long addr,unsigned long end,unsigned long floor,unsigned long ceiling)
@@ -353,11 +363,17 @@ static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud, pmd =pmd_offset (pud, addr); next =pmd_addr_end (addr, end);if (!is_hugepd (__hugepd (pmd_val (*pmd)))) { +if (pmd_none_or_clear_bad (pmd)) +continue ; +/* * if it is not hugepd pointer, we should already find * it cleared. */ -WARN_ON (!pmd_none_or_clear_bad (pmd)); +WARN_ON (!IS_ENABLED (CONFIG_PPC_8xx)); + +hugetlb_free_pte_range (tlb, pmd, addr); +continue ; }/*
arch/powerpc/mm/pgtable.c +9 -1
@@ -264,6 +264,12 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,#if defined(CONFIG_PPC_8xx)void set_huge_pte_at (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pte_t pte) { +pmd_t *pmd =pmd_ptr (mm, addr); +pte_basic_t val; +pte_basic_t *entry = &ptep->pte; +int num =is_hugepd (*((hugepd_t *)pmd)) ?1 :SZ_512K /SZ_4K ; +int i; +/* * Make sure hardware valid bit is not set. We don't do * tlb flush for this update.
@@ -274,7 +280,9 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_ pte =set_pte_filter (pte); - ptep->pte =pte_val (pte); + val =pte_val (pte); +for (i =0 ; i < num; i++, entry++, val +=SZ_4K ) + *entry = val; }#endif #endif /* CONFIG_HUGETLB_PAGE */
Signature · 1 line
2.25.0
PATCH v4 27/45 powerpc/8xx: Only 8M pages are hugepte pages now
In reply to Christophe Leroy512k pages are now standard pages, so only 8M pages are hugepte.
No more handling of normal page tables through hugepd allocation and freeing, and hugepte helpers can also be simplified.
--- arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 7 +++---- arch/powerpc/mm/hugetlbpage.c | 16 +++------------- 2 files changed, 6 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +3 -4
@@ -13,13 +13,13 @@ static inline pte_t *hugepd_page(hugepd_t hpd)static inline unsigned int hugepd_shift (hugepd_t hpd) { -return ((hpd_val (hpd) & _PMD_PAGE_MASK) >>1 ) +17 ; +return PAGE_SHIFT_8M ; }static inline pte_t *hugepte_offset (hugepd_t hpd,unsigned long addr,unsigned int pdshift) { -unsigned long idx = (addr & ((1UL << pdshift) -1 )) >>PAGE_SHIFT ; +unsigned long idx = (addr & (SZ_4M -1 )) >>PAGE_SHIFT ;return hugepd_page (hpd) + idx; }
@@ -32,8 +32,7 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma,static inline void hugepd_populate (hugepd_t *hpdp,pte_t *new,unsigned int pshift) { - *hpdp =__hugepd (__pa (new) | _PMD_USER | _PMD_PRESENT | - (pshift ==PAGE_SHIFT_8M ? _PMD_PAGE_8M : _PMD_PAGE_512K)); + *hpdp =__hugepd (__pa (new) | _PMD_USER | _PMD_PRESENT | _PMD_PAGE_8M); }static inline int check_and_get_huge_psize (int shift)
arch/powerpc/mm/hugetlbpage.c +3 -13
@@ -54,24 +54,17 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (pshift >= pdshift) { cachep =PGT_CACHE (PTE_T_ORDER ); num_hugepd =1 << (pshift - pdshift); - new =NULL ; - }else if (IS_ENABLED (CONFIG_PPC_8xx)) { - cachep =NULL ; - num_hugepd =1 ; - new =pte_alloc_one (mm); }else { cachep =PGT_CACHE (pdshift - pshift); num_hugepd =1 ; - new =NULL ; } -if (!cachep && !new) { +if (!cachep) {WARN_ONCE (1 ,"No page table cache created for hugetlb tables" );return -ENOMEM ; } -if (cachep) - new =kmem_cache_alloc (cachep,pgtable_gfp_flags (mm,GFP_KERNEL )); + new =kmem_cache_alloc (cachep,pgtable_gfp_flags (mm,GFP_KERNEL ));BUG_ON (pshift >HUGEPD_SHIFT_MASK );BUG_ON ((unsigned long )new &HUGEPD_SHIFT_MASK );
@@ -102,10 +95,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,if (i < num_hugepd) {for (i = i -1 ; i >=0 ; i--, hpdp--) *hpdp =__hugepd (0 ); -if (cachep) -kmem_cache_free (cachep, new); -else -pte_free (mm, new); +kmem_cache_free (cachep, new); }else {kmemleak_ignore (new); }
Signature · 1 line
2.25.0
PATCH v4 28/45 powerpc/8xx: MM_SLICE is not needed anymore
In reply to Christophe LeroyAs the 8xx now manages 512k pages in standard page tables, it doesn't need CONFIG_PPC_MM_SLICES anymore.
Don't select it anymore and remove all related code.
--- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 64 -------------------- arch/powerpc/include/asm/nohash/32/slice.h | 20 ------ arch/powerpc/include/asm/slice.h | 2 - arch/powerpc/platforms/Kconfig.cputype | 1 - 4 files changed, 87 deletions(-) delete mode 100644 arch/powerpc/include/asm/nohash/32/slice.h
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0 -64
@@ -176,12 +176,6 @@*/ #define SPRN_M_TW 799 -#ifdef CONFIG_PPC_MM_SLICES -#include <asm/nohash/32/slice.h> -#define SLICE_ARRAY_SIZE (1 << (32 - SLICE_LOW_SHIFT - 1)) -#define LOW_SLICE_ARRAY_SZ SLICE_ARRAY_SIZE -#endif -#if defined(CONFIG_PPC_4K_PAGES )#define mmu_virtual_psize MMU_PAGE_4K#elif defined(CONFIG_PPC_16K_PAGES )
@@ -199,71 +193,13 @@#include <linux/mmdebug.h> -struct slice_mask { -u64 low_slices; - DECLARE_BITMAP(high_slices, 0); -}; -typedef struct {unsigned int id;unsigned int active;unsigned long vdso_base; -#ifdef CONFIG_PPC_MM_SLICES -u16 user_psize;/* page size index */ -unsigned char low_slices_psize[SLICE_ARRAY_SIZE ]; -unsigned char high_slices_psize[0 ]; -unsigned long slb_addr_limit; -struct slice_mask mask_base_psize;/* 4k or 16k */ -struct slice_mask mask_512k; -struct slice_mask mask_8m; -#endif void *pte_frag; }mm_context_t ; -#ifdef CONFIG_PPC_MM_SLICES -static inline u16 mm_ctx_user_psize (mm_context_t *ctx) -{ -return ctx->user_psize; -} - -static inline void mm_ctx_set_user_psize (mm_context_t *ctx,u16 user_psize) -{ - ctx->user_psize = user_psize; -} - -static inline unsigned char *mm_ctx_low_slices (mm_context_t *ctx) -{ -return ctx->low_slices_psize; -} - -static inline unsigned char *mm_ctx_high_slices (mm_context_t *ctx) -{ -return ctx->high_slices_psize; -} - -static inline unsigned long mm_ctx_slb_addr_limit (mm_context_t *ctx) -{ -return ctx->slb_addr_limit; -} - -static inline void mm_ctx_set_slb_addr_limit (mm_context_t *ctx,unsigned long limit) -{ - ctx->slb_addr_limit = limit; -} - -static inline struct slice_mask *slice_mask_for_size (mm_context_t *ctx,int psize) -{ -if (psize ==MMU_PAGE_512K ) -return &ctx->mask_512k; -if (psize ==MMU_PAGE_8M ) -return &ctx->mask_8m; - -BUG_ON (psize != mmu_virtual_psize); - -return &ctx->mask_base_psize; -} -#endif /* CONFIG_PPC_MM_SLICE */ -#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE))
arch/powerpc/include/asm/nohash/32/slice.h deleted +0 -20
@@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_NOHASH_32_SLICE_H -#define _ASM_POWERPC_NOHASH_32_SLICE_H - -#ifdef CONFIG_PPC_MM_SLICES - -#define SLICE_LOW_SHIFT 26/* 64 slices */ -#define SLICE_LOW_TOP (0x100000000ull) -#define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT) -#define GET_LOW_SLICE_INDEX (addr) ((addr) >> SLICE_LOW_SHIFT) - -#define SLICE_HIGH_SHIFT 0 -#define SLICE_NUM_HIGH 0ul -#define GET_HIGH_SLICE_INDEX (addr) (addr & 0) - -#define SLB_ADDR_LIMIT_DEFAULT DEFAULT_MAP_WINDOW - -#endif /* CONFIG_PPC_MM_SLICES */ - -#endif /* _ASM_POWERPC_NOHASH_32_SLICE_H */
arch/powerpc/include/asm/slice.h +0 -2
@@ -4,8 +4,6 @@#ifdef CONFIG_PPC_BOOK3S_64 #include <asm/book3s/64/slice.h> -#elif defined(CONFIG_PPC_MMU_NOHASH_32 ) -#include <asm/nohash/32/slice.h> #endif #ifndef __ASSEMBLY__
arch/powerpc/platforms/Kconfig.cputype +0 -1
@@ -55,7 +55,6 @@ config PPC_8xx select SYS_SUPPORTS_HUGETLBFS select PPC_HAVE_KUEP select PPC_HAVE_KUAP - select PPC_MM_SLICES if HUGETLB_PAGE select HAVE_ARCH_VMAP_STACK config 40x
Signature · 1 line
2.25.0
PATCH v4 29/45 powerpc/8xx: Move PPC_PIN_TLB options into 8xx Kconfig
In reply to Christophe LeroyPPC_PIN_TLB options are dedicated to the 8xx, move them into the 8xx Kconfig.
While we are at it, add some text to explain what it does.
--- arch/powerpc/Kconfig | 20 --------------- arch/powerpc/platforms/8xx/Kconfig | 41 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 20 deletions(-)
arch/powerpc/Kconfig +0 -20
@@ -1227,26 +1227,6 @@ config TASK_SIZE hex "Size of user task space" if TASK_SIZE_BOOL default "0x80000000" if PPC_8xx default "0xc0000000" - -config PIN_TLB - bool "Pinned Kernel TLBs (860 ONLY)" - depends on ADVANCED_OPTIONS && PPC_8xx && \ - !DEBUG_PAGEALLOC && !STRICT_KERNEL_RWX - -config PIN_TLB_DATA - bool "Pinned TLB for DATA" - depends on PIN_TLB - default y - -config PIN_TLB_IMMR - bool "Pinned TLB for IMMR" - depends on PIN_TLB || PPC_EARLY_DEBUG_CPM - default y - -config PIN_TLB_TEXT - bool "Pinned TLB for TEXT" - depends on PIN_TLB - default y endmenu if PPC64
arch/powerpc/platforms/8xx/Kconfig +41 -0
45 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v4 30/45 powerpc/8xx: Add function to set pinned TLBs
In reply to Christophe LeroyPinned TLBs cannot be modified when the MMU is enabled.
Create a function to rewrite the pinned TLB entries with MMU off.
To set pinned TLB, we have to turn off MMU, disable pinning, do a TLB flush (Either with tlbie and tlbia) then reprogam the TLB entries, enable pinning and turn on MMU.
If using tlbie, it cleared entries in both instruction and data TLB regardless whether pinning is disabled or not.
If using tlbia, it clears all entries of the TLB which has disabled pinning.
To make it easy, just clear all entries in both TLBs, and reprogram them.
The function takes two arguments, the top of the memory to consider and whether data is RO under _sinittext.
When DEBUG_PAGEALLOC is set, the top is the end of kernel rodata. Otherwise, that's the top of physical RAM.
Everything below _sinittext is set RX, over _sinittext that's RW.
---
v2: Function rewritten to manage all entries at once.
--- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 2 + arch/powerpc/kernel/head_8xx.S | 103 +++++++++++++++++++ 2 files changed, 105 insertions(+)
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +2 -0
@@ -193,6 +193,8 @@#include <linux/mmdebug.h> +void mmu_pin_tlb (unsigned long top,bool readonly); + typedef struct { unsigned int id; unsigned int active;
arch/powerpc/kernel/head_8xx.S +103 -0
115 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v4 31/45 powerpc/8xx: Don't set IMMR map anymore at boot
In reply to Christophe LeroyOnly early debug requires IMMR to be mapped early.
No need to set it up and pin it in assembly. Map it through page tables at udbg init when necessary.
If CONFIG_PIN_TLB_IMMR is selected, pin it once we don't need the 32 Mb pinned RAM anymore.
---
v2: Disable TLB reservation to modify entry 31
--- arch/powerpc/kernel/head_8xx.S | 39 +++++++++++++----------------- arch/powerpc/mm/mmu_decl.h | 4 +++ arch/powerpc/mm/nohash/8xx.c | 15 +++++++++--- arch/powerpc/platforms/8xx/Kconfig | 2 +- arch/powerpc/sysdev/cpm_common.c | 2 ++ 5 files changed, 35 insertions(+), 27 deletions(-)
arch/powerpc/kernel/head_8xx.S +17 -22
@@ -749,6 +749,23 @@ start_here: rfi /* Load up the kernel context */ 2: +#ifdef CONFIG_PIN_TLB_IMMR + lis r0, MD_TWAM@h + oris r0, r0, 0x1f00 + mtspr SPRN_MD_CTR, r0 + LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID) + tlbie r0 + mtspr SPRN_MD_EPN, r0 + LOAD_REG_IMMEDIATE(r0, MD_SVALID | MD_PS512K | MD_GUARDED) + mtspr SPRN_MD_TWC, r0 + mfspr r0, SPRN_IMMR + rlwinm r0, r0, 0, 0xfff80000 + ori r0, r0, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \ + _PAGE_NO_CACHE | _PAGE_PRESENT + mtspr SPRN_MD_RPN, r0 + lis r0, (MD_TWAM | MD_RSV4I)@h + mtspr SPRN_MD_CTR, r0 +#endif tlbia /* Clear all TLB entries */ sync /* wait for tlbia/tlbie to finish */
@@ -797,28 +814,6 @@ initial_mmu: ori r8, r8, MD_APG_INIT@l mtspr SPRN_MD_AP, r8 - /* Map a 512k page for the IMMR to get the processor - * internal registers (among other things). - */ -#ifdef CONFIG_PIN_TLB_IMMR - oris r10, r10, MD_RSV4I@h - ori r10, r10, 0x1c00 - mtspr SPRN_MD_CTR, r10 - - mfspr r9, 638 /* Get current IMMR */ - andis. r9, r9, 0xfff8 /* Get 512 kbytes boundary */ - - lis r8, VIRT_IMMR_BASE@h /* Create vaddr for TLB */ - ori r8, r8, MD_EVALID /* Mark it valid */ - mtspr SPRN_MD_EPN, r8 - li r8, MD_PS512K | MD_GUARDED /* Set 512k byte page */ - ori r8, r8, MD_SVALID /* Make it valid */ - mtspr SPRN_MD_TWC, r8 - mr r8, r9 /* Create paddr for TLB */ - ori r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */ - mtspr SPRN_MD_RPN, r8 -#endif - /* Now map the lower RAM (up to 32 Mbytes) into the ITLB. */ #ifdef CONFIG_PIN_TLB_TEXT lis r8, MI_RSV4I@h
arch/powerpc/mm/mmu_decl.h +4 -0
@@ -182,6 +182,10 @@ static inline void mmu_mark_initmem_nx(void) { }static inline void mmu_mark_rodata_ro (void ) { }#endif +#ifdef CONFIG_PPC_8xx +void __init mmu_mapin_immr (void ); +#endif +#ifdef CONFIG_PPC_DEBUG_WX void ptdump_check_wx (void );#else
arch/powerpc/mm/nohash/8xx.c +11 -4
@@ -66,7 +66,7 @@ void __init MMU_init_hw(void)if (IS_ENABLED (CONFIG_PIN_TLB_DATA )) {unsigned long ctr =mfspr (SPRN_MD_CTR ) &0xfe000000 ;unsigned long flags =0xf0 |MD_SPS16K | _PAGE_SH | _PAGE_DIRTY; -int i =IS_ENABLED (CONFIG_PIN_TLB_IMMR ) ?29 :28 ; +int i =28 ;unsigned long addr =0 ;unsigned long mem = total_lowmem;
@@ -81,12 +81,19 @@ void __init MMU_init_hw(void) } } -static void __init mmu_mapin_immr (void ) +static bool immr_is_mapped__initdata ; + +void __init mmu_mapin_immr (void ) {unsigned long p =PHYS_IMMR_BASE ;unsigned long v =VIRT_IMMR_BASE ;int offset; +if (immr_is_mapped) +return ; + + immr_is_mapped = true; +for (offset =0 ; offset <IMMR_SIZE ; offset +=PAGE_SIZE )map_kernel_page (v + offset, p + offset,PAGE_KERNEL_NCG ); }
@@ -122,9 +129,10 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top) {unsigned long mapped; +mmu_mapin_immr (); +if (__map_without_ltlbs) { mapped =0 ; -mmu_mapin_immr ();if (!IS_ENABLED (CONFIG_PIN_TLB_IMMR ))patch_instruction_site (&patch__dtlbmiss_immr_jmp,ppc_inst (PPC_INST_NOP ));if (!IS_ENABLED (CONFIG_PIN_TLB_TEXT ))
@@ -143,7 +151,6 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)*/ mmu_mapin_ram_chunk (0 , einittext8,PAGE_KERNEL_X );mmu_mapin_ram_chunk (einittext8, mapped,PAGE_KERNEL ); -mmu_mapin_immr (); }mmu_patch_cmp_limit (&patch__dtlbmiss_linmem_top, mapped);
arch/powerpc/platforms/8xx/Kconfig +1 -1
@@ -187,7 +187,7 @@ config PIN_TLB_DATA config PIN_TLB_IMMR bool "Pinned TLB for IMMR" - depends on PIN_TLB || PPC_EARLY_DEBUG_CPM + depends on PIN_TLB default y help This pins the IMMR area with a 512kbytes page. In case
arch/powerpc/sysdev/cpm_common.c +2 -0
@@ -68,6 +68,8 @@ static void udbg_putc_cpm(char c)void __init udbg_init_cpm (void ) {#ifdef CONFIG_PPC_8xx +mmu_mapin_immr (); + cpm_udbg_txdesc = (u32 __iomem __force *) (CONFIG_PPC_EARLY_DEBUG_CPM_ADDR -PHYS_IMMR_BASE +VIRT_IMMR_BASE );
Signature · 1 line
2.25.0
PATCH v4 32/45 powerpc/8xx: Always pin TLBs at startup.
In reply to Christophe LeroyAt startup, map 32 Mbytes of memory through 4 pages of 8M, and PIN them inconditionnaly. They need to be pinned because KASAN is using page tables early and the TLBs might be dynamically replaced otherwise.
Remove RSV4I flag after installing mappings unless CONFIG_PIN_TLB_XXXX is selected.
--- arch/powerpc/kernel/head_8xx.S | 31 +++++++++++++++++-------------- arch/powerpc/mm/nohash/8xx.c | 19 +------------------ 2 files changed, 18 insertions(+), 32 deletions(-)
arch/powerpc/kernel/head_8xx.S +17 -14
@@ -765,6 +765,14 @@ start_here: mtspr SPRN_MD_RPN, r0 lis r0, (MD_TWAM | MD_RSV4I)@h mtspr SPRN_MD_CTR, r0 +#endif +#ifndef CONFIG_PIN_TLB_TEXT + li r0, 0 + mtspr SPRN_MI_CTR, r0 +#endif +#if !defined(CONFIG_PIN_TLB_DATA) && !defined(CONFIG_PIN_TLB_IMMR) + lis r0, MD_TWAM@h + mtspr SPRN_MD_CTR, r0 #endif tlbia /* Clear all TLB entries */ sync /* wait for tlbia/tlbie to finish */
@@ -802,10 +810,6 @@ initial_mmu: mtspr SPRN_MD_CTR, r10 /* remove PINNED DTLB entries */ tlbia /* Invalidate all TLB entries */ -#ifdef CONFIG_PIN_TLB_DATA - oris r10, r10, MD_RSV4I@h - mtspr SPRN_MD_CTR, r10 /* Set data TLB control */ -#endif lis r8, MI_APG_INIT@h /* Set protection modes */ ori r8, r8, MI_APG_INIT@l
@@ -814,33 +818,32 @@ initial_mmu: ori r8, r8, MD_APG_INIT@l mtspr SPRN_MD_AP, r8 - /* Now map the lower RAM (up to 32 Mbytes) into the ITLB. */ -#ifdef CONFIG_PIN_TLB_TEXT + /* Map the lower RAM (up to 32 Mbytes) into the ITLB and DTLB */ lis r8, MI_RSV4I@h ori r8, r8, 0x1c00 -#endif + oris r12, r10, MD_RSV4I@h + ori r12, r12, 0x1c00 li r9, 4 /* up to 4 pages of 8M */ mtctr r9 lis r9, KERNELBASE@h /* Create vaddr for TLB */ li r10, MI_PS8MEG | MI_SVALID /* Set 8M byte page */ li r11, MI_BOOTINIT /* Create RPN for address 0 */ - lis r12, _einittext@h - ori r12, r12, _einittext@l 1: -#ifdef CONFIG_PIN_TLB_TEXT mtspr SPRN_MI_CTR, r8 /* Set instruction MMU control */ addi r8, r8, 0x100 -#endif - ori r0, r9, MI_EVALID /* Mark it valid */ mtspr SPRN_MI_EPN, r0 mtspr SPRN_MI_TWC, r10 mtspr SPRN_MI_RPN, r11 /* Store TLB entry */ + mtspr SPRN_MD_CTR, r12 + addi r12, r12, 0x100 + mtspr SPRN_MD_EPN, r0 + mtspr SPRN_MD_TWC, r10 + mtspr SPRN_MD_RPN, r11 addis r9, r9, 0x80 addis r11, r11, 0x80 - cmpl cr0, r9, r12 - bdnzf gt, 1b + bdnz 1b /* Since the cache is enabled according to the information we * just loaded into the TLB, invalidate and enable the caches here.
arch/powerpc/mm/nohash/8xx.c +1 -18
@@ -62,23 +62,6 @@ unsigned long p_block_mapped(phys_addr_t pa)*/ void __init MMU_init_hw (void ) { -/* PIN up to the 3 first 8Mb after IMMR in DTLB table */ -if (IS_ENABLED (CONFIG_PIN_TLB_DATA )) { -unsigned long ctr =mfspr (SPRN_MD_CTR ) &0xfe000000 ; -unsigned long flags =0xf0 |MD_SPS16K | _PAGE_SH | _PAGE_DIRTY; -int i =28 ; -unsigned long addr =0 ; -unsigned long mem = total_lowmem; - -for (; i <32 && mem >=LARGE_PAGE_SIZE_8M ; i++) { -mtspr (SPRN_MD_CTR , ctr | (i <<8 )); -mtspr (SPRN_MD_EPN , (unsigned long )__va (addr) |MD_EVALID ); -mtspr (SPRN_MD_TWC ,MD_PS8MEG |MD_SVALID ); -mtspr (SPRN_MD_RPN , addr | flags | _PAGE_PRESENT); - addr +=LARGE_PAGE_SIZE_8M ; - mem -=LARGE_PAGE_SIZE_8M ; - } - } }static bool immr_is_mapped__initdata ;
@@ -226,7 +209,7 @@ void __init setup_initial_memory_limit(phys_addr_t first_memblock_base,BUG_ON (first_memblock_base !=0 );/* 8xx can only access 32MB at the moment */ -memblock_set_current_limit (min_t (u64, first_memblock_size,0x02000000 )); +memblock_set_current_limit (min_t (u64, first_memblock_size,SZ_32M )); }/*
Signature · 1 line
2.25.0
PATCH v4 33/45 powerpc/8xx: Drop special handling of Linear and IMMR mappings in I/D TLB handlers
In reply to Christophe LeroyUp to now, linear and IMMR mappings are managed via huge TLB entries through specific code directly in TLB miss handlers. This implies some patching of the TLB miss handlers at startup, and a lot of dedicated code.
Remove all this specific dedicated code.
For now we are back to normal handling via standard 4k pages. In the next patches, linear memory mapping and IMMR mapping will be managed through huge pages.
--- arch/powerpc/kernel/head_8xx.S | 29 +-------- arch/powerpc/mm/nohash/8xx.c | 106 +-------------------------------- 2 files changed, 3 insertions(+), 132 deletions(-)
arch/powerpc/kernel/head_8xx.S +2 -27
@@ -207,31 +207,21 @@ InstructionTLBMiss: mfspr r10, SPRN_SRR0 /* Get effective address of fault */ INVALIDATE_ADJACENT_PAGES_CPU15(r10) mtspr SPRN_MD_EPN, r10 - /* Only modules will cause ITLB Misses as we always - * pin the first 8MB of kernel memory */ #ifdef ITLB_MISS_KERNEL mfcr r11 -#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT) +#if defined(SIMPLE_KERNEL_ADDRESS) cmpi cr0, r10, 0 /* Address >= 0x80000000 */ #else rlwinm r10, r10, 16, 0xfff8 cmpli cr0, r10, PAGE_OFFSET@h -#ifndef CONFIG_PIN_TLB_TEXT - /* It is assumed that kernel code fits into the first 32M */ -0: cmpli cr7, r10, (PAGE_OFFSET + 0x2000000)@h - patch_site 0b, patch__itlbmiss_linmem_top -#endif #endif #endif mfspr r10, SPRN_M_TWB /* Get level 1 table */ #ifdef ITLB_MISS_KERNEL -#if defined(SIMPLE_KERNEL_ADDRESS) && defined(CONFIG_PIN_TLB_TEXT) +#if defined(SIMPLE_KERNEL_ADDRESS) bge+ 3f #else blt+ 3f -#endif -#ifndef CONFIG_PIN_TLB_TEXT - blt cr7, ITLBMissLinear #endif rlwinm r10, r10, 0, 20, 31 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
@@ -327,19 +317,9 @@ DataStoreTLBMiss: mfspr r10, SPRN_MD_EPN rlwinm r10, r10, 16, 0xfff8 cmpli cr0, r10, PAGE_OFFSET@h -#ifndef CONFIG_PIN_TLB_IMMR - cmpli cr6, r10, VIRT_IMMR_BASE@h -#endif -0: cmpli cr7, r10, (PAGE_OFFSET + 0x2000000)@h - patch_site 0b, patch__dtlbmiss_linmem_top mfspr r10, SPRN_M_TWB /* Get level 1 table */ blt+ 3f -#ifndef CONFIG_PIN_TLB_IMMR -0: beq- cr6, DTLBMissIMMR - patch_site 0b, patch__dtlbmiss_immr_jmp -#endif - blt cr7, DTLBMissLinear rlwinm r10, r10, 0, 20, 31 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha 3:
@@ -571,14 +551,9 @@ FixupDAR:/* Entry point for dcbx workaround. */ cmpli cr1, r11, PAGE_OFFSET@h mfspr r11, SPRN_M_TWB /* Get level 1 table */ blt+ cr1, 3f - rlwinm r11, r10, 16, 0xfff8 - -0: cmpli cr7, r11, (PAGE_OFFSET + 0x1800000)@h - patch_site 0b, patch__fixupdar_linmem_top /* create physical page address from effective address */ tophys(r11, r10) - blt- cr7, 201f mfspr r11, SPRN_M_TWB /* Get level 1 table */ rlwinm r11, r11, 0, 20, 31 oris r11, r11, (swapper_pg_dir - PAGE_OFFSET)@ha
arch/powerpc/mm/nohash/8xx.c +1 -105
131 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v4 34/45 powerpc/8xx: Remove now unused TLB miss functions
In reply to Christophe LeroyThe code to setup linear and IMMR mapping via huge TLB entries is not called anymore. Remove it.
Also remove the handling of removed code exits in the perf driver.
--- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 8 +- arch/powerpc/kernel/head_8xx.S | 83 -------------------- arch/powerpc/perf/8xx-pmu.c | 10 --- 3 files changed, 1 insertion(+), 100 deletions(-)
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +1 -7
@@ -240,13 +240,7 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize) }/* patch sites */ -extern s32 patch__itlbmiss_linmem_top, patch__itlbmiss_linmem_top8; -extern s32 patch__dtlbmiss_linmem_top, patch__dtlbmiss_immr_jmp; -extern s32 patch__fixupdar_linmem_top; -extern s32 patch__dtlbmiss_romem_top, patch__dtlbmiss_romem_top8; - -extern s32 patch__itlbmiss_exit_1, patch__itlbmiss_exit_2; -extern s32 patch__dtlbmiss_exit_1, patch__dtlbmiss_exit_2, patch__dtlbmiss_exit_3; +extern s32 patch__itlbmiss_exit_1, patch__dtlbmiss_exit_1;extern s32 patch__itlbmiss_perf, patch__dtlbmiss_perf;#endif /* !__ASSEMBLY__ */
arch/powerpc/kernel/head_8xx.S +0 -83
95 lines not on this page · raw message
arch/powerpc/perf/8xx-pmu.c +0 -10
@@ -100,9 +100,6 @@ static int mpc8xx_pmu_add(struct perf_event *event, int flags)unsigned long target =patch_site_addr (&patch__itlbmiss_perf);patch_branch_site (&patch__itlbmiss_exit_1, target,0 ); -#ifndef CONFIG_PIN_TLB_TEXT -patch_branch_site (&patch__itlbmiss_exit_2, target,0 ); -#endif } val = itlb_miss_counter;break ;
@@ -111,8 +108,6 @@ static int mpc8xx_pmu_add(struct perf_event *event, int flags)unsigned long target =patch_site_addr (&patch__dtlbmiss_perf);patch_branch_site (&patch__dtlbmiss_exit_1, target,0 ); -patch_branch_site (&patch__dtlbmiss_exit_2, target,0 ); -patch_branch_site (&patch__dtlbmiss_exit_3, target,0 ); } val = dtlb_miss_counter;break ;
@@ -175,9 +170,6 @@ static void mpc8xx_pmu_del(struct perf_event *event, int flags) __PPC_SPR(SPRN_SPRG_SCRATCH0));patch_instruction_site (&patch__itlbmiss_exit_1, insn); -#ifndef CONFIG_PIN_TLB_TEXT -patch_instruction_site (&patch__itlbmiss_exit_2, insn); -#endif }break ;case PERF_8xx_ID_DTLB_LOAD_MISS:
@@ -187,8 +179,6 @@ static void mpc8xx_pmu_del(struct perf_event *event, int flags) __PPC_SPR(SPRN_DAR));patch_instruction_site (&patch__dtlbmiss_exit_1, insn); -patch_instruction_site (&patch__dtlbmiss_exit_2, insn); -patch_instruction_site (&patch__dtlbmiss_exit_3, insn); }break ; }
Signature · 1 line
2.25.0
PATCH v4 35/45 powerpc/8xx: Move DTLB perf handling closer.
In reply to Christophe LeroyNow that space have been freed next to the DTLB miss handler, it's associated DTLB perf handling can be brought back in the same place.
--- arch/powerpc/kernel/head_8xx.S | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
arch/powerpc/kernel/head_8xx.S +11 -12
@@ -344,6 +344,17 @@ DataStoreTLBMiss: rfi patch_site 0b, patch__dtlbmiss_exit_1 +#ifdef CONFIG_PERF_EVENTS + patch_site 0f, patch__dtlbmiss_perf +0: lwz r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) + addi r10, r10, 1 + stw r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) + mfspr r10, SPRN_DAR + mtspr SPRN_DAR, r11 /* Tag DAR */ + mfspr r11, SPRN_M_TW + rfi +#endif + /* This is an instruction TLB error on the MPC8xx. This could be due * to many reasons, such as executing guarded memory or illegal instruction * addresses. There is nothing to do but handle a big time error fault.
@@ -390,18 +401,6 @@ DARFixed:/* Return from dcbx instruction bug workaround */ /* 0x300 is DataAccess exception, needed by bad_page_fault() */ EXC_XFER_LITE(0x300, handle_page_fault) -/* Called from DataStoreTLBMiss when perf TLB misses events are activated */ -#ifdef CONFIG_PERF_EVENTS - patch_site 0f, patch__dtlbmiss_perf -0: lwz r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) - addi r10, r10, 1 - stw r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0) - mfspr r10, SPRN_DAR - mtspr SPRN_DAR, r11 /* Tag DAR */ - mfspr r11, SPRN_M_TW - rfi -#endif - stack_overflow: vmap_stack_overflow_exception
Signature · 1 line
2.25.0
PATCH v4 36/45 powerpc/mm: Don't be too strict with _etext alignment on PPC32
In reply to Christophe LeroySimilar to PPC64, accept to map RO data as ROX as a trade off between between security and memory usage.
Having RO data executable is not a high risk as RO data can't be modified to forge an exploit.
--- arch/powerpc/Kconfig | 26 -------------------------- arch/powerpc/kernel/vmlinux.lds.S | 3 +-- 2 files changed, 1 insertion(+), 28 deletions(-)
arch/powerpc/Kconfig +0 -26
@@ -778,32 +778,6 @@ config THREAD_SHIFT Used to define the stack size. The default is almost always what you want. Only change this if you know what you are doing. -config ETEXT_SHIFT_BOOL - bool "Set custom etext alignment" if STRICT_KERNEL_RWX && \ - (PPC_BOOK3S_32 || PPC_8xx) - depends on ADVANCED_OPTIONS - help - This option allows you to set the kernel end of text alignment. When - RAM is mapped by blocks, the alignment needs to fit the size and - number of possible blocks. The default should be OK for most configs. - - Say N here unless you know what you are doing. - -config ETEXT_SHIFT - int "_etext shift" if ETEXT_SHIFT_BOOL - range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 - range 19 23 if STRICT_KERNEL_RWX && PPC_8xx - default 17 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 - default 19 if STRICT_KERNEL_RWX && PPC_8xx - default PPC_PAGE_SHIFT - help - On Book3S 32 (603+), IBATs are used to map kernel text. - Smaller is the alignment, greater is the number of necessary IBATs. - - On 8xx, large pages (512kb or 8M) are used to map kernel linear - memory. Aligning to 8M reduces TLB misses as only 8M pages are used - in that case. - config DATA_SHIFT_BOOL bool "Set custom data alignment" if STRICT_KERNEL_RWX && \ (PPC_BOOK3S_32 || PPC_8xx)
arch/powerpc/kernel/vmlinux.lds.S +1 -2
@@ -15,7 +15,6 @@ #include <asm/thread_info.h> #define STRICT_ALIGN_SIZE (1 << CONFIG_DATA_SHIFT) -#define ETEXT_ALIGN_SIZE (1 << CONFIG_ETEXT_SHIFT) ENTRY(_stext)
@@ -116,7 +115,7 @@ SECTIONS } :text - . = ALIGN(ETEXT_ALIGN_SIZE); + . = ALIGN(PAGE_SIZE); _etext = .; PROVIDE32 (etext = .);
Signature · 1 line
2.25.0
PATCH v4 37/45 powerpc/8xx: Refactor kernel address boundary comparison
In reply to Christophe LeroyNow that linear and IMMR dedicated TLB handling is gone, kernel boundary address comparison is similar in ITLB miss handler and in DTLB miss handler.
Create a macro named compare_to_kernel_boundary.
When TASK_SIZE is strictly below 0x80000000 and PAGE_OFFSET is above 0x80000000, it is enough to compare to 0x8000000, and this can be done with a single instruction.
Using not. instruction, we get to use 'blt' conditional branch as when doing a regular comparison:
0x00000000 <= addr <= 0x7fffffff ==>0xffffffff >= NOT(addr) >= 0x80000000
The above test corresponds to a 'blt'
Otherwise, do a regular comparison using two instructions.
--- arch/powerpc/kernel/head_8xx.S | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
arch/powerpc/kernel/head_8xx.S +8 -14
@@ -32,10 +32,15 @@ #include "head_32.h" +.macro compare_to_kernel_boundary scratch, addr #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000 /* By simply checking Address >= 0x80000000, we know if its a kernel address */ -#define SIMPLE_KERNEL_ADDRESS 1 + not. \scratch, \addr +#else + rlwinm \scratch, \addr, 16, 0xfff8 + cmpli cr0, \scratch, PAGE_OFFSET@h #endif +.endm /* * We need an ITLB miss handler for kernel addresses if:
@@ -209,20 +214,11 @@ InstructionTLBMiss: mtspr SPRN_MD_EPN, r10 #ifdef ITLB_MISS_KERNEL mfcr r11 -#if defined(SIMPLE_KERNEL_ADDRESS) - cmpi cr0, r10, 0 /* Address >= 0x80000000 */ -#else - rlwinm r10, r10, 16, 0xfff8 - cmpli cr0, r10, PAGE_OFFSET@h -#endif + compare_to_kernel_boundary r10, r10 #endif mfspr r10, SPRN_M_TWB /* Get level 1 table */ #ifdef ITLB_MISS_KERNEL -#if defined(SIMPLE_KERNEL_ADDRESS) - bge+ 3f -#else blt+ 3f -#endif rlwinm r10, r10, 0, 20, 31 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha 3:
@@ -288,9 +284,7 @@ DataStoreTLBMiss: * kernel page tables. */ mfspr r10, SPRN_MD_EPN - rlwinm r10, r10, 16, 0xfff8 - cmpli cr0, r10, PAGE_OFFSET@h - + compare_to_kernel_boundary r10, r10 mfspr r10, SPRN_M_TWB /* Get level 1 table */ blt+ 3f rlwinm r10, r10, 0, 20, 31
Signature · 1 line
2.25.0
PATCH v4 38/45 powerpc/8xx: Add a function to early map kernel via huge pages
In reply to Christophe LeroyAdd a function to early map kernel memory using huge pages.
For 512k pages, just use standard page table and map in using 512k pages.
For 8M pages, create a hugepd table and populate the two PGD entries with it.
This function can only be used to create page tables at startup. Once the regular SLAB allocation functions replace memblock functions, this function cannot allocate new pages anymore. However it can still update existing mappings with new protections.
hugepd_none() macro is moved into asm/hugetlb.h to be usable outside of mm/hugetlbpage.c
early_pte_alloc_kernel() is made visible.
_PAGE_HUGE flag is now displayed by ptdump.
---
v2: Select CONFIG_HUGETLBFS instead of CONFIG_HUGETLB_PAGE which leads to linktime failure
--- .../include/asm/nohash/32/hugetlb-8xx.h | 5 ++ arch/powerpc/include/asm/pgtable.h | 2 + arch/powerpc/mm/nohash/8xx.c | 52 +++++++++++++++++++ arch/powerpc/mm/pgtable_32.c | 2 +- arch/powerpc/mm/ptdump/8xx.c | 5 ++ arch/powerpc/platforms/Kconfig.cputype | 1 + 6 files changed, 66 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +5 -0
@@ -35,6 +35,11 @@ static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshi *hpdp =__hugepd (__pa (new) | _PMD_USER | _PMD_PRESENT | _PMD_PAGE_8M); } +static inline void hugepd_populate_kernel (hugepd_t *hpdp,pte_t *new,unsigned int pshift) +{ + *hpdp =__hugepd (__pa (new) | _PMD_PRESENT | _PMD_PAGE_8M); +} +static inline int check_and_get_huge_psize (int shift) {return shift_to_mmu_psize (shift);
arch/powerpc/include/asm/pgtable.h +2 -0
@@ -107,6 +107,8 @@ unsigned long vmalloc_to_phys(void *vmalloc_addr);void pgtable_cache_add (unsigned int shift); +pte_t *early_pte_alloc_kernel (pmd_t *pmdp,unsigned long va); +#if defined(CONFIG_STRICT_KERNEL_RWX ) || defined(CONFIG_PPC32 )void mark_initmem_nx (void );#else
arch/powerpc/mm/nohash/8xx.c +52 -0
67 lines not on this page · raw message
arch/powerpc/mm/pgtable_32.c +1 -1
@@ -61,7 +61,7 @@ static void __init *early_alloc_pgtable(unsigned long size)return ptr; } -static pte_t __init *early_pte_alloc_kernel (pmd_t *pmdp,unsigned long va) +pte_t __init *early_pte_alloc_kernel (pmd_t *pmdp,unsigned long va) {if (pmd_none (*pmdp)) {pte_t *ptep =early_alloc_pgtable (PTE_FRAG_SIZE );
arch/powerpc/mm/ptdump/8xx.c +5 -0
@@ -11,6 +11,11 @@static const struct flag_info flag_array[] = { { + .mask = _PAGE_HUGE, + .val = _PAGE_HUGE, + .set ="h" , + .clear =" " , + }, { .mask = _PAGE_RO | _PAGE_NA, .val =0 , .set ="rw" ,
arch/powerpc/platforms/Kconfig.cputype +1 -0
@@ -56,6 +56,7 @@ config PPC_8xx select PPC_HAVE_KUEP select PPC_HAVE_KUAP select HAVE_ARCH_VMAP_STACK + select HUGETLBFS config 40x bool "AMCC 40x"
Signature · 1 line
2.25.0
PATCH v4 39/45 powerpc/8xx: Map IMMR with a huge page
In reply to Christophe LeroyMap the IMMR area with a single 512k huge page.
--- arch/powerpc/mm/nohash/8xx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/mm/nohash/8xx.c +2 -6
@@ -118,17 +118,13 @@ static bool immr_is_mapped __initdata;void __init mmu_mapin_immr (void ) { -unsigned long p =PHYS_IMMR_BASE ; -unsigned long v =VIRT_IMMR_BASE ; -int offset; -if (immr_is_mapped)return ; immr_is_mapped = true; -for (offset =0 ; offset <IMMR_SIZE ; offset +=PAGE_SIZE ) -map_kernel_page (v + offset, p + offset,PAGE_KERNEL_NCG ); +__early_map_kernel_hugepage (VIRT_IMMR_BASE ,PHYS_IMMR_BASE , +PAGE_KERNEL_NCG ,MMU_PAGE_512K , true); }unsigned long __init mmu_mapin_ram (unsigned long base,unsigned long top)
Signature · 1 line
2.25.0
PATCH v4 40/45 powerpc/8xx: Map linear memory with huge pages
In reply to Christophe LeroyMap linear memory space with 512k and 8M pages whenever possible.
Three mappings are performed:
- One for kernel text
- One for RO data
- One for the rest
Separating the mappings is done to be able to update the protection later when using STRICT_KERNEL_RWX.
The ITLB miss handler now need to also handle huge TLBs unless kernel text in pinned.
--- arch/powerpc/kernel/head_8xx.S | 4 +-- arch/powerpc/mm/nohash/8xx.c | 50 +++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-)
arch/powerpc/kernel/head_8xx.S +2 -2
@@ -224,7 +224,7 @@ InstructionTLBMiss: 3: mtcr r11 #endif -#ifdef CONFIG_HUGETLBFS +#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT) lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10) /* Get level 1 entry */ mtspr SPRN_MD_TWC, r11 #else
@@ -234,7 +234,7 @@ InstructionTLBMiss: #endif mfspr r10, SPRN_MD_TWC lwz r10, 0(r10) /* Get the pte */ -#ifdef CONFIG_HUGETLBFS +#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT) rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K mtspr SPRN_MI_TWC, r11 #endif
arch/powerpc/mm/nohash/8xx.c +49 -1
69 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v4 41/45 powerpc/8xx: Allow STRICT_KERNEL_RwX with pinned TLB
In reply to Christophe LeroyPinned TLB are 8M. Now that there is no strict boundary anymore between text and RO data, it is possible to use 8M pinned executable TLB that covers both text and RO data.
When PIN_TLB_DATA or PIN_TLB_TEXT is selected, enforce 8M RW data alignment and allow STRICT_KERNEL_RWX.
---
v2: Use the new function that sets all pinned TLBs at once.
--- arch/powerpc/Kconfig | 8 +++++--- arch/powerpc/mm/nohash/8xx.c | 9 +++++++-- arch/powerpc/platforms/8xx/Kconfig | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-)
arch/powerpc/Kconfig +5 -3
@@ -779,9 +779,10 @@ config THREAD_SHIFT want. Only change this if you know what you are doing. config DATA_SHIFT_BOOL - bool "Set custom data alignment" if STRICT_KERNEL_RWX && \ - (PPC_BOOK3S_32 || PPC_8xx) + bool "Set custom data alignment" depends on ADVANCED_OPTIONS + depends on STRICT_KERNEL_RWX + depends on PPC_BOOK3S_32 || (PPC_8xx && !PIN_TLB_DATA && !PIN_TLB_TEXT) help This option allows you to set the kernel data alignment. When RAM is mapped by blocks, the alignment needs to fit the size and
@@ -803,7 +804,8 @@ config DATA_SHIFT On 8xx, large pages (512kb or 8M) are used to map kernel linear memory. Aligning to 8M reduces TLB misses as only 8M pages are used - in that case. + in that case. If PIN_TLB is selected, it must be aligned to 8M as + 8M pages will be pinned. config FORCE_MAX_ZONEORDER int "Maximum zone order"
arch/powerpc/mm/nohash/8xx.c +7 -2
@@ -127,8 +127,8 @@ void __init mmu_mapin_immr(void) PAGE_KERNEL_NCG, MMU_PAGE_512K, true); } -static void __init mmu_mapin_ram_chunk (unsigned long offset,unsigned long top, -pgprot_t prot,bool new) +static void mmu_mapin_ram_chunk (unsigned long offset,unsigned long top, +pgprot_t prot,bool new) {unsigned long v =PAGE_OFFSET + offset;unsigned long p = offset;
@@ -181,6 +181,9 @@ void mmu_mark_initmem_nx(void)mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_TEXT , false);mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL , false); + +if (IS_ENABLED (CONFIG_PIN_TLB_TEXT )) +mmu_pin_tlb (block_mapped_ram, false); }#ifdef CONFIG_STRICT_KERNEL_RWX
@@ -189,6 +192,8 @@ void mmu_mark_rodata_ro(void)unsigned long sinittext =__pa (_sinittext);mmu_mapin_ram_chunk (0 , sinittext,PAGE_KERNEL_ROX , false); +if (IS_ENABLED (CONFIG_PIN_TLB_DATA )) + mmu_pin_tlb(block_mapped_ram, true); }#endif
arch/powerpc/platforms/8xx/Kconfig +1 -1
@@ -167,7 +167,7 @@ menu "8xx advanced setup" config PIN_TLB bool "Pinned Kernel TLBs" - depends on ADVANCED_OPTIONS && !DEBUG_PAGEALLOC && !STRICT_KERNEL_RWX + depends on ADVANCED_OPTIONS && !DEBUG_PAGEALLOC help On the 8xx, we have 32 instruction TLBs and 32 data TLBs. In each table 4 TLBs can be pinned.
Signature · 1 line
2.25.0
PATCH v4 42/45 powerpc/8xx: Allow large TLBs with DEBUG_PAGEALLOC
In reply to Christophe LeroyDEBUG_PAGEALLOC only manages RW data.
Text and RO data can still be mapped with hugepages and pinned TLB.
In order to map with hugepages, also enforce a 512kB data alignment minimum. That's a trade-off between size of speed, taking into account that DEBUG_PAGEALLOC is a debug option. Anyway the alignment is still tunable.
We also allow tuning of alignment for book3s to limit the complexity of the test in Kconfig that will anyway disappear in the following patches once DEBUG_PAGEALLOC is handled together with BATs.
--- arch/powerpc/Kconfig | 11 +++++++---- arch/powerpc/mm/init_32.c | 5 ++++- arch/powerpc/mm/nohash/8xx.c | 11 ++++++++--- arch/powerpc/platforms/8xx/Kconfig | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-)
arch/powerpc/Kconfig +7 -4
@@ -781,8 +781,9 @@ config THREAD_SHIFT config DATA_SHIFT_BOOL bool "Set custom data alignment" depends on ADVANCED_OPTIONS - depends on STRICT_KERNEL_RWX - depends on PPC_BOOK3S_32 || (PPC_8xx && !PIN_TLB_DATA && !PIN_TLB_TEXT) + depends on STRICT_KERNEL_RWX || DEBUG_PAGEALLOC + depends on PPC_BOOK3S_32 || (PPC_8xx && !PIN_TLB_DATA && \ + (!PIN_TLB_TEXT || !STRICT_KERNEL_RWX)) help This option allows you to set the kernel data alignment. When RAM is mapped by blocks, the alignment needs to fit the size and
@@ -793,10 +794,12 @@ config DATA_SHIFT_BOOL config DATA_SHIFT int "Data shift" if DATA_SHIFT_BOOL default 24 if STRICT_KERNEL_RWX && PPC64 - range 17 28 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 - range 19 23 if STRICT_KERNEL_RWX && PPC_8xx + range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_BOOK3S_32 + range 19 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_8xx default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 default 23 if STRICT_KERNEL_RWX && PPC_8xx + default 23 if DEBUG_PAGEALLOC && PPC_8xx && PIN_TLB_DATA + default 19 if DEBUG_PAGEALLOC && PPC_8xx default PPC_PAGE_SHIFT help On Book3S 32 (603+), DBATs are used to map kernel text and rodata RO.
arch/powerpc/mm/init_32.c +4 -1
@@ -96,11 +96,14 @@ static void __init MMU_setup(void)if (strstr (boot_command_line,"noltlbs" )) { __map_without_ltlbs =1 ; } +if (IS_ENABLED (CONFIG_PPC_8xx)) +return ; +if (debug_pagealloc_enabled ()) { __map_without_bats =1 ; __map_without_ltlbs =1 ; } -if (strict_kernel_rwx_enabled () && !IS_ENABLED (CONFIG_PPC_8xx)) +if (strict_kernel_rwx_enabled ()) __map_without_ltlbs =1 ; }
arch/powerpc/mm/nohash/8xx.c +8 -3
@@ -150,7 +150,8 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top) {unsigned long etext8 =ALIGN (__pa (_etext),SZ_8M );unsigned long sinittext =__pa (_sinittext); -unsigned long boundary =strict_kernel_rwx_enabled () ? sinittext : etext8; +bool strict_boundary =strict_kernel_rwx_enabled () ||debug_pagealloc_enabled (); +unsigned long boundary = strict_boundary ? sinittext : etext8;unsigned long einittext8 =ALIGN (__pa (_einittext),SZ_8M );WARN_ON (top < einittext8);
@@ -161,8 +162,12 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)return 0 ;mmu_mapin_ram_chunk (0 , boundary,PAGE_KERNEL_TEXT , true); -mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_TEXT , true); -mmu_mapin_ram_chunk (einittext8, top,PAGE_KERNEL , true); +if (debug_pagealloc_enabled ()) { + top = boundary; + }else { +mmu_mapin_ram_chunk (boundary, einittext8,PAGE_KERNEL_TEXT , true); +mmu_mapin_ram_chunk (einittext8, top,PAGE_KERNEL , true); + }if (top >SZ_32M )memblock_set_current_limit (top);
arch/powerpc/platforms/8xx/Kconfig +1 -1
@@ -167,7 +167,7 @@ menu "8xx advanced setup" config PIN_TLB bool "Pinned Kernel TLBs" - depends on ADVANCED_OPTIONS && !DEBUG_PAGEALLOC + depends on ADVANCED_OPTIONS help On the 8xx, we have 32 instruction TLBs and 32 data TLBs. In each table 4 TLBs can be pinned.
Signature · 1 line
2.25.0
PATCH v4 43/45 powerpc/8xx: Implement dedicated kasan_init_region()
In reply to Christophe LeroyImplement a kasan_init_region() dedicated to 8xx that allocates KASAN regions using huge pages.
--- arch/powerpc/mm/kasan/8xx.c | 74 ++++++++++++++++++++++++++++++++++ arch/powerpc/mm/kasan/Makefile | 1 + 2 files changed, 75 insertions(+) create mode 100644 arch/powerpc/mm/kasan/8xx.c
arch/powerpc/mm/kasan/8xx.c new file +74 -0
@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define DISABLE_BRANCH_PROFILING + +#include <linux/kasan.h> +#include <linux/memblock.h> +#include <linux/hugetlb.h> +#include <asm/pgalloc.h> + +static int __init +kasan_init_shadow_8M (unsigned long k_start,unsigned long k_end,void *block) +{ +pmd_t *pmd =pmd_ptr_k (k_start); +unsigned long k_cur, k_next; + +for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd +=2 , block +=SZ_8M ) { +pte_basic_t *new; + + k_next =pgd_addr_end (k_cur, k_end); + k_next =pgd_addr_end (k_next, k_end); +if ((void *)pmd_page_vaddr (*pmd) != kasan_early_shadow_pte) +continue ; + + new =memblock_alloc (sizeof (pte_basic_t),SZ_4K ); +if (!new) +return -ENOMEM ; + + *new =pte_val (pte_mkhuge (pfn_pte (PHYS_PFN (__pa (block)),PAGE_KERNEL ))); + +hugepd_populate_kernel ((hugepd_t *)pmd, (pte_t *)new,PAGE_SHIFT_8M ); +hugepd_populate_kernel ((hugepd_t *)pmd +1 , (pte_t *)new,PAGE_SHIFT_8M ); + } +return 0 ; +} + +int __init kasan_init_region (void *start,size_t size) +{ +unsigned long k_start = (unsigned long )kasan_mem_to_shadow (start); +unsigned long k_end = (unsigned long )kasan_mem_to_shadow (start + size); +unsigned long k_cur; +int ret; +void *block; + + block =memblock_alloc (k_end - k_start,SZ_8M ); +if (!block) +return -ENOMEM ; + +if (IS_ALIGNED (k_start,SZ_8M )) { +kasan_init_shadow_8M (k_start,ALIGN_DOWN (k_end,SZ_8M ), block); + k_cur =ALIGN_DOWN (k_end,SZ_8M ); +if (k_cur == k_end) + goto finish; + }else { + k_cur = k_start; + } + + ret =kasan_init_shadow_page_tables (k_start, k_end); +if (ret) +return ret; + +for (; k_cur < k_end; k_cur +=PAGE_SIZE ) { +pmd_t *pmd =pmd_ptr_k (k_cur); +void *va = block + k_cur - k_start; +pte_t pte =pfn_pte (PHYS_PFN (__pa (va)),PAGE_KERNEL ); + +if (k_cur <ALIGN_DOWN (k_end,SZ_512K )) + pte =pte_mkhuge (pte); + +__set_pte_at (&init_mm, k_cur,pte_offset_kernel (pmd, k_cur), pte,0 ); + } +finish: +flush_tlb_kernel_range (k_start, k_end); +return 0 ; +}
arch/powerpc/mm/kasan/Makefile +1 -0
@@ -3,3 +3,4 @@ KASAN_SANITIZE := n obj-$(CONFIG_PPC32) += kasan_init_32.o +obj-$(CONFIG_PPC_8xx) += 8xx.o
Signature · 1 line
2.25.0
PATCH v4 44/45 powerpc/32s: Allow mapping with BATs with DEBUG_PAGEALLOC
In reply to Christophe LeroyDEBUG_PAGEALLOC only manages RW data.
Text and RO data can still be mapped with BATs.
In order to map with BATs, also enforce data alignment. Set by default to 256M which is a good compromise for keeping enough BATs for also KASAN and IMMR.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/mm/book3s32/mmu.c | 6 ++++++ arch/powerpc/mm/init_32.c | 5 ++--- 3 files changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/Kconfig +1 -0
@@ -797,6 +797,7 @@ config DATA_SHIFT range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_BOOK3S_32 range 19 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_8xx default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32 + default 18 if DEBUG_PAGEALLOC && PPC_BOOK3S_32 default 23 if STRICT_KERNEL_RWX && PPC_8xx default 23 if DEBUG_PAGEALLOC && PPC_8xx && PIN_TLB_DATA default 19 if DEBUG_PAGEALLOC && PPC_8xx
arch/powerpc/mm/book3s32/mmu.c +6 -0
@@ -170,6 +170,12 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)pr_debug ("RAM mapped without BATs\n" );return base; } +if (debug_pagealloc_enabled ()) { +if (base >= border) +return base; +if (top >= border) + top = border; + }if (!strict_kernel_rwx_enabled () || base >= border || top <= border)return __mmu_mapin_ram (base, top);
arch/powerpc/mm/init_32.c +2 -3
@@ -99,10 +99,9 @@ static void __init MMU_setup(void)if (IS_ENABLED (CONFIG_PPC_8xx))return ; -if (debug_pagealloc_enabled ()) { - __map_without_bats =1 ; +if (debug_pagealloc_enabled ()) __map_without_ltlbs =1 ; - } +if (strict_kernel_rwx_enabled ()) __map_without_ltlbs =1 ; }
Signature · 1 line
2.25.0
PATCH v4 45/45 powerpc/32s: Implement dedicated kasan_init_region()
In reply to Christophe LeroyImplement a kasan_init_region() dedicated to book3s/32 that allocates KASAN regions using BATs.
--- arch/powerpc/include/asm/kasan.h | 1 + arch/powerpc/mm/kasan/Makefile | 1 + arch/powerpc/mm/kasan/book3s_32.c | 57 +++++++++++++++++++++++++++ arch/powerpc/mm/kasan/kasan_init_32.c | 2 +- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/mm/kasan/book3s_32.c
arch/powerpc/include/asm/kasan.h +1 -0
@@ -34,6 +34,7 @@ static inline void kasan_init(void) { }static inline void kasan_late_init (void ) { }#endif +void kasan_update_early_region (unsigned long k_start,unsigned long k_end,pte_t pte);int kasan_init_shadow_page_tables (unsigned long k_start,unsigned long k_end);int kasan_init_region (void *start,size_t size);
arch/powerpc/mm/kasan/Makefile +1 -0
@@ -4,3 +4,4 @@ KASAN_SANITIZE := n obj-$(CONFIG_PPC32) += kasan_init_32.o obj-$(CONFIG_PPC_8xx) += 8xx.o +obj-$(CONFIG_PPC_BOOK3S_32) += book3s_32.o
arch/powerpc/mm/kasan/book3s_32.c new file +57 -0
57 lines not on this page · raw message
arch/powerpc/mm/kasan/kasan_init_32.c +1 -1
@@ -79,7 +79,7 @@ int __init __weak kasan_init_region(void *start, size_t size)return 0 ; } -static void __init +void __init kasan_update_early_region (unsigned long k_start,unsigned long k_end,pte_t pte) {unsigned long k_cur;
Signature · 1 line
2.25.0
Quoted 9 lines · Christophe Leroy
The main purpose of this big series is to:
- reorganise huge page handling to avoid usingmm_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.[...]
Patches 1-6 and 9-45 applied to powerpc/next.
[01/45] powerpc/kasan: Fix error detection on memory allocation
https://git.kernel.org/powerpc/c/d132443a73d7a131775df46f33000f67ed92de1e [02/45] powerpc/kasan: Fix issues by lowering KASAN_SHADOW_END https://git.kernel.org/powerpc/c/3a66a24f6060e6775f8c02ac52329ea0152d7e58 [03/45] powerpc/kasan: Fix shadow pages allocation failure https://git.kernel.org/powerpc/c/d2a91cef9bbdeb87b7449fdab1a6be6000930210 [04/45] powerpc/kasan: Remove unnecessary page table locking https://git.kernel.org/powerpc/c/7c31c05e00fc5ff2067332c5f80e525573e7269c [05/45] powerpc/kasan: Refactor update of early shadow mappings https://git.kernel.org/powerpc/c/7dec42ab57f2f59feba82abf0353164479bfde4c [06/45] powerpc/kasan: Declare kasan_init_region() weak https://git.kernel.org/powerpc/c/ec97d022f621c6c850aec46d8818b49c6aae95ad [09/45] powerpc/ptdump: Add _PAGE_COHERENT flag https://git.kernel.org/powerpc/c/3af4786eb429b2df76cbd7ce3bae21467ac3e4fb [10/45] powerpc/ptdump: Display size of BATs https://git.kernel.org/powerpc/c/6b30830e2003d9d77696084ebe2fc19dbe7d6f70 [11/45] powerpc/ptdump: Standardise display of BAT flags https://git.kernel.org/powerpc/c/8961a2a5353cca5451f648f4838cd848a3b2354c [12/45] powerpc/ptdump: Properly handle non standard page size https://git.kernel.org/powerpc/c/b00ff6d8c1c3898b0f768cbb38ef722d25bd2f39 [13/45] powerpc/ptdump: Handle hugepd at PGD level https://git.kernel.org/powerpc/c/6b789a26d7da2e0256d199da980369ef8fb49ec6 [14/45] powerpc/32s: Don't warn when mapping RO data ROX. https://git.kernel.org/powerpc/c/4b19f96a81bceaf0bcf44d79c0855c61158065ec [15/45] powerpc/mm: Allocate static page tables for fixmap https://git.kernel.org/powerpc/c/925ac141d106b55acbe112a9272f970631a3c082 [16/45] powerpc/mm: Fix conditions to perform MMU specific management by blocks on PPC32. https://git.kernel.org/powerpc/c/4e3319c23a66dabfd6c35f4d2633d64d99b68096 [17/45] powerpc/mm: PTE_ATOMIC_UPDATES is only for 40x https://git.kernel.org/powerpc/c/fadaac67c9007cad9fc485e36dcc54460d6d5886 [18/45] powerpc/mm: Refactor pte_update() on nohash/32 https://git.kernel.org/powerpc/c/2db99aeb63dd6e8808dc054d181c4d0e8645bbe0 [19/45] powerpc/mm: Refactor pte_update() on book3s/32 https://git.kernel.org/powerpc/c/1c1bf294882bd12669e39ccd7680c4ce34b7c15c [20/45] powerpc/mm: Standardise __ptep_test_and_clear_young() params between PPC32 and PPC64 https://git.kernel.org/powerpc/c/c7fa77016eb6093df38fdabdb7a89bb9617e7185 [21/45] powerpc/mm: Standardise pte_update() prototype between PPC32 and PPC64 https://git.kernel.org/powerpc/c/06f52524870122fb43b214d27e8f4546da36f8ba [22/45] powerpc/mm: Create a dedicated pte_update() for 8xx https://git.kernel.org/powerpc/c/6ad41bfbc907be0cd414f09fa5382d2133376595 [23/45] powerpc/mm: Reduce hugepd size for 8M hugepages on 8xx https://git.kernel.org/powerpc/c/b12c07a4bb064c0a8db7554557b89d40f57c936f [24/45] powerpc/8xx: Drop CONFIG_8xx_COPYBACK option https://git.kernel.org/powerpc/c/d3efcd38c0b99162d889e36a30425345a18edb33 [25/45] powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages. https://git.kernel.org/powerpc/c/a891c43b97d315ee5f9fe8e797d3d48fc351e053 [26/45] powerpc/8xx: Manage 512k huge pages as standard pages. https://git.kernel.org/powerpc/c/b250c8c08c79d1eb5354c7eaa84b7505f5f2d921 [27/45] powerpc/8xx: Only 8M pages are hugepte pages now https://git.kernel.org/powerpc/c/d4870b89acd7c362ded08f9295e8d143cf7e0024 [28/45] powerpc/8xx: MM_SLICE is not needed anymore https://git.kernel.org/powerpc/c/555904d07eef3a2e5fc458419edf6174362c4ddd [29/45] powerpc/8xx: Move PPC_PIN_TLB options into 8xx Kconfig https://git.kernel.org/powerpc/c/5d4656696c30cef56b2ab506b203533c818af04d [30/45] powerpc/8xx: Add function to set pinned TLBs https://git.kernel.org/powerpc/c/f76c8f6d257cefda60221c83af7f97d9f74cb3ce [31/45] powerpc/8xx: Don't set IMMR map anymore at boot https://git.kernel.org/powerpc/c/136a9a0f74d2e0d9de5515190fe80344b86b45cf [32/45] powerpc/8xx: Always pin TLBs at startup. https://git.kernel.org/powerpc/c/684c1664e0de63398aceb748343541b48d398710 [33/45] powerpc/8xx: Drop special handling of Linear and IMMR mappings in I/D TLB handlers https://git.kernel.org/powerpc/c/400dc0f86102d2ad11d3601f1948fbb02e926431 [34/45] powerpc/8xx: Remove now unused TLB miss functions https://git.kernel.org/powerpc/c/1251288e64ba44969e1c4d59e5ee88a6e873447b [35/45] powerpc/8xx: Move DTLB perf handling closer. https://git.kernel.org/powerpc/c/0c8c2c9c201b44eed6c10d7c5c8d25fe5aab87ce [36/45] powerpc/mm: Don't be too strict with _etext alignment on PPC32 https://git.kernel.org/powerpc/c/a0591b60eef965f7f5255ad4696bbba9af4b43d0 [37/45] powerpc/8xx: Refactor kernel address boundary comparison https://git.kernel.org/powerpc/c/c8bef10a9f17b2b9549e37878b2bcd48039c136b [38/45] powerpc/8xx: Add a function to early map kernel via huge pages https://git.kernel.org/powerpc/c/34536d78068318def0a370462cbc3319e1ca9014 [39/45] powerpc/8xx: Map IMMR with a huge page https://git.kernel.org/powerpc/c/a623bb5861dc442dc8de9edc9b3116f8b7c235c4 [40/45] powerpc/8xx: Map linear memory with huge pages https://git.kernel.org/powerpc/c/cf209951fa7f2e7a8ec92f45f27ea11bc024bbfc [41/45] powerpc/8xx: Allow STRICT_KERNEL_RwX with pinned TLB https://git.kernel.org/powerpc/c/da1adea07576722da4597b0df7d00931f0203229 [42/45] powerpc/8xx: Allow large TLBs with DEBUG_PAGEALLOC https://git.kernel.org/powerpc/c/fcdafd10a363cf3278ce29c6c9a92930380c6cd8 [43/45] powerpc/8xx: Implement dedicated kasan_init_region() https://git.kernel.org/powerpc/c/a2feeb2c2ecbd9c9206d66f238ca710b760c9ef5 [44/45] powerpc/32s: Allow mapping with BATs with DEBUG_PAGEALLOC https://git.kernel.org/powerpc/c/2b279c0348af62f42be346c1ea6d70bac98df0f9 [45/45] powerpc/32s: Implement dedicated kasan_init_region() https://git.kernel.org/powerpc/c/7974c4732642f710b5111165ae1f7f7fed822282
cheers