From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752781AbbCWM13 (ORCPT ); Mon, 23 Mar 2015 08:27:29 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41526 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbbCWM11 (ORCPT ); Mon, 23 Mar 2015 08:27:27 -0400 Date: Mon, 23 Mar 2015 05:26:49 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, luto@kernel.org, spender@grsecurity.net, dvlasenk@redhat.com, torvalds@linux-foundation.org, mingo@kernel.org, bp@alien8.de Reply-To: a.p.zijlstra@chello.nl, tglx@linutronix.de, linux-kernel@vger.kernel.org, bp@alien8.de, mingo@kernel.org, dvlasenk@redhat.com, torvalds@linux-foundation.org, hpa@zytor.com, luto@kernel.org, spender@grsecurity.net In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm/entry, perf: Explicitly optimize vm86 handling in code_segment_base() Git-Commit-ID: 383f3af3f88aadafe1fcf1948987ad538683fb8c 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: 383f3af3f88aadafe1fcf1948987ad538683fb8c Gitweb: http://git.kernel.org/tip/383f3af3f88aadafe1fcf1948987ad538683fb8c Author: Andy Lutomirski AuthorDate: Wed, 18 Mar 2015 18:33:30 -0700 Committer: Ingo Molnar CommitDate: Mon, 23 Mar 2015 11:13:41 +0100 x86/asm/entry, perf: Explicitly optimize vm86 handling in code_segment_base() There's no point in checking the VM bit on 64-bit, and, since we're explicitly checking it, we can use user_mode_ignore_vm86() after the check. While we're at it, rearrange the #ifdef slightly to make the code flow a bit clearer. Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brad Spengler Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/dc1457a734feccd03a19bb3538a7648582f57cdd.1426728647.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/perf_event.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 979963b..56f7e60 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -2147,18 +2147,19 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) static unsigned long code_segment_base(struct pt_regs *regs) { /* + * For IA32 we look at the GDT/LDT segment base to convert the + * effective IP to a linear address. + */ + +#ifdef CONFIG_X86_32 + /* * If we are in VM86 mode, add the segment offset to convert to a * linear address. */ if (regs->flags & X86_VM_MASK) return 0x10 * regs->cs; - /* - * For IA32 we look at the GDT/LDT segment base to convert the - * effective IP to a linear address. - */ -#ifdef CONFIG_X86_32 - if (user_mode(regs) && regs->cs != __USER_CS) + if (user_mode_ignore_vm86(regs) && regs->cs != __USER_CS) return get_segment_base(regs->cs); #else if (user_mode(regs) && !user_64bit_mode(regs) &&