1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
- 32-bit capability addresses (64 in practice on x86_64)
- if addressing the last slot, that refers to the cspace itself
- when referencing this slot, the cspace is referenced
- when allocating to this slot, an address is assigned
k = cspace bits (1 << k slots)
g = cspace guard bits
cspace A
k=8 g=0
+==========+
| .... |
| | cspace B
+----------+ k=8 g=4
| cnode | 0x42 --> +==========+
+----------+ | .... |
| .... | | | cspace C
| | +----------+ k=16 g=4
+----------+ | cnode | 0x24 --> +==========+
|%reserved%| 0xFF +----------+ | .... |
+==========+ | .... | | |
| | +----------+
+----------+ | page | 0xBEEF
|%reserved%| 0xFF +----------+
+==========+ | .... |
| |
+----------+
|%reserved%| 0xFFFF
+==========+
Example capability address:
0xAAGBBGCC
| || ||
+-||-||----> cspace A slot address
+|-||----> cspace B guard (always zero)
+-||----> cspace B slot address
+|----> cspace C guard (always zero)
+----> cspace C slot address
Page capability in cspace C: 0x420240BEEF
cspace B: 0x420FFFFFFF (last 24 bits not used)
cspace C: 0x42024FFFFF
To allocate a new page in cspace B, address slot 0x420FFFFFFF
Example usage scenario: process manager spawns a process
- The process manager's cspace is k=8 g=24
- A cspace of process caps is kept at 0x80XXXYYY (k=12)
- The cspace for pid 0x123 is thus at 0x80123YYY
- To insert caps into the new process, process manager addresses them at
0x80123YYY (or 0x80123FFF to capalloc)
- To destroy the process, the process manager just destroys 0x80123FFF