summaryrefslogtreecommitdiff
path: root/cpu/access_control/gdt.txt
blob: c803ace168af9529e453f7eb812379361e5f32bf (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Each entry is n*4 bits long, where n is the current mode in bits
TODO: Specify a limit for them

It uses the following format:
	(higher address)
	+---------------------+-------------------------+
	| upper 4 bits: flags | lower 1/2: base address |
	+---------------------+-------------------------+
	| upper 4 bits: type  | lower 1/2: limit        |
	+---------------------+-------------------------+
	| permissions required to use                   |
	+-----------------------------------------------+
	| permissions not allowed to use                |
	+-----------------------------------------------+
	(lower address)

Unspecified bits are ignored for the gdt's purposes

type: 
	0: null, inactive
	1: <normal>
	???

flags for <normal> type segments:
	3: invert region access (specifies a region of memory not allowed for this entry)
	2: readable
	1: writable
	0: executable

base address:
	This number is added to the address for all pointers referencing this segment

limit:
	This is the maximum value allowed for the address of the pointer referencing this segment

permissions required to use:
	The active task must have all of the permissions set here to use this segment

permissions not allowed to use:
	The active task must not have any of these permissions to use this segment

32-bit example:
	 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
	+------------------------------------------------------------------------------------------------+
	| 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0 |
	| 0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0 |
	| 1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 |
	| 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  0 |
	+------------------------------------------------------------------------------------------------+

flags: 0 1 0 0
	not inverted
	readable
	not writable
	not executable

base address: 1  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0
	0x9000

type: 0 0 0 1
	type 1: <normal>

limit: 0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0
	0x400

permissions required: 1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
	must have 31st permission to use this segment

permissions not allowed: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  0
	must not have 1st or 2nd permission to use this segment

Access MUST be checked prior to any action, speculative or otherwise