From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161091AbbBDOnT (ORCPT ); Wed, 4 Feb 2015 09:43:19 -0500 Received: from terminus.zytor.com ([198.137.202.10]:39045 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966016AbbBDOm6 (ORCPT ); Wed, 4 Feb 2015 09:42:58 -0500 Date: Wed, 4 Feb 2015 06:41:59 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: hpa@zytor.com, hillf.zj@alibaba-inc.com, luto@amacapital.net, linux-kernel@vger.kernel.org, keescook@chromium.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, aarcange@redhat.com, acme@kernel.org, Valdis.Kletnieks@vt.edu, paulus@samba.org, mingo@kernel.org, vince@deater.net Reply-To: tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, Valdis.Kletnieks@vt.edu, acme@kernel.org, aarcange@redhat.com, paulus@samba.org, mingo@kernel.org, vince@deater.net, hpa@zytor.com, hillf.zj@alibaba-inc.com, luto@amacapital.net, linux-kernel@vger.kernel.org, keescook@chromium.org In-Reply-To: <0db86397f968996fb772c443c251415b0b430ddd.1414190806.git.luto@amacapital.net> References: <0db86397f968996fb772c443c251415b0b430ddd.1414190806.git.luto@amacapital.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/x86] x86: Add a comment clarifying LDT context switching Git-Commit-ID: 22c4bd9fa921c2b1b3f2420d7b9dabbe982f3059 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 22c4bd9fa921c2b1b3f2420d7b9dabbe982f3059 Gitweb: http://git.kernel.org/tip/22c4bd9fa921c2b1b3f2420d7b9dabbe982f3059 Author: Andy Lutomirski AuthorDate: Fri, 24 Oct 2014 15:58:09 -0700 Committer: Ingo Molnar CommitDate: Wed, 4 Feb 2015 12:10:43 +0100 x86: Add a comment clarifying LDT context switching The code is correct, but only for a rather subtle reason. This confused me for quite a while when I read switch_mm, so clarify the code to avoid confusing other people, too. TBH, I wouldn't be surprised if this code was only correct by accident. Signed-off-by: Andy Lutomirski Reviewed-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Cc: Kees Cook Cc: Andrea Arcangeli Cc: Vince Weaver Cc: "hillf.zj" Cc: Valdis Kletnieks Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Linus Torvalds Link: http://lkml.kernel.org/r/0db86397f968996fb772c443c251415b0b430ddd.1414190806.git.luto@amacapital.net Signed-off-by: Ingo Molnar --- arch/x86/include/asm/mmu_context.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 4b75d59..52c1835 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -55,12 +55,14 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, /* * Load the LDT, if the LDT is different. * - * It's possible leave_mm(prev) has been called. If so, - * then prev->context.ldt could be out of sync with the - * LDT descriptor or the LDT register. This can only happen - * if prev->context.ldt is non-null, since we never free - * an LDT. But LDTs can't be shared across mms, so - * prev->context.ldt won't be equal to next->context.ldt. + * It's possible that prev->context.ldt doesn't match + * the LDT register. This can happen if leave_mm(prev) + * was called and then modify_ldt changed + * prev->context.ldt but suppressed an IPI to this CPU. + * In this case, prev->context.ldt != NULL, because we + * never free an LDT while the mm still exists. That + * means that next->context.ldt != prev->context.ldt, + * because mms never share an LDT. */ if (unlikely(prev->context.ldt != next->context.ldt)) load_LDT_nolock(&next->context);