cleanup/refactor pgtable.h
Subsystems (2)
PATCH 18/19 powerpc/nohash: Refactor pte_clear()
In reply to Christophe Leroypte_clear() are doing the same on nohash/32 and nohash/64,
Keep the static inline version of nohash/64, make it common and remove the macro version of nohash/32.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 3 --- arch/powerpc/include/asm/nohash/64/pgtable.h | 7 ------- arch/powerpc/include/asm/nohash/pgtable.h | 6 ++++++ 3 files changed, 6 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -3
@@ -153,9 +153,6 @@#ifndef __ASSEMBLY__ -#define pte_clear (mm, addr, ptep) \ - do { pte_update(mm, addr, ptep, ~0, 0, 0); } while (0) -#define pmd_none (pmd) (!pmd_val(pmd))#define pmd_bad (pmd) (pmd_val(pmd) & _PMD_BAD)#define pmd_present (pmd) (pmd_val(pmd) & _PMD_PRESENT_MASK)
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -7
@@ -159,13 +159,6 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, __young; \ }) -static inline void pte_clear (struct mm_struct *mm,unsigned long addr, -pte_t * ptep) -{ -pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); -} - -/* Set the dirty and/or accessed bits atomically in a linux PTE */ static inline void __ptep_set_access_flags(struct vm_area_struct *vma, pte_t *ptep, pte_t entry,
arch/powerpc/include/asm/nohash/pgtable.h +6 -0
@@ -96,6 +96,12 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, }#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +static inline void pte_clear (struct mm_struct *mm,unsigned long addr, +pte_t * ptep) +{ +pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); +} +/* Generic accessors to PTE bits */ #ifndef pte_mkwrite_novmastatic inline pte_t pte_mkwrite_novma (pte_t pte)
Signature · 1 line
2.41.0
cover cleanup/refactor pgtable.h
This series is a cleanup of pgtable.h for nohash mainly
Main purpose is to refactor a lot of common code between nohash/32 and nohash/64.
This series is a prerequisite for following series that will rework PAGE flags and implement execute-only protection.
Christophe Leroy (19):
powerpc/8xx: Fix pte_access_permitted() for PAGE_NONE powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() powerpc/40x: Remove stale PTE_ATOMIC_UPDATES macro
powerpc: Remove pte_ERROR()
powerpc: Deduplicate prototypes of ptep_set_access_flags() and
phys_mem_access_prot()
powerpc: Refactor update_mmu_cache_range()
powerpc: Untangle fixmap.h and pgtable.h and mmu.h powerpc/nohash: Remove {pte/pmd}_protnone() powerpc/nohash: Refactor declaration of {map/unmap}_kernel_page() powerpc/nohash: Move 8xx version of pte_update() into pte-8xx.h powerpc/nohash: Replace #ifdef CONFIG_44x by IS_ENABLED(CONFIG_44x) in
pgtable.h
powerpc/nohash: Refactor pte_update()
powerpc/nohash: Refactor checking of no-change in pte_update() powerpc/nohash: Deduplicate _PAGE_CHG_MASK
powerpc/nohash: Deduplicate pte helpers
powerpc/nohash: Refactor ptep_test_and_clear_young() powerpc/nohash: Deduplicate ptep_set_wrprotect() and
ptep_get_and_clear()
powerpc/nohash: Refactor pte_clear()
powerpc/nohash: Refactor __ptep_set_access_flags()
arch/powerpc/include/asm/book3s/32/pgtable.h | 12 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 +- arch/powerpc/include/asm/book3s/pgtable.h | 33 --- arch/powerpc/include/asm/fixmap.h | 16 +- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 1 - arch/powerpc/include/asm/nohash/32/pgtable.h | 201 +------------------ arch/powerpc/include/asm/nohash/32/pte-40x.h | 3 - arch/powerpc/include/asm/nohash/32/pte-8xx.h | 64 ++++++ arch/powerpc/include/asm/nohash/64/pgtable.h | 118 +---------- arch/powerpc/include/asm/nohash/pgtable.h | 182 +++++++++++++---- arch/powerpc/include/asm/pgtable.h | 32 +++ arch/powerpc/mm/init_32.c | 1 + arch/powerpc/mm/mem.c | 1 + arch/powerpc/mm/nohash/8xx.c | 2 + arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- arch/powerpc/mm/nohash/e500_hugetlbpage.c | 3 +- arch/powerpc/platforms/8xx/cpm1.c | 1 + 17 files changed, 268 insertions(+), 407 deletions(-)
Signature · 1 line
2.41.0
PATCH 12/19 powerpc/nohash: Refactor pte_update()
pte_update() is similar.
Take the nohash/32 version which works on nohash/64 and add the debug call to assert_pte_locked() which is only on nohash/64.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 33 --------------- arch/powerpc/include/asm/nohash/64/pgtable.h | 17 -------- arch/powerpc/include/asm/nohash/pgtable.h | 42 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 50 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -33
@@ -9,8 +9,6 @@#include <linux/threads.h> #include <asm/mmu.h> /* For sub-arch specific PPC_PIN_SIZE */ -extern int icache_44x_need_flush; -#endif /* __ASSEMBLY__ */ #define PTE_INDEX_SIZE PTE_SHIFT
@@ -203,37 +201,6 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp =__pmd (0 ); } -/* -* PTE updates. This function is called whenever an existing -* valid PTE is updated. This does -not- include set_pte_at() -* which nowadays only sets a new PTE. -* -* Depending on the type of MMU, we may need to use atomic updates -* 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 pte_update -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 =pte_val (*p); -pte_basic_t new = (old & ~(pte_basic_t )clr) | set; - - *p =__pte (new); - -if (IS_ENABLED (CONFIG_44x) && (old & _PAGE_USER) && (old & _PAGE_EXEC)) - icache_44x_need_flush =1 ; - -return old; -} -#endif -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNGstatic inline int __ptep_test_and_clear_young (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -17
@@ -171,23 +171,6 @@ static inline void p4d_set(p4d_t *p4dp, unsigned long val) *p4dp =__p4d (val); } -/* Atomic PTE updates */ -static inline unsigned long pte_update (struct mm_struct *mm, -unsigned long addr, -pte_t *ptep,unsigned long clr, -unsigned long set, -int huge) -{ -unsigned long old =pte_val (*ptep); - *ptep =__pte ((old & ~clr) | set); - -/* huge pages use the old page table lock */ -if (!huge) -assert_pte_locked (mm, addr); - -return old; -} -static inline int pte_young (pte_t pte) {return pte_val (pte) & _PAGE_ACCESSED;
arch/powerpc/include/asm/nohash/pgtable.h +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 11/19 powerpc/nohash: Replace #ifdef CONFIG_44x by IS_ENABLED(CONFIG_44x) in pgtable.h
In reply to Christophe LeroyNo need of a #ifdef, use IS_ENABLED(CONFIG_44x)
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +2 -5
@@ -9,9 +9,7 @@#include <linux/threads.h> #include <asm/mmu.h> /* For sub-arch specific PPC_PIN_SIZE */ -#ifdef CONFIG_44xextern int icache_44x_need_flush; -#endif #endif /* __ASSEMBLY__ */
@@ -229,10 +227,9 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p *p =__pte (new); -#ifdef CONFIG_44x -if ((old & _PAGE_USER) && (old & _PAGE_EXEC)) +if (IS_ENABLED (CONFIG_44x) && (old & _PAGE_USER) && (old & _PAGE_EXEC)) icache_44x_need_flush =1 ; -#endif + return old; }#endif
Signature · 1 line
2.41.0
PATCH 5/19 powerpc: Deduplicate prototypes of ptep_set_access_flags() and phys_mem_access_prot()
In reply to Christophe LeroyPrototypes of ptep_set_access_flags() and phys_mem_access_prot() are identical for book3s and nohash.
Deduplicate them.
--- arch/powerpc/include/asm/book3s/pgtable.h | 9 --------- arch/powerpc/include/asm/nohash/pgtable.h | 10 ---------- arch/powerpc/include/asm/pgtable.h | 10 ++++++++++ 3 files changed, 10 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/book3s/pgtable.h +0 -9
@@ -9,15 +9,6 @@#endif #ifndef __ASSEMBLY__ -#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS -extern int ptep_set_access_flags (struct vm_area_struct *vma,unsigned long address, -pte_t *ptep,pte_t entry,int dirty); - -struct file ; -extern pgprot_t phys_mem_access_prot (struct file *file,unsigned long pfn, -unsigned long size,pgprot_t vma_prot); -#define __HAVE_PHYS_MEM_ACCESS_PROT -void __update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep);/*
arch/powerpc/include/asm/nohash/pgtable.h +0 -10
@@ -207,11 +207,6 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,mb (); } - -#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS -extern int ptep_set_access_flags (struct vm_area_struct *vma,unsigned long address, -pte_t *ptep,pte_t entry,int dirty); -/* * Macro to mark a page protection value as "uncacheable". */
@@ -240,11 +235,6 @@ extern int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addre#define pgprot_writecombine pgprot_noncached_wc -struct file ; -extern pgprot_t phys_mem_access_prot (struct file *file,unsigned long pfn, -unsigned long size,pgprot_t vma_prot); -#define __HAVE_PHYS_MEM_ACCESS_PROT -#ifdef CONFIG_HUGETLB_PAGE static inline int hugepd_ok (hugepd_t hpd) {
arch/powerpc/include/asm/pgtable.h +10 -0
@@ -110,6 +110,16 @@ void mark_initmem_nx(void);static inline void mark_initmem_nx (void ) { }#endif +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS +int ptep_set_access_flags (struct vm_area_struct *vma,unsigned long address, +pte_t *ptep,pte_t entry,int dirty); + +struct file ; +pgprot_t phys_mem_access_prot (struct file *file,unsigned long pfn, +unsigned long size,pgprot_t vma_prot); +#define __HAVE_PHYS_MEM_ACCESS_PROT + +/* * When used, PTE_FRAG_NR is defined in subarch pgtable.h * so we are sure it is included when arriving here.
Signature · 1 line
2.41.0
PATCH 9/19 powerpc/nohash: Refactor declaration of {map/unmap}_kernel_page()
In reply to Christophe Leroymap_kernel_page() and unmap_kernel_page() have the same prototypes on nohash/32 and nohash/64, keep only one declaration.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 8 -------- arch/powerpc/include/asm/nohash/64/pgtable.h | 2 -- arch/powerpc/include/asm/nohash/pgtable.h | 3 +++ arch/powerpc/mm/nohash/book3e_pgtable.c | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -8
@@ -58,14 +58,6 @@ extern int icache_44x_need_flush;#define pgd_ERROR (e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -#ifndef __ASSEMBLY__ - -int map_kernel_page (unsigned long va,phys_addr_t pa,pgprot_t prot); -void unmap_kernel_page (unsigned long va); - -#endif /* !__ASSEMBLY__ */ - -/* * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary * value (for now) on others, from where we can start layout kernel
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -2
@@ -309,8 +309,6 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,/* We borrow MSB 56 (LSB 7) to store the exclusive marker in swap PTEs. */ #define _PAGE_SWP_EXCLUSIVE 0x80 -int map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t prot); -void unmap_kernel_page (unsigned long va);extern int __meminit vmemmap_create_mapping (unsigned long start,unsigned long page_size,unsigned long phys);
arch/powerpc/include/asm/nohash/pgtable.h +3 -0
@@ -242,5 +242,8 @@ static inline int pud_huge(pud_t pud)#define is_hugepd (hpd) (hugepd_ok(hpd))#endif +int map_kernel_page (unsigned long va,phys_addr_t pa,pgprot_t prot); +void unmap_kernel_page (unsigned long va); +#endif /* __ASSEMBLY__ */ #endif
arch/powerpc/mm/nohash/book3e_pgtable.c +1 -1
@@ -71,7 +71,7 @@ static void __init *early_alloc_pgtable(unsigned long size)* map_kernel_page adds an entry to the ioremap page table * and adds an entry to the HPT, possibly bolting it */ -int __ref map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t prot) +int __ref map_kernel_page (unsigned long ea,phys_addr_t pa,pgprot_t prot) {pgd_t *pgdp;p4d_t *p4dp;
Signature · 1 line
2.41.0
PATCH 8/19 powerpc/nohash: Remove {pte/pmd}_protnone()
In reply to Christophe LeroyOnly book3s/64 selects ARCH_SUPPORTS_NUMA_BALANCING so CONFIG_NUMA_BALANCING can't be selected on nohash targets.
Remove pte_protnone() and pmd_protnone().
--- arch/powerpc/include/asm/nohash/pgtable.h | 17 ----------------- 1 file changed, 17 deletions(-)
arch/powerpc/include/asm/nohash/pgtable.h +0 -17
@@ -35,23 +35,6 @@ static inline bool pte_hashpte(pte_t pte) { return false; }static inline bool pte_ci (pte_t pte) {return pte_val (pte) & _PAGE_NO_CACHE; }static inline bool pte_exec (pte_t pte) {return pte_val (pte) & _PAGE_EXEC; } -#ifdef CONFIG_NUMA_BALANCING -/* -* These work without NUMA balancing but the kernel does not care. See the -* comment in include/linux/pgtable.h . On powerpc, this will only -* work for user pages and always return true for kernel pages. -*/ -static inline int pte_protnone (pte_t pte) -{ -return pte_present (pte) && !pte_user (pte); -} - -static inline int pmd_protnone (pmd_t pmd) -{ -return pte_protnone (pmd_pte (pmd)); -} -#endif /* CONFIG_NUMA_BALANCING */ -static inline int pte_present (pte_t pte) {return pte_val (pte) & _PAGE_PRESENT;
Signature · 1 line
2.41.0
PATCH 15/19 powerpc/nohash: Deduplicate pte helpers
In reply to Christophe LeroyDeduplicate following helpers that are identical on nohash/32 and nohash/64:
pte_mkwrite_novma()
pte_mkdirty()
pte_mkyoung()
pte_wrprotect()
pte_mkexec()
pte_young()
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 36 -------------------- arch/powerpc/include/asm/nohash/64/pgtable.h | 25 -------------- arch/powerpc/include/asm/nohash/pgtable.h | 36 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 61 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -36
@@ -156,37 +156,6 @@#define pte_clear (mm, addr, ptep) \ do { pte_update(mm, addr, ptep, ~0, 0, 0); } while (0) -#ifndef pte_mkwrite_novma -static inline pte_t pte_mkwrite_novma (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_RW); -} -#endif - -static inline pte_t pte_mkdirty (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_DIRTY); -} - -static inline pte_t pte_mkyoung (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_ACCESSED); -} - -#ifndef pte_wrprotect -static inline pte_t pte_wrprotect (pte_t pte) -{ -return __pte (pte_val (pte) & ~_PAGE_RW); -} -#endif - -#ifndef pte_mkexec -static inline pte_t pte_mkexec (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_EXEC); -} -#endif -#define pmd_none (pmd) (!pmd_val(pmd))#define pmd_bad (pmd) (pmd_val(pmd) & _PMD_BAD)#define pmd_present (pmd) (pmd_val(pmd) & _PMD_PRESENT_MASK)
@@ -238,11 +207,6 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma, }#endif -static inline int pte_young (pte_t pte) -{ -return pte_val (pte) & _PAGE_ACCESSED; -} -/* * Note that on Book E processors, the pmd contains the kernel virtual * (lowmem) address of the pte page. The physical address is less useful
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -25
@@ -80,26 +80,6 @@#ifndef __ASSEMBLY__/* pte_clear moved to later in this file */ -static inline pte_t pte_mkwrite_novma (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_RW); -} - -static inline pte_t pte_mkdirty (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_DIRTY); -} - -static inline pte_t pte_mkyoung (pte_t pte) -{ -return __pte (pte_val (pte) | _PAGE_ACCESSED); -} - -static inline pte_t pte_wrprotect (pte_t pte) -{ -return __pte (pte_val (pte) & ~_PAGE_RW); -} -#define PMD_BAD_BITS (PTE_TABLE_SIZE-1)#define PUD_BAD_BITS (PMD_TABLE_SIZE-1)
@@ -165,11 +145,6 @@ static inline void p4d_set(p4d_t *p4dp, unsigned long val) *p4dp =__p4d (val); } -static inline int pte_young (pte_t pte) -{ -return pte_val (pte) & _PAGE_ACCESSED; -} -static inline int __ptep_test_and_clear_young (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {
arch/powerpc/include/asm/nohash/pgtable.h +36 -0
@@ -70,6 +70,37 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p#endif /* Generic accessors to PTE bits */ +#ifndef pte_mkwrite_novma +static inline pte_t pte_mkwrite_novma (pte_t pte) +{ +return __pte (pte_val (pte) | _PAGE_RW); +} +#endif + +static inline pte_t pte_mkdirty (pte_t pte) +{ +return __pte (pte_val (pte) | _PAGE_DIRTY); +} + +static inline pte_t pte_mkyoung (pte_t pte) +{ +return __pte (pte_val (pte) | _PAGE_ACCESSED); +} + +#ifndef pte_wrprotect +static inline pte_t pte_wrprotect (pte_t pte) +{ +return __pte (pte_val (pte) & ~_PAGE_RW); +} +#endif + +#ifndef pte_mkexec +static inline pte_t pte_mkexec (pte_t pte) +{ +return __pte (pte_val (pte) | _PAGE_EXEC); +} +#endif +#ifndef pte_writestatic inline int pte_write (pte_t pte) {
@@ -96,6 +127,11 @@ static inline bool pte_hw_valid(pte_t pte)return pte_val (pte) & _PAGE_PRESENT; } +static inline int pte_young (pte_t pte) +{ +return pte_val (pte) & _PAGE_ACCESSED; +} +/* * Don't just check for any non zero bits in __PAGE_USER, since for book3e * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in
Signature · 1 line
2.41.0
PATCH 14/19 powerpc/nohash: Deduplicate _PAGE_CHG_MASK
In reply to Christophe Leroy_PAGE_CHG_MASK is identical between nohash/32 and nohash/64, deduplicate it.
While at it, clean the #ifdef for PTE_RPN_MASK in nohash/32 as it is already CONFIG_PPC32.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 8 +------- arch/powerpc/include/asm/nohash/64/pgtable.h | 6 ------ arch/powerpc/include/asm/nohash/pgtable.h | 6 ++++++ 3 files changed, 7 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +1 -7
@@ -143,7 +143,7 @@* The mask covered by the RPN must be a ULL on 32-bit platforms with * 64-bit PTEs. */ -#if defined(CONFIG_PPC32 ) && defined(CONFIG_PTE_64BIT ) +#ifdef CONFIG_PTE_64BIT #define PTE_RPN_MASK (~((1ULL << PTE_RPN_SHIFT) - 1))#define MAX_POSSIBLE_PHYSMEM_BITS 36#else
@@ -151,12 +151,6 @@#define MAX_POSSIBLE_PHYSMEM_BITS 32#endif -/* -* _PAGE_CHG_MASK masks of bits that are to be preserved across -* pgprot changes. -*/ -#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPECIAL) -#ifndef __ASSEMBLY__#define pte_clear (mm, addr, ptep) \
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -6
@@ -75,12 +75,6 @@#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1)) -/* -* _PAGE_CHG_MASK masks of bits that are to be preserved across -* pgprot changes. -*/ -#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPECIAL) -#define H_PAGE_4K_PFN 0#ifndef __ASSEMBLY__
arch/powerpc/include/asm/nohash/pgtable.h +6 -0
@@ -13,6 +13,12 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p#include <asm/nohash/32/pgtable.h> #endif +/* +* _PAGE_CHG_MASK masks of bits that are to be preserved across +* pgprot changes. +*/ +#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPECIAL) +/* Permission masks used for kernel mappings */ #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)#define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | _PAGE_NO_CACHE)
Signature · 1 line
2.41.0
PATCH 3/19 powerpc/40x: Remove stale PTE_ATOMIC_UPDATES macro
In reply to Christophe Leroy40x TLB handlers were reworked by commit 2c74e2586bb9 ("powerpc/40x:
Rework 40x PTE access and TLB miss") to not require PTE_ATOMIC_UPDATES anymore.
Then commit 4e1df545e2fa ("powerpc/pgtable: Drop PTE_ATOMIC_UPDATES") removed all code related to PTE_ATOMIC_UPDATES.
Remove left over PTE_ATOMIC_UPDATES macro.
--- arch/powerpc/include/asm/nohash/32/pte-40x.h | 3 --- 1 file changed, 3 deletions(-)
arch/powerpc/include/asm/nohash/32/pte-40x.h +0 -3
@@ -69,9 +69,6 @@#define _PTE_NONE_MASK 0 -/* Until my rework is finished, 40x still needs atomic PTE updates */ -#define PTE_ATOMIC_UPDATES 1 -#define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED)#define _PAGE_BASE (_PAGE_BASE_NC)
Signature · 1 line
2.41.0
PATCH 16/19 powerpc/nohash: Refactor ptep_test_and_clear_young()
In reply to Christophe LeroyRemove ptep_test_and_clear_young() macro, make __ptep_test_and_clear_young() common to nohash/32 and nohash/64 and change it to become ptep_test_and_clear_young()
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 11 ----------- arch/powerpc/include/asm/nohash/64/pgtable.h | 19 +------------------ arch/powerpc/include/asm/nohash/pgtable.h | 11 +++++++++++ 3 files changed, 12 insertions(+), 29 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -11
@@ -164,17 +164,6 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp =__pmd (0 ); } -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -static inline int __ptep_test_and_clear_young (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) -{ -unsigned long old; - old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 ); -return (old & _PAGE_ACCESSED) !=0 ; -} -#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ - __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep) -#define __HAVE_ARCH_PTEP_GET_AND_CLEARstatic inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
arch/powerpc/include/asm/nohash/64/pgtable.h +1 -18
@@ -145,22 +145,6 @@ static inline void p4d_set(p4d_t *p4dp, unsigned long val) *p4dp =__p4d (val); } -static inline int __ptep_test_and_clear_young (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) -{ -unsigned long old; - - old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 ); -return (old & _PAGE_ACCESSED) !=0 ; -} -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ -({ \ - int __r; \ - __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \ - __r; \ -}) -#define __HAVE_ARCH_PTEP_SET_WRPROTECTstatic inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
@@ -178,8 +162,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH#define ptep_clear_flush_young (__vma, __address, __ptep) \ ({ \ - int __young = __ptep_test_and_clear_young((__vma)->vm_mm, __address, \ - __ptep); \ + int __young = ptep_test_and_clear_young(__vma, __address, __ptep);\ __young; \ })
arch/powerpc/include/asm/nohash/pgtable.h +11 -0
@@ -69,6 +69,17 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p }#endif +static inline int ptep_test_and_clear_young (struct vm_area_struct *vma, +unsigned long addr,pte_t *ptep) +{ +unsigned long old; + + old =pte_update (vma->vm_mm, addr, ptep, _PAGE_ACCESSED,0 ,0 ); + +return (old & _PAGE_ACCESSED) !=0 ; +} +#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +/* Generic accessors to PTE bits */ #ifndef pte_mkwrite_novmastatic inline pte_t pte_mkwrite_novma (pte_t pte)
Signature · 1 line
2.41.0
PATCH 1/19 powerpc/8xx: Fix pte_access_permitted() for PAGE_NONE
In reply to Christophe LeroyOn 8xx, PAGE_NONE is handled by setting _PAGE_NA instead of clearing _PAGE_USER.
But then pte_user() returns 1 also for PAGE_NONE.
As _PAGE_NA prevent reads, add a specific version of pte_read() that returns 0 when _PAGE_NA is set instead of always returning 1.
--- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 7 +++++++ arch/powerpc/include/asm/nohash/pgtable.h | 2 ++ 2 files changed, 9 insertions(+)
arch/powerpc/include/asm/nohash/32/pte-8xx.h +7 -0
@@ -94,6 +94,13 @@ static inline pte_t pte_wrprotect(pte_t pte)#define pte_wrprotect pte_wrprotect +static inline int pte_read (pte_t pte) +{ +return (pte_val (pte) & _PAGE_RO) != _PAGE_NA; +} + +#define pte_read pte_read +static inline int pte_write (pte_t pte) {return !(pte_val (pte) & _PAGE_RO);
arch/powerpc/include/asm/nohash/pgtable.h +2 -0
@@ -25,7 +25,9 @@ static inline int pte_write(pte_t pte) return pte_val(pte) & _PAGE_RW; }#endif +#ifndef pte_readstatic inline int pte_read (pte_t pte) {return 1 ; } +#endif static inline int pte_dirty (pte_t pte) {return pte_val (pte) & _PAGE_DIRTY; }static inline int pte_special (pte_t pte) {return pte_val (pte) & _PAGE_SPECIAL; }static inline int pte_none (pte_t pte) {return (pte_val (pte) & ~_PTE_NONE_MASK) ==0 ; }
Signature · 1 line
2.41.0
PATCH 10/19 powerpc/nohash: Move 8xx version of pte_update() into pte-8xx.h
In reply to Christophe LeroyNo point in having 8xx special pte_update() in common header, move it into pte-8xx.h
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 57 +------------------- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 57 ++++++++++++++++++++ 2 files changed, 58 insertions(+), 56 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +1 -56
@@ -219,63 +219,8 @@ 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 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 pmd_t *pmd_off (struct mm_struct *mm,unsigned long addr); -static int hugepd_ok (hugepd_t hpd); - -static int number_of_cells_per_pte (pmd_t *pmd,pte_basic_t val,int huge) -{ -if (!huge) -return PAGE_SIZE /SZ_4K ; -else if (hugepd_ok (*((hugepd_t *)pmd))) -return 1 ; -else if (IS_ENABLED (CONFIG_PPC_4K_PAGES ) && !(val & _PAGE_HUGE)) -return SZ_16K /SZ_4K ; -else -return SZ_512K /SZ_4K ; -} - -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 = (pte_basic_t *)p; -pte_basic_t old =pte_val (*p); -pte_basic_t new = (old & ~(pte_basic_t )clr) | set; -int num, i; -pmd_t *pmd =pmd_off (mm, addr); - - num =number_of_cells_per_pte (pmd, new, huge); - -for (i =0 ; i < num; i +=PAGE_SIZE /SZ_4K , new +=PAGE_SIZE ) { - *entry++ = new; -if (IS_ENABLED (CONFIG_PPC_16K_PAGES ) && num !=1 ) { - *entry++ = new; - *entry++ = new; - *entry++ = new; - } - } - -return old; -} - -#ifdef CONFIG_PPC_16K_PAGES -#define ptep_get ptep_get -static inline pte_t ptep_get (pte_t *ptep) -{ -pte_basic_t val =READ_ONCE (ptep->pte); -pte_t pte = {val, val, val, val}; - -return pte; -} -#endif /* CONFIG_PPC_16K_PAGES */ - -#else +#ifndef pte_updatestatic inline pte_basic_t pte_update (struct mm_struct *mm,unsigned long addr,pte_t *p,unsigned long clr,unsigned long set,int huge) {
arch/powerpc/include/asm/nohash/32/pte-8xx.h +57 -0
63 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 17/19 powerpc/nohash: Deduplicate ptep_set_wrprotect() and ptep_get_and_clear()
In reply to Christophe Leroyptep_set_wrprotect() and ptep_get_and_clear are identical for nohash/32 and nohash/64.
Make them common.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 16 ---------------- arch/powerpc/include/asm/nohash/64/pgtable.h | 15 --------------- arch/powerpc/include/asm/nohash/pgtable.h | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 31 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -16
@@ -164,22 +164,6 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp =__pmd (0 ); } -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) -{ -return __pte (pte_update (mm, addr, ptep, ~0 ,0 ,0 )); -} - -#define __HAVE_ARCH_PTEP_SET_WRPROTECT -#ifndef ptep_set_wrprotect -static inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) -{ -pte_update (mm, addr, ptep, _PAGE_RW,0 ,0 ); -} -#endif -#ifndef __ptep_set_access_flags static inline void __ptep_set_access_flags(struct vm_area_struct *vma, pte_t *ptep, pte_t entry,
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -15
@@ -145,13 +145,6 @@ static inline void p4d_set(p4d_t *p4dp, unsigned long val) *p4dp =__p4d (val); } -#define __HAVE_ARCH_PTEP_SET_WRPROTECT -static inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr, -pte_t *ptep) -{ -pte_update (mm, addr, ptep, _PAGE_RW,0 ,0 ); -} -#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECTstatic inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
@@ -166,14 +159,6 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, __young; \ }) -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) -{ -unsigned long old =pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); -return __pte (old); -} -static inline void pte_clear (struct mm_struct *mm,unsigned long addr,pte_t * ptep) {
arch/powerpc/include/asm/nohash/pgtable.h +16 -0
@@ -80,6 +80,22 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, }#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +#ifndef ptep_set_wrprotect +static inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr, +pte_t *ptep) +{ +pte_update (mm, addr, ptep, _PAGE_RW,0 ,0 ); +} +#endif +#define __HAVE_ARCH_PTEP_SET_WRPROTECT + +static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep) +{ +return __pte (pte_update (mm, addr, ptep, ~0UL ,0 ,0 )); +} +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +/* Generic accessors to PTE bits */ #ifndef pte_mkwrite_novmastatic inline pte_t pte_mkwrite_novma (pte_t pte)
Signature · 1 line
2.41.0
PATCH 7/19 powerpc: Untangle fixmap.h and pgtable.h and mmu.h
In reply to Christophe Leroyfixmap.h need pgtable.h for [un]map_kernel_page()
pgtable.h need fixmap.h for FIXADDR_TOP.
Untangle the two files by moving FIXADDR_TOP into pgtable.h
Also move VIRT_IMMR_BASE to fixmap.h to avoid fixmap.h in mmu.h
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 9 ++++++++- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 + arch/powerpc/include/asm/fixmap.h | 16 ++++------------ arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 1 - arch/powerpc/include/asm/nohash/32/pgtable.h | 9 ++++++++- arch/powerpc/include/asm/nohash/64/pgtable.h | 1 + arch/powerpc/mm/init_32.c | 1 + arch/powerpc/mm/mem.c | 1 + arch/powerpc/mm/nohash/8xx.c | 2 ++ arch/powerpc/platforms/8xx/cpm1.c | 1 + 10 files changed, 27 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +8 -1
@@ -170,7 +170,14 @@ void unmap_kernel_page(unsigned long va);* value (for now) on others, from where we can start layout kernel * virtual space that goes below PKMAP and FIXMAP */ -#include <asm/fixmap.h> + +#define FIXADDR_SIZE 0 +#ifdef CONFIG_KASAN +#include <asm/kasan.h> +#define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) +#else +#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) +#endif /* * ioremap_bot starts at that address. Early ioremaps move down from there,
arch/powerpc/include/asm/book3s/64/pgtable.h +1 -0
@@ -316,6 +316,7 @@ extern unsigned long pci_io_base;#define IOREMAP_START (ioremap_bot)#define IOREMAP_END (KERN_IO_END - FIXADDR_SIZE)#define FIXADDR_SIZE SZ_32M +#define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE)#ifndef __ASSEMBLY__
arch/powerpc/include/asm/fixmap.h +4 -12
@@ -23,18 +23,6 @@#include <asm/kmap_size.h> #endif -#ifdef CONFIG_PPC64 -#define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE) -#else -#define FIXADDR_SIZE 0 -#ifdef CONFIG_KASAN -#include <asm/kasan.h> -#define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) -#else -#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) -#endif -#endif -/* * Here we define all the compile-time 'special' virtual * addresses. The point is to have a constant address at
@@ -119,5 +107,9 @@ static inline void __set_fixmap(enum fixed_addresses idx,#define __early_set_fixmap __set_fixmap +#ifdef CONFIG_PPC_8xx +#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE)) +#endif +#endif /* !__ASSEMBLY__ */ #endif
arch/powerpc/include/asm/nohash/32/mmu-8xx.h +0 -1
@@ -188,7 +188,6 @@ typedef struct { } mm_context_t;#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000) -#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE))/* Page size definitions, common between 32 and 64-bit *
arch/powerpc/include/asm/nohash/32/pgtable.h +8 -1
@@ -71,7 +71,14 @@ void unmap_kernel_page(unsigned long va);* value (for now) on others, from where we can start layout kernel * virtual space that goes below PKMAP and FIXMAP */ -#include <asm/fixmap.h> + +#define FIXADDR_SIZE 0 +#ifdef CONFIG_KASAN +#include <asm/kasan.h> +#define FIXADDR_TOP (KASAN_SHADOW_START - PAGE_SIZE) +#else +#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE)) +#endif /* * ioremap_bot starts at that address. Early ioremaps move down from there,
arch/powerpc/include/asm/nohash/64/pgtable.h +1 -0
@@ -57,6 +57,7 @@#define IOREMAP_START (ioremap_bot)#define IOREMAP_END (KERN_IO_START + KERN_IO_SIZE - FIXADDR_SIZE)#define FIXADDR_SIZE SZ_32M +#define FIXADDR_TOP (IOREMAP_END + FIXADDR_SIZE)/* * Defines the address of the vmemap area, in its own region on
arch/powerpc/mm/init_32.c +1 -0
@@ -39,6 +39,7 @@#include <asm/hugetlb.h> #include <asm/kup.h> #include <asm/kasan.h> +#include <asm/fixmap.h> #include <mm/mmu_decl.h>
arch/powerpc/mm/mem.c +1 -0
@@ -26,6 +26,7 @@#include <asm/ftrace.h> #include <asm/code-patching.h> #include <asm/setup.h> +#include <asm/fixmap.h> #include <mm/mmu_decl.h>
arch/powerpc/mm/nohash/8xx.c +2 -0
@@ -10,6 +10,8 @@#include <linux/memblock.h> #include <linux/hugetlb.h> +#include <asm/fixmap.h> +#include <mm/mmu_decl.h> #define IMMR_SIZE (FIX_IMMR_SIZE << PAGE_SHIFT)
arch/powerpc/platforms/8xx/cpm1.c +1 -0
@@ -40,6 +40,7 @@#include <asm/io.h> #include <asm/rheap.h> #include <asm/cpm.h> +#include <asm/fixmap.h> #include <sysdev/fsl_soc.h>
Signature · 1 line
2.41.0
PATCH 6/19 powerpc: Refactor update_mmu_cache_range()
In reply to Christophe LeroyOn nohash, this function voids except for E500 with hugepages.
Take the book3s version and include that exception in the logic and rename E500 update_mmu_cache_range() as __update_mmu_cache() which gets called by update_mmu_cache_range().
--- arch/powerpc/include/asm/book3s/pgtable.h | 24 ----------------------- arch/powerpc/include/asm/nohash/pgtable.h | 15 -------------- arch/powerpc/include/asm/pgtable.h | 22 +++++++++++++++++++++ arch/powerpc/mm/nohash/e500_hugetlbpage.c | 3 +-- 4 files changed, 23 insertions(+), 41 deletions(-)
arch/powerpc/include/asm/book3s/pgtable.h +0 -24
@@ -8,28 +8,4 @@#include <asm/book3s/32/pgtable.h> #endif -#ifndef __ASSEMBLY__ -void __update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep); - -/* -* This gets called at the end of handling a page fault, when -* the kernel has put a new PTE into the page table for the process. -* We use it to ensure coherency between the i-cache and d-cache -* for the page which has just been mapped in. -* On machines which use an MMU hash table, we use this to put a -* corresponding HPTE into the hash table ahead of time, instead of -* waiting for the inevitable extra hash-table miss exception. -*/ -static inline void update_mmu_cache_range (struct vm_fault *vmf, -struct vm_area_struct *vma,unsigned long address, -pte_t *ptep,unsigned int nr) -{ -if (IS_ENABLED (CONFIG_PPC32 ) && !mmu_has_feature (MMU_FTR_HPTE_TABLE )) -return ; -if (radix_enabled ()) -return ; -__update_mmu_cache (vma, address, ptep); -} - -#endif /* __ASSEMBLY__ */ #endif
arch/powerpc/include/asm/nohash/pgtable.h +0 -15
@@ -259,20 +259,5 @@ static inline int pud_huge(pud_t pud)#define is_hugepd (hpd) (hugepd_ok(hpd))#endif -/* -* This gets called at the end of handling a page fault, when -* the kernel has put a new PTE into the page table for the process. -* We use it to ensure coherency between the i-cache and d-cache -* for the page which has just been mapped in. -*/ -#if defined(CONFIG_PPC_E500 ) && defined(CONFIG_HUGETLB_PAGE ) -void update_mmu_cache_range (struct vm_fault *vmf,struct vm_area_struct *vma, -unsigned long address,pte_t *ptep,unsigned int nr); -#else -static inline void update_mmu_cache_range (struct vm_fault *vmf, -struct vm_area_struct *vma,unsigned long address, -pte_t *ptep,unsigned int nr) {} -#endif -#endif /* __ASSEMBLY__ */ #endif
arch/powerpc/include/asm/pgtable.h +22 -0
@@ -119,6 +119,28 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot);#define __HAVE_PHYS_MEM_ACCESS_PROT +void __update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep); + +/* +* This gets called at the end of handling a page fault, when +* the kernel has put a new PTE into the page table for the process. +* We use it to ensure coherency between the i-cache and d-cache +* for the page which has just been mapped in. +* On machines which use an MMU hash table, we use this to put a +* corresponding HPTE into the hash table ahead of time, instead of +* waiting for the inevitable extra hash-table miss exception. +*/ +static inline void update_mmu_cache_range (struct vm_fault *vmf, +struct vm_area_struct *vma,unsigned long address, +pte_t *ptep,unsigned int nr) +{ +if (IS_ENABLED (CONFIG_PPC32 ) && !mmu_has_feature (MMU_FTR_HPTE_TABLE ) && + !(IS_ENABLED (CONFIG_PPC_E500 ) &&IS_ENABLED (CONFIG_HUGETLB_PAGE ))) +return ; +if (radix_enabled ()) +return ; +__update_mmu_cache (vma, address, ptep); +}/* * When used, PTE_FRAG_NR is defined in subarch pgtable.h
arch/powerpc/mm/nohash/e500_hugetlbpage.c +1 -2
@@ -178,8 +178,7 @@ book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea, pte_t pte)* * This must always be called with the pte lock held. */ -void update_mmu_cache_range (struct vm_fault *vmf,struct vm_area_struct *vma, -unsigned long address,pte_t *ptep,unsigned int nr) +void __update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t *ptep) {if (is_vm_hugetlb_page (vma))book3e_hugetlb_preload (vma, address, *ptep);
Signature · 1 line
2.41.0
PATCH 2/19 powerpc/64e: Fix wrong test in __ptep_test_and_clear_young()
In reply to Christophe LeroyCommit 45201c879469 ("powerpc/nohash: Remove hash related code from nohash headers.") replaced:
if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
return 0;
By:
if (pte_young(*ptep))
return 0;
But it should be:
if (!pte_young(*ptep))
return 0;
Fix it.
--- arch/powerpc/include/asm/nohash/64/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/nohash/64/pgtable.h +1 -1
@@ -197,7 +197,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, {unsigned long old; -if (pte_young (*ptep)) +if (!pte_young (*ptep))return 0 ; old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 );return (old & _PAGE_ACCESSED) !=0 ;
Signature · 1 line
2.41.0
PATCH 13/19 powerpc/nohash: Refactor checking of no-change in pte_update()
In reply to Christophe LeroyOn nohash/64, a few callers of pte_update() check if there is really a change in order to avoid an unnecessary write.
Refactor that inside pte_update().
--- arch/powerpc/include/asm/nohash/64/pgtable.h | 9 --------- arch/powerpc/include/asm/nohash/pgtable.h | 3 +++ 2 files changed, 3 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -9
@@ -181,8 +181,6 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm, {unsigned long old; -if (!pte_young (*ptep)) -return 0 ; old =pte_update (mm, addr, ptep, _PAGE_ACCESSED,0 ,0 );return (old & _PAGE_ACCESSED) !=0 ; }
@@ -198,10 +196,6 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,static inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { - -if ((pte_val (*ptep) & _PAGE_RW) ==0 ) -return ; -pte_update (mm, addr, ptep, _PAGE_RW,0 ,0 ); }
@@ -209,9 +203,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,static inline void huge_ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep) { -if ((pte_val (*ptep) & _PAGE_RW) ==0 ) -return ; -pte_update (mm, addr, ptep, _PAGE_RW,0 ,1 ); }
arch/powerpc/include/asm/nohash/pgtable.h +3 -0
@@ -47,6 +47,9 @@ 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 (new == old) +return old; + *p =__pte (new);if (IS_ENABLED (CONFIG_44x) && (old & _PAGE_USER) && (old & _PAGE_EXEC))
Signature · 1 line
2.41.0
PATCH 19/19 powerpc/nohash: Refactor __ptep_set_access_flags()
In reply to Christophe Leroynohash/32 version of __ptep_set_access_flags() does the same as nohash/64 version, the only difference is that nohash/32 version is more complete and uses pte_update().
Make it common and remove the nohash/64 version.
--- arch/powerpc/include/asm/nohash/32/pgtable.h | 16 ---------------- arch/powerpc/include/asm/nohash/64/pgtable.h | 15 --------------- arch/powerpc/include/asm/nohash/pgtable.h | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 31 deletions(-)
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -16
@@ -161,22 +161,6 @@ static inline void pmd_clear(pmd_t *pmdp) *pmdp =__pmd (0 ); } -#ifndef __ptep_set_access_flags -static inline void __ptep_set_access_flags (struct vm_area_struct *vma, -pte_t *ptep,pte_t entry, -unsigned long address, -int psize) -{ -unsigned long set =pte_val (entry) & - (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); -int huge = psize > mmu_virtual_psize ?1 :0 ; - -pte_update (vma->vm_mm, address, ptep,0 , set, huge); - -flush_tlb_page (vma, address); -} -#endif -/* * Note that on Book E processors, the pmd contains the kernel virtual * (lowmem) address of the pte page. The physical address is less useful
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -15
@@ -159,21 +159,6 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, __young; \ }) -/* Set the dirty and/or accessed bits atomically in a linux PTE */ -static inline void __ptep_set_access_flags (struct vm_area_struct *vma, -pte_t *ptep,pte_t entry, -unsigned long address, -int psize) -{ -unsigned long bits =pte_val (entry) & - (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); - -unsigned long old =pte_val (*ptep); - *ptep =__pte (old | bits); - -flush_tlb_page (vma, address); -} -#define pmd_ERROR (e) \ pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))#define pgd_ERROR (e) \
arch/powerpc/include/asm/nohash/pgtable.h +17 -0
@@ -102,6 +102,23 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,pte_update (mm, addr, ptep, ~0UL ,0 ,0 ); } +/* Set the dirty and/or accessed bits atomically in a linux PTE */ +#ifndef __ptep_set_access_flags +static inline void __ptep_set_access_flags (struct vm_area_struct *vma, +pte_t *ptep,pte_t entry, +unsigned long address, +int psize) +{ +unsigned long set =pte_val (entry) & + (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); +int huge = psize > mmu_virtual_psize ?1 :0 ; + +pte_update (vma->vm_mm, address, ptep,0 , set, huge); + +flush_tlb_page (vma, address); +} +#endif +/* Generic accessors to PTE bits */ #ifndef pte_mkwrite_novmastatic inline pte_t pte_mkwrite_novma (pte_t pte)
Signature · 1 line
2.41.0
PATCH 4/19 powerpc: Remove pte_ERROR()
In reply to Christophe Leroypte_ERROR() is used neither in powerpc code nor in common mm code.
Remove it.
--- arch/powerpc/include/asm/book3s/32/pgtable.h | 3 --- arch/powerpc/include/asm/book3s/64/pgtable.h | 2 -- arch/powerpc/include/asm/nohash/32/pgtable.h | 3 --- arch/powerpc/include/asm/nohash/64/pgtable.h | 2 -- 4 files changed, 10 deletions(-)
arch/powerpc/include/asm/book3s/32/pgtable.h +0 -3
@@ -224,9 +224,6 @@ void unmap_kernel_page(unsigned long va);/* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0 -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \ - (unsigned long long)pte_val(e))#define pgd_ERROR (e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))/*
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -2
@@ -1014,8 +1014,6 @@ static inline pmd_t *pud_pgtable(pud_t pud)return (pmd_t *)__va (pud_val (pud) & ~PUD_MASKED_BITS ); } -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))#define pmd_ERROR (e) \ pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))#define pud_ERROR (e) \
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -3
@@ -55,9 +55,6 @@ extern int icache_44x_need_flush;#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \ - (unsigned long long)pte_val(e))#define pgd_ERROR (e) \ pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -2
@@ -269,8 +269,6 @@ static inline void __ptep_set_access_flags(struct vm_area_struct *vma,flush_tlb_page (vma, address); } -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))#define pmd_ERROR (e) \ pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))#define pgd_ERROR (e) \
Signature · 1 line
2.41.0
kernel test robot
build botRe: [PATCH v1 07/19] powerpc: Untangle fixmap.h and pgtable.h and mmu.h
In reply to Christophe Leroykernel test robot noticed the following build errors:
Hi Christophe,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.6-rc1 next-20230913]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christophe-Leroy/powerpc-8xx-Fix-pte_access_permitted-for-PAGE_NONE/20230912-031616 base: linus/master patch link: https://lore.kernel.org/r/c94717708db817a0a0a6349431a2701252686899.1694443576.git.christophe.leroy%40csgroup.eu patch subject: [PATCH v1 07/19] powerpc: Untangle fixmap.h and pgtable.h and mmu.h config: powerpc-randconfig-r013-20230912 (https://download.01.org/0day-ci/archive/20230913/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
arch/powerpc/platforms/83xx/misc.c: In function 'mpc83xx_setup_arch':
>> arch/powerpc/platforms/83xx/misc.c:126:28: error: implicit declaration of function 'fix_to_virt'; did you mean 'bus_to_virt'? [-Werror=implicit-function-declaration]
126 | unsigned long va = fix_to_virt(FIX_IMMR_BASE);
| ^~~~~~~~~~~
| bus_to_virt
>> arch/powerpc/platforms/83xx/misc.c:126:40: error: 'FIX_IMMR_BASE' undeclared (first use in this function)
126 | unsigned long va = fix_to_virt(FIX_IMMR_BASE);
| ^~~~~~~~~~~~~ arch/powerpc/platforms/83xx/misc.c:126:40: note: each undeclared identifier is reported only once for each function it appears in
cc1: all warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for HOTPLUG_CPU
Depends on [n]: SMP [=y] && (PPC_PSERIES [=n] || PPC_PMAC [=n] || PPC_POWERNV [=n] || FSL_SOC_BOOKE [=n]) Selected by [y]:
- PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]
vim +/FIX_IMMR_BASE +126 arch/powerpc/platforms/83xx/misc.c
fff69fd03d1290 Kevin Hao 2016-08-23 121
fff69fd03d1290 Kevin Hao 2016-08-23 122 void __init mpc83xx_setup_arch(void)
fff69fd03d1290 Kevin Hao 2016-08-23 123 {
6b7c095a51e1ba Christophe Leroy 2019-09-16 124 phys_addr_t immrbase = get_immrbase();
6b7c095a51e1ba Christophe Leroy 2019-09-16 125 int immrsize = IS_ALIGNED(immrbase, SZ_2M) ? SZ_2M : SZ_1M;
6b7c095a51e1ba Christophe Leroy 2019-09-16 @126 unsigned long va = fix_to_virt(FIX_IMMR_BASE);
6b7c095a51e1ba Christophe Leroy 2019-09-16 127
1ce844973bb516 Christophe Leroy 2022-06-14 128 if (ppc_md.progress)
1ce844973bb516 Christophe Leroy 2022-06-14 129 ppc_md.progress("mpc83xx_setup_arch()", 0);
1ce844973bb516 Christophe Leroy 2022-06-14 130
6b7c095a51e1ba Christophe Leroy 2019-09-16 131 setbat(-1, va, immrbase, immrsize, PAGE_KERNEL_NCG);
6b7c095a51e1ba Christophe Leroy 2019-09-16 132 update_bats();
6b7c095a51e1ba Christophe Leroy 2019-09-16 133 }
0deae39cec6dab Christophe Leroy 2018-12-10 134 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki