aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorThomas Huth <thuth@linux.vnet.ibm.com>2014-10-31 09:10:14 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-11-18 12:22:57 -0500
commitb19556231156ce3e58ffd677747bf3ef7890a937 (patch)
treeea54837410bb14a420c9b4d9e3746a5564965476 /Documentation
parenteaf785d51dc6782da4cc87b5e891c8a9f8fa2c27 (diff)
s390/docs: Fix the documentation of the address spaces
The information about the address spaces was completely outdated, since the usage of the address spaces changed quite a bit since the early days. This patch now updates the information about the usage of the address spaces, mostly by using the description from Heiko's patch "rework uaccess code - fix locking issues" (457f2180951cdcbfb4657ddcc83b486e93497f56). Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/s390/Debugging390.txt88
1 files changed, 61 insertions, 27 deletions
diff --git a/Documentation/s390/Debugging390.txt b/Documentation/s390/Debugging390.txt
index 462321c1aeea..2120eec48a5c 100644
--- a/Documentation/s390/Debugging390.txt
+++ b/Documentation/s390/Debugging390.txt
@@ -114,28 +114,25 @@ s/390 z/Architecture
114 114
11516-17 16-17 Address Space Control 11516-17 16-17 Address Space Control
116 116
117 00 Primary Space Mode when DAT on 117 00 Primary Space Mode:
118 The linux kernel currently runs in this mode, CR1 is affiliated with 118 The register CR1 contains the primary address-space control ele-
119 this mode & points to the primary segment table origin etc. 119 ment (PASCE), which points to the primary space region/segment
120 120 table origin.
121 01 Access register mode this mode is used in functions to 121
122 copy data between kernel & user space. 122 01 Access register mode
123 123
124 10 Secondary space mode not used in linux however CR7 the 124 10 Secondary Space Mode:
125 register affiliated with this mode is & this & normally 125 The register CR7 contains the secondary address-space control
126 CR13=CR7 to allow us to copy data between kernel & user space. 126 element (SASCE), which points to the secondary space region or
127 We do this as follows: 127 segment table origin.
128 We set ar2 to 0 to designate its 128
129 affiliated gpr ( gpr2 )to point to primary=kernel space. 129 11 Home Space Mode:
130 We set ar4 to 1 to designate its 130 The register CR13 contains the home space address-space control
131 affiliated gpr ( gpr4 ) to point to secondary=home=user space 131 element (HASCE), which points to the home space region/segment
132 & then essentially do a memcopy(gpr2,gpr4,size) to 132 table origin.
133 copy data between the address spaces, the reason we use home space for the 133
134 kernel & don't keep secondary space free is that code will not run in 134 See "Address Spaces on Linux for s/390 & z/Architecture" below
135 secondary space. 135 for more information about address space usage in Linux.
136
137 11 Home Space Mode all user programs run in this mode.
138 it is affiliated with CR13.
139 136
14018-19 18-19 Condition codes (CC) 13718-19 18-19 Condition codes (CC)
141 138
@@ -249,9 +246,9 @@ currently 4TB of physical memory currently on z/Architecture.
249Address Spaces on Linux for s/390 & z/Architecture 246Address Spaces on Linux for s/390 & z/Architecture
250================================================== 247==================================================
251 248
252Our addressing scheme is as follows 249Our addressing scheme is basically as follows:
253
254 250
251 Primary Space Home Space
255Himem 0x7fffffff 2GB on s/390 ***************** **************** 252Himem 0x7fffffff 2GB on s/390 ***************** ****************
256currently 0x3ffffffffff (2^42)-1 * User Stack * * * 253currently 0x3ffffffffff (2^42)-1 * User Stack * * *
257on z/Architecture. ***************** * * 254on z/Architecture. ***************** * *
@@ -264,9 +261,46 @@ on z/Architecture. ***************** * *
264 * Sections * * * 261 * Sections * * *
2650x00000000 ***************** **************** 2620x00000000 ***************** ****************
266 263
267This also means that we need to look at the PSW problem state bit 264This also means that we need to look at the PSW problem state bit and the
268or the addressing mode to decide whether we are looking at 265addressing mode to decide whether we are looking at user or kernel space.
269user or kernel space. 266
267User space runs in primary address mode (or access register mode within
268the vdso code).
269
270The kernel usually also runs in home space mode, however when accessing
271user space the kernel switches to primary or secondary address mode if
272the mvcos instruction is not available or if a compare-and-swap (futex)
273instruction on a user space address is performed.
274
275When also looking at the ASCE control registers, this means:
276
277User space:
278- runs in primary or access register mode
279- cr1 contains the user asce
280- cr7 contains the user asce
281- cr13 contains the kernel asce
282
283Kernel space:
284- runs in home space mode
285- cr1 contains the user or kernel asce
286 -> the kernel asce is loaded when a uaccess requires primary or
287 secondary address mode
288- cr7 contains the user or kernel asce, (changed with set_fs())
289- cr13 contains the kernel asce
290
291In case of uaccess the kernel changes to:
292- primary space mode in case of a uaccess (copy_to_user) and uses
293 e.g. the mvcp instruction to access user space. However the kernel
294 will stay in home space mode if the mvcos instruction is available
295- secondary space mode in case of futex atomic operations, so that the
296 instructions come from primary address space and data from secondary
297 space
298
299In case of KVM, the kernel runs in home space mode, but cr1 gets switched
300to contain the gmap asce before the SIE instruction gets executed. When
301the SIE instruction is finished, cr1 will be switched back to contain the
302user asce.
303
270 304
271Virtual Addresses on s/390 & z/Architecture 305Virtual Addresses on s/390 & z/Architecture
272=========================================== 306===========================================