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" (457f218095
).
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
eaf785d51d
commit
b195562311
|
@ -114,28 +114,25 @@ s/390 z/Architecture
|
||||||
|
|
||||||
16-17 16-17 Address Space Control
|
16-17 16-17 Address Space Control
|
||||||
|
|
||||||
00 Primary Space Mode when DAT on
|
00 Primary Space Mode:
|
||||||
The linux kernel currently runs in this mode, CR1 is affiliated with
|
The register CR1 contains the primary address-space control ele-
|
||||||
this mode & points to the primary segment table origin etc.
|
ment (PASCE), which points to the primary space region/segment
|
||||||
|
table origin.
|
||||||
|
|
||||||
01 Access register mode this mode is used in functions to
|
01 Access register mode
|
||||||
copy data between kernel & user space.
|
|
||||||
|
|
||||||
10 Secondary space mode not used in linux however CR7 the
|
10 Secondary Space Mode:
|
||||||
register affiliated with this mode is & this & normally
|
The register CR7 contains the secondary address-space control
|
||||||
CR13=CR7 to allow us to copy data between kernel & user space.
|
element (SASCE), which points to the secondary space region or
|
||||||
We do this as follows:
|
segment table origin.
|
||||||
We set ar2 to 0 to designate its
|
|
||||||
affiliated gpr ( gpr2 )to point to primary=kernel space.
|
|
||||||
We set ar4 to 1 to designate its
|
|
||||||
affiliated gpr ( gpr4 ) to point to secondary=home=user space
|
|
||||||
& then essentially do a memcopy(gpr2,gpr4,size) to
|
|
||||||
copy data between the address spaces, the reason we use home space for the
|
|
||||||
kernel & don't keep secondary space free is that code will not run in
|
|
||||||
secondary space.
|
|
||||||
|
|
||||||
11 Home Space Mode all user programs run in this mode.
|
11 Home Space Mode:
|
||||||
it is affiliated with CR13.
|
The register CR13 contains the home space address-space control
|
||||||
|
element (HASCE), which points to the home space region/segment
|
||||||
|
table origin.
|
||||||
|
|
||||||
|
See "Address Spaces on Linux for s/390 & z/Architecture" below
|
||||||
|
for more information about address space usage in Linux.
|
||||||
|
|
||||||
18-19 18-19 Condition codes (CC)
|
18-19 18-19 Condition codes (CC)
|
||||||
|
|
||||||
|
@ -249,9 +246,9 @@ currently 4TB of physical memory currently on z/Architecture.
|
||||||
Address Spaces on Linux for s/390 & z/Architecture
|
Address Spaces on Linux for s/390 & z/Architecture
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
Our addressing scheme is as follows
|
Our addressing scheme is basically as follows:
|
||||||
|
|
||||||
|
|
||||||
|
Primary Space Home Space
|
||||||
Himem 0x7fffffff 2GB on s/390 ***************** ****************
|
Himem 0x7fffffff 2GB on s/390 ***************** ****************
|
||||||
currently 0x3ffffffffff (2^42)-1 * User Stack * * *
|
currently 0x3ffffffffff (2^42)-1 * User Stack * * *
|
||||||
on z/Architecture. ***************** * *
|
on z/Architecture. ***************** * *
|
||||||
|
@ -264,9 +261,46 @@ on z/Architecture. ***************** * *
|
||||||
* Sections * * *
|
* Sections * * *
|
||||||
0x00000000 ***************** ****************
|
0x00000000 ***************** ****************
|
||||||
|
|
||||||
This also means that we need to look at the PSW problem state bit
|
This also means that we need to look at the PSW problem state bit and the
|
||||||
or the addressing mode to decide whether we are looking at
|
addressing mode to decide whether we are looking at user or kernel space.
|
||||||
user or kernel space.
|
|
||||||
|
User space runs in primary address mode (or access register mode within
|
||||||
|
the vdso code).
|
||||||
|
|
||||||
|
The kernel usually also runs in home space mode, however when accessing
|
||||||
|
user space the kernel switches to primary or secondary address mode if
|
||||||
|
the mvcos instruction is not available or if a compare-and-swap (futex)
|
||||||
|
instruction on a user space address is performed.
|
||||||
|
|
||||||
|
When also looking at the ASCE control registers, this means:
|
||||||
|
|
||||||
|
User space:
|
||||||
|
- runs in primary or access register mode
|
||||||
|
- cr1 contains the user asce
|
||||||
|
- cr7 contains the user asce
|
||||||
|
- cr13 contains the kernel asce
|
||||||
|
|
||||||
|
Kernel space:
|
||||||
|
- runs in home space mode
|
||||||
|
- cr1 contains the user or kernel asce
|
||||||
|
-> the kernel asce is loaded when a uaccess requires primary or
|
||||||
|
secondary address mode
|
||||||
|
- cr7 contains the user or kernel asce, (changed with set_fs())
|
||||||
|
- cr13 contains the kernel asce
|
||||||
|
|
||||||
|
In case of uaccess the kernel changes to:
|
||||||
|
- primary space mode in case of a uaccess (copy_to_user) and uses
|
||||||
|
e.g. the mvcp instruction to access user space. However the kernel
|
||||||
|
will stay in home space mode if the mvcos instruction is available
|
||||||
|
- secondary space mode in case of futex atomic operations, so that the
|
||||||
|
instructions come from primary address space and data from secondary
|
||||||
|
space
|
||||||
|
|
||||||
|
In case of KVM, the kernel runs in home space mode, but cr1 gets switched
|
||||||
|
to contain the gmap asce before the SIE instruction gets executed. When
|
||||||
|
the SIE instruction is finished, cr1 will be switched back to contain the
|
||||||
|
user asce.
|
||||||
|
|
||||||
|
|
||||||
Virtual Addresses on s/390 & z/Architecture
|
Virtual Addresses on s/390 & z/Architecture
|
||||||
===========================================
|
===========================================
|
||||||
|
|
Loading…
Reference in a new issue