sortix-mirror/sortix/x64
Jonas 'Sortie' Termansen 36b01eb2d3 Fixed the horrible 'nofoo' bug!
When compiled with gcc 4.6.1, 32-bit Sortix would triple fault during
early boot: When the TLB is being flushed, somehow a garbage value had
sneaked into Sortix::Memory::currentdir, and a non-page aligned (and
garbage) page directory is loaded. (Triple fault, here we come!)

However, adding a volatile addr_t foo after the currentdir variable
actually caused the system to boot correctly - the garbage was written
into that variable instead. To debug the problem, I set the foo value
to 0: as long as !foo (hence the name nofoo) everything was alright.

After closer examination I found that the initrd open code wrote to a
pointer supplied by kernel.cpp. The element pointed to was on the
stack. Worse, its address was the same as currentdir (now foo).

Indeed, the stack had gone into the kernel's data segment!

Turns out that this gcc configuration stores variables in the data
segment in the reverse order they are defined in, whereas previous
compilers did the opposite. The hack used to set up the stack during
early boot relied on this (now obviously incorrect) fact.

In effect, the stack was initialized to the end of the stack, not
the start of it: completely ignoring all the nice stack space
allocated in kernel.cpp.

I did not see that one coming.
2011-12-25 03:41:59 +01:00
..
base.s Fixed the horrible 'nofoo' bug! 2011-12-25 03:41:59 +01:00
bits.h Initial version of Sortix. 2011-08-05 14:25:00 +02:00
boot.s Made Sortix compatible with gcc 4.6.1. 2011-12-25 00:10:56 +01:00
gdt.s Added support for 64-bit interrupts. 2011-11-30 23:30:14 +01:00
interrupt.s Added support for 64-bit interrupts. 2011-11-30 23:30:14 +01:00
memorymanagement.cpp Made Sortix compatible with gcc 4.6.1. 2011-12-25 00:10:56 +01:00
memorymanagement.h Rewrote memory management again and added support for x64 and forking. 2011-10-10 01:02:57 +02:00
process.cpp Stack is now aligned in 64-bit Sortix threads. 2011-12-01 21:43:35 +01:00
scheduler.cpp The initial ramdisk is now mapped onto a special location. 2011-12-22 14:13:18 +01:00
syscall.s Fixed 64-bit resumed system calls. 2011-12-01 14:29:49 +01:00
thread.cpp x64 now compiles again and runs on real hardware. 2011-11-29 01:31:54 +01:00
x64.cpp x64 now compiles again and runs on real hardware. 2011-11-29 01:31:54 +01:00
x64.h x64 now compiles again and runs on real hardware. 2011-11-29 01:31:54 +01:00