File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -670,4 +670,47 @@ __naked void ldx_w_zero_extend_check(void)
670670 : __clobber_all );
671671}
672672
673+ SEC ("socket" )
674+ __description ("s>>=31" )
675+ __success __success_unpriv __retval (0 )
676+ __naked void arsh_31 (void )
677+ {
678+ /* Below is what LLVM generates in cilium's bpf_wiregard.o */
679+ asm volatile (" \
680+ call %[bpf_get_prandom_u32]; \
681+ w2 = w0; \
682+ w2 s>>= 31; \
683+ w2 &= -134; /* w2 becomes 0 or -134 */ \
684+ if w2 s> -1 goto +2; \
685+ if w2 != -136 goto +1; \
686+ w0 /= 0; \
687+ w0 = 0; \
688+ exit; \
689+ " :
690+ : __imm (bpf_get_prandom_u32 )
691+ : __clobber_all );
692+ }
693+
694+ SEC ("socket" )
695+ __description ("s>>=63" )
696+ __success __success_unpriv __retval (0 )
697+ __naked void arsh_63 (void )
698+ {
699+ /* Copy of arsh_31 with s/w/r/ */
700+ asm volatile (" \
701+ call %[bpf_get_prandom_u32]; \
702+ r2 = r0; \
703+ r2 <<= 32; \
704+ r2 s>>= 63; \
705+ r2 &= -134; \
706+ if r2 s> -1 goto +2; \
707+ if r2 != -136 goto +1; \
708+ r0 /= 0; \
709+ r0 = 0; \
710+ exit; \
711+ " :
712+ : __imm (bpf_get_prandom_u32 )
713+ : __clobber_all );
714+ }
715+
673716char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments