Skip to content

Commit 7e2cf44

Browse files
eddyz87intel-lab-lkp
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#101228 Signed-off-by: Eduard Zingerman <[email protected]>
1 parent 759eda7 commit 7e2cf44

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"
@@ -176,7 +176,7 @@ void test_verifier_meta_access(void) { RUN(verifier_meta_access); }
176176
void test_verifier_movsx(void) { RUN(verifier_movsx); }
177177
void test_verifier_netfilter_ctx(void) { RUN(verifier_netfilter_ctx); }
178178
void test_verifier_netfilter_retcode(void) { RUN(verifier_netfilter_retcode); }
179-
void test_verifier_nocsr(void) { RUN(verifier_nocsr); }
179+
void test_verifier_bpf_fastcall(void) { RUN(verifier_bpf_fastcall); }
180180
void test_verifier_or_jmp32_k(void) { RUN(verifier_or_jmp32_k); }
181181
void test_verifier_precision(void) { RUN(verifier_precision); }
182182
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")
@@ -430,7 +430,7 @@ __naked static void bad_write_in_subprog_aux(void)
430430
{
431431
asm volatile (
432432
"r0 = 1;"
433-
"*(u64 *)(r1 - 0) = r0;" /* invalidates nocsr contract for caller: */
433+
"*(u64 *)(r1 - 0) = r0;" /* invalidates bpf_fastcall contract for caller: */
434434
"exit;" /* caller stack at -8 used outside of the pattern */
435435
::: __clobber_all);
436436
}
@@ -445,15 +445,15 @@ __naked void bad_helper_write(void)
445445
{
446446
asm volatile (
447447
"r1 = 1;"
448-
/* nocsr pattern with stack offset -8 */
448+
/* bpf_fastcall pattern with stack offset -8 */
449449
"*(u64 *)(r10 - 8) = r1;"
450450
"call %[bpf_get_smp_processor_id];"
451451
"r1 = *(u64 *)(r10 - 8);"
452452
"r1 = r10;"
453453
"r1 += -8;"
454454
"r2 = 1;"
455455
"r3 = 42;"
456-
/* read dst is fp[-8], thus nocsr rewrite not applied */
456+
/* read dst is fp[-8], thus bpf_fastcall rewrite not applied */
457457
"call %[bpf_probe_read_kernel];"
458458
"exit;"
459459
:
@@ -553,7 +553,7 @@ __arch_x86_64
553553
__log_level(4) __msg("stack depth 8")
554554
__xlated("2: r0 = &(void __percpu *)(r0)")
555555
__success
556-
__naked void helper_call_does_not_prevent_nocsr(void)
556+
__naked void helper_call_does_not_prevent_bpf_fastcall(void)
557557
{
558558
asm volatile (
559559
"r1 = 1;"
@@ -640,7 +640,7 @@ __naked int bpf_loop_interaction1(void)
640640
{
641641
asm volatile (
642642
"r1 = 1;"
643-
/* nocsr stack region at -16, but could be removed */
643+
/* bpf_fastcall stack region at -16, but could be removed */
644644
"*(u64 *)(r10 - 16) = r1;"
645645
"call %[bpf_get_smp_processor_id];"
646646
"r1 = *(u64 *)(r10 - 16);"
@@ -680,7 +680,7 @@ __naked int bpf_loop_interaction2(void)
680680
{
681681
asm volatile (
682682
"r1 = 42;"
683-
/* nocsr stack region at -16, cannot be removed */
683+
/* bpf_fastcall stack region at -16, cannot be removed */
684684
"*(u64 *)(r10 - 16) = r1;"
685685
"call %[bpf_get_smp_processor_id];"
686686
"r1 = *(u64 *)(r10 - 16);"
@@ -710,8 +710,8 @@ __msg("stack depth 512+0")
710710
__xlated("r0 = &(void __percpu *)(r0)")
711711
__success
712712
/* cumulative_stack_depth() stack usage is MAX_BPF_STACK,
713-
* called subprogram uses an additional slot for nocsr spill/fill,
714-
* since nocsr spill/fill could be removed the program still fits
713+
* called subprogram uses an additional slot for bpf_fastcall spill/fill,
714+
* since bpf_fastcall spill/fill could be removed the program still fits
715715
* in MAX_BPF_STACK and should be accepted.
716716
*/
717717
__naked int cumulative_stack_depth(void)
@@ -749,7 +749,7 @@ __xlated("3: r0 = &(void __percpu *)(r0)")
749749
__xlated("4: r0 = *(u32 *)(r0 +0)")
750750
__xlated("5: exit")
751751
__success
752-
__naked int nocsr_max_stack_ok(void)
752+
__naked int bpf_fastcall_max_stack_ok(void)
753753
{
754754
asm volatile(
755755
"r1 = 42;"
@@ -771,15 +771,15 @@ __arch_x86_64
771771
__log_level(4)
772772
__msg("stack depth 520")
773773
__failure
774-
__naked int nocsr_max_stack_fail(void)
774+
__naked int bpf_fastcall_max_stack_fail(void)
775775
{
776776
asm volatile(
777777
"r1 = 42;"
778778
"*(u64 *)(r10 - %[max_bpf_stack]) = r1;"
779779
"*(u64 *)(r10 - %[max_bpf_stack_8]) = r1;"
780780
"call %[bpf_get_smp_processor_id];"
781781
"r1 = *(u64 *)(r10 - %[max_bpf_stack_8]);"
782-
/* call to prandom blocks nocsr rewrite */
782+
/* call to prandom blocks bpf_fastcall rewrite */
783783
"*(u64 *)(r10 - %[max_bpf_stack_8]) = r1;"
784784
"call %[bpf_get_prandom_u32];"
785785
"r1 = *(u64 *)(r10 - %[max_bpf_stack_8]);"

0 commit comments

Comments
 (0)