]> www.infradead.org Git - users/dwmw2/linux.git/commit
bpf, x86, riscv, arm: no_caller_saved_registers for bpf_get_smp_processor_id()
authorEduard Zingerman <eddyz87@gmail.com>
Mon, 22 Jul 2024 23:38:37 +0000 (16:38 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 29 Jul 2024 22:05:05 +0000 (15:05 -0700)
commit91b7fbf3936f5c27d1673264dc24a713290e2165
treeebabfbc28ab41c57b9684db2bd8e588ae4fbc4b7
parent5b5f51bff1b66cedb62b5ba74a1878341204e057
bpf, x86, riscv, arm: no_caller_saved_registers for bpf_get_smp_processor_id()

The function bpf_get_smp_processor_id() is processed in a different
way, depending on the arch:
- on x86 verifier replaces call to bpf_get_smp_processor_id() with a
  sequence of instructions that modify only r0;
- on riscv64 jit replaces call to bpf_get_smp_processor_id() with a
  sequence of instructions that modify only r0;
- on arm64 jit replaces call to bpf_get_smp_processor_id() with a
  sequence of instructions that modify only r0 and tmp registers.

These rewrites satisfy attribute no_caller_saved_registers contract.
Allow rewrite of no_caller_saved_registers patterns for
bpf_get_smp_processor_id() in order to use this function as a canary
for no_caller_saved_registers tests.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240722233844.1406874-4-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
kernel/bpf/helpers.c
kernel/bpf/verifier.c