linux_dsm_epyc7002/arch/arm64/include/asm
Pratyush Anand 9f416319f4 arm64: fix unwind_frame() for filtered out fn for function graph tracing
do_task_stat() calls get_wchan(), which further does unwind_frame().
unwind_frame() restores frame->pc to original value in case function
graph tracer has modified a return address (LR) in a stack frame to hook
a function return. However, if function graph tracer has hit a filtered
function, then we can't unwind it as ftrace_push_return_trace() has
biased the index(frame->graph) with a 'huge negative'
offset(-FTRACE_NOTRACE_DEPTH).

Moreover, arm64 stack walker defines index(frame->graph) as unsigned
int, which can not compare a -ve number.

Similar problem we can have with calling of walk_stackframe() from
save_stack_trace_tsk() or dump_backtrace().

This patch fixes unwind_frame() to test the index for -ve value and
restore index accordingly before we can restore frame->pc.

Reproducer:

cd /sys/kernel/debug/tracing/
echo schedule > set_graph_notrace
echo 1 > options/display-graph
echo wakeup > current_tracer
ps -ef | grep -i agent

Above commands result in:
Unable to handle kernel paging request at virtual address ffff801bd3d1e000
pgd = ffff8003cbe97c00
[ffff801bd3d1e000] *pgd=0000000000000000, *pud=0000000000000000
Internal error: Oops: 96000006 [#1] SMP
[...]
CPU: 5 PID: 11696 Comm: ps Not tainted 4.11.0+ #33
[...]
task: ffff8003c21ba000 task.stack: ffff8003cc6c0000
PC is at unwind_frame+0x12c/0x180
LR is at get_wchan+0xd4/0x134
pc : [<ffff00000808892c>] lr : [<ffff0000080860b8>] pstate: 60000145
sp : ffff8003cc6c3ab0
x29: ffff8003cc6c3ab0 x28: 0000000000000001
x27: 0000000000000026 x26: 0000000000000026
x25: 00000000000012d8 x24: 0000000000000000
x23: ffff8003c1c04000 x22: ffff000008c83000
x21: ffff8003c1c00000 x20: 000000000000000f
x19: ffff8003c1bc0000 x18: 0000fffffc593690
x17: 0000000000000000 x16: 0000000000000001
x15: 0000b855670e2b60 x14: 0003e97f22cf1d0f
x13: 0000000000000001 x12: 0000000000000000
x11: 00000000e8f4883e x10: 0000000154f47ec8
x9 : 0000000070f367c0 x8 : 0000000000000000
x7 : 00008003f7290000 x6 : 0000000000000018
x5 : 0000000000000000 x4 : ffff8003c1c03cb0
x3 : ffff8003c1c03ca0 x2 : 00000017ffe80000
x1 : ffff8003cc6c3af8 x0 : ffff8003d3e9e000

Process ps (pid: 11696, stack limit = 0xffff8003cc6c0000)
Stack: (0xffff8003cc6c3ab0 to 0xffff8003cc6c4000)
[...]
[<ffff00000808892c>] unwind_frame+0x12c/0x180
[<ffff000008305008>] do_task_stat+0x864/0x870
[<ffff000008305c44>] proc_tgid_stat+0x3c/0x48
[<ffff0000082fde0c>] proc_single_show+0x5c/0xb8
[<ffff0000082b27e0>] seq_read+0x160/0x414
[<ffff000008289e6c>] __vfs_read+0x58/0x164
[<ffff00000828b164>] vfs_read+0x88/0x144
[<ffff00000828c2e8>] SyS_read+0x60/0xc0
[<ffff0000080834a0>] __sys_trace_return+0x0/0x4

Fixes: 20380bb390 (arm64: ftrace: fix a stack tracer's output under function graph tracer)
Signed-off-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
[catalin.marinas@arm.com: replace WARN_ON with WARN_ON_ONCE]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2018-02-23 13:46:38 +00:00
..
xen License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acenv.h
acpi.h arm64: mm: Remove arch_apei_flush_tlb_one() 2017-11-07 12:13:33 +01:00
alternative.h arm64: alternatives: use tpidr_el2 on VHE hosts 2018-01-13 10:44:33 +00:00
arch_gicv3.h irqchip/gic-v3: Add support for Range Selector (RS) feature 2017-10-19 11:22:34 +01:00
arch_timer.h First batch of KVM changes for 4.15 2017-11-16 13:00:24 -08:00
arm_dsu_pmu.h perf: ARM DynamIQ Shared Unit PMU support 2018-01-02 16:43:12 +00:00
arm-cci.h
asm-bug.h arm64: asm-bug: Renumber macro local labels to avoid clashes 2017-10-25 15:57:15 +01:00
asm-offsets.h
asm-uaccess.h arm64: mm: Add additional parameter to uaccess_ttbr0_disable 2018-01-17 13:57:49 +01:00
assembler.h KVM changes for 4.16 2018-02-10 13:16:35 -08:00
atomic_ll_sc.h arm64: Remove redundant mov from LL/SC cmpxchg 2017-05-15 18:30:10 +01:00
atomic_lse.h arm64: atomics: Remove '&' from '+&' asm constraint in lse atomics 2017-07-20 10:20:54 +01:00
atomic.h locking/atomic: Remove linux/atomic.h:atomic_fetch_or() 2016-06-16 10:48:32 +02:00
barrier.h arm64: Implement array_index_mask_nospec() 2018-02-06 22:53:30 +00:00
bitops.h
bitrev.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
boot.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
brk-imm.h arm64: move brk immediate argument definitions to separate header 2016-02-23 17:43:25 +00:00
bug.h arm64: Add ASM_BUG() 2017-08-08 16:28:13 +01:00
cache.h arm64: cache: Identify VPIPT I-caches 2017-03-20 16:17:02 +00:00
cacheflush.h arm64: KVM: Add invalidate_icache_range helper 2018-01-08 15:20:43 +01:00
checksum.h arm64: add missing conversion to __wsum in ip_fast_csum() 2017-06-29 16:32:43 +01:00
clocksource.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cmpxchg.h arm64: xchg: hazard against entire exchange variable 2017-05-09 17:44:50 +01:00
compat.h signal: unify compat_siginfo_t 2018-01-15 17:40:31 -06:00
compiler.h
cpu_ops.h
cpu.h arm64/sve: Probe SVE capabilities and usable vector lengths 2017-11-03 15:24:17 +00:00
cpucaps.h arm64: cpufeature: Detect CPU RAS Extentions 2018-01-16 15:05:48 +00:00
cpufeature.h arm64/sve: Report SVE to userspace via CPUID only if supported 2017-12-14 15:14:30 +00:00
cpuidle.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cputype.h arm64: Fix compilation error while accessing MPIDR_HWID_BITMASK from .S files 2018-02-19 12:13:29 +00:00
current.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
daifflags.h arm64: Move the async/fiq helpers to explicitly set process context flags 2017-11-02 15:55:41 +00:00
dcc.h arm64: dcc: simplify accessors 2016-09-09 11:41:13 +01:00
debug-monitors.h arm64: Add uprobe support 2016-11-07 18:15:21 +00:00
device.h xen/arm,arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..." 2017-05-02 11:14:42 +02:00
dma-mapping.h dma-mapping: move dma_mark_clean to dma-direct.h 2018-01-10 16:41:12 +01:00
dmi.h
efi.h arm64: kpti: Fix the interaction between ASID switching and software PAN 2018-01-16 17:37:48 +00:00
elf.h arm64: elf.h: Correct comment about READ_IMPLIES_EXEC propagation 2017-10-09 10:00:23 +01:00
esr.h arm64: kernel: Prepare for a DISR user 2018-01-16 15:07:12 +00:00
exception.h arm64: kernel: Prepare for a DISR user 2018-01-16 15:07:12 +00:00
exec.h arm64: suspend: Reconfigure PSTATE after resume from idle 2016-10-20 09:50:54 +01:00
extable.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fb.h
fixmap.h arm64: kaslr: Put kernel vectors address in separate data page 2017-12-11 13:41:20 +00:00
fpsimd.h arm64: fpsimd: Fix state leakage when migrating after sigreturn 2018-01-16 14:39:50 +00:00
fpsimdmacros.h arm64/sve: Low-level SVE architectural state manipulation functions 2017-11-03 15:24:14 +00:00
ftrace.h arm64: Fix misspellings in comments. 2016-03-04 18:19:17 +00:00
futex.h arm64: futex: Mask __user pointers prior to dereference 2018-02-06 22:53:42 +00:00
hardirq.h arm64: kdump: implement machine_crash_shutdown() 2017-04-05 18:29:15 +01:00
hugetlb.h arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables 2018-02-16 18:13:57 +00:00
hw_breakpoint.h arm64: cpufeature: Make ID reg accessor naming less counterintuitive 2017-04-04 16:55:41 +01:00
hwcap.h
hypervisor.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
insn.h arm64: Prevent cpu hotplug rwsem recursion 2017-05-26 10:10:45 +02:00
io.h ARM64: Implement pci_remap_cfgspace() interface 2017-04-24 13:53:13 -05:00
irq_work.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irq.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irqflags.h arm64: Move the async/fiq helpers to explicitly set process context flags 2017-11-02 15:55:41 +00:00
jump_label.h
kasan.h kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage 2018-02-06 18:32:43 -08:00
Kbuild arch: Remove clkdev.h asm-generic from Kbuild 2018-01-03 09:02:11 -08:00
kernel-pgtable.h arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0() 2018-02-06 22:53:14 +00:00
kexec.h arm64: kdump: implement machine_crash_shutdown() 2017-04-05 18:29:15 +01:00
kgdb.h arm64: kgdb: Match pstate size with gdbserver protocol 2016-06-16 19:20:51 +01:00
kprobes.h kprobes: move kprobe declarations to asm-generic/kprobes.h 2017-02-27 18:43:45 -08:00
kvm_arm.h KVM: arm64: Emulate RAS error registers and set HCR_EL2's TERR & TEA 2018-01-16 15:09:47 +00:00
kvm_asm.h arm64: Implement branch predictor hardening for Falkor 2018-01-08 18:47:07 +00:00
kvm_coproc.h
kvm_emulate.h KVM: arm64: Emulate RAS error registers and set HCR_EL2's TERR & TEA 2018-01-16 15:09:47 +00:00
kvm_host.h KVM changes for 4.16 2018-02-10 13:16:35 -08:00
kvm_hyp.h KVM: arm/arm64: Detangle kvm_mmu.h from kvm_hyp.h 2018-01-08 15:20:43 +01:00
kvm_mmio.h KVM: arm/arm64: Export mmio_read/write_bus 2016-05-20 15:39:42 +02:00
kvm_mmu.h arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables 2018-02-16 18:13:57 +00:00
linkage.h arm64: relax assembly code alignment from 16 byte to 4 byte 2017-09-18 11:20:19 +01:00
lse.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
memblock.h
memory.h kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage 2018-02-06 18:32:43 -08:00
mmu_context.h arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables 2018-02-16 18:13:57 +00:00
mmu.h arm64: sdei: Add trampoline code for remapping the kernel 2018-01-14 18:49:50 +00:00
mmzone.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
module.h arm64: ftrace: emit ftrace-mod.o contents through code 2017-12-01 13:04:59 +00:00
neon.h arm64: neon: Temporarily add a kernel_mode_begin_partial() definition 2017-08-04 15:10:12 +01:00
numa.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
page-def.h arm64: factor out PAGE_* and CONT_* definitions 2017-08-15 18:35:00 +01:00
page.h arm64: factor out PAGE_* and CONT_* definitions 2017-08-15 18:35:00 +01:00
paravirt.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
percpu.h arm64: alternatives: use tpidr_el2 on VHE hosts 2018-01-13 10:44:33 +00:00
perf_event.h arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type 2017-12-05 15:02:41 +01:00
pgalloc.h arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables 2018-02-16 18:13:57 +00:00
pgtable-hwdef.h KVM changes for 4.16 2018-02-10 13:16:35 -08:00
pgtable-prot.h KVM changes for 4.16 2018-02-10 13:16:35 -08:00
pgtable-types.h arch, mm: convert all architectures to use 5level-fixup.h 2017-03-09 11:48:47 -08:00
pgtable.h arm64: mm: Use READ_ONCE/WRITE_ONCE when accessing page tables 2018-02-16 18:13:57 +00:00
probes.h arm64: Remove reference to asm/opcodes.h 2016-12-05 10:42:34 +00:00
proc-fns.h arm64: mm: Move ASID from TTBR0 to TTBR1 2017-12-11 13:40:25 +00:00
processor.h 2nd set of arm64 updates for 4.16: 2018-02-08 10:44:25 -08:00
ptdump.h arm64: dump: Add checking for writable and exectuable pages 2016-11-07 18:15:04 +00:00
ptrace.h Merge branch 'arm64/exception-stack' of git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux into for-next/core 2017-08-09 15:37:49 +01:00
sdei.h arm64: sdei: Add trampoline code for remapping the kernel 2018-01-14 18:49:50 +00:00
seccomp.h
sections.h arm64: mmu: add the entry trampolines start/end section markers into sections.h 2018-01-14 18:49:50 +00:00
shmparam.h
signal32.h arm64: compat: Remove leftover variable declaration 2017-08-10 18:17:32 +01:00
simd.h arm64: neon: Forbid when irqs are disabled 2017-08-09 15:05:59 +01:00
smp_plat.h
smp.h arm64: kexec: have own crash_smp_send_stop() for crash dump for nonpanic cores 2017-08-21 18:01:04 +01:00
sparsemem.h arm64: add kconfig symbol to configure physical address size 2017-12-22 17:30:33 +00:00
spinlock_types.h locking/qrwlock, arm64: Move rwlock implementation over to qrwlocks 2017-10-25 10:57:25 +02:00
spinlock.h arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics 2018-02-06 22:53:11 +00:00
stack_pointer.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stackprotector.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stacktrace.h arm64: fix unwind_frame() for filtered out fn for function graph tracing 2018-02-23 13:46:38 +00:00
stage2_pgtable-nopmd.h kvm: arm64: Get rid of fake page table levels 2016-04-21 14:58:21 +02:00
stage2_pgtable-nopud.h kvm: arm64: Get rid of fake page table levels 2016-04-21 14:58:21 +02:00
stage2_pgtable.h kvm: arm64: Get rid of fake page table levels 2016-04-21 14:58:21 +02:00
stat.h
string.h arm64: uaccess: Implement *_flushcache variants 2017-08-09 12:16:26 +01:00
suspend.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sync_bitops.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
syscall.h
sysreg.h KVM: arm64: Emulate RAS error registers and set HCR_EL2's TERR & TEA 2018-01-16 15:09:47 +00:00
system_misc.h Merge branch 'aarch64/for-next/ras-apei' into aarch64/for-next/core 2017-06-26 10:54:27 +01:00
thread_info.h Construct init thread stack in the linker script rather than by union 2018-01-09 23:21:02 +00:00
timex.h arm64: Use physical counter for in-kernel reads when booted in EL2 2017-11-06 16:23:09 +01:00
tlb.h
tlbflush.h arm64: mm: Invalidate both kernel and user ASIDs when performing TLBI 2017-12-11 13:40:44 +00:00
topology.h Merge branch 'pm-cpufreq' 2017-11-13 01:34:49 +01:00
traps.h arm64: kernel: Survive corrected RAS errors notified by SError 2018-01-16 15:06:28 +00:00
uaccess.h arm64: uaccess: Formalise types for access_ok() 2018-02-19 13:59:58 +00:00
unistd32.h Remove compat_sys_getdents64() 2017-04-17 12:52:22 -04:00
unistd.h Remove compat_sys_getdents64() 2017-04-17 12:52:22 -04:00
uprobes.h arm64: Add uprobe support 2016-11-07 18:15:21 +00:00
vdso_datapage.h arm64: Add support for CLOCK_MONOTONIC_RAW in clock_gettime() vDSO 2016-07-12 16:06:32 +01:00
vdso.h
virt.h arm64: hyp-stub/KVM: Kill __hyp_get_vectors 2017-04-09 07:49:34 -07:00
vmap_stack.h arm64: Add vmap_stack header file 2018-01-13 10:45:03 +00:00
word-at-a-time.h Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00