Skip to content

Commit a662851

Browse files
author
Geoffrey Challen
committed
Initial fix of upstream merge.
2 parents 93cc12e + 15abe49 commit a662851

File tree

42 files changed

+828
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+828
-74
lines changed

CHANGES

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,96 @@ various other people, all of whom are (hopefully) listed below.
1212
------------------------------------------------------------
1313

1414

15+
OS/161 2.0.3 released 20160124
16+
------------------------------
17+
18+
20170124 dholland in base
19+
- Remove obsolete, redundant, or not useful test programs:
20+
guzzle (same as hog)
21+
kitchen (equivalent to multiexec -n 4 sink)
22+
sink (same as conman)
23+
sty (equivalent to multiexec -n 6 hog)
24+
quinthuge (offers little over triplehuge, can be done with multiexec)
25+
quintmat, quintsort (ditto)
26+
27+
20170118 dholland in base
28+
- Make -g -Og the flags when "debug" is enabled in a kernel config
29+
(which it is in the non-OPT ones) and add an additional kernel
30+
config verb "debugonly" to get just -g in case that becomes
31+
necessary. This should significantly improve the output code
32+
quality from gcc without compromising debugging. (However, gcc
33+
being gcc, it also sometimes leads to additional spurious
34+
warnings that don't occur with either -g or -O2.)
35+
36+
20170118 dholland in base
37+
- Add a MI mainbus_debugger() function that goes through the right
38+
MD paths to trigger the debugger hook in the ltrace device. Also
39+
add a menu function "debug" to trigger it.
40+
41+
20170118 dholland in base
42+
- Add some bits to forktest to try to catch the case where the fork
43+
child returns from the next system call instead of from fork.
44+
(Which is a moderately common bug, caused by races copying the
45+
trapframe information in the kernel.)
46+
47+
20170117 dholland in base
48+
- Add a menu command "deadlock" to intentionally deadlock.
49+
50+
20170117 dholland in base, from Sam Fishman
51+
- Fix parallelvm -w so that if one of the forks fails the whole
52+
thing doesn't wedge.
53+
54+
20170117 dholland in base, reported by Sam Fishman
55+
- Don't do semfs I/O from NULL, or from/to insufficiently sized
56+
buffers. Like the 20150615 change, except covering the rest of
57+
the tests that use the semaphores that were doing it wrong:
58+
multiexec, parallelvm, and schedpong.
59+
60+
20170117 dholland in base, from Sam Fishman
61+
- Add assembler directives to exception-mips1.S that tell gdb how
62+
to read trap frames correctly. Garbage-collect old stuff left
63+
over from making it work with a (much) older version of gdb a
64+
long time back. This also usually makes it possible to trace back
65+
through a syscall into a userlevel process; include a gdb script
66+
with tools for making this useful.
67+
68+
20170117 dholland in base
69+
- Merge the deadlock detector into base. It was a success last year.
70+
- Mention in the comments that the hangman hooks in locks need to
71+
be called atomically.
72+
73+
20170117 dholland in base, reported by Jeffrey Cai, patch from Sam Fishman
74+
- Fix off-by-one in tac that makes it skip the first line of files.
75+
76+
20170117 dholland in base, from Sam Fishman
77+
- Make badcall's "pipe with unaligned pointer" test clean up after
78+
itself if the operation succeeds. Otherwise it leaks fds and that
79+
can intefere with other tests.
80+
81+
20170116 dholland in base, reported by Sam Fishman
82+
- Don't allow opening an entirely empty pathname to succeed, and
83+
don't allow success for this case in badcall either.
84+
85+
20170116 dholland in base, from Sasha Fedorova
86+
- Fix write buffer size in filetest.
87+
88+
20160325 dholland in base
89+
- Fix macro parenthesis bug in ROUNDUP().
90+
91+
20160304 dholland in base, from Sam Fishman
92+
- Make runtest.py handle spacing in the command strings it's given.
93+
94+
20160216 dholland in base
95+
- Fix spacing problems in ls -l output for large files.
96+
97+
20160203 dholland in base
98+
- Expand comments attached to cpustacks[]/cputhreads[], prompted by
99+
James Mickens.
100+
101+
20160125 dholland in base, from Nikhil Benesch.
102+
- Fix stupid argument handling bug in test.py.
103+
104+
15105
OS/161 2.0.2 released 20160112
16106
------------------------------
17107

@@ -53,6 +143,14 @@ OS/161 2.0.2 released 20160112
53143
anyway. If they aren't actually constant because of bugs, reading
54144
a stale or even garbage value is not going to hurt more.
55145

146+
20160107 dholland in deadlock-detector
147+
- Add a deadlock detector. For now this will be supplied to
148+
instructors as a supplementary patch, because it intrudes into
149+
the synchronization primitives and affects what students do
150+
there. We are planning to try it on our students this coming
151+
semester; if that works out well, I'll probably merge it into
152+
base.
153+
56154
20160107 dholland in base
57155
- In testbin/multiexec, if fork fails partway through, continue
58156
with the forks we got. Otherwise the subprocesses we started hang

kern/arch/mips/include/trapframe.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ struct trapframe {
6969
uint32_t tf_s7;
7070
uint32_t tf_t8;
7171
uint32_t tf_t9;
72-
uint32_t tf_k0; /* dummy (see exception-mips1.S comments) */
73-
uint32_t tf_k1; /* dummy */
7472
uint32_t tf_gp;
7573
uint32_t tf_sp;
7674
uint32_t tf_s8;

kern/arch/mips/locore/exception-mips1.S

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ mips_general_end:
101101
.text
102102
.type common_exception,@function
103103
.ent common_exception
104+
.cfi_startproc
105+
.cfi_signal_frame
104106
common_exception:
105107
mfc0 k0, c0_status /* Get status register */
106108
andi k0, k0, CST_KUp /* Check the we-were-in-user-mode bit */
@@ -130,11 +132,12 @@ common_exception:
130132
*/
131133

132134
/*
133-
* Allocate stack space for 37 words to hold the trap frame,
135+
* Allocate stack space for 35 words to hold the trap frame,
134136
* plus four more words for a minimal argument block, plus
135137
* one more for proper (64-bit) stack alignment.
136138
*/
137-
addi sp, sp, -168
139+
addi sp, sp, -160
140+
.cfi_def_cfa sp, 0
138141

139142
/*
140143
* Save general registers.
@@ -143,70 +146,89 @@ common_exception:
143146
*
144147
* The order here must match mips/include/trapframe.h.
145148
*
146-
* gdb disassembles this code to try to figure out what registers
147-
* are where, and it isn't very bright. So in order to make gdb be
148-
* able to trace the stack back through here, we play some silly
149-
* games.
149+
* gdb uses the .cfi_offset assembler directives inserted below to
150+
* to figure out where each register is stored. Since we've marked
151+
* this function as a "signal handler" with the .cfi_signal_frame
152+
* directive, gdb won't complain about the fact that the stack
153+
* is noncontiguous (if we're coming from userland).
150154
*
151-
* In particular:
152-
* (1) We store the return address register into the epc slot,
153-
* which makes gdb think it's the return address slot. Then
154-
* we store the real epc value over that.
155-
* (2) We store the current sp into the sp slot, which makes gdb
156-
* think it's the stack pointer slot. Then we store the real
157-
* value.
158-
* (3) gdb also assumes that saved registers in a function are
159-
* saved in order. This is why we put epc where it is, and
160-
* handle the real value of ra afterwards.
161-
* (4) Because gdb will think we're saving k0 and k1, we need to
162-
* leave slots for them in the trap frame, even though the
163-
* stuff we save there is useless.
155+
* We also play a trick with the return address: we mark the ra
156+
* register as stored to the stack normally and then mark the
157+
* return address for *this* function as being in the k1 register
158+
* using the .cfi_return_column directive. gdb is then able to
159+
* recognize that the ra we've stored here is the return address
160+
* for the function that was executing when this exception was
161+
* taken.
164162
*
165-
* This logic has not been tested against a recent gdb and has
166-
* probably bitrotted. Someone(TM) should figure out what gdb
167-
* currently expects -- or maybe even patch gdb to understand a
168-
* better form of this that doesn't waste so many cycles.
163+
* All of the cfi (call frame information) material is compiled
164+
* into the .eh_frame section of the compiled kernel.
169165
*/
170-
sw ra, 160(sp) /* dummy for gdb */
171-
sw s8, 156(sp) /* save s8 */
172-
sw sp, 152(sp) /* dummy for gdb */
173-
sw gp, 148(sp) /* save gp */
174-
sw k1, 144(sp) /* dummy for gdb */
175-
sw k0, 140(sp) /* dummy for gdb */
176-
177-
sw k1, 152(sp) /* real saved sp */
166+
sw s8, 148(sp) /* save s8 */
167+
.cfi_offset s8, 148
168+
sw k1, 144(sp) /* real saved sp */
169+
.cfi_offset sp, 144
170+
sw gp, 140(sp) /* save gp */
178171
nop /* delay slot for store */
172+
.cfi_offset gp, 140
179173

174+
.cfi_return_column k1
180175
mfc0 k1, c0_epc /* Copr.0 reg 13 == PC for exception */
181-
sw k1, 160(sp) /* real saved PC */
176+
sw k1, 152(sp) /* real saved PC */
177+
.cfi_offset k1, 152
182178

183179
sw t9, 136(sp)
180+
.cfi_offset t9, 136
184181
sw t8, 132(sp)
182+
.cfi_offset t8, 132
185183
sw s7, 128(sp)
184+
.cfi_offset s7, 128
186185
sw s6, 124(sp)
186+
.cfi_offset s6, 124
187187
sw s5, 120(sp)
188+
.cfi_offset s5, 120
188189
sw s4, 116(sp)
190+
.cfi_offset s4, 116
189191
sw s3, 112(sp)
192+
.cfi_offset s3, 112
190193
sw s2, 108(sp)
194+
.cfi_offset s2, 108
191195
sw s1, 104(sp)
196+
.cfi_offset s1, 104
192197
sw s0, 100(sp)
198+
.cfi_offset s0, 100
193199
sw t7, 96(sp)
200+
.cfi_offset t7, 96
194201
sw t6, 92(sp)
202+
.cfi_offset t6, 92
195203
sw t5, 88(sp)
204+
.cfi_offset t5, 88
196205
sw t4, 84(sp)
206+
.cfi_offset t4, 84
197207
sw t3, 80(sp)
208+
.cfi_offset t3, 80
198209
sw t2, 76(sp)
210+
.cfi_offset t2, 76
199211
sw t1, 72(sp)
212+
.cfi_offset t1, 72
200213
sw t0, 68(sp)
214+
.cfi_offset t0, 68
201215
sw a3, 64(sp)
216+
.cfi_offset a3, 64
202217
sw a2, 60(sp)
218+
.cfi_offset a2, 60
203219
sw a1, 56(sp)
220+
.cfi_offset a1, 56
204221
sw a0, 52(sp)
222+
.cfi_offset a0, 52
205223
sw v1, 48(sp)
224+
.cfi_offset v1, 48
206225
sw v0, 44(sp)
226+
.cfi_offset v0, 44
207227
sw AT, 40(sp)
228+
.cfi_offset AT, 40
208229

209230
sw ra, 36(sp)
231+
.cfi_offset ra, 36
210232

211233
/*
212234
* Save special registers.
@@ -227,11 +249,6 @@ common_exception:
227249
mfc0 t4, c0_cause
228250
sw t4, 24(sp) /* Copr.0 reg 13 == exception cause */
229251

230-
/*
231-
* Pretend to save $0 for gdb's benefit.
232-
*/
233-
sw $0, 12(sp)
234-
235252
/*
236253
* Load the curthread register if coming from user mode.
237254
*/
@@ -260,9 +277,6 @@ common_exception:
260277
jal mips_trap /* call it */
261278
nop /* delay slot */
262279

263-
/* Something must be here or gdb doesn't find the stack frame. */
264-
nop
265-
266280
/*
267281
* Now restore stuff and return from the exception.
268282
* Interrupts should be off.
@@ -309,20 +323,17 @@ exception_return:
309323
lw s7, 128(sp)
310324
lw t8, 132(sp)
311325
lw t9, 136(sp)
326+
lw gp, 140(sp) /* restore gp */
327+
/* 144(sp) stack pointer - below */
328+
lw s8, 148(sp) /* restore s8 */
329+
lw k1, 152(sp) /* fetch exception return PC into k1 */
312330

313-
/* 140(sp) "saved" k0 was dummy garbage anyway */
314-
/* 144(sp) "saved" k1 was dummy garbage anyway */
315-
316-
lw gp, 148(sp) /* restore gp */
317-
/* 152(sp) stack pointer - below */
318-
lw s8, 156(sp) /* restore s8 */
319-
lw k0, 160(sp) /* fetch exception return PC into k0 */
320-
321-
lw sp, 152(sp) /* fetch saved sp (must be last) */
331+
lw sp, 144(sp) /* fetch saved sp (must be last) */
322332

323333
/* done */
324-
jr k0 /* jump back */
334+
jr k1 /* jump back */
325335
rfe /* in delay slot */
336+
.cfi_endproc
326337
.end common_exception
327338

328339
/*

kern/arch/mips/locore/trap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ mips_trap(struct trapframe *tf)
130130
bool iskern;
131131
int spl;
132132

133-
/* The trap frame is supposed to be 37 registers long. */
134-
KASSERT(sizeof(struct trapframe)==(37*4));
133+
/* The trap frame is supposed to be 35 registers long. */
134+
KASSERT(sizeof(struct trapframe)==(35*4));
135135

136136
/*
137137
* Extract the exception code info from the register fields.

kern/arch/mips/thread/cpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
*
5555
* These arrays are also used to start up new CPUs, for roughly the
5656
* same reasons.
57+
*
58+
* The values in the current cpu's slots in these arrays are updated
59+
* with the current thread's information in trap.c before heading to
60+
* userlevel, as well as being initialized in cpu_machdep_init below.
61+
* This means that (unless something really horrible happens) on entry
62+
* to the kernel, and when a new CPU starts up in cpu_start_secondary,
63+
* they will have the information needed to figure out who we are and
64+
* proceed.
5765
*/
5866

5967
vaddr_t cpustacks[MAXCPUS];

kern/arch/sys161/dev/lamebus_machdep.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <mainbus.h>
4343
#include <sys161/bus.h>
4444
#include <lamebus/lamebus.h>
45+
#include <lamebus/ltrace.h>
4546
#include "autoconf.h"
4647

4748
/*
@@ -275,6 +276,15 @@ mainbus_send_ipi(struct cpu *target)
275276
lamebus_assert_ipi(lamebus, target);
276277
}
277278

279+
/*
280+
* Trigger the debugger.
281+
*/
282+
void
283+
mainbus_debugger(void)
284+
{
285+
ltrace_stop(0);
286+
}
287+
278288
/*
279289
* Interrupt dispatcher.
280290
*/

kern/conf/DUMBVM

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
include conf/conf.kern # get definitions of available options
55

6-
debug # Compile with debug info.
6+
debug # Compile with debug info and -Og.
7+
#debugonly # Compile with debug info only (no -Og).
8+
options hangman # Deadlock detection. (off by default)
79

810
#
911
# Device drivers for hardware.

kern/conf/DUMBVM-OPT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
include conf/conf.kern # get definitions of available options
88

99
#debug # Optimizing compile (no debug).
10+
#debugonly
1011
options noasserts # Disable assertions.
1112

1213
#

kern/conf/GENERIC

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
include conf/conf.kern # get definitions of available options
66

77
debug # Compile with debug info.
8+
#debugonly # Compile with debug info only (no -Og).
9+
#options hangman # Deadlock detection. (off by default)
810

911
#
1012
# Device drivers for hardware.

0 commit comments

Comments
 (0)