Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705688

Re: FSGSBASE ABI considerations

From Andy Lutomirski <luto@kernel.org>
Newsgroups linux.kernel
Subject Re: FSGSBASE ABI considerations
Date 2017-08-07 18:20 +0200
Message-ID <ubSV6-2zz-53@gated-at.bofh.it> (permalink)
References <u99fI-JN-7@gated-at.bofh.it> <u9qqd-2Vo-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Jul 31, 2017, at 5:23 PM, Bae, Chang Seok <chang.seok.bae@intel.com> wrote:

>> 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.
>> (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're stuck with (1).
>
> While implementing (1) is still unclear for context switch, here is one idea for (1b):
> - thread struct has new entry for ldt pointer that last seen
> - modify_ldt happens
> - ldtr upated for active threads via IPI
> - for inactive threads being scheduled in, ldtr updated before __switch_to
> - in __switch_to, read ldtr by sldt and compare the new ldt pointer
>    sldt is ucode that likely takes only a couple cycles
> - mostly matched given modify_ldt is rare
> - unmatched, don't write gsbase if gs indicating LDT

That won't be reliable -- LDTR could change more than once and be
reused between context switches.  If we went this route, I think we'd
put a u64 version in ldt_struct.  We'd also need to audit and fix up
every access to thread.fs/gsbase.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

RE: FSGSBASE ABI considerations "Bae, Chang Seok" <chang.seok.bae@intel.com> - 2017-07-31 23:30 +0200
  Re: FSGSBASE ABI considerations Andy Lutomirski <luto@kernel.org> - 2017-08-07 18:20 +0200

csiph-web