On Tue, Mar 21, 2023 at 5:19 PM Luca <l...@orpolo.org> wrote:
> > Every thread needs to have its own values of fs_base / gs_base, and
> > you need to store/restore them on context switch by accessing the
> > appropriate MSR. There's also the swapgs instruction that I'm told is
> > useful if you also use gs for kernel's own needs (such as per-CPU
> > data).
>
> I see there are also the rdfsbase/wrfsbase/rdgsbase/wrfgsbase
> instructions which would simplify a lot this part, but they are
> relatively new (~10 years)... I guess we need to handle also the case
> using MSRs/swapgs, which seems quite complicated if made efficient, as
> it requires to keep track of the GS state on each trap entry. I'll try
> to have a simple implementation that works, and eventually optimize it
> later.

Also FWIW: x86_64 glibc isn't actually using gs, and I doubt it's ever
going to. So while a full proper implementation should support gs as
well as fs, just supporting fs should be enough to get glibc going.

Sergey

Reply via email to