Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel: GDT array, fixed descriptors
Update the `gs` segment register with the address of the userspace TLS at every thread-switch, before returning to userspace. In order to update the TLS segment, we need to know its offset in the GDT at any moment. Because the GDT was implemented with a vec, with dynamic size in mind, and descriptors were pushed to it and their index never saved, this was impossible to implement. This commit drops the dynamic size property of the GDT and LDT, for a simpler fixed-sized array of descriptors, where every descriptor's index is fixed and public, and the full content of the GDT is known at compile time. There is no foreseeable situation where the GDT would need to be dynamically sized, so a fixed-sized array seems more appropriate. This led to a lot of simplifications in the code: * Because we no longer need Vecs to hold the table, the gdt module no longer relies on the Heap. * No more pointer wizardry, the table exists in one and only one place: the `GDT` structure, which in .data, and not on the heap. * The GdtManager is now finally as dumb as it was meant to be: holds two tables, and swaps them on `commit()`. That's it. * No more reconstructing mem::forgotten tables from `sgdt`. Because we don't (yet) have const generics, the LDT gets the same size as the GDT, but is filled with null descriptors. This is only 10 u64 more in the .data, so no big deal.
- Loading branch information