Skip to content

Commit e0a8e0d

Browse files
chleroyScott Wood
authored and
Scott Wood
committed
powerpc/8xx: Handle PAGE_USER via APG bits
Use of APG for handling PAGE_USER. All pages PP exec bits are set to either 000 or 011, which means respectively RW for Supervisor and no access for User, or RO for Supervisor and no access for user. Then we use the APG to say whether accesses are according to Page rules or "all Supervisor" rules (Access to all) Therefore, we define 2 APG groups corresponding to _PAGE_USER. Mx_AP are initialised as follows: GP0 => No user => 01 (all accesses performed according to page definition) GP1 => User => 00 (all accesses performed as supervisor according to page definition) This removes the special 8xx handling in pte_update() Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Scott Wood <[email protected]>
1 parent 83b086c commit e0a8e0d

File tree

3 files changed

+21
-46
lines changed

3 files changed

+21
-46
lines changed

arch/powerpc/include/asm/pgtable-ppc32.h

-19
Original file line numberDiff line numberDiff line change
@@ -170,24 +170,6 @@ static inline unsigned long pte_update(pte_t *p,
170170
#ifdef PTE_ATOMIC_UPDATES
171171
unsigned long old, tmp;
172172

173-
#ifdef CONFIG_PPC_8xx
174-
unsigned long tmp2;
175-
176-
__asm__ __volatile__("\
177-
1: lwarx %0,0,%4\n\
178-
andc %1,%0,%5\n\
179-
or %1,%1,%6\n\
180-
/* 0x200 == Extended encoding, bit 22 */ \
181-
/* Bit 22 has to be 1 when _PAGE_USER is unset and _PAGE_RO is set */ \
182-
rlwimi %1,%1,32-1,0x200\n /* get _PAGE_RO */ \
183-
rlwinm %3,%1,32-2,0x200\n /* get _PAGE_USER */ \
184-
andc %1,%1,%3\n\
185-
stwcx. %1,0,%4\n\
186-
bne- 1b"
187-
: "=&r" (old), "=&r" (tmp), "=m" (*p), "=&r" (tmp2)
188-
: "r" (p), "r" (clr), "r" (set), "m" (*p)
189-
: "cc" );
190-
#else /* CONFIG_PPC_8xx */
191173
__asm__ __volatile__("\
192174
1: lwarx %0,0,%3\n\
193175
andc %1,%0,%4\n\
@@ -198,7 +180,6 @@ static inline unsigned long pte_update(pte_t *p,
198180
: "=&r" (old), "=&r" (tmp), "=m" (*p)
199181
: "r" (p), "r" (clr), "r" (set), "m" (*p)
200182
: "cc" );
201-
#endif /* CONFIG_PPC_8xx */
202183
#else /* PTE_ATOMIC_UPDATES */
203184
unsigned long old = pte_val(*p);
204185
*p = __pte((old & ~clr) | set);

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

+9-18
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,27 @@
3434
#define _PAGE_SPECIAL 0x0008 /* SW entry, forced to 0 by the TLB miss */
3535
#define _PAGE_DIRTY 0x0100 /* C: page changed */
3636

37-
/* These 4 software bits must be masked out when the entry is loaded
38-
* into the TLB, 1 SW bit left(0x0080).
37+
/* These 4 software bits must be masked out when the L2 entry is loaded
38+
* into the TLB.
3939
*/
40-
#define _PAGE_GUARDED 0x0010 /* software: guarded access */
41-
#define _PAGE_ACCESSED 0x0020 /* software: page referenced */
42-
#define _PAGE_WRITETHRU 0x0040 /* software: caching is write through */
40+
#define _PAGE_GUARDED 0x0010 /* Copied to L1 G entry in DTLB */
41+
#define _PAGE_USER 0x0020 /* Copied to L1 APG lsb */
42+
#define _PAGE_ACCESSED 0x0040 /* software: page referenced */
43+
#define _PAGE_WRITETHRU 0x0080 /* software: caching is write through */
4344

44-
/* Setting any bits in the nibble with the follow two controls will
45-
* require a TLB exception handler change. It is assumed unused bits
46-
* are always zero.
47-
*/
48-
#define _PAGE_RO 0x0400 /* lsb PP bits */
49-
#define _PAGE_USER 0x0800 /* msb PP bits */
50-
/* set when _PAGE_USER is unset and _PAGE_RO is set */
51-
#define _PAGE_KNLRO 0x0200
45+
#define _PAGE_RO 0x0600 /* Supervisor RO, User no access */
5246

5347
#define _PMD_PRESENT 0x0001
5448
#define _PMD_BAD 0x0ff0
5549
#define _PMD_PAGE_MASK 0x000c
5650
#define _PMD_PAGE_8M 0x000c
5751

58-
#define _PTE_NONE_MASK _PAGE_KNLRO
59-
6052
/* Until my rework is finished, 8xx still needs atomic PTE updates */
6153
#define PTE_ATOMIC_UPDATES 1
6254

6355
/* We need to add _PAGE_SHARED to kernel pages */
64-
#define _PAGE_KERNEL_RO (_PAGE_SHARED | _PAGE_RO | _PAGE_KNLRO)
65-
#define _PAGE_KERNEL_ROX (_PAGE_SHARED | _PAGE_RO | _PAGE_KNLRO | \
66-
_PAGE_EXEC)
56+
#define _PAGE_KERNEL_RO (_PAGE_SHARED | _PAGE_RO)
57+
#define _PAGE_KERNEL_ROX (_PAGE_SHARED | _PAGE_RO | _PAGE_EXEC)
6758
#define _PAGE_KERNEL_RW (_PAGE_SHARED | _PAGE_DIRTY | _PAGE_RW | \
6859
_PAGE_HWWRITE)
6960
#define _PAGE_KERNEL_RWX (_PAGE_SHARED | _PAGE_DIRTY | _PAGE_RW | \

arch/powerpc/kernel/head_8xx.S

+12-9
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,15 @@ InstructionTLBMiss:
351351
rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29
352352
lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */
353353

354-
/* Load the MI_TWC with the attributes for this "segment." */
355-
MTSPR_CPU6(SPRN_MI_TWC, r11, r3) /* Set segment attributes */
356-
rlwinm r11, r11,0,0,19 /* Extract page descriptor page address */
357354
/* Extract level 2 index */
358355
rlwinm r10, r10, 32 - (PAGE_SHIFT - 2), 32 - PAGE_SHIFT, 29
359-
lwzx r10, r10, r11 /* Get the pte */
356+
rlwimi r10, r11, 0, 0, 32 - PAGE_SHIFT - 1 /* Add level 2 base */
357+
lwz r10, 0(r10) /* Get the pte */
358+
359+
/* Insert the APG into the TWC from the Linux PTE. */
360+
rlwimi r11, r10, 0, 26, 26
361+
/* Load the MI_TWC with the attributes for this "segment." */
362+
MTSPR_CPU6(SPRN_MI_TWC, r11, r3) /* Set segment attributes */
360363

361364
#ifdef CONFIG_SWAP
362365
rlwinm r11, r10, 32-5, _PAGE_PRESENT
@@ -365,12 +368,12 @@ InstructionTLBMiss:
365368
#endif
366369
li r11, RPN_PATTERN
367370
/* The Linux PTE won't go exactly into the MMU TLB.
368-
* Software indicator bits 21 and 28 must be clear.
371+
* Software indicator bits 20-23 and 28 must be clear.
369372
* Software indicator bits 24, 25, 26, and 27 must be
370373
* set. All other Linux PTE bits control the behavior
371374
* of the MMU.
372375
*/
373-
rlwimi r10, r11, 0, 0x07f8 /* Set 24-27, clear 21-23,28 */
376+
rlwimi r10, r11, 0, 0x0ff8 /* Set 24-27, clear 20-23,28 */
374377
MTSPR_CPU6(SPRN_MI_RPN, r10, r3) /* Update TLB entry */
375378

376379
/* Restore registers */
@@ -411,13 +414,13 @@ DataStoreTLBMiss:
411414
rlwimi r10, r11, 0, 0, 32 - PAGE_SHIFT - 1 /* Add level 2 base */
412415
lwz r10, 0(r10) /* Get the pte */
413416

414-
/* Insert the Guarded flag into the TWC from the Linux PTE.
415-
* It is bit 27 of both the Linux PTE and the TWC (at least
417+
/* Insert the Guarded flag and APG into the TWC from the Linux PTE.
418+
* It is bit 26-27 of both the Linux PTE and the TWC (at least
416419
* I got that right :-). It will be better when we can put
417420
* this into the Linux pgd/pmd and load it in the operation
418421
* above.
419422
*/
420-
rlwimi r11, r10, 0, 27, 27
423+
rlwimi r11, r10, 0, 26, 27
421424
/* Insert the WriteThru flag into the TWC from the Linux PTE.
422425
* It is bit 25 in the Linux PTE and bit 30 in the TWC
423426
*/

0 commit comments

Comments
 (0)