forked from jos-technion/JOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab2-questionary.txt
170 lines (156 loc) · 8.14 KB
/
lab2-questionary.txt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
=== This template file contains questions you need to answer.
=== Fill your answers on appropriate blank lines only.
=== Don't start any line with three equal signs "===".
=== Don't edit any lines starting from three equal signs.
=== Use C notation to write numbers: 42 for decimal, 0x2a for hexadecimal.
=== We may check most of the answers automatically, so "forty two" or
=== "26+16" won't work for this example. Spaces are mostly ignored, so
=== " 42 " is OK (without quotes of course).
=== When asked to specify address & instruction, do it in the form of
=== gdb output "ADDRESS: INSTRUCTION", for example "0x7c26: or $0x1,%eax"
=== Don't make lines longer than 80 characters. You don't need to fit your
=== answer in a single line, you can start a new line at will.
=== However, when asked to fill "a table" make each table raw a single line.
=== Q What's the purpose of leaving virtual memory region
=== 0xeebfe000-0xeec00000 inaccessible?
=== (free form, up to 10 words)
fence when the user stack overflows, you get a fault (page fault)
=== Q What's the value of vpd global variable?
0xeffbf000
=== Q Consider virtual address V=0xeffbfefc which is mapped to some
=== physical address P. Assume TLB is empty and kernel performs read
=== from V. How many times P is accessed? Hint: V is not an arbitrary
=== address.
1
=== Q Denote your answer to the previous question as X. Imagine that
=== we've asked the same question for some V2 and the answer was X2. If
=== it's possible that X2>X, write an example V2, otherwise, write "NO".
=== For example, if your previous answer is 100, for which V2 the
=== answer could be 101 or greater?
0xeffbf3bf
=== Q What's the size (in bytes) of pp_link entry in struct Page?
8
=== Q Define a segment descriptor with the following properties:
=== segment present in memory, spans 0x12345600-0x3579c5ff (linear)
=== addresses and intended to be used by application. All bits which
=== are not responsible for above properties are set to zero.
=== (in the form WORD1 WORD2 as would be output by gdb's x/2x)
0x5600579d 0x12c3f434
=== Q Define a page table entry with the following properties:
=== frame starts at 0x1234000. It can be written by the kernel
=== without causing any errors, but has never been written yet. On
=== the other hand, application cannot write to the page, but has
=== recently successfully read from it. All bits which are not
=== responsible for above properties are set to zero.
=== (a single memory WORD as would be output by gdb's x/1x)
0x1234027
=== Q Consider JOS kernel code:
=== mystery_t x;
=== char* value = return_a_pointer();
=== *value = 10;
=== x = (mystery_t) value;
=== What type mystery_t should refer to?
=== (remove leading "====" from the correct answer line)
uintptr_t
==== physaddr_t
=== Q What information is stored in page directory when i386_vm_init()
=== finishes? For each non-empty PD entry specify:
=== - decimal index (0-1023)
=== - hexadecimal address of virtual memory mapped by this entry
=== - name of kernel data structure which is intended to be
=== accessible through this PDE (when appropriate, in quotes)
=== - general name (free form, up to 10 words in quotes)
=== Sort the table by the index in ascending order. If several
=== consequent entries are only differ in address field, you can
=== specify ellipses ("...") instead of an "inner" entries. Please
=== align columns into readable table using spaces.
=== Format example (all the values are made up; omit the header):
=== INDEX ADDRESS DATA-STRUCTURE NAME/DESCRIPTION
=== 24 0x12345 "struct Segdesc gdt[]" "Global descriptor table"
=== ...
=== 42 0x98765 "struct Segdesc gdt[]" "Global descriptor table"
=== 50 0x00011 "" "boot loader code"
0 0x0 "" "null page"
956 0x117000 "struct Page* pages" "all free pages"
957 0x116005 "pde_t *pgdir" "Global descriptor table"
958 0x117000 "kernel stack" "kernel stack"
959 0x116003 "pde_t *pgdir" "Global descriptor table"
960 0x9f020 "" "page for kernel"
...
1023 0x5e00 "" "page for kernel"
1028 0xf0117018 "struct Page* page" "mapped phyiscal page"
...
1304 0xf01155b8 "struct Page* page" "mapped phyiscal page"
=== Q What is the first instruction which would be "broken" if
=== i386_vm_init() wouldn't remap PDE 0? (address & instruction)
260 asm volatile("lgdt gdt_pd");
=== Q Can this instruction be "fixed" (i.e. replaced by another
=== instruction which would produce the desired effect)?
=== If yes, write the "fixed" instruction, otherwise write NO.
NO
=== Q Propose two ways to change i386_vm_init() (or other places) to
=== support JOS kernel bigger than 4MB.
=== Way 1 (free form, up to 40 words, don't need to use all 40!)
change the KERNBASE to something smaller, and make the user part smaller.
=== Way 2 (free form, up to 40 words, don't need to use all 40!)
change the KSTACKTOP to something bigger. so ther kernel will have more memory
=== Q Which virtual addresses are readable by the user?
=== (in the form ADDR1-ADDR2, if none, specify NONE)
0xeebfd000-0xeebfe000
0xeebff000-0xef800000
=== Q Which virtual addresses are writable by the user?
=== (in the form ADDR1-ADDR2, if none, specify NONE)
0xeebfd000-0xeebfe000
0xeebff000-0xeec00000
=== Q Assume a hacker can change N bits inside page table (on any
=== level, PD or PT) after it has been set up by the kernel (and
=== before full TLB flush). What is the minimal N to gain full
=== control of the system from hacker's user space process?
1049600
=== Q What's the maximum amount of physical memory this kernel can
=== support? (number of megabytes, without MB suffix)
256
=== Q What single constant can be changed in kernel source to make
=== this limit 2 times lower (if kernel normally supports 10MB,
=== we want to make it support only 5MB?
KERNBASE
=== Q What value should this constant be changed to?
0xf8000000
=== Q Assume the computer has the maximum amount of memory supported
=== by the (unmodified) kernel. What's the overhead of managing this
=== memory in terms of (physical) memory spent?
=== Specify only data structures which size depends on the amount of
=== physical memory and exclude the "fixed" overhead. For example,
=== if data structure size is 123K+0.01*(memory size) and maximum
=== amount of memory is 100MB, specify 0.01*100MB = 1024KB.
=== For each such data structure specify:
=== - size in KB (without "KB suffix")
=== - name of kernel data structure (when appropriate, in quotes)
=== - general name (free form, up to 10 words in quotes)
=== Sort the table by the size in ascending order. Please
=== align columns into readable table using spaces.
=== Format example (all the values are made up; omit the header):
=== SIZE DATA-STRUCTURE NAME/DESCRIPTION
=== 42 "struct Segdesc gdt[]" "Global descriptor table"
194 "struct Page *pages" "all free pages"
====================================================================
=== Q What challenge(s) have you chosen to implement? (specify
=== challenge numbers separated by spaces, if more than one)
5
=== Q If the challenge requires changing the kernel source, list the
=== files which you have changed/added during implementation.
=== (one file per line, relative to lab directory containing .git/)
monitor.c
pmap.c
monitor.h
pmap.h
=== Q Describe you solution.
=== (free form, up to 500 words, don't need to use all 500!)
I've added one function to pmap.c which takes a page number,
and checks wether the page is allocated or not.
in monitor.c, I've added 4 methods,
mon_alloc_page, which allocates a page using page_alloc (pmap),
mon_free_page, which takes a page, and frees it using page_free (pmap),
mon_page_status, which takes a page, and checks wether it's allocated or not.
mon_page_ref, which takes a page, and prints number of references to the page.
NOTE: all the functions that takes a page, can handle multiple pages as well.