x86_64
x86_64 copied to clipboard
`Descriptor::tss_segment` too restrictive?
I'm trying to implement multitasking in user mode with the following setup:
- Each task has a user-mode and kernel-mode stack
- The kernel-mode stack pointer is placed in the privilege stack table of the TSS (so it is switched to on interrupts, exceptions, and system calls)
- On a context switch, the privilege stack table is updated to point to the kernel-mode stack for the new task
But with this crate, there is a problem. To add the TSS, the Descriptor::tss_segment function should be called with the TaskStateSegment structure, to create a Descriptor that can be added to the GDT. But the function expects a &'static reference to the TaskStateSegment, which means that, once called, no further modifications are possible to the TSS (the &'static reference cannot coexist with any mutable references), so it is not possible to update the TSS on context switching.
Would it be a good idea to loosen the requirements for calling this function?