Skip to content

Commit 812fadc

Browse files
chleroympe
authored andcommitted
powerpc/mm: extend _PAGE_PRIVILEGED to all CPUs
commit ac29c64 ("powerpc/mm: Replace _PAGE_USER with _PAGE_PRIVILEGED") introduced _PAGE_PRIVILEGED for BOOK3S/64 This patch generalises _PAGE_PRIVILEGED for all CPUs, allowing to have either _PAGE_PRIVILEGED or _PAGE_USER or both. PPC_8xx has a _PAGE_SHARED flag which is set for and only for all non user pages. Lets rename it _PAGE_PRIVILEGED to remove confusion as it has nothing to do with Linux shared pages. On BookE, there's a _PAGE_BAP_SR which has to be set for kernel pages: defining _PAGE_PRIVILEGED as _PAGE_BAP_SR will make this generic Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 5f35649 commit 812fadc

File tree

10 files changed

+28
-54
lines changed

10 files changed

+28
-54
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define _PAGE_BIT_SWAP_TYPE 0
1616

1717
#define _PAGE_RO 0
18-
#define _PAGE_SHARED 0
18+
#define _PAGE_USER 0
1919

2020
#define _PAGE_EXEC 0x00001 /* execute permission */
2121
#define _PAGE_WRITE 0x00002 /* write access allowed */

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/* Definitions for 8xx embedded chips. */
3232
#define _PAGE_PRESENT 0x0001 /* Page is valid */
3333
#define _PAGE_NO_CACHE 0x0002 /* I: cache inhibit */
34-
#define _PAGE_SHARED 0x0004 /* No ASID (context) compare */
34+
#define _PAGE_PRIVILEGED 0x0004 /* No ASID (context) compare */
3535
#define _PAGE_SPECIAL 0x0008 /* SW entry, forced to 0 by the TLB miss */
3636
#define _PAGE_DIRTY 0x0100 /* C: page changed */
3737

@@ -54,13 +54,5 @@
5454
/* Until my rework is finished, 8xx still needs atomic PTE updates */
5555
#define PTE_ATOMIC_UPDATES 1
5656

57-
/* We need to add _PAGE_SHARED to kernel pages */
58-
#define _PAGE_KERNEL_RO (_PAGE_SHARED | _PAGE_RO)
59-
#define _PAGE_KERNEL_ROX (_PAGE_SHARED | _PAGE_RO | _PAGE_EXEC)
60-
#define _PAGE_KERNEL_RW (_PAGE_SHARED | _PAGE_DIRTY | _PAGE_RW | \
61-
_PAGE_HWWRITE)
62-
#define _PAGE_KERNEL_RWX (_PAGE_SHARED | _PAGE_DIRTY | _PAGE_RW | \
63-
_PAGE_HWWRITE | _PAGE_EXEC)
64-
6557
#endif /* __KERNEL__ */
6658
#endif /* _ASM_POWERPC_NOHASH_32_PTE_8xx_H */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define _PAGE_KERNEL_RWX (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY | _PAGE_BAP_SX)
5656
#define _PAGE_KERNEL_ROX (_PAGE_BAP_SR | _PAGE_BAP_SX)
5757
#define _PAGE_USER (_PAGE_BAP_UR | _PAGE_BAP_SR) /* Can be read */
58+
#define _PAGE_PRIVILEGED (_PAGE_BAP_SR)
5859

5960
#define _PAGE_HASHPTE 0
6061
#define _PAGE_BUSY 0

arch/powerpc/include/asm/pte-common.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#ifndef _PAGE_HASHPTE
99
#define _PAGE_HASHPTE 0
1010
#endif
11-
#ifndef _PAGE_SHARED
12-
#define _PAGE_SHARED 0
13-
#endif
1411
#ifndef _PAGE_HWWRITE
1512
#define _PAGE_HWWRITE 0
1613
#endif
@@ -45,6 +42,14 @@
4542
#ifndef _PAGE_PTE
4643
#define _PAGE_PTE 0
4744
#endif
45+
/* At least one of _PAGE_PRIVILEGED or _PAGE_USER must be defined */
46+
#ifndef _PAGE_PRIVILEGED
47+
#define _PAGE_PRIVILEGED 0
48+
#else
49+
#ifndef _PAGE_USER
50+
#define _PAGE_USER 0
51+
#endif
52+
#endif
4853

4954
#ifndef _PMD_PRESENT_MASK
5055
#define _PMD_PRESENT_MASK _PMD_PRESENT
@@ -54,16 +59,18 @@
5459
#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
5560
#endif
5661
#ifndef _PAGE_KERNEL_RO
57-
#define _PAGE_KERNEL_RO (_PAGE_RO)
62+
#define _PAGE_KERNEL_RO (_PAGE_PRIVILEGED | _PAGE_RO)
5863
#endif
5964
#ifndef _PAGE_KERNEL_ROX
60-
#define _PAGE_KERNEL_ROX (_PAGE_EXEC | _PAGE_RO)
65+
#define _PAGE_KERNEL_ROX (_PAGE_PRIVILEGED | _PAGE_RO | _PAGE_EXEC)
6166
#endif
6267
#ifndef _PAGE_KERNEL_RW
63-
#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
68+
#define _PAGE_KERNEL_RW (_PAGE_PRIVILEGED | _PAGE_DIRTY | _PAGE_RW | \
69+
_PAGE_HWWRITE)
6470
#endif
6571
#ifndef _PAGE_KERNEL_RWX
66-
#define _PAGE_KERNEL_RWX (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE | _PAGE_EXEC)
72+
#define _PAGE_KERNEL_RWX (_PAGE_PRIVILEGED | _PAGE_DIRTY | _PAGE_RW | \
73+
_PAGE_HWWRITE | _PAGE_EXEC)
6774
#endif
6875
#ifndef _PAGE_HPTEFLAGS
6976
#define _PAGE_HPTEFLAGS _PAGE_HASHPTE
@@ -85,7 +92,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
8592
*/
8693
static inline bool pte_user(pte_t pte)
8794
{
88-
return (pte_val(pte) & _PAGE_USER) == _PAGE_USER;
95+
return (pte_val(pte) & (_PAGE_USER | _PAGE_PRIVILEGED)) == _PAGE_USER;
8996
}
9097
#endif /* __ASSEMBLY__ */
9198

@@ -116,6 +123,7 @@ static inline bool pte_user(pte_t pte)
116123
#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
117124
_PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
118125
_PAGE_USER | _PAGE_ACCESSED | _PAGE_RO | \
126+
_PAGE_PRIVILEGED | \
119127
_PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC)
120128

121129
/*

arch/powerpc/kernel/head_8xx.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ DTLBMissIMMR:
678678
mtspr SPRN_MD_TWC, r10
679679
mfspr r10, SPRN_IMMR /* Get current IMMR */
680680
rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */
681-
ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \
681+
ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_PRIVILEGED | _PAGE_DIRTY | \
682682
_PAGE_PRESENT | _PAGE_NO_CACHE
683683
mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
684684

@@ -696,7 +696,7 @@ DTLBMissLinear:
696696
li r11, MD_PS8MEG | MD_SVALID
697697
mtspr SPRN_MD_TWC, r11
698698
rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */
699-
ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \
699+
ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_PRIVILEGED | _PAGE_DIRTY | \
700700
_PAGE_PRESENT
701701
mtspr SPRN_MD_RPN, r10 /* Update TLB entry */
702702

@@ -715,7 +715,7 @@ ITLBMissLinear:
715715
li r11, MI_PS8MEG | MI_SVALID | _PAGE_EXEC
716716
mtspr SPRN_MI_TWC, r11
717717
rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */
718-
ori r10, r10, 0xf0 | MI_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \
718+
ori r10, r10, 0xf0 | MI_SPS16K | _PAGE_PRIVILEGED | _PAGE_DIRTY | \
719719
_PAGE_PRESENT
720720
mtspr SPRN_MI_RPN, r10 /* Update TLB entry */
721721

arch/powerpc/mm/8xx_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void __init MMU_init_hw(void)
6767
/* PIN up to the 3 first 8Mb after IMMR in DTLB table */
6868
#ifdef CONFIG_PIN_TLB_DATA
6969
unsigned long ctr = mfspr(SPRN_MD_CTR) & 0xfe000000;
70-
unsigned long flags = 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY;
70+
unsigned long flags = 0xf0 | MD_SPS16K | _PAGE_PRIVILEGED | _PAGE_DIRTY;
7171
#ifdef CONFIG_PIN_TLB_IMMR
7272
int i = 29;
7373
#else

arch/powerpc/mm/dump_linuxpagetables.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,8 @@ struct flag_info {
112112

113113
static const struct flag_info flag_array[] = {
114114
{
115-
#ifdef CONFIG_PPC_BOOK3S_64
116-
.mask = _PAGE_PRIVILEGED,
117-
.val = 0,
118-
#else
119-
.mask = _PAGE_USER,
115+
.mask = _PAGE_USER | _PAGE_PRIVILEGED,
120116
.val = _PAGE_USER,
121-
#endif
122117
.set = "user",
123118
.clear = " ",
124119
}, {
@@ -229,10 +224,6 @@ static const struct flag_info flag_array[] = {
229224
.mask = _PAGE_SPECIAL,
230225
.val = _PAGE_SPECIAL,
231226
.set = "special",
232-
}, {
233-
.mask = _PAGE_SHARED,
234-
.val = _PAGE_SHARED,
235-
.set = "shared",
236227
}
237228
};
238229

arch/powerpc/mm/pgtable.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ static inline int pte_looks_normal(pte_t pte)
5454
return 0;
5555
#else
5656
return (pte_val(pte) &
57-
(_PAGE_PRESENT | _PAGE_SPECIAL | _PAGE_NO_CACHE | _PAGE_USER)) ==
57+
(_PAGE_PRESENT | _PAGE_SPECIAL | _PAGE_NO_CACHE | _PAGE_USER |
58+
_PAGE_PRIVILEGED)) ==
5859
(_PAGE_PRESENT | _PAGE_USER);
5960
#endif
6061
}

arch/powerpc/mm/pgtable_32.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,7 @@ ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
9898

9999
/* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */
100100
flags &= ~(_PAGE_USER | _PAGE_EXEC);
101-
102-
#ifdef _PAGE_BAP_SR
103-
/* _PAGE_USER contains _PAGE_BAP_SR on BookE using the new PTE format
104-
* which means that we just cleared supervisor access... oops ;-) This
105-
* restores it
106-
*/
107-
flags |= _PAGE_BAP_SR;
108-
#endif
101+
flags |= _PAGE_PRIVILEGED;
109102

110103
return __ioremap_caller(addr, size, flags, __builtin_return_address(0));
111104
}

arch/powerpc/mm/pgtable_64.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,8 @@ void __iomem * ioremap_prot(phys_addr_t addr, unsigned long size,
244244
/*
245245
* Force kernel mapping.
246246
*/
247-
#if defined(CONFIG_PPC_BOOK3S_64)
248-
flags |= _PAGE_PRIVILEGED;
249-
#else
250247
flags &= ~_PAGE_USER;
251-
#endif
252-
253-
254-
#ifdef _PAGE_BAP_SR
255-
/* _PAGE_USER contains _PAGE_BAP_SR on BookE using the new PTE format
256-
* which means that we just cleared supervisor access... oops ;-) This
257-
* restores it
258-
*/
259-
flags |= _PAGE_BAP_SR;
260-
#endif
248+
flags |= _PAGE_PRIVILEGED;
261249

262250
if (ppc_md.ioremap)
263251
return ppc_md.ioremap(addr, size, flags, caller);

0 commit comments

Comments
 (0)