xref: /xv6-public/Notes (revision 0a70d042)
1bootmain.c doesn't work right if the ELF sections aren't
2sector-aligned. so you can't use ld -N. and the sections may also need
3to be non-zero length, only really matters for tiny "kernels".
4
5kernel loaded at 1 megabyte. stack same place that bootasm.S left it.
6
7kinit() should find real mem size
8  and rescue useable memory below 1 meg
9
10no paging, no use of page table hardware, just segments
11
12no user area: no magic kernel stack mapping
13  so no copying of kernel stack during fork
14  though there is a kernel stack page for each process
15
16no kernel malloc(), just kalloc() for user core
17
18user pointers aren't valid in the kernel
19
20setting up first process
21  we do want a process zero, as template
22    but not runnable
23  just set up return-from-trap frame on new kernel stack
24  fake user program that calls exec
25
26map text read-only?
27shared text?
28
29what's on the stack during a trap or sys call?
30  PUSHA before scheduler switch? for callee-saved registers.
31  segment contents?
32  what does iret need to get out of the kernel?
33  how does INT know what kernel stack to use?
34
35are interrupts turned on in the kernel? probably.
36
37per-cpu curproc
38one tss per process, or one per cpu?
39one segment array per cpu, or per process?
40
41pass curproc explicitly, or implicit from cpu #?
42  e.g. argument to newproc()?
43
44test stack expansion
45test running out of memory, process slots
46
47we can't really use a separate stack segment, since stack addresses
48need to work correctly as ordinary pointers. the same may be true of
49data vs text. how can we have a gap between data and stack, so that
50both can grow, without committing 4GB of physical memory? does this
51mean we need paging?
52
53what's the simplest way to add the paging we need?
54  one page table, re-write it each time we leave the kernel?
55  page table per process?
56  probably need to use 0-0xffffffff segments, so that
57    both data and stack pointers always work
58  so is it now worth it to make a process's phys mem contiguous?
59  or could use segment limits and 4 meg pages?
60    but limits would prevent using stack pointers as data pointers
61  how to write-protect text? not important?
62
63perhaps have fixed-size stack, put it in the data segment?
64
65oops, if kernel stack is in contiguous user phys mem, then moving
66users' memory (e.g. to expand it) will wreck any pointers into the
67kernel stack.
68
69do we need to set fs and gs? so user processes can't abuse them?
70
71setupsegs() may modify current segment table, is that legal?
72
73trap() ought to lgdt on return, since currently only done in swtch()
74
75protect hardware interrupt vectors from user INT instructions?
76