OpenCloudOS-Kernel/arch/s390/kernel
Mark Rutland fee86a4ed5 ftrace: selftest: remove broken trace_direct_tramp
The ftrace selftest code has a trace_direct_tramp() function which it
uses as a direct call trampoline. This happens to work on x86, since the
direct call's return address is in the usual place, and can be returned
to via a RET, but in general the calling convention for direct calls is
different from regular function calls, and requires a trampoline written
in assembly.

On s390, regular function calls place the return address in %r14, and an
ftrace patch-site in an instrumented function places the trampoline's
return address (which is within the instrumented function) in %r0,
preserving the original %r14 value in-place. As a regular C function
will return to the address in %r14, using a C function as the trampoline
results in the trampoline returning to the caller of the instrumented
function, skipping the body of the instrumented function.

Note that the s390 issue is not detcted by the ftrace selftest code, as
the instrumented function is trivial, and returning back into the caller
happens to be equivalent.

On arm64, regular function calls place the return address in x30, and
an ftrace patch-site in an instrumented function saves this into r9
and places the trampoline's return address (within the instrumented
function) in x30. A regular C function will return to the address in
x30, but will not restore x9 into x30. Consequently, using a C function
as the trampoline results in returning to the trampoline's return
address having corrupted x30, such that when the instrumented function
returns, it will return back into itself.

To avoid future issues in this area, remove the trace_direct_tramp()
function, and require that each architecture with direct calls provides
a stub trampoline, named ftrace_stub_direct_tramp. This can be written
to handle the architecture's trampoline calling convention, and in
future could be used elsewhere (e.g. in the ftrace ops sample, to
measure the overhead of direct calls), so we may as well always build it
in.

Link: https://lkml.kernel.org/r/20230321140424.345218-8-revest@chromium.org

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Li Huafei <lihuafei1@huawei.com>
Cc: Xu Kuohai <xukuohai@huawei.com>
Signed-off-by: Florent Revest <revest@chromium.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2023-03-21 13:59:29 -04:00
..
syscalls arch: syscalls: simplify uapi/kapi directory creation 2022-03-31 12:03:46 +09:00
vdso32 s390/vdso: remove -nostdlib compiler flag 2021-11-16 12:29:19 +01:00
vdso64 s390/vdso: Drop '-shared' from KBUILD_CFLAGS_64 2023-01-26 12:42:57 +09:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Makefile s390/cpum_cf: merge source files for CPU Measurement counter facility 2023-01-25 20:51:10 +01:00
abs_lowcore.c s390/mm: allocate Absolute Lowcore Area in decompressor 2023-01-13 14:15:06 +01:00
alternative.c s390/alternatives: remove padding generation code 2022-05-17 15:16:28 +02:00
asm-offsets.c s390/entry: sort out physical vs virtual pointers usage in sie64a 2022-10-26 14:27:41 +02:00
audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
audit.h
cache.c s390/cache: change type from unsigned long long to unsigned long 2023-01-25 20:51:09 +01:00
compat_audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
compat_linux.c s390: use generic UID16 implementation 2019-01-18 09:33:18 +01:00
compat_linux.h s390/compat: cleanup compat_linux.h header file 2022-05-06 20:45:16 +02:00
compat_ptrace.h
compat_signal.c s390/vx: use simple assignments to access __vector128 members 2023-02-09 20:11:23 +01:00
cpcmd.c s390/cpcmd: use physical address for command and response 2021-10-26 15:21:28 +02:00
cpufeature.c s390/uvdevice: autoload module based on CPU facility 2022-07-19 16:18:49 +02:00
crash_dump.c s390/vx: use simple assignments to access __vector128 members 2023-02-09 20:11:23 +01:00
debug.c s390/debug: remove function type cast 2022-11-23 16:24:07 +01:00
diag.c s390/diag: make __diag8c_tmp_amode31 static 2023-02-06 11:13:54 +01:00
dis.c s390/disassembler: update opcode table 2021-12-16 19:58:07 +01:00
dumpstack.c exit: Add and use make_task_dead. 2021-12-13 12:04:45 -06:00
early.c s390/setup: do not complain about parameters handled in decompressor 2023-02-27 15:29:36 +01:00
early_printk.c s390/sclp: remove unused sclp_early_printk_forced 2020-09-21 08:08:44 +02:00
earlypgm.S s390: generate register offsets into pt_regs automatically 2022-05-25 11:46:02 +02:00
ebcdic.c
entry.S s390/mcck: cleanup user process termination path 2023-02-28 13:19:05 +01:00
entry.h s390: move __amode31_base declaration to proper header file 2023-01-13 14:15:07 +01:00
fpu.c s390/vx: add vx-insn.h wrapper include file 2022-12-06 16:18:23 +01:00
ftrace.c ftrace: Remove return value of ftrace_arch_modify_*() 2022-05-26 21:13:00 -04:00
ftrace.h s390: raise minimum supported machine generation to z10 2022-03-10 15:58:17 +01:00
guarded_storage.c
head64.S s390/early: fix sclp_early_sccb variable lifetime 2023-01-13 14:15:04 +01:00
idle.c s390 updates for 6.3 merge window 2023-02-21 15:09:17 -08:00
ima_arch.c s390/kexec_file: Disable kexec_load when IPLed secure 2019-04-29 10:44:03 +02:00
ipl.c s390/ipl: add loadparm parameter to eckd ipl/reipl data 2023-02-06 11:13:52 +01:00
ipl_vmparm.c s390/cio: remove unused include linux/spinlock.h from cio.h 2021-07-27 09:39:13 +02:00
irq.c s390/irq,idle: simplify idle check 2023-02-15 11:07:01 +01:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kdebugfs.c s390: no need to check return value of debugfs_create functions 2019-01-28 15:58:55 +01:00
kexec_elf.c kexec: Fix file verification on S390 2019-09-10 13:27:51 +01:00
kexec_image.c kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE 2019-08-19 21:54:15 -07:00
kprobes.c s390/kprobes: fix current_kprobe never cleared after kprobes reenter 2023-03-02 15:33:11 +01:00
kprobes.h s390/kprobes: define insn cache ops within private header file 2022-11-23 16:24:07 +01:00
kprobes_insn_page.S s390/kprobes: move insn_page to text segment 2020-10-09 23:45:30 +02:00
lgr.c s390/lgr: use simple assignment instead of memcpy 2022-02-06 23:31:29 +01:00
machine_kexec.c s390/mm: allocate Absolute Lowcore Area in decompressor 2023-01-13 14:15:06 +01:00
machine_kexec_file.c s390/kexec: fix ipl report address for kdump 2023-01-10 14:37:02 +01:00
machine_kexec_reloc.c s390/kaslr: add support for R_390_JMP_SLOT relocation type 2020-05-20 10:13:27 +02:00
mcount.S ftrace: selftest: remove broken trace_direct_tramp 2023-03-21 13:59:29 -04:00
module.c jump_label: mips: move module NOP patching into arch code 2022-06-24 09:48:55 +02:00
nmi.c s390/mcck: cleanup user process termination path 2023-02-28 13:19:05 +01:00
nospec-branch.c s390: raise minimum supported machine generation to z10 2022-03-10 15:58:17 +01:00
nospec-sysfs.c s390: introduce nospec_uses_trampoline() 2021-10-26 15:21:29 +02:00
numa.c drivers/base/node: consolidate node device subsystem initialization in node_dev_init() 2022-03-22 15:57:10 -07:00
os_info.c s390/mm: allocate Absolute Lowcore Area in decompressor 2023-01-13 14:15:06 +01:00
perf_cpum_cf.c s390 updates for 6.3 merge window 2023-02-21 15:09:17 -08:00
perf_cpum_cf_events.c s390/cpumf: add new extended counter set for IBM z16 2022-05-16 10:58:33 +02:00
perf_cpum_sf.c s390/cpum_sf: use READ_ONCE_ALIGNED_128() instead of 128-bit cmpxchg 2023-02-28 13:19:05 +01:00
perf_event.c s390/stack: add union to reflect kvm stack slot usages 2022-06-01 12:03:17 +02:00
perf_pai_crypto.c perf/core: Add perf_sample_save_raw_data() helper 2023-01-18 11:57:19 +01:00
perf_pai_ext.c s390 updates for 6.3 merge window 2023-02-21 15:09:17 -08:00
perf_regs.c perf/arch: Remove perf_sample_data::regs_user_copy 2020-11-09 18:12:34 +01:00
process.c s390/mm: start kernel with DAT enabled 2023-01-13 14:15:05 +01:00
processor.c s390/cpufeature: rework to allow more than only hwcap bits 2022-07-19 16:18:49 +02:00
ptrace.c s390/vx: use simple assignments to access __vector128 members 2023-02-09 20:11:23 +01:00
reipl.S s390: add missing ENDPROC statements to assembler functions 2019-05-02 13:54:11 +02:00
relocate_kernel.S s390/kexec: set end-of-ipl flag in last diag308 call 2022-04-25 13:54:12 +02:00
rethook.c s390/rethook: add local rethook header file 2023-02-06 11:13:53 +01:00
rethook.h s390/rethook: add local rethook header file 2023-02-06 11:13:53 +01:00
runtime_instr.c s390/runtime_instrumentation: fix storage key handling 2020-08-17 13:17:10 +02:00
setup.c s390/mem_detect: do not truncate online memory ranges info 2023-02-14 11:45:40 +01:00
signal.c s390/vx: use simple assignments to access __vector128 members 2023-02-09 20:11:23 +01:00
smp.c s390/smp: perform cpu reset before delegating work to target cpu 2023-02-28 13:19:06 +01:00
stacktrace.c s390/kprobes: replace kretprobe with rethook 2023-01-22 18:42:35 +01:00
sthyi.c s390/sthyi: use register pair instead of register asm 2021-06-18 16:41:22 +02:00
syscall.c s390: add support for BEAR enhancement facility 2021-10-26 15:21:29 +02:00
sysinfo.c s390/extable: move EX_TABLE define to asm-extable.h 2022-03-08 00:33:00 +01:00
text_amode31.S s390/tty3270: add support for diag 8c 2023-01-09 14:33:56 +01:00
time.c s390/stp: clock_delta should be signed 2022-05-11 14:40:57 +02:00
topology.c s390: remove invalid email address of Heiko Carstens 2022-02-06 23:31:29 +01:00
trace.c s390/ftrace: fix potential crashes when switching tracers 2020-04-22 16:20:55 +02:00
traps.c s390/traps: improve panic message for translation-specification exception 2022-03-27 22:18:38 +02:00
unwind_bc.c s390/unwind: avoid duplicated unwinding entries for kretprobes 2022-03-27 22:18:39 +02:00
uprobes.c s390: raise minimum supported machine generation to z10 2022-03-10 15:58:17 +01:00
uv.c KVM: s390: pv: avoid export before import if possible 2022-11-23 09:06:50 +00:00
vdso.c mm: remove zap_page_range and create zap_vma_pages 2023-01-18 17:12:55 -08:00
vmlinux.lds.S s390 updates for 6.3 merge window 2023-02-21 15:09:17 -08:00
vtime.c cputime: remove cputime_to_nsecs fallback 2022-12-27 12:52:17 +01:00