Re: [PATCH v3 02/11] x86/ldt: Simplify LDT switching logic
From: Borislav Petkov
Date: Wed Jun 21 2017 - 05:40:33 EST
On Tue, Jun 20, 2017 at 10:22:08PM -0700, Andy Lutomirski wrote:
> Originally, Linux reloaded the LDT whenever the prev mm or the next
> mm had an LDT. It was changed in 0bbed3beb4f2 ("[PATCH]
> Thread-Local Storage (TLS) support") (from the historical tree) like
> - /* load_LDT, if either the previous or next thread
> - * has a non-default LDT.
> + /*
> + * load the LDT, if the LDT is different:
> - if (next->context.size+prev->context.size)
> + if (unlikely(prev->context.ldt != next->context.ldt))
> The current code is unlikely to avoid any LDT reloads, since different
> mms won't share an LDT.
> When we redo lazy mode to stop flush IPIs without switching to
> init_mm, though, the current logic would become incorrect: it will
> be possible to have real_prev == next but nonetheless have a stale
> LDT descriptor.
> Simplify the code to update LDTR if either the previous or the next
> mm has an LDT, i.e. effectively restore the historical logic..
> While we're at it, clean up the code by moving all the ifdeffery to
> a header where it belongs.
> Acked-by: Rik van Riel <riel@xxxxxxxxxx>
> Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
> arch/x86/include/asm/mmu_context.h | 26 ++++++++++++++++++++++++++
> arch/x86/mm/tlb.c | 20 ++------------------
> 2 files changed, 28 insertions(+), 18 deletions(-)
Reviewed-by: Borislav Petkov <bp@xxxxxxx>
Good mailing practices for 400: avoid top-posting and trim the reply.