Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752669AbdFUJk3 (ORCPT ); Wed, 21 Jun 2017 05:40:29 -0400 Received: from mail.skyhub.de ([5.9.137.197]:52944 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751069AbdFUJk1 (ORCPT ); Wed, 21 Jun 2017 05:40:27 -0400 Date: Wed, 21 Jun 2017 11:40:15 +0200 From: Borislav Petkov To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Rik van Riel , Dave Hansen , Arjan van de Ven , Peter Zijlstra Subject: Re: [PATCH v3 02/11] x86/ldt: Simplify LDT switching logic Message-ID: <20170621094015.nknwc5iec7zn56xl@pd.tnic> References: <2a859ac01245f9594c58f9d0a8b2ed8a7cd2507e.1498022414.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2a859ac01245f9594c58f9d0a8b2ed8a7cd2507e.1498022414.git.luto@kernel.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1563 Lines: 42 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 > this: > > - /* 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)) > load_LDT(&next->context); > > 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 > Signed-off-by: Andy Lutomirski > --- > 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 -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.