Skip to content

Commit 0bcc62a

Browse files
Alexei Starovoitovanakryiko
authored andcommitted
bpf: Add bpf_nop_mov() asm macro.
bpf_nop_mov(var) asm macro emits nop register move: rX = rX. If 'var' is a scalar and not a fixed constant the verifier will assign ID to it. If it's later spilled the stack slot will carry that ID as well. Hence the range refining comparison "if rX < const" will update all copies including spilled slot. This macro is a temporary workaround until the verifier gets smarter. Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 907dbd3 commit 0bcc62a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/testing/selftests/bpf/bpf_experimental.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ l_true: \
323323
})
324324
#endif
325325

326+
#ifndef bpf_nop_mov
327+
#define bpf_nop_mov(var) \
328+
asm volatile("%[reg]=%[reg]"::[reg]"r"((short)var))
329+
#endif
330+
326331
/* Description
327332
* Assert that a conditional expression is true.
328333
* Returns

0 commit comments

Comments
 (0)