forked from Minki/linux
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 <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brad Spengler <spender@grsecurity.net> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/dc1457a734feccd03a19bb3538a7648582f57cdd.1426728647.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
a67e7277d0
commit
383f3af3f8
@ -2146,6 +2146,12 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
|
|||||||
*/
|
*/
|
||||||
static unsigned long code_segment_base(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
|
* If we are in VM86 mode, add the segment offset to convert to a
|
||||||
* linear address.
|
* linear address.
|
||||||
@ -2153,12 +2159,7 @@ static unsigned long code_segment_base(struct pt_regs *regs)
|
|||||||
if (regs->flags & X86_VM_MASK)
|
if (regs->flags & X86_VM_MASK)
|
||||||
return 0x10 * regs->cs;
|
return 0x10 * regs->cs;
|
||||||
|
|
||||||
/*
|
if (user_mode_ignore_vm86(regs) && regs->cs != __USER_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)
|
|
||||||
return get_segment_base(regs->cs);
|
return get_segment_base(regs->cs);
|
||||||
#else
|
#else
|
||||||
if (user_mode(regs) && !user_64bit_mode(regs) &&
|
if (user_mode(regs) && !user_64bit_mode(regs) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user