All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Brad Spengler <spender@grsecurity.net>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 4/9] x86, perf: Explicitly optimize vm86 handling in code_segment_base
Date: Wed, 18 Mar 2015 18:33:30 -0700	[thread overview]
Message-ID: <dc1457a734feccd03a19bb3538a7648582f57cdd.1426728647.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1426728647.git.luto@kernel.org>
In-Reply-To: <cover.1426728647.git.luto@kernel.org>

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.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 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 979963bb3977..56f7e60ad732 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) &&
-- 
2.3.0


  parent reply	other threads:[~2015-03-19  1:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19  1:33 [PATCH 0/9] user_mode_vm removal and associated cleanups Andy Lutomirski
2015-03-19  1:33 ` [PATCH 1/9] x86, fault: Use TASK_SIZE_MAX in is_prefetch Andy Lutomirski
2015-03-23 12:20   ` [tip:x86/asm] x86/mm/fault: Use TASK_SIZE_MAX in is_prefetch() tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 2/9] x86, perf: Fix incorrect TIF_IA32 check in code_segment_base Andy Lutomirski
2015-03-23 12:20   ` [tip:x86/asm] x86/asm/entry, perf: Fix incorrect TIF_IA32 check in code_segment_base() tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 3/9] x86: Add user_mode_ignore_vm86 Andy Lutomirski
2015-03-23 12:26   ` [tip:x86/asm] x86/asm/entry: Add user_mode_ignore_vm86() tip-bot for Andy Lutomirski
2015-03-23 19:38     ` Andy Lutomirski
2015-03-24 19:44       ` Ingo Molnar
2015-03-24 19:46         ` Andy Lutomirski
2015-03-27 13:48           ` Denys Vlasenko
2015-03-29  7:08             ` Ingo Molnar
2015-03-29  9:02               ` [PATCH] x86/asm/entry: Remove user_mode_ignore_vm86() Ingo Molnar
2015-03-29 12:13                 ` Borislav Petkov
2015-03-29 13:24                   ` Andy Lutomirski
2015-03-31 12:39                 ` [tip:x86/asm] " tip-bot for Ingo Molnar
2015-03-29 11:55               ` [tip:x86/asm] x86/asm/entry: Add user_mode_ignore_vm86() Borislav Petkov
2015-03-29 20:51               ` Denys Vlasenko
2015-03-19  1:33 ` Andy Lutomirski [this message]
2015-03-23 12:26   ` [tip:x86/asm] x86/asm/entry, perf: Explicitly optimize vm86 handling in code_segment_base() tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 5/9] x86, traps: Use user_mode_ignore_vm86 where appropriate Andy Lutomirski
2015-03-23 12:27   ` [tip:x86/asm] x86/asm/entry: Use user_mode_ignore_vm86() " tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 6/9] x86: Make user_mode work correctly if regs came from vm86 mode Andy Lutomirski
2015-03-23 12:27   ` [tip:x86/asm] x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 7/9] x86, treewide: s/user_mode_vm/user_mode/g Andy Lutomirski
2015-03-23 12:27   ` [tip:x86/asm] x86/asm/entry: Change all 'user_mode_vm()' calls to 'user_mode()' tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 8/9] x86: Remove user_mode_vm Andy Lutomirski
2015-03-23 12:28   ` [tip:x86/asm] x86/asm/entry: Remove user_mode_vm() tip-bot for Andy Lutomirski
2015-03-19  1:33 ` [PATCH 9/9] x86, traps: Replace some open-coded vm86 checks with v8086_mode Andy Lutomirski
2015-03-23 12:28   ` [tip:x86/asm] x86/asm/entry: Replace some open-coded VM86 checks with v8086_mode() checks tip-bot for Andy Lutomirski
2015-03-19  6:33 ` [PATCH 0/9] user_mode_vm removal and associated cleanups Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc1457a734feccd03a19bb3538a7648582f57cdd.1426728647.git.luto@kernel.org \
    --to=luto@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dvlasenk@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spender@grsecurity.net \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.