alistair23-linux/arch/x86
Adrian Hunter 6855dc41b2 x86: Add entry trampolines to kcore
Without program headers for PTI entry trampoline pages, the trampoline
virtual addresses do not map to anything.

Example before:

 sudo gdb --quiet vmlinux /proc/kcore
 Reading symbols from vmlinux...done.
 [New process 1]
 Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.16.0 root=UUID=a6096b83-b763-4101-807e-f33daff63233'.
 #0  0x0000000000000000 in irq_stack_union ()
 (gdb) x /21ib 0xfffffe0000006000
    0xfffffe0000006000:  Cannot access memory at address 0xfffffe0000006000
 (gdb) quit

After:

 sudo gdb --quiet vmlinux /proc/kcore
 [sudo] password for ahunter:
 Reading symbols from vmlinux...done.
 [New process 1]
 Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.16.0-fix-4-00005-gd6e65a8b4072 root=UUID=a6096b83-b7'.
 #0  0x0000000000000000 in irq_stack_union ()
 (gdb) x /21ib 0xfffffe0000006000
    0xfffffe0000006000:  swapgs
    0xfffffe0000006003:  mov    %rsp,-0x3e12(%rip)        # 0xfffffe00000021f8
    0xfffffe000000600a:  xchg   %ax,%ax
    0xfffffe000000600c:  mov    %cr3,%rsp
    0xfffffe000000600f:  bts    $0x3f,%rsp
    0xfffffe0000006014:  and    $0xffffffffffffe7ff,%rsp
    0xfffffe000000601b:  mov    %rsp,%cr3
    0xfffffe000000601e:  mov    -0x3019(%rip),%rsp        # 0xfffffe000000300c
    0xfffffe0000006025:  pushq  $0x2b
    0xfffffe0000006027:  pushq  -0x3e35(%rip)        # 0xfffffe00000021f8
    0xfffffe000000602d:  push   %r11
    0xfffffe000000602f:  pushq  $0x33
    0xfffffe0000006031:  push   %rcx
    0xfffffe0000006032:  push   %rdi
    0xfffffe0000006033:  mov    $0xffffffff91a00010,%rdi
    0xfffffe000000603a:  callq  0xfffffe0000006046
    0xfffffe000000603f:  pause
    0xfffffe0000006041:  lfence
    0xfffffe0000006044:  jmp    0xfffffe000000603f
    0xfffffe0000006046:  mov    %rdi,(%rsp)
    0xfffffe000000604a:  retq
 (gdb) quit

In addition, entry trampolines all map to the same page.  Represent that
by giving the corresponding program headers in kcore the same offset.

This has the benefit that, when perf tools uses /proc/kcore as a source
for kernel object code, samples from different CPU trampolines are
aggregated together.  Note, such aggregation is normal for profiling
i.e. people want to profile the object code, not every different virtual
address the object code might be mapped to (across different processes
for example).

Notes by PeterZ:

This also adds the KCORE_REMAP functionality.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/1528289651-4113-4-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-08-14 19:13:26 -03:00
..
boot x86/boot: Fix if_changed build flip/flop bug 2018-07-25 12:00:08 +02:00
configs
crypto crypto: x86 - Add missing RETs 2018-07-01 23:33:20 +08:00
entry x86/entry/64: Remove %ebx handling from error_entry/exit 2018-07-24 10:07:36 +02:00
events Merge branch 'perf/urgent' into perf/core, to pick up fixes 2018-08-02 09:59:20 +02:00
hyperv x86/hyper-v: Fix the circular dependency in IPI enlightenment 2018-07-06 12:32:59 +02:00
ia32
include Merge branch 'perf/urgent' into perf/core, to pick up fixes 2018-08-02 09:59:20 +02:00
kernel Merge branch 'perf/urgent' into perf/core, to pick up fixes 2018-08-02 09:59:20 +02:00
kvm kvm, mm: account shadow page tables to kmemcg 2018-07-26 19:38:03 -07:00
lib libnvdimm for 4.18 2018-06-08 17:21:52 -07:00
math-emu
mm x86: Add entry trampolines to kcore 2018-08-14 19:13:26 -03:00
net treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
oprofile
pci treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
platform x86/efi: Access EFI MMIO data as unencrypted when SEV is active 2018-07-22 14:10:38 +02:00
power x86/mm: Stop pretending pgtable_l5_enabled is a variable 2018-05-19 11:56:57 +02:00
purgatory x86/purgatory: add missing FORCE to Makefile target 2018-07-14 11:11:09 -07:00
ras
realmode
tools
um mm: use vma_init() to initialize VMAs on stack and data segments 2018-07-26 19:38:03 -07:00
video
xen xen: fixes for 4.18-rc5 2018-07-14 12:30:13 -07:00
.gitignore
Kbuild
Kconfig x86/asm/memcpy_mcsafe: Fix copy_to_user_mcsafe() exception handling 2018-07-16 00:05:05 +02:00
Kconfig.cpu
Kconfig.debug x86, nfit_test: Add unit test for memcpy_mcsafe() 2018-05-22 23:18:31 -07:00
Makefile Merge branch 'linus' into x86/urgent 2018-06-22 21:20:35 +02:00
Makefile.um
Makefile_32.cpu