Skip to content

Commit 5b2753f

Browse files
chleroyScott Wood
authored and
Scott Wood
committed
powerpc/8xx: Implementation of PAGE_EXEC
This patch implements PAGE_EXEC capability on the 8xx. All pages PP exec bits are set to 000, which means Execute for Supervisor and no Execute for User. Then we use the APG to say whether accesses are according to Page rules, "all Supervisor" rules (Exec for all) and "all User" rules (Exec for noone) Therefore, we define 4 APG groups. msb is _PAGE_EXEC, lsb is _PAGE_USER. MI_AP is initialised as follows: GP0 (00) => Not User, no exec => 11 (all accesses performed as user) GP1 (01) => User but no exec => 11 (all accesses performed as user) GP2 (10) => Not User, exec => 01 (rights according to page definition) GP3 (11) => User, exec => 00 (all accesses performed as supervisor) Signed-off-by: Christophe Leroy <[email protected]> [scottwood: comments: s/exec/data/ on data side, and s/pages/pages'/] Signed-off-by: Scott Wood <[email protected]>
1 parent e0a8e0d commit 5b2753f

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

arch/powerpc/include/asm/cputable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ enum {
366366
CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP | \
367367
CPU_FTR_COMMON | CPU_FTR_FPU_UNAVAILABLE)
368368
#define CPU_FTRS_CLASSIC32 (CPU_FTR_COMMON | CPU_FTR_USE_TB)
369-
#define CPU_FTRS_8XX (CPU_FTR_USE_TB)
369+
#define CPU_FTRS_8XX (CPU_FTR_USE_TB | CPU_FTR_NOEXECUTE)
370370
#define CPU_FTRS_40X (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE)
371371
#define CPU_FTRS_44X (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE)
372372
#define CPU_FTRS_440x6 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE | \

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

+26
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@
2727
#define MI_Ks 0x80000000 /* Should not be set */
2828
#define MI_Kp 0x40000000 /* Should always be set */
2929

30+
/*
31+
* All pages' PP exec bits are set to 000, which means Execute for Supervisor
32+
* and no Execute for User.
33+
* Then we use the APG to say whether accesses are according to Page rules,
34+
* "all Supervisor" rules (Exec for all) and "all User" rules (Exec for noone)
35+
* Therefore, we define 4 APG groups. msb is _PAGE_EXEC, lsb is _PAGE_USER
36+
* 0 (00) => Not User, no exec => 11 (all accesses performed as user)
37+
* 1 (01) => User but no exec => 11 (all accesses performed as user)
38+
* 2 (10) => Not User, exec => 01 (rights according to page definition)
39+
* 3 (11) => User, exec => 00 (all accesses performed as supervisor)
40+
*/
41+
#define MI_APG_INIT 0xf4ffffff
42+
3043
/* The effective page number register. When read, contains the information
3144
* about the last instruction TLB miss. When MI_RPN is written, bits in
3245
* this register are used to create the TLB entry.
@@ -87,6 +100,19 @@
87100
#define MD_Ks 0x80000000 /* Should not be set */
88101
#define MD_Kp 0x40000000 /* Should always be set */
89102

103+
/*
104+
* All pages' PP data bits are set to either 000 or 011, which means
105+
* respectively RW for Supervisor and no access for User, or RO for
106+
* Supervisor and no access for user.
107+
* Then we use the APG to say whether accesses are according to Page rules or
108+
* "all Supervisor" rules (Access to all)
109+
* Therefore, we define 2 APG groups. lsb is _PAGE_USER
110+
* 0 => No user => 01 (all accesses performed according to page definition)
111+
* 1 => User => 00 (all accesses performed as supervisor
112+
* according to page definition)
113+
*/
114+
#define MD_APG_INIT 0x4fffffff
115+
90116
/* The effective page number register. When read, contains the information
91117
* about the last instruction TLB miss. When MD_RPN is written, bits in
92118
* this register are used to create the TLB entry.

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
*/
4040
#define _PAGE_GUARDED 0x0010 /* Copied to L1 G entry in DTLB */
4141
#define _PAGE_USER 0x0020 /* Copied to L1 APG lsb */
42-
#define _PAGE_ACCESSED 0x0040 /* software: page referenced */
42+
#define _PAGE_EXEC 0x0040 /* Copied to L1 APG */
4343
#define _PAGE_WRITETHRU 0x0080 /* software: caching is write through */
44+
#define _PAGE_ACCESSED 0x0800 /* software: page referenced */
4445

4546
#define _PAGE_RO 0x0600 /* Supervisor RO, User no access */
4647

arch/powerpc/kernel/head_8xx.S

+9-3
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ InstructionTLBMiss:
357357
lwz r10, 0(r10) /* Get the pte */
358358

359359
/* Insert the APG into the TWC from the Linux PTE. */
360-
rlwimi r11, r10, 0, 26, 26
360+
rlwimi r11, r10, 0, 25, 26
361361
/* Load the MI_TWC with the attributes for this "segment." */
362362
MTSPR_CPU6(SPRN_MI_TWC, r11, r3) /* Set segment attributes */
363363

@@ -449,6 +449,7 @@ DataStoreTLBMiss:
449449
*/
450450
li r11, RPN_PATTERN
451451
rlwimi r10, r11, 0, 24, 28 /* Set 24-27, clear 28 */
452+
rlwimi r10, r11, 0, 20, 20 /* clear 20 */
452453
MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */
453454

454455
/* Restore registers */
@@ -769,15 +770,20 @@ initial_mmu:
769770
ori r8, r8, MI_EVALID /* Mark it valid */
770771
mtspr SPRN_MI_EPN, r8
771772
mtspr SPRN_MD_EPN, r8
772-
li r8, MI_PS8MEG /* Set 8M byte page */
773+
li r8, MI_PS8MEG | (2 << 5) /* Set 8M byte page, APG 2 */
773774
ori r8, r8, MI_SVALID /* Make it valid */
774775
mtspr SPRN_MI_TWC, r8
776+
li r8, MI_PS8MEG /* Set 8M byte page, APG 0 */
777+
ori r8, r8, MI_SVALID /* Make it valid */
775778
mtspr SPRN_MD_TWC, r8
776779
li r8, MI_BOOTINIT /* Create RPN for address 0 */
777780
mtspr SPRN_MI_RPN, r8 /* Store TLB entry */
778781
mtspr SPRN_MD_RPN, r8
779-
lis r8, MI_Kp@h /* Set the protection mode */
782+
lis r8, MI_APG_INIT@h /* Set protection modes */
783+
ori r8, r8, MI_APG_INIT@l
780784
mtspr SPRN_MI_AP, r8
785+
lis r8, MD_APG_INIT@h
786+
ori r8, r8, MD_APG_INIT@l
781787
mtspr SPRN_MD_AP, r8
782788

783789
/* Map another 8 MByte at the IMMR to get the processor

0 commit comments

Comments
 (0)