- User code can use the new RD/WR FS/GS BASE instructions.I wonder how java avoids the lack of the user-space
Apparently some users really want this for, umm, userspace threading.
Think Java.
The major disadvantage is that user code can use the new instructions.I don't think this can represent the problem, at least not
Now userspace is going to do totally stupid shite like writing some
nonzero value to GS and then doing WRGSBASE or like linking some
idiotic library that uses WRGSBASE into a perfectly innocent program
like dosemu2 and resulting in utterly nonsensical descriptor state.
----- interaction with modify_ldt() -----Does 1b mean that any call to modify_ldt(), even the
The first sticking point we'll hit is modify_ldt() and, in particular,
what happens if you call modify_ldt() to change the base of a segment
that is ioaded into gs by another thread in the same mm.
Our current behavior here is nonsensical: on 32-bit kernels, FS would
be fully refreshed on other threads and GS might be depending on
compiler options. On 64-bit kernels, neither FS nor GS is immediately
refreshed. Historically, we didn't refresh anything reliably. On the
bright side, this means that existing modify_ldt() users are (AFAIK)
tolerant of somewhat crazy behavior.
On an FSGSBASE-enabled system, I think we need to provide
deterministic, documented, tested behavior. I can think of three
plausible choices:
1a. modify_ldt() immediately updates FSBASE and GSBASE all threads
that reference the modified selector.
1b. modify_ldt() immediatley updates FSBASE and GSBASE on all threads
that reference the LDT.
2. modify_ldt() leaves FSBASE and GSBASE alone on all threads.But do we have fsgsbase on 32bit kernels at all?
(2) is trivial to implement, whereas (1a) and (1b) are a bit nasty to
implement when FSGSBASE is on.
The tricky bit is that 32-bit kernels can't do (2), so, if we want
modify_ldt() to behave the same on 32-bit and 64-bit kernels, we'reIf you mean 1a, then to me it looks like a lot of efforts
stuck with (1).
Thoughts?I am far from the kernel development so my thoughts