Skip to content

Commit b9fb448

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm: Make pte_pgprot return all pte bits
Other archs do the same and instead of adding required pte bits (which got masked out) in __ioremap_at(), make sure we filter only pfn bits out. Fixes: 26973fa ("powerpc/mm: use pte helpers in generic code") Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 4ffe713 commit b9fb448

File tree

9 files changed

+10
-40
lines changed

9 files changed

+10
-40
lines changed

arch/powerpc/include/asm/book3s/32/pgtable.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ static inline bool pte_user(pte_t pte)
4848
#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HASHPTE | _PAGE_DIRTY | \
4949
_PAGE_ACCESSED | _PAGE_SPECIAL)
5050

51-
/* Mask of bits returned by pte_pgprot() */
52-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
53-
_PAGE_WRITETHRU | _PAGE_USER | _PAGE_ACCESSED | \
54-
_PAGE_RW | _PAGE_DIRTY)
55-
5651
/*
5752
* We define 2 sets of base prot bits, one for basic pages (ie,
5853
* cacheable kernel and user pages) and one for non cacheable
@@ -396,7 +391,6 @@ static inline int pte_young(pte_t pte) { return !!(pte_val(pte) & _PAGE_ACCESSE
396391
static inline int pte_special(pte_t pte) { return !!(pte_val(pte) & _PAGE_SPECIAL); }
397392
static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; }
398393
static inline bool pte_exec(pte_t pte) { return true; }
399-
static inline pgprot_t pte_pgprot(pte_t pte) { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
400394

401395
static inline int pte_present(pte_t pte)
402396
{

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@
128128

129129
#define H_PTE_PKEY (H_PTE_PKEY_BIT0 | H_PTE_PKEY_BIT1 | H_PTE_PKEY_BIT2 | \
130130
H_PTE_PKEY_BIT3 | H_PTE_PKEY_BIT4)
131-
/*
132-
* Mask of bits returned by pte_pgprot()
133-
*/
134-
#define PAGE_PROT_BITS (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT | \
135-
H_PAGE_4K_PFN | _PAGE_PRIVILEGED | _PAGE_ACCESSED | \
136-
_PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_EXEC | \
137-
_PAGE_SOFT_DIRTY | H_PTE_PKEY)
138131
/*
139132
* We define 2 sets of base prot bits, one for basic pages (ie,
140133
* cacheable kernel and user pages) and one for non cacheable
@@ -496,7 +489,6 @@ static inline bool pte_exec(pte_t pte)
496489
return !!(pte_raw(pte) & cpu_to_be64(_PAGE_EXEC));
497490
}
498491

499-
static inline pgprot_t pte_pgprot(pte_t pte) { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
500492

501493
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
502494
static inline bool pte_soft_dirty(pte_t pte)

arch/powerpc/include/asm/nohash/32/pte-40x.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@
7373
/* Until my rework is finished, 40x still needs atomic PTE updates */
7474
#define PTE_ATOMIC_UPDATES 1
7575

76-
/* Mask of bits returned by pte_pgprot() */
77-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_NO_CACHE | \
78-
_PAGE_WRITETHRU | _PAGE_USER | _PAGE_ACCESSED | \
79-
_PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC)
80-
8176
#define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED)
8277
#define _PAGE_BASE (_PAGE_BASE_NC)
8378

arch/powerpc/include/asm/nohash/32/pte-44x.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@
9393
#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW)
9494
#define _PAGE_KERNEL_RWX (_PAGE_DIRTY | _PAGE_RW | _PAGE_EXEC)
9595

96-
/* Mask of bits returned by pte_pgprot() */
97-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
98-
_PAGE_WRITETHRU | _PAGE_USER | _PAGE_ACCESSED | \
99-
_PAGE_RW | _PAGE_DIRTY | _PAGE_EXEC)
100-
10196
/* TODO: Add large page lowmem mapping support */
10297
#define _PMD_PRESENT 0
10398
#define _PMD_PRESENT_MASK (PAGE_MASK)

arch/powerpc/include/asm/nohash/32/pte-8xx.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@
5555
#define _PAGE_KERNEL_RW (_PAGE_SH | _PAGE_DIRTY)
5656
#define _PAGE_KERNEL_RWX (_PAGE_SH | _PAGE_DIRTY | _PAGE_EXEC)
5757

58-
/* Mask of bits returned by pte_pgprot() */
59-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_NO_CACHE | \
60-
_PAGE_ACCESSED | _PAGE_RO | _PAGE_NA | \
61-
_PAGE_SH | _PAGE_DIRTY | _PAGE_EXEC)
62-
6358
#define _PMD_PRESENT 0x0001
6459
#define _PMD_PRESENT_MASK _PMD_PRESENT
6560
#define _PMD_BAD 0x0fd0

arch/powerpc/include/asm/nohash/32/pte-fsl-booke.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
/* No page size encoding in the linux PTE */
4040
#define _PAGE_PSIZE 0
4141

42-
/* Mask of bits returned by pte_pgprot() */
43-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
44-
_PAGE_WRITETHRU | _PAGE_USER | _PAGE_ACCESSED | \
45-
_PAGE_RW | _PAGE_DIRTY | _PAGE_EXEC)
46-
4742
#define _PMD_PRESENT 0
4843
#define _PMD_PRESENT_MASK (PAGE_MASK)
4944
#define _PMD_BAD (~PAGE_MASK)

arch/powerpc/include/asm/nohash/pgtable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE_MASK)
5252
static inline bool pte_hashpte(pte_t pte) { return false; }
5353
static inline bool pte_ci(pte_t pte) { return pte_val(pte) & _PAGE_NO_CACHE; }
5454
static inline bool pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_EXEC; }
55-
static inline pgprot_t pte_pgprot(pte_t pte) { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
5655

5756
#ifdef CONFIG_NUMA_BALANCING
5857
/*

arch/powerpc/include/asm/nohash/pte-book3e.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@
8282
#define _PTE_NONE_MASK 0
8383
#endif
8484

85-
/* Mask of bits returned by pte_pgprot() */
86-
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
87-
_PAGE_WRITETHRU | _PAGE_USER | _PAGE_ACCESSED | \
88-
_PAGE_PRIVILEGED | _PAGE_RW | _PAGE_DIRTY | _PAGE_EXEC)
89-
9085
/*
9186
* We define 2 sets of base prot bits, one for basic pages (ie,
9287
* cacheable kernel and user pages) and one for non cacheable

arch/powerpc/include/asm/pgtable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ struct mm_struct;
4646
/* Keep these as a macros to avoid include dependency mess */
4747
#define pte_page(x) pfn_to_page(pte_pfn(x))
4848
#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
49+
/*
50+
* Select all bits except the pfn
51+
*/
52+
static inline pgprot_t pte_pgprot(pte_t pte)
53+
{
54+
unsigned long pte_flags;
55+
56+
pte_flags = pte_val(pte) & ~PTE_RPN_MASK;
57+
return __pgprot(pte_flags);
58+
}
4959

5060
/*
5161
* ZERO_PAGE is a global shared page that is always zero: used

0 commit comments

Comments
 (0)