Skip to content

Commit 332ce96

Browse files
chleroympe
authored andcommitted
powerpc/8xx: Reduce time spent in allow_user_access() and friends
To enable/disable kernel access to user space, the 8xx has to modify the properties of access group 1. This is done by writing predefined values into SPRN_Mx_AP registers. As of today, a __put_user() gives: 00000d64 <my_test>: d64: 3d 20 4f ff lis r9,20479 d68: 61 29 ff ff ori r9,r9,65535 d6c: 7d 3a c3 a6 mtspr 794,r9 d70: 39 20 00 00 li r9,0 d74: 90 83 00 00 stw r4,0(r3) d78: 3d 20 6f ff lis r9,28671 d7c: 61 29 ff ff ori r9,r9,65535 d80: 7d 3a c3 a6 mtspr 794,r9 d84: 4e 80 00 20 blr Because only groups 0 and 1 are used, the definition of groups 2 to 15 doesn't matter. By setting unused bits to 0 instead on 1, one instruction is removed for each lock and unlock action: 00000d5c <my_test>: d5c: 3d 20 40 00 lis r9,16384 d60: 7d 3a c3 a6 mtspr 794,r9 d64: 39 20 00 00 li r9,0 d68: 90 83 00 00 stw r4,0(r3) d6c: 3d 20 60 00 lis r9,24576 d70: 7d 3a c3 a6 mtspr 794,r9 d74: 4e 80 00 20 blr Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/57425c33dd72f292b1a23570244b81419072a7aa.1586945153.git.christophe.leroy@c-s.fr
1 parent e51c3e1 commit 332ce96

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
* Therefore, we define 2 APG groups. lsb is _PMD_USER
3737
* 0 => Kernel => 01 (all accesses performed according to page definition)
3838
* 1 => User => 00 (all accesses performed as supervisor iaw page definition)
39-
* 2-16 => NA => 11 (all accesses performed as user iaw page definition)
39+
* 2-15 => Not Used
4040
*/
41-
#define MI_APG_INIT 0x4fffffff
41+
#define MI_APG_INIT 0x40000000
4242

4343
/*
4444
* 0 => Kernel => 01 (all accesses performed according to page definition)
4545
* 1 => User => 10 (all accesses performed according to swaped page definition)
46-
* 2-16 => NA => 11 (all accesses performed as user iaw page definition)
46+
* 2-15 => Not Used
4747
*/
48-
#define MI_APG_KUEP 0x6fffffff
48+
#define MI_APG_KUEP 0x60000000
4949

5050
/* The effective page number register. When read, contains the information
5151
* about the last instruction TLB miss. When MI_RPN is written, bits in
@@ -115,16 +115,16 @@
115115
* Therefore, we define 2 APG groups. lsb is _PMD_USER
116116
* 0 => Kernel => 01 (all accesses performed according to page definition)
117117
* 1 => User => 00 (all accesses performed as supervisor iaw page definition)
118-
* 2-16 => NA => 11 (all accesses performed as user iaw page definition)
118+
* 2-15 => Not Used
119119
*/
120-
#define MD_APG_INIT 0x4fffffff
120+
#define MD_APG_INIT 0x40000000
121121

122122
/*
123123
* 0 => No user => 01 (all accesses performed according to page definition)
124124
* 1 => User => 10 (all accesses performed according to swaped page definition)
125-
* 2-16 => NA => 11 (all accesses performed as user iaw page definition)
125+
* 2-15 => Not Used
126126
*/
127-
#define MD_APG_KUAP 0x6fffffff
127+
#define MD_APG_KUAP 0x60000000
128128

129129
/* The effective page number register. When read, contains the information
130130
* about the last instruction TLB miss. When MD_RPN is written, bits in

0 commit comments

Comments
 (0)