From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758448AbbJIRJl (ORCPT ); Fri, 9 Oct 2015 13:09:41 -0400 Received: from mail.skyhub.de ([78.46.96.112]:36815 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbbJIRJk (ORCPT ); Fri, 9 Oct 2015 13:09:40 -0400 Date: Fri, 9 Oct 2015 19:08:59 +0200 From: Borislav Petkov To: Brian Gerst Cc: Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , Denys Vlasenko , Linus Torvalds Subject: [PATCH] x86/entry/64/compat: Document sysenter_fix_flags's reason for existence Message-ID: <20151009170859.GA24266@pd.tnic> References: <19eb235828b2d2a52c53459e09f2974e15e65a35.1444091584.git.luto@kernel.org> <20151007111038.GC5046@nazgul.tnic> <20151007150509.GA23710@nazgul.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20151007150509.GA23710@nazgul.tnic> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov Date: Fri, 9 Oct 2015 19:04:09 +0200 Subject: [PATCH] x86/entry/64/compat: Document sysenter_fix_flags's reason for existence The code under the label can normally be inline, without the jumping back and forth but the latter is an optimization. Document that. Signed-off-by: Borislav Petkov --- arch/x86/entry/entry_64_compat.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index cf9641cd4796..92b0b27b43c6 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -102,6 +102,12 @@ ENTRY(entry_SYSENTER_compat) * NT was set instead of doing an unconditional popfq. * This needs to happen before enabling interrupts so that * we don't get preempted with NT set. + * + * NB.: sysenter_fix_flags is a label with the code under it moved + * out-of-line as an optimization: NT is unlikely to be set in the + * majority of the cases and instead of polluting the I$ unnecessarily, + * we're keeping that code behind a branch which will predict as + * not-taken and therefore its instructions won't be fetched. */ testl $X86_EFLAGS_NT, EFLAGS(%rsp) jnz sysenter_fix_flags -- 2.3.5 -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.