[PATCH v1 00/19] cleanup/refactor pgtable.h
STALE1058d
21 messages,
2 authors,
2023-09-13 · open the first message on its own page
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(-)
--
2.41.0
On 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().
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/book3s/pgtable.h b/arch/powerpc/include/asm/book3s/pgtable.h
index 6f4578daea6c..f42d68c6b314 100644
--- a/arch/powerpc/include/asm/book3s/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/pgtable.h @@ -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 diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 5b6647fb398b..a9056f4fad48 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index bcdbdeda65d3..2b4489bb7d99 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h @@ -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 diff --git a/arch/powerpc/mm/nohash/e500_hugetlbpage.c b/arch/powerpc/mm/nohash/e500_hugetlbpage.c
index 6b30e40d4590..a134d28a0e4d 100644
--- a/arch/powerpc/mm/nohash/e500_hugetlbpage.c
+++ b/arch/powerpc/mm/nohash/e500_hugetlbpage.c @@ -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 ); --
2.41.0
Only book3s/64 selects ARCH_SUPPORTS_NUMA_BALANCING so
CONFIG_NUMA_BALANCING can't be selected on nohash targets.
Remove pte_protnone() and pmd_protnone().
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/pgtable.h | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index a9056f4fad48..ab26af2b421a 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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 ; --
2.41.0
_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.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index ae7f3c8afd4f..a39ecd498084 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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) \ diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index cba08a62c52c..34a518a1c04d 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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__ diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 8adaacbbdd1d..c64a040f4a6a 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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) --
2.41.0
Deduplicate following helpers that are identical on
nohash/32 and nohash/64:
pte_mkwrite_novma()
pte_mkdirty()
pte_mkyoung()
pte_wrprotect()
pte_mkexec()
pte_young()
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index a39ecd498084..de51f78449a0 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 34a518a1c04d..e8bbc6ec1084 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 )
{ diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index c64a040f4a6a..21f232d2e34f 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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_write
static 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 --
2.41.0
pte_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.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 0be464af4cb1..481594097f46 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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) diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index dc6e35c3a53f..b59fbf754f82 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 , diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 7e810a84ac15..464eb771db82 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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_novma
static inline pte_t pte_mkwrite_novma ( pte_t pte ) --
2.41.0
nohash/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.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 481594097f46..9164a9e41b02 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index b59fbf754f82..36b9bad428cc 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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) \ diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 464eb771db82..1493f0b09ae9 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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_novma
static inline pte_t pte_mkwrite_novma ( pte_t pte ) --
2.41.0
Remove 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()
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index de51f78449a0..b7605000bd91 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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_CLEAR
static inline pte_t ptep_get_and_clear ( struct mm_struct * mm , unsigned long addr ,
pte_t * ptep ) diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index e8bbc6ec1084..56041036fa34 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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_WRPROTECT
static 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 ; \
})
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 21f232d2e34f..2b043b72f642 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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_novma
static inline pte_t pte_mkwrite_novma ( pte_t pte ) --
2.41.0
No need of a #ifdef, use IS_ENABLED(CONFIG_44x)
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/32/pgtable.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index be8bca42bdce..a74476de1ef6 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -9,9 +9,7 @@
#include <linux/threads.h>
#include <asm/mmu.h> /* For sub-arch specific PPC_PIN_SIZE */
- #ifdef CONFIG_44x
extern 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 --
2.41.0
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.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index a74476de1ef6..ae7f3c8afd4f 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 44 x , 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_YOUNG
static inline int __ptep_test_and_clear_young ( struct mm_struct * mm ,
unsigned long addr , pte_t * ptep ) diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index f5a8e8a9dba4..b149a39f2685 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 ; diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 3d684b500fe6..bd5c3a4baabd 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -2,6 +2,11 @@
#ifndef _ASM_POWERPC_NOHASH_PGTABLE_H
#define _ASM_POWERPC_NOHASH_PGTABLE_H
+ #ifndef __ASSEMBLY__
+ 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 );
+ #endif
+
#if defined(CONFIG_PPC64)
#include <asm/nohash/64/pgtable.h>
#else @@ -18,6 +23,43 @@
#ifndef __ASSEMBLY__
+ extern int icache_44x_need_flush ;
+
+ /*
+ * 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 44 x , 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 ;
+
+ /* huge pages use the old page table lock */
+ if ( ! huge )
+ assert_pte_locked ( mm , addr );
+
+ return old ;
+ }
+ #endif
+
/* Generic accessors to PTE bits */
#ifndef pte_write
static inline int pte_write ( pte_t pte ) --
2.41.0
pte_ERROR() is used neither in powerpc code nor in common mm code.
Remove it.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 9b13eb14e21b..543c3691839b 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -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 ))
/* diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 5c497c862d75..7c4ad1e03a49 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -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) \ diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index f99c53a5f184..868aecbec8d1 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 ))
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index eb6891e34cbd..8083c04a1e6d 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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) \ --
2.41.0
Commit 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.
Fixes: 45201c879469 ("powerpc/nohash: Remove hash related code from nohash headers.")
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/64/pgtable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 5cd9acf58a7d..eb6891e34cbd 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 ; --
2.41.0
On 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().
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/64/pgtable.h | 9 ---------
arch/powerpc/include/asm/nohash/pgtable.h | 3 +++
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index b149a39f2685..cba08a62c52c 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 );
}
diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index bd5c3a4baabd..8adaacbbdd1d 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -47,6 +47,9 @@ static inline pte_basic_t pte_update(struct mm_struct *mm, unsigned long addr, p
pte_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 )) --
2.41.0
fixmap.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
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 543c3691839b..45b69ae2631e 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -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 , diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 7c4ad1e03a49..dbd545e73161 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -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__
diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index a832aeafe560..f9068dd8dfce 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h @@ -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 diff --git a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
index 0e93a4728c9e..141d82e249a8 100644
--- a/arch/powerpc/include/asm/nohash/32/mmu-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/mmu-8xx.h @@ -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
* diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 868aecbec8d1..c8311ee08811 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 , diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 8083c04a1e6d..dee3fc654d40 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index d8adc452f431..4e71dfe7d026 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c @@ -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>
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8b121df7b08f..08f3ec9d522b 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c @@ -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>
diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c
index dbbfe897455d..bb9c39b449d1 100644
--- a/arch/powerpc/mm/nohash/8xx.c
+++ b/arch/powerpc/mm/nohash/8xx.c @@ -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) diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
index ebb5f6a27dbf..b24d4102fbf6 100644
--- a/arch/powerpc/platforms/8xx/cpm1.c
+++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -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>
--
2.41.0
Prototypes of ptep_set_access_flags() and phys_mem_access_prot() are identical
for book3s and nohash.
Deduplicate them.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/book3s/pgtable.h b/arch/powerpc/include/asm/book3s/pgtable.h
index 3b7bd36a2321..6f4578daea6c 100644
--- a/arch/powerpc/include/asm/book3s/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/pgtable.h @@ -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 );
/* diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index c721478c5934..5b6647fb398b 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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 )
{ diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index d0ee46de248e..bcdbdeda65d3 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h @@ -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 . --
2.41.0
map_kernel_page() and unmap_kernel_page() have the same prototypes
on nohash/32 and nohash/64, keep only one declaration.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index c8311ee08811..26289e4e767c 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index dee3fc654d40..f5a8e8a9dba4 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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 ); diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index ab26af2b421a..3d684b500fe6 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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 diff --git a/arch/powerpc/mm/nohash/book3e_pgtable.c b/arch/powerpc/mm/nohash/book3e_pgtable.c
index b80fc4a91a53..1c5e4ecbebeb 100644
--- a/arch/powerpc/mm/nohash/book3e_pgtable.c
+++ b/arch/powerpc/mm/nohash/book3e_pgtable.c @@ -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 ; --
2.41.0
No point in having 8xx special pte_update() in common header,
move it into pte-8xx.h
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 26289e4e767c..be8bca42bdce 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 8 xx , the page tables are a bit special . For 16 k pages , we have
- * 4 identical entries . For 512 k pages , we have 128 entries as if it was
- * 4 k pages , but they are flagged as 512 k 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_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 )
{ diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
index e6fe1d5731f2..52395a5ecd70 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h @@ -187,6 +187,63 @@ static inline unsigned long pte_leaf_size(pte_t pte)
#define pte_leaf_size pte_leaf_size
+ /*
+ * On the 8 xx , the page tables are a bit special . For 16 k pages , we have
+ * 4 identical entries . For 512 k pages , we have 128 entries as if it was
+ * 4 k pages , but they are flagged as 512 k pages for the hardware .
+ * For other page sizes , we have a single entry in the table .
+ */
+ static pmd_t * pmd_off ( struct mm_struct * mm , unsigned long addr );
+ static int hugepd_ok ( hugepd_t hpd );
+
+ static inline 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 ;
+ }
+
+ #define pte_update pte_update
+
+ #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 */
+
#endif
#endif /* __KERNEL__ */ --
2.41.0
40x 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.
Fixes: 2c74e2586bb9 ("powerpc/40x: Rework 40x PTE access and TLB miss")
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/32/pte-40x.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pte-40x.h b/arch/powerpc/include/asm/nohash/32/pte-40x.h
index 6fe46e754556..0b4e5f8ce3e8 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-40x.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-40x.h @@ -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)
--
2.41.0
ptep_set_wrprotect() and ptep_get_and_clear are identical for
nohash/32 and nohash/64.
Make them common.
Signed-off-by: Christophe Leroy <redacted>
---
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(-)
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index b7605000bd91..0be464af4cb1 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -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 , diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index 56041036fa34..dc6e35c3a53f 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h @@ -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_WRPROTECT
static 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 )
{ diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 2b043b72f642..7e810a84ac15 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -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_novma
static inline pte_t pte_mkwrite_novma ( pte_t pte ) --
2.41.0
On 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.
Fixes: 351750331fc1 ("powerpc/mm: Introduce _PAGE_NA")
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/include/asm/nohash/32/pte-8xx.h | 7 +++++++
arch/powerpc/include/asm/nohash/pgtable.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/include/asm/nohash/32/pte-8xx.h
index 21f681ee535a..e6fe1d5731f2 100644
--- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h
+++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h @@ -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 ); diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h
index 56ea48276356..c721478c5934 100644
--- a/arch/powerpc/include/asm/nohash/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -25,7 +25,9 @@ static inline int pte_write(pte_t pte)
return pte_val ( pte ) & _PAGE_RW ;
}
#endif
+ #ifndef pte_read
static 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 ; } --
2.41.0
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/202309131942.k7EzJho8-lkp@intel.com/config )
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/202309131942.k7EzJho8-lkp@intel.com/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 [off-list ref]
| Closes: https://lore.kernel.org/oe-kbuild-all/202309131942.k7EzJho8-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/powerpc/platforms/83xx/misc.c: In function 'mpc83xx_setup_arch': quoted 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 quoted 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
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki