Skip to content

Commit e9f3c94

Browse files
eddyz87Kernel Patches Daemon
authored andcommitted
selftests/bpf: rename nocsr -> bpf_fastcall in selftests
Attribute used by LLVM implementation of the feature had been changed from no_caller_saved_registers to bpf_fastcall (see [1]). This commit replaces references to nocsr by references to bpf_fastcall to keep LLVM and selftests parts in sync. [1] llvm/llvm-project#105417 Acked-by: Yonghong Song <[email protected]> Signed-off-by: Eduard Zingerman <[email protected]>
1 parent ccf8363 commit e9f3c94

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tools/testing/selftests/bpf/prog_tests/verifier.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#include "verifier_movsx.skel.h"
5454
#include "verifier_netfilter_ctx.skel.h"
5555
#include "verifier_netfilter_retcode.skel.h"
56-
#include "verifier_nocsr.skel.h"
56+
#include "verifier_bpf_fastcall.skel.h"
5757
#include "verifier_or_jmp32_k.skel.h"
5858
#include "verifier_precision.skel.h"
5959
#include "verifier_prevent_map_lookup.skel.h"
@@ -177,7 +177,7 @@ void test_verifier_meta_access(void) { RUN(verifier_meta_access); }
177177
void test_verifier_movsx(void) { RUN(verifier_movsx); }
178178
void test_verifier_netfilter_ctx(void) { RUN(verifier_netfilter_ctx); }
179179
void test_verifier_netfilter_retcode(void) { RUN(verifier_netfilter_retcode); }
180-
void test_verifier_nocsr(void) { RUN(verifier_nocsr); }
180+
void test_verifier_bpf_fastcall(void) { RUN(verifier_bpf_fastcall); }
181181
void test_verifier_or_jmp32_k(void) { RUN(verifier_or_jmp32_k); }
182182
void test_verifier_precision(void) { RUN(verifier_precision); }
183183
void test_verifier_prevent_map_lookup(void) { RUN(verifier_prevent_map_lookup); }

tools/testing/selftests/bpf/progs/verifier_nocsr.c renamed to tools/testing/selftests/bpf/progs/verifier_bpf_fastcall.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ __naked void simple(void)
3939
: __clobber_all);
4040
}
4141

42-
/* The logic for detecting and verifying nocsr pattern is the same for
42+
/* The logic for detecting and verifying bpf_fastcall pattern is the same for
4343
* any arch, however x86 differs from arm64 or riscv64 in a way
4444
* bpf_get_smp_processor_id is rewritten:
4545
* - on x86 it is done by verifier
@@ -52,7 +52,7 @@ __naked void simple(void)
5252
*
5353
* It is really desirable to check instruction indexes in the xlated
5454
* patterns, so add this canary test to check that function rewrite by
55-
* jit is correctly processed by nocsr logic, keep the rest of the
55+
* jit is correctly processed by bpf_fastcall logic, keep the rest of the
5656
* tests as x86.
5757
*/
5858
SEC("raw_tp")
@@ -463,7 +463,7 @@ __naked static void bad_write_in_subprog_aux(void)
463463
{
464464
asm volatile (
465465
"r0 = 1;"
466-
"*(u64 *)(r1 - 0) = r0;" /* invalidates nocsr contract for caller: */
466+
"*(u64 *)(r1 - 0) = r0;" /* invalidates bpf_fastcall contract for caller: */
467467
"exit;" /* caller stack at -8 used outside of the pattern */
468468
::: __clobber_all);
469469
}
@@ -480,15 +480,15 @@ __naked void bad_helper_write(void)
480480
{
481481
asm volatile (
482482
"r1 = 1;"
483-
/* nocsr pattern with stack offset -8 */
483+
/* bpf_fastcall pattern with stack offset -8 */
484484
"*(u64 *)(r10 - 8) = r1;"
485485
"call %[bpf_get_smp_processor_id];"
486486
"r1 = *(u64 *)(r10 - 8);"
487487
"r1 = r10;"
488488
"r1 += -8;"
489489
"r2 = 1;"
490490
"r3 = 42;"
491-
/* read dst is fp[-8], thus nocsr rewrite not applied */
491+
/* read dst is fp[-8], thus bpf_fastcall rewrite not applied */
492492
"call %[bpf_probe_read_kernel];"
493493
"exit;"
494494
:
@@ -598,7 +598,7 @@ __arch_x86_64
598598
__log_level(4) __msg("stack depth 8")
599599
__xlated("2: r0 = &(void __percpu *)(r0)")
600600
__success
601-
__naked void helper_call_does_not_prevent_nocsr(void)
601+
__naked void helper_call_does_not_prevent_bpf_fastcall(void)
602602
{
603603
asm volatile (
604604
"r1 = 1;"
@@ -689,7 +689,7 @@ __naked int bpf_loop_interaction1(void)
689689
{
690690
asm volatile (
691691
"r1 = 1;"
692-
/* nocsr stack region at -16, but could be removed */
692+
/* bpf_fastcall stack region at -16, but could be removed */
693693
"*(u64 *)(r10 - 16) = r1;"
694694
"call %[bpf_get_smp_processor_id];"
695695
"r1 = *(u64 *)(r10 - 16);"
@@ -729,7 +729,7 @@ __naked int bpf_loop_interaction2(void)
729729
{
730730
asm volatile (
731731
"r1 = 42;"
732-
/* nocsr stack region at -16, cannot be removed */
732+
/* bpf_fastcall stack region at -16, cannot be removed */
733733
"*(u64 *)(r10 - 16) = r1;"
734734
"call %[bpf_get_smp_processor_id];"
735735
"r1 = *(u64 *)(r10 - 16);"
@@ -759,8 +759,8 @@ __msg("stack depth 512+0")
759759
__xlated("r0 = &(void __percpu *)(r0)")
760760
__success
761761
/* cumulative_stack_depth() stack usage is MAX_BPF_STACK,
762-
* called subprogram uses an additional slot for nocsr spill/fill,
763-
* since nocsr spill/fill could be removed the program still fits
762+
* called subprogram uses an additional slot for bpf_fastcall spill/fill,
763+
* since bpf_fastcall spill/fill could be removed the program still fits
764764
* in MAX_BPF_STACK and should be accepted.
765765
*/
766766
__naked int cumulative_stack_depth(void)
@@ -798,7 +798,7 @@ __xlated("3: r0 = &(void __percpu *)(r0)")
798798
__xlated("4: r0 = *(u32 *)(r0 +0)")
799799
__xlated("5: exit")
800800
__success
801-
__naked int nocsr_max_stack_ok(void)
801+
__naked int bpf_fastcall_max_stack_ok(void)
802802
{
803803
asm volatile(
804804
"r1 = 42;"
@@ -820,15 +820,15 @@ __arch_x86_64
820820
__log_level(4)
821821
__msg("stack depth 520")
822822
__failure
823-
__naked int nocsr_max_stack_fail(void)
823+
__naked int bpf_fastcall_max_stack_fail(void)
824824
{
825825
asm volatile(
826826
"r1 = 42;"
827827
"*(u64 *)(r10 - %[max_bpf_stack]) = r1;"
828828
"*(u64 *)(r10 - %[max_bpf_stack_8]) = r1;"
829829
"call %[bpf_get_smp_processor_id];"
830830
"r1 = *(u64 *)(r10 - %[max_bpf_stack_8]);"
831-
/* call to prandom blocks nocsr rewrite */
831+
/* call to prandom blocks bpf_fastcall rewrite */
832832
"*(u64 *)(r10 - %[max_bpf_stack_8]) = r1;"
833833
"call %[bpf_get_prandom_u32];"
834834
"r1 = *(u64 *)(r10 - %[max_bpf_stack_8]);"

0 commit comments

Comments
 (0)