Loading...
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bpf.h>
4#include <limits.h>
5#include <bpf/bpf_helpers.h>
6#include "bpf_misc.h"
7
8#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
9 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
10 defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \
11 defined(__TARGET_ARCH_loongarch)) && \
12 __clang_major__ >= 18
13
14SEC("socket")
15__description("SDIV32, non-zero imm divisor, check 1")
16__success __success_unpriv __retval(-20)
17__naked void sdiv32_non_zero_imm_1(void)
18{
19 asm volatile (" \
20 w0 = -41; \
21 w0 s/= 2; \
22 exit; \
23" ::: __clobber_all);
24}
25
26SEC("socket")
27__description("SDIV32, non-zero imm divisor, check 2")
28__success __success_unpriv __retval(-20)
29__naked void sdiv32_non_zero_imm_2(void)
30{
31 asm volatile (" \
32 w0 = 41; \
33 w0 s/= -2; \
34 exit; \
35" ::: __clobber_all);
36}
37
38SEC("socket")
39__description("SDIV32, non-zero imm divisor, check 3")
40__success __success_unpriv __retval(20)
41__naked void sdiv32_non_zero_imm_3(void)
42{
43 asm volatile (" \
44 w0 = -41; \
45 w0 s/= -2; \
46 exit; \
47" ::: __clobber_all);
48}
49
50SEC("socket")
51__description("SDIV32, non-zero imm divisor, check 4")
52__success __success_unpriv __retval(-21)
53__naked void sdiv32_non_zero_imm_4(void)
54{
55 asm volatile (" \
56 w0 = -42; \
57 w0 s/= 2; \
58 exit; \
59" ::: __clobber_all);
60}
61
62SEC("socket")
63__description("SDIV32, non-zero imm divisor, check 5")
64__success __success_unpriv __retval(-21)
65__naked void sdiv32_non_zero_imm_5(void)
66{
67 asm volatile (" \
68 w0 = 42; \
69 w0 s/= -2; \
70 exit; \
71" ::: __clobber_all);
72}
73
74SEC("socket")
75__description("SDIV32, non-zero imm divisor, check 6")
76__success __success_unpriv __retval(21)
77__naked void sdiv32_non_zero_imm_6(void)
78{
79 asm volatile (" \
80 w0 = -42; \
81 w0 s/= -2; \
82 exit; \
83" ::: __clobber_all);
84}
85
86SEC("socket")
87__description("SDIV32, non-zero imm divisor, check 7")
88__success __success_unpriv __retval(21)
89__naked void sdiv32_non_zero_imm_7(void)
90{
91 asm volatile (" \
92 w0 = 42; \
93 w0 s/= 2; \
94 exit; \
95" ::: __clobber_all);
96}
97
98SEC("socket")
99__description("SDIV32, non-zero imm divisor, check 8")
100__success __success_unpriv __retval(20)
101__naked void sdiv32_non_zero_imm_8(void)
102{
103 asm volatile (" \
104 w0 = 41; \
105 w0 s/= 2; \
106 exit; \
107" ::: __clobber_all);
108}
109
110SEC("socket")
111__description("SDIV32, non-zero reg divisor, check 1")
112__success __success_unpriv __retval(-20)
113__naked void sdiv32_non_zero_reg_1(void)
114{
115 asm volatile (" \
116 w0 = -41; \
117 w1 = 2; \
118 w0 s/= w1; \
119 exit; \
120" ::: __clobber_all);
121}
122
123SEC("socket")
124__description("SDIV32, non-zero reg divisor, check 2")
125__success __success_unpriv __retval(-20)
126__naked void sdiv32_non_zero_reg_2(void)
127{
128 asm volatile (" \
129 w0 = 41; \
130 w1 = -2; \
131 w0 s/= w1; \
132 exit; \
133" ::: __clobber_all);
134}
135
136SEC("socket")
137__description("SDIV32, non-zero reg divisor, check 3")
138__success __success_unpriv __retval(20)
139__naked void sdiv32_non_zero_reg_3(void)
140{
141 asm volatile (" \
142 w0 = -41; \
143 w1 = -2; \
144 w0 s/= w1; \
145 exit; \
146" ::: __clobber_all);
147}
148
149SEC("socket")
150__description("SDIV32, non-zero reg divisor, check 4")
151__success __success_unpriv __retval(-21)
152__naked void sdiv32_non_zero_reg_4(void)
153{
154 asm volatile (" \
155 w0 = -42; \
156 w1 = 2; \
157 w0 s/= w1; \
158 exit; \
159" ::: __clobber_all);
160}
161
162SEC("socket")
163__description("SDIV32, non-zero reg divisor, check 5")
164__success __success_unpriv __retval(-21)
165__naked void sdiv32_non_zero_reg_5(void)
166{
167 asm volatile (" \
168 w0 = 42; \
169 w1 = -2; \
170 w0 s/= w1; \
171 exit; \
172" ::: __clobber_all);
173}
174
175SEC("socket")
176__description("SDIV32, non-zero reg divisor, check 6")
177__success __success_unpriv __retval(21)
178__naked void sdiv32_non_zero_reg_6(void)
179{
180 asm volatile (" \
181 w0 = -42; \
182 w1 = -2; \
183 w0 s/= w1; \
184 exit; \
185" ::: __clobber_all);
186}
187
188SEC("socket")
189__description("SDIV32, non-zero reg divisor, check 7")
190__success __success_unpriv __retval(21)
191__naked void sdiv32_non_zero_reg_7(void)
192{
193 asm volatile (" \
194 w0 = 42; \
195 w1 = 2; \
196 w0 s/= w1; \
197 exit; \
198" ::: __clobber_all);
199}
200
201SEC("socket")
202__description("SDIV32, non-zero reg divisor, check 8")
203__success __success_unpriv __retval(20)
204__naked void sdiv32_non_zero_reg_8(void)
205{
206 asm volatile (" \
207 w0 = 41; \
208 w1 = 2; \
209 w0 s/= w1; \
210 exit; \
211" ::: __clobber_all);
212}
213
214SEC("socket")
215__description("SDIV64, non-zero imm divisor, check 1")
216__success __success_unpriv __retval(-20)
217__naked void sdiv64_non_zero_imm_1(void)
218{
219 asm volatile (" \
220 r0 = -41; \
221 r0 s/= 2; \
222 exit; \
223" ::: __clobber_all);
224}
225
226SEC("socket")
227__description("SDIV64, non-zero imm divisor, check 2")
228__success __success_unpriv __retval(-20)
229__naked void sdiv64_non_zero_imm_2(void)
230{
231 asm volatile (" \
232 r0 = 41; \
233 r0 s/= -2; \
234 exit; \
235" ::: __clobber_all);
236}
237
238SEC("socket")
239__description("SDIV64, non-zero imm divisor, check 3")
240__success __success_unpriv __retval(20)
241__naked void sdiv64_non_zero_imm_3(void)
242{
243 asm volatile (" \
244 r0 = -41; \
245 r0 s/= -2; \
246 exit; \
247" ::: __clobber_all);
248}
249
250SEC("socket")
251__description("SDIV64, non-zero imm divisor, check 4")
252__success __success_unpriv __retval(-21)
253__naked void sdiv64_non_zero_imm_4(void)
254{
255 asm volatile (" \
256 r0 = -42; \
257 r0 s/= 2; \
258 exit; \
259" ::: __clobber_all);
260}
261
262SEC("socket")
263__description("SDIV64, non-zero imm divisor, check 5")
264__success __success_unpriv __retval(-21)
265__naked void sdiv64_non_zero_imm_5(void)
266{
267 asm volatile (" \
268 r0 = 42; \
269 r0 s/= -2; \
270 exit; \
271" ::: __clobber_all);
272}
273
274SEC("socket")
275__description("SDIV64, non-zero imm divisor, check 6")
276__success __success_unpriv __retval(21)
277__naked void sdiv64_non_zero_imm_6(void)
278{
279 asm volatile (" \
280 r0 = -42; \
281 r0 s/= -2; \
282 exit; \
283" ::: __clobber_all);
284}
285
286SEC("socket")
287__description("SDIV64, non-zero reg divisor, check 1")
288__success __success_unpriv __retval(-20)
289__naked void sdiv64_non_zero_reg_1(void)
290{
291 asm volatile (" \
292 r0 = -41; \
293 r1 = 2; \
294 r0 s/= r1; \
295 exit; \
296" ::: __clobber_all);
297}
298
299SEC("socket")
300__description("SDIV64, non-zero reg divisor, check 2")
301__success __success_unpriv __retval(-20)
302__naked void sdiv64_non_zero_reg_2(void)
303{
304 asm volatile (" \
305 r0 = 41; \
306 r1 = -2; \
307 r0 s/= r1; \
308 exit; \
309" ::: __clobber_all);
310}
311
312SEC("socket")
313__description("SDIV64, non-zero reg divisor, check 3")
314__success __success_unpriv __retval(20)
315__naked void sdiv64_non_zero_reg_3(void)
316{
317 asm volatile (" \
318 r0 = -41; \
319 r1 = -2; \
320 r0 s/= r1; \
321 exit; \
322" ::: __clobber_all);
323}
324
325SEC("socket")
326__description("SDIV64, non-zero reg divisor, check 4")
327__success __success_unpriv __retval(-21)
328__naked void sdiv64_non_zero_reg_4(void)
329{
330 asm volatile (" \
331 r0 = -42; \
332 r1 = 2; \
333 r0 s/= r1; \
334 exit; \
335" ::: __clobber_all);
336}
337
338SEC("socket")
339__description("SDIV64, non-zero reg divisor, check 5")
340__success __success_unpriv __retval(-21)
341__naked void sdiv64_non_zero_reg_5(void)
342{
343 asm volatile (" \
344 r0 = 42; \
345 r1 = -2; \
346 r0 s/= r1; \
347 exit; \
348" ::: __clobber_all);
349}
350
351SEC("socket")
352__description("SDIV64, non-zero reg divisor, check 6")
353__success __success_unpriv __retval(21)
354__naked void sdiv64_non_zero_reg_6(void)
355{
356 asm volatile (" \
357 r0 = -42; \
358 r1 = -2; \
359 r0 s/= r1; \
360 exit; \
361" ::: __clobber_all);
362}
363
364SEC("socket")
365__description("SMOD32, non-zero imm divisor, check 1")
366__success __success_unpriv __retval(-1)
367__naked void smod32_non_zero_imm_1(void)
368{
369 asm volatile (" \
370 w0 = -41; \
371 w0 s%%= 2; \
372 exit; \
373" ::: __clobber_all);
374}
375
376SEC("socket")
377__description("SMOD32, non-zero imm divisor, check 2")
378__success __success_unpriv __retval(1)
379__naked void smod32_non_zero_imm_2(void)
380{
381 asm volatile (" \
382 w0 = 41; \
383 w0 s%%= -2; \
384 exit; \
385" ::: __clobber_all);
386}
387
388SEC("socket")
389__description("SMOD32, non-zero imm divisor, check 3")
390__success __success_unpriv __retval(-1)
391__naked void smod32_non_zero_imm_3(void)
392{
393 asm volatile (" \
394 w0 = -41; \
395 w0 s%%= -2; \
396 exit; \
397" ::: __clobber_all);
398}
399
400SEC("socket")
401__description("SMOD32, non-zero imm divisor, check 4")
402__success __success_unpriv __retval(0)
403__naked void smod32_non_zero_imm_4(void)
404{
405 asm volatile (" \
406 w0 = -42; \
407 w0 s%%= 2; \
408 exit; \
409" ::: __clobber_all);
410}
411
412SEC("socket")
413__description("SMOD32, non-zero imm divisor, check 5")
414__success __success_unpriv __retval(0)
415__naked void smod32_non_zero_imm_5(void)
416{
417 asm volatile (" \
418 w0 = 42; \
419 w0 s%%= -2; \
420 exit; \
421" ::: __clobber_all);
422}
423
424SEC("socket")
425__description("SMOD32, non-zero imm divisor, check 6")
426__success __success_unpriv __retval(0)
427__naked void smod32_non_zero_imm_6(void)
428{
429 asm volatile (" \
430 w0 = -42; \
431 w0 s%%= -2; \
432 exit; \
433" ::: __clobber_all);
434}
435
436SEC("socket")
437__description("SMOD32, non-zero reg divisor, check 1")
438__success __success_unpriv __retval(-1)
439__naked void smod32_non_zero_reg_1(void)
440{
441 asm volatile (" \
442 w0 = -41; \
443 w1 = 2; \
444 w0 s%%= w1; \
445 exit; \
446" ::: __clobber_all);
447}
448
449SEC("socket")
450__description("SMOD32, non-zero reg divisor, check 2")
451__success __success_unpriv __retval(1)
452__naked void smod32_non_zero_reg_2(void)
453{
454 asm volatile (" \
455 w0 = 41; \
456 w1 = -2; \
457 w0 s%%= w1; \
458 exit; \
459" ::: __clobber_all);
460}
461
462SEC("socket")
463__description("SMOD32, non-zero reg divisor, check 3")
464__success __success_unpriv __retval(-1)
465__naked void smod32_non_zero_reg_3(void)
466{
467 asm volatile (" \
468 w0 = -41; \
469 w1 = -2; \
470 w0 s%%= w1; \
471 exit; \
472" ::: __clobber_all);
473}
474
475SEC("socket")
476__description("SMOD32, non-zero reg divisor, check 4")
477__success __success_unpriv __retval(0)
478__naked void smod32_non_zero_reg_4(void)
479{
480 asm volatile (" \
481 w0 = -42; \
482 w1 = 2; \
483 w0 s%%= w1; \
484 exit; \
485" ::: __clobber_all);
486}
487
488SEC("socket")
489__description("SMOD32, non-zero reg divisor, check 5")
490__success __success_unpriv __retval(0)
491__naked void smod32_non_zero_reg_5(void)
492{
493 asm volatile (" \
494 w0 = 42; \
495 w1 = -2; \
496 w0 s%%= w1; \
497 exit; \
498" ::: __clobber_all);
499}
500
501SEC("socket")
502__description("SMOD32, non-zero reg divisor, check 6")
503__success __success_unpriv __retval(0)
504__naked void smod32_non_zero_reg_6(void)
505{
506 asm volatile (" \
507 w0 = -42; \
508 w1 = -2; \
509 w0 s%%= w1; \
510 exit; \
511" ::: __clobber_all);
512}
513
514SEC("socket")
515__description("SMOD64, non-zero imm divisor, check 1")
516__success __success_unpriv __retval(-1)
517__naked void smod64_non_zero_imm_1(void)
518{
519 asm volatile (" \
520 r0 = -41; \
521 r0 s%%= 2; \
522 exit; \
523" ::: __clobber_all);
524}
525
526SEC("socket")
527__description("SMOD64, non-zero imm divisor, check 2")
528__success __success_unpriv __retval(1)
529__naked void smod64_non_zero_imm_2(void)
530{
531 asm volatile (" \
532 r0 = 41; \
533 r0 s%%= -2; \
534 exit; \
535" ::: __clobber_all);
536}
537
538SEC("socket")
539__description("SMOD64, non-zero imm divisor, check 3")
540__success __success_unpriv __retval(-1)
541__naked void smod64_non_zero_imm_3(void)
542{
543 asm volatile (" \
544 r0 = -41; \
545 r0 s%%= -2; \
546 exit; \
547" ::: __clobber_all);
548}
549
550SEC("socket")
551__description("SMOD64, non-zero imm divisor, check 4")
552__success __success_unpriv __retval(0)
553__naked void smod64_non_zero_imm_4(void)
554{
555 asm volatile (" \
556 r0 = -42; \
557 r0 s%%= 2; \
558 exit; \
559" ::: __clobber_all);
560}
561
562SEC("socket")
563__description("SMOD64, non-zero imm divisor, check 5")
564__success __success_unpriv __retval(-0)
565__naked void smod64_non_zero_imm_5(void)
566{
567 asm volatile (" \
568 r0 = 42; \
569 r0 s%%= -2; \
570 exit; \
571" ::: __clobber_all);
572}
573
574SEC("socket")
575__description("SMOD64, non-zero imm divisor, check 6")
576__success __success_unpriv __retval(0)
577__naked void smod64_non_zero_imm_6(void)
578{
579 asm volatile (" \
580 r0 = -42; \
581 r0 s%%= -2; \
582 exit; \
583" ::: __clobber_all);
584}
585
586SEC("socket")
587__description("SMOD64, non-zero imm divisor, check 7")
588__success __success_unpriv __retval(0)
589__naked void smod64_non_zero_imm_7(void)
590{
591 asm volatile (" \
592 r0 = 42; \
593 r0 s%%= 2; \
594 exit; \
595" ::: __clobber_all);
596}
597
598SEC("socket")
599__description("SMOD64, non-zero imm divisor, check 8")
600__success __success_unpriv __retval(1)
601__naked void smod64_non_zero_imm_8(void)
602{
603 asm volatile (" \
604 r0 = 41; \
605 r0 s%%= 2; \
606 exit; \
607" ::: __clobber_all);
608}
609
610SEC("socket")
611__description("SMOD64, non-zero reg divisor, check 1")
612__success __success_unpriv __retval(-1)
613__naked void smod64_non_zero_reg_1(void)
614{
615 asm volatile (" \
616 r0 = -41; \
617 r1 = 2; \
618 r0 s%%= r1; \
619 exit; \
620" ::: __clobber_all);
621}
622
623SEC("socket")
624__description("SMOD64, non-zero reg divisor, check 2")
625__success __success_unpriv __retval(1)
626__naked void smod64_non_zero_reg_2(void)
627{
628 asm volatile (" \
629 r0 = 41; \
630 r1 = -2; \
631 r0 s%%= r1; \
632 exit; \
633" ::: __clobber_all);
634}
635
636SEC("socket")
637__description("SMOD64, non-zero reg divisor, check 3")
638__success __success_unpriv __retval(-1)
639__naked void smod64_non_zero_reg_3(void)
640{
641 asm volatile (" \
642 r0 = -41; \
643 r1 = -2; \
644 r0 s%%= r1; \
645 exit; \
646" ::: __clobber_all);
647}
648
649SEC("socket")
650__description("SMOD64, non-zero reg divisor, check 4")
651__success __success_unpriv __retval(0)
652__naked void smod64_non_zero_reg_4(void)
653{
654 asm volatile (" \
655 r0 = -42; \
656 r1 = 2; \
657 r0 s%%= r1; \
658 exit; \
659" ::: __clobber_all);
660}
661
662SEC("socket")
663__description("SMOD64, non-zero reg divisor, check 5")
664__success __success_unpriv __retval(0)
665__naked void smod64_non_zero_reg_5(void)
666{
667 asm volatile (" \
668 r0 = 42; \
669 r1 = -2; \
670 r0 s%%= r1; \
671 exit; \
672" ::: __clobber_all);
673}
674
675SEC("socket")
676__description("SMOD64, non-zero reg divisor, check 6")
677__success __success_unpriv __retval(0)
678__naked void smod64_non_zero_reg_6(void)
679{
680 asm volatile (" \
681 r0 = -42; \
682 r1 = -2; \
683 r0 s%%= r1; \
684 exit; \
685" ::: __clobber_all);
686}
687
688SEC("socket")
689__description("SMOD64, non-zero reg divisor, check 7")
690__success __success_unpriv __retval(0)
691__naked void smod64_non_zero_reg_7(void)
692{
693 asm volatile (" \
694 r0 = 42; \
695 r1 = 2; \
696 r0 s%%= r1; \
697 exit; \
698" ::: __clobber_all);
699}
700
701SEC("socket")
702__description("SMOD64, non-zero reg divisor, check 8")
703__success __success_unpriv __retval(1)
704__naked void smod64_non_zero_reg_8(void)
705{
706 asm volatile (" \
707 r0 = 41; \
708 r1 = 2; \
709 r0 s%%= r1; \
710 exit; \
711" ::: __clobber_all);
712}
713
714SEC("socket")
715__description("SDIV32, zero divisor")
716__success __success_unpriv __retval(0)
717__naked void sdiv32_zero_divisor(void)
718{
719 asm volatile (" \
720 w0 = 42; \
721 w1 = 0; \
722 w2 = -1; \
723 w2 s/= w1; \
724 w0 = w2; \
725 exit; \
726" ::: __clobber_all);
727}
728
729SEC("socket")
730__description("SDIV64, zero divisor")
731__success __success_unpriv __retval(0)
732__naked void sdiv64_zero_divisor(void)
733{
734 asm volatile (" \
735 r0 = 42; \
736 r1 = 0; \
737 r2 = -1; \
738 r2 s/= r1; \
739 r0 = r2; \
740 exit; \
741" ::: __clobber_all);
742}
743
744SEC("socket")
745__description("SMOD32, zero divisor")
746__success __success_unpriv __retval(-1)
747__naked void smod32_zero_divisor(void)
748{
749 asm volatile (" \
750 w0 = 42; \
751 w1 = 0; \
752 w2 = -1; \
753 w2 s%%= w1; \
754 w0 = w2; \
755 exit; \
756" ::: __clobber_all);
757}
758
759SEC("socket")
760__description("SMOD64, zero divisor")
761__success __success_unpriv __retval(-1)
762__naked void smod64_zero_divisor(void)
763{
764 asm volatile (" \
765 r0 = 42; \
766 r1 = 0; \
767 r2 = -1; \
768 r2 s%%= r1; \
769 r0 = r2; \
770 exit; \
771" ::: __clobber_all);
772}
773
774SEC("socket")
775__description("SDIV64, overflow r/r, LLONG_MIN/-1")
776__success __retval(1)
777__arch_x86_64
778__xlated("0: r2 = 0x8000000000000000")
779__xlated("2: r3 = -1")
780__xlated("3: r4 = r2")
781__xlated("4: r11 = r3")
782__xlated("5: r11 += 1")
783__xlated("6: if r11 > 0x1 goto pc+4")
784__xlated("7: if r11 == 0x0 goto pc+1")
785__xlated("8: r2 = 0")
786__xlated("9: r2 = -r2")
787__xlated("10: goto pc+1")
788__xlated("11: r2 s/= r3")
789__xlated("12: r0 = 0")
790__xlated("13: if r2 != r4 goto pc+1")
791__xlated("14: r0 = 1")
792__xlated("15: exit")
793__naked void sdiv64_overflow_rr(void)
794{
795 asm volatile (" \
796 r2 = %[llong_min] ll; \
797 r3 = -1; \
798 r4 = r2; \
799 r2 s/= r3; \
800 r0 = 0; \
801 if r2 != r4 goto +1; \
802 r0 = 1; \
803 exit; \
804" :
805 : __imm_const(llong_min, LLONG_MIN)
806 : __clobber_all);
807}
808
809SEC("socket")
810__description("SDIV64, r/r, small_val/-1")
811__success __retval(-5)
812__arch_x86_64
813__xlated("0: r2 = 5")
814__xlated("1: r3 = -1")
815__xlated("2: r11 = r3")
816__xlated("3: r11 += 1")
817__xlated("4: if r11 > 0x1 goto pc+4")
818__xlated("5: if r11 == 0x0 goto pc+1")
819__xlated("6: r2 = 0")
820__xlated("7: r2 = -r2")
821__xlated("8: goto pc+1")
822__xlated("9: r2 s/= r3")
823__xlated("10: r0 = r2")
824__xlated("11: exit")
825__naked void sdiv64_rr_divisor_neg_1(void)
826{
827 asm volatile (" \
828 r2 = 5; \
829 r3 = -1; \
830 r2 s/= r3; \
831 r0 = r2; \
832 exit; \
833" :
834 :
835 : __clobber_all);
836}
837
838SEC("socket")
839__description("SDIV64, overflow r/i, LLONG_MIN/-1")
840__success __retval(1)
841__arch_x86_64
842__xlated("0: r2 = 0x8000000000000000")
843__xlated("2: r4 = r2")
844__xlated("3: r2 = -r2")
845__xlated("4: r0 = 0")
846__xlated("5: if r2 != r4 goto pc+1")
847__xlated("6: r0 = 1")
848__xlated("7: exit")
849__naked void sdiv64_overflow_ri(void)
850{
851 asm volatile (" \
852 r2 = %[llong_min] ll; \
853 r4 = r2; \
854 r2 s/= -1; \
855 r0 = 0; \
856 if r2 != r4 goto +1; \
857 r0 = 1; \
858 exit; \
859" :
860 : __imm_const(llong_min, LLONG_MIN)
861 : __clobber_all);
862}
863
864SEC("socket")
865__description("SDIV64, r/i, small_val/-1")
866__success __retval(-5)
867__arch_x86_64
868__xlated("0: r2 = 5")
869__xlated("1: r4 = r2")
870__xlated("2: r2 = -r2")
871__xlated("3: r0 = r2")
872__xlated("4: exit")
873__naked void sdiv64_ri_divisor_neg_1(void)
874{
875 asm volatile (" \
876 r2 = 5; \
877 r4 = r2; \
878 r2 s/= -1; \
879 r0 = r2; \
880 exit; \
881" :
882 :
883 : __clobber_all);
884}
885
886SEC("socket")
887__description("SDIV32, overflow r/r, INT_MIN/-1")
888__success __retval(1)
889__arch_x86_64
890__xlated("0: w2 = -2147483648")
891__xlated("1: w3 = -1")
892__xlated("2: w4 = w2")
893__xlated("3: r11 = r3")
894__xlated("4: w11 += 1")
895__xlated("5: if w11 > 0x1 goto pc+4")
896__xlated("6: if w11 == 0x0 goto pc+1")
897__xlated("7: w2 = 0")
898__xlated("8: w2 = -w2")
899__xlated("9: goto pc+1")
900__xlated("10: w2 s/= w3")
901__xlated("11: r0 = 0")
902__xlated("12: if w2 != w4 goto pc+1")
903__xlated("13: r0 = 1")
904__xlated("14: exit")
905__naked void sdiv32_overflow_rr(void)
906{
907 asm volatile (" \
908 w2 = %[int_min]; \
909 w3 = -1; \
910 w4 = w2; \
911 w2 s/= w3; \
912 r0 = 0; \
913 if w2 != w4 goto +1; \
914 r0 = 1; \
915 exit; \
916" :
917 : __imm_const(int_min, INT_MIN)
918 : __clobber_all);
919}
920
921SEC("socket")
922__description("SDIV32, r/r, small_val/-1")
923__success __retval(5)
924__arch_x86_64
925__xlated("0: w2 = -5")
926__xlated("1: w3 = -1")
927__xlated("2: w4 = w2")
928__xlated("3: r11 = r3")
929__xlated("4: w11 += 1")
930__xlated("5: if w11 > 0x1 goto pc+4")
931__xlated("6: if w11 == 0x0 goto pc+1")
932__xlated("7: w2 = 0")
933__xlated("8: w2 = -w2")
934__xlated("9: goto pc+1")
935__xlated("10: w2 s/= w3")
936__xlated("11: w0 = w2")
937__xlated("12: exit")
938__naked void sdiv32_rr_divisor_neg_1(void)
939{
940 asm volatile (" \
941 w2 = -5; \
942 w3 = -1; \
943 w4 = w2; \
944 w2 s/= w3; \
945 w0 = w2; \
946 exit; \
947" :
948 :
949 : __clobber_all);
950}
951
952SEC("socket")
953__description("SDIV32, overflow r/i, INT_MIN/-1")
954__success __retval(1)
955__arch_x86_64
956__xlated("0: w2 = -2147483648")
957__xlated("1: w4 = w2")
958__xlated("2: w2 = -w2")
959__xlated("3: r0 = 0")
960__xlated("4: if w2 != w4 goto pc+1")
961__xlated("5: r0 = 1")
962__xlated("6: exit")
963__naked void sdiv32_overflow_ri(void)
964{
965 asm volatile (" \
966 w2 = %[int_min]; \
967 w4 = w2; \
968 w2 s/= -1; \
969 r0 = 0; \
970 if w2 != w4 goto +1; \
971 r0 = 1; \
972 exit; \
973" :
974 : __imm_const(int_min, INT_MIN)
975 : __clobber_all);
976}
977
978SEC("socket")
979__description("SDIV32, r/i, small_val/-1")
980__success __retval(-5)
981__arch_x86_64
982__xlated("0: w2 = 5")
983__xlated("1: w4 = w2")
984__xlated("2: w2 = -w2")
985__xlated("3: w0 = w2")
986__xlated("4: exit")
987__naked void sdiv32_ri_divisor_neg_1(void)
988{
989 asm volatile (" \
990 w2 = 5; \
991 w4 = w2; \
992 w2 s/= -1; \
993 w0 = w2; \
994 exit; \
995" :
996 :
997 : __clobber_all);
998}
999
1000SEC("socket")
1001__description("SMOD64, overflow r/r, LLONG_MIN/-1")
1002__success __retval(0)
1003__arch_x86_64
1004__xlated("0: r2 = 0x8000000000000000")
1005__xlated("2: r3 = -1")
1006__xlated("3: r4 = r2")
1007__xlated("4: r11 = r3")
1008__xlated("5: r11 += 1")
1009__xlated("6: if r11 > 0x1 goto pc+3")
1010__xlated("7: if r11 == 0x1 goto pc+3")
1011__xlated("8: w2 = 0")
1012__xlated("9: goto pc+1")
1013__xlated("10: r2 s%= r3")
1014__xlated("11: r0 = r2")
1015__xlated("12: exit")
1016__naked void smod64_overflow_rr(void)
1017{
1018 asm volatile (" \
1019 r2 = %[llong_min] ll; \
1020 r3 = -1; \
1021 r4 = r2; \
1022 r2 s%%= r3; \
1023 r0 = r2; \
1024 exit; \
1025" :
1026 : __imm_const(llong_min, LLONG_MIN)
1027 : __clobber_all);
1028}
1029
1030SEC("socket")
1031__description("SMOD64, r/r, small_val/-1")
1032__success __retval(0)
1033__arch_x86_64
1034__xlated("0: r2 = 5")
1035__xlated("1: r3 = -1")
1036__xlated("2: r4 = r2")
1037__xlated("3: r11 = r3")
1038__xlated("4: r11 += 1")
1039__xlated("5: if r11 > 0x1 goto pc+3")
1040__xlated("6: if r11 == 0x1 goto pc+3")
1041__xlated("7: w2 = 0")
1042__xlated("8: goto pc+1")
1043__xlated("9: r2 s%= r3")
1044__xlated("10: r0 = r2")
1045__xlated("11: exit")
1046__naked void smod64_rr_divisor_neg_1(void)
1047{
1048 asm volatile (" \
1049 r2 = 5; \
1050 r3 = -1; \
1051 r4 = r2; \
1052 r2 s%%= r3; \
1053 r0 = r2; \
1054 exit; \
1055" :
1056 :
1057 : __clobber_all);
1058}
1059
1060SEC("socket")
1061__description("SMOD64, overflow r/i, LLONG_MIN/-1")
1062__success __retval(0)
1063__arch_x86_64
1064__xlated("0: r2 = 0x8000000000000000")
1065__xlated("2: r4 = r2")
1066__xlated("3: w2 = 0")
1067__xlated("4: r0 = r2")
1068__xlated("5: exit")
1069__naked void smod64_overflow_ri(void)
1070{
1071 asm volatile (" \
1072 r2 = %[llong_min] ll; \
1073 r4 = r2; \
1074 r2 s%%= -1; \
1075 r0 = r2; \
1076 exit; \
1077" :
1078 : __imm_const(llong_min, LLONG_MIN)
1079 : __clobber_all);
1080}
1081
1082SEC("socket")
1083__description("SMOD64, r/i, small_val/-1")
1084__success __retval(0)
1085__arch_x86_64
1086__xlated("0: r2 = 5")
1087__xlated("1: r4 = r2")
1088__xlated("2: w2 = 0")
1089__xlated("3: r0 = r2")
1090__xlated("4: exit")
1091__naked void smod64_ri_divisor_neg_1(void)
1092{
1093 asm volatile (" \
1094 r2 = 5; \
1095 r4 = r2; \
1096 r2 s%%= -1; \
1097 r0 = r2; \
1098 exit; \
1099" :
1100 :
1101 : __clobber_all);
1102}
1103
1104SEC("socket")
1105__description("SMOD32, overflow r/r, INT_MIN/-1")
1106__success __retval(0)
1107__arch_x86_64
1108__xlated("0: w2 = -2147483648")
1109__xlated("1: w3 = -1")
1110__xlated("2: w4 = w2")
1111__xlated("3: r11 = r3")
1112__xlated("4: w11 += 1")
1113__xlated("5: if w11 > 0x1 goto pc+3")
1114__xlated("6: if w11 == 0x1 goto pc+4")
1115__xlated("7: w2 = 0")
1116__xlated("8: goto pc+1")
1117__xlated("9: w2 s%= w3")
1118__xlated("10: goto pc+1")
1119__xlated("11: w2 = w2")
1120__xlated("12: r0 = r2")
1121__xlated("13: exit")
1122__naked void smod32_overflow_rr(void)
1123{
1124 asm volatile (" \
1125 w2 = %[int_min]; \
1126 w3 = -1; \
1127 w4 = w2; \
1128 w2 s%%= w3; \
1129 r0 = r2; \
1130 exit; \
1131" :
1132 : __imm_const(int_min, INT_MIN)
1133 : __clobber_all);
1134}
1135
1136SEC("socket")
1137__description("SMOD32, r/r, small_val/-1")
1138__success __retval(0)
1139__arch_x86_64
1140__xlated("0: w2 = -5")
1141__xlated("1: w3 = -1")
1142__xlated("2: w4 = w2")
1143__xlated("3: r11 = r3")
1144__xlated("4: w11 += 1")
1145__xlated("5: if w11 > 0x1 goto pc+3")
1146__xlated("6: if w11 == 0x1 goto pc+4")
1147__xlated("7: w2 = 0")
1148__xlated("8: goto pc+1")
1149__xlated("9: w2 s%= w3")
1150__xlated("10: goto pc+1")
1151__xlated("11: w2 = w2")
1152__xlated("12: r0 = r2")
1153__xlated("13: exit")
1154__naked void smod32_rr_divisor_neg_1(void)
1155{
1156 asm volatile (" \
1157 w2 = -5; \
1158 w3 = -1; \
1159 w4 = w2; \
1160 w2 s%%= w3; \
1161 r0 = r2; \
1162 exit; \
1163" :
1164 :
1165 : __clobber_all);
1166}
1167
1168SEC("socket")
1169__description("SMOD32, overflow r/i, INT_MIN/-1")
1170__success __retval(0)
1171__arch_x86_64
1172__xlated("0: w2 = -2147483648")
1173__xlated("1: w4 = w2")
1174__xlated("2: w2 = 0")
1175__xlated("3: r0 = r2")
1176__xlated("4: exit")
1177__naked void smod32_overflow_ri(void)
1178{
1179 asm volatile (" \
1180 w2 = %[int_min]; \
1181 w4 = w2; \
1182 w2 s%%= -1; \
1183 r0 = r2; \
1184 exit; \
1185" :
1186 : __imm_const(int_min, INT_MIN)
1187 : __clobber_all);
1188}
1189
1190SEC("socket")
1191__description("SMOD32, r/i, small_val/-1")
1192__success __retval(0)
1193__arch_x86_64
1194__xlated("0: w2 = 5")
1195__xlated("1: w4 = w2")
1196__xlated("2: w2 = 0")
1197__xlated("3: w0 = w2")
1198__xlated("4: exit")
1199__naked void smod32_ri_divisor_neg_1(void)
1200{
1201 asm volatile (" \
1202 w2 = 5; \
1203 w4 = w2; \
1204 w2 s%%= -1; \
1205 w0 = w2; \
1206 exit; \
1207" :
1208 :
1209 : __clobber_all);
1210}
1211
1212#else
1213
1214SEC("socket")
1215__description("cpuv4 is not supported by compiler or jit, use a dummy test")
1216__success
1217int dummy_test(void)
1218{
1219 return 0;
1220}
1221
1222#endif
1223
1224char _license[] SEC("license") = "GPL";
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/bpf.h>
4#include <bpf/bpf_helpers.h>
5#include "bpf_misc.h"
6
7#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
8 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
9 defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) || \
10 defined(__TARGET_ARCH_loongarch)) && \
11 __clang_major__ >= 18
12
13SEC("socket")
14__description("SDIV32, non-zero imm divisor, check 1")
15__success __success_unpriv __retval(-20)
16__naked void sdiv32_non_zero_imm_1(void)
17{
18 asm volatile (" \
19 w0 = -41; \
20 w0 s/= 2; \
21 exit; \
22" ::: __clobber_all);
23}
24
25SEC("socket")
26__description("SDIV32, non-zero imm divisor, check 2")
27__success __success_unpriv __retval(-20)
28__naked void sdiv32_non_zero_imm_2(void)
29{
30 asm volatile (" \
31 w0 = 41; \
32 w0 s/= -2; \
33 exit; \
34" ::: __clobber_all);
35}
36
37SEC("socket")
38__description("SDIV32, non-zero imm divisor, check 3")
39__success __success_unpriv __retval(20)
40__naked void sdiv32_non_zero_imm_3(void)
41{
42 asm volatile (" \
43 w0 = -41; \
44 w0 s/= -2; \
45 exit; \
46" ::: __clobber_all);
47}
48
49SEC("socket")
50__description("SDIV32, non-zero imm divisor, check 4")
51__success __success_unpriv __retval(-21)
52__naked void sdiv32_non_zero_imm_4(void)
53{
54 asm volatile (" \
55 w0 = -42; \
56 w0 s/= 2; \
57 exit; \
58" ::: __clobber_all);
59}
60
61SEC("socket")
62__description("SDIV32, non-zero imm divisor, check 5")
63__success __success_unpriv __retval(-21)
64__naked void sdiv32_non_zero_imm_5(void)
65{
66 asm volatile (" \
67 w0 = 42; \
68 w0 s/= -2; \
69 exit; \
70" ::: __clobber_all);
71}
72
73SEC("socket")
74__description("SDIV32, non-zero imm divisor, check 6")
75__success __success_unpriv __retval(21)
76__naked void sdiv32_non_zero_imm_6(void)
77{
78 asm volatile (" \
79 w0 = -42; \
80 w0 s/= -2; \
81 exit; \
82" ::: __clobber_all);
83}
84
85SEC("socket")
86__description("SDIV32, non-zero imm divisor, check 7")
87__success __success_unpriv __retval(21)
88__naked void sdiv32_non_zero_imm_7(void)
89{
90 asm volatile (" \
91 w0 = 42; \
92 w0 s/= 2; \
93 exit; \
94" ::: __clobber_all);
95}
96
97SEC("socket")
98__description("SDIV32, non-zero imm divisor, check 8")
99__success __success_unpriv __retval(20)
100__naked void sdiv32_non_zero_imm_8(void)
101{
102 asm volatile (" \
103 w0 = 41; \
104 w0 s/= 2; \
105 exit; \
106" ::: __clobber_all);
107}
108
109SEC("socket")
110__description("SDIV32, non-zero reg divisor, check 1")
111__success __success_unpriv __retval(-20)
112__naked void sdiv32_non_zero_reg_1(void)
113{
114 asm volatile (" \
115 w0 = -41; \
116 w1 = 2; \
117 w0 s/= w1; \
118 exit; \
119" ::: __clobber_all);
120}
121
122SEC("socket")
123__description("SDIV32, non-zero reg divisor, check 2")
124__success __success_unpriv __retval(-20)
125__naked void sdiv32_non_zero_reg_2(void)
126{
127 asm volatile (" \
128 w0 = 41; \
129 w1 = -2; \
130 w0 s/= w1; \
131 exit; \
132" ::: __clobber_all);
133}
134
135SEC("socket")
136__description("SDIV32, non-zero reg divisor, check 3")
137__success __success_unpriv __retval(20)
138__naked void sdiv32_non_zero_reg_3(void)
139{
140 asm volatile (" \
141 w0 = -41; \
142 w1 = -2; \
143 w0 s/= w1; \
144 exit; \
145" ::: __clobber_all);
146}
147
148SEC("socket")
149__description("SDIV32, non-zero reg divisor, check 4")
150__success __success_unpriv __retval(-21)
151__naked void sdiv32_non_zero_reg_4(void)
152{
153 asm volatile (" \
154 w0 = -42; \
155 w1 = 2; \
156 w0 s/= w1; \
157 exit; \
158" ::: __clobber_all);
159}
160
161SEC("socket")
162__description("SDIV32, non-zero reg divisor, check 5")
163__success __success_unpriv __retval(-21)
164__naked void sdiv32_non_zero_reg_5(void)
165{
166 asm volatile (" \
167 w0 = 42; \
168 w1 = -2; \
169 w0 s/= w1; \
170 exit; \
171" ::: __clobber_all);
172}
173
174SEC("socket")
175__description("SDIV32, non-zero reg divisor, check 6")
176__success __success_unpriv __retval(21)
177__naked void sdiv32_non_zero_reg_6(void)
178{
179 asm volatile (" \
180 w0 = -42; \
181 w1 = -2; \
182 w0 s/= w1; \
183 exit; \
184" ::: __clobber_all);
185}
186
187SEC("socket")
188__description("SDIV32, non-zero reg divisor, check 7")
189__success __success_unpriv __retval(21)
190__naked void sdiv32_non_zero_reg_7(void)
191{
192 asm volatile (" \
193 w0 = 42; \
194 w1 = 2; \
195 w0 s/= w1; \
196 exit; \
197" ::: __clobber_all);
198}
199
200SEC("socket")
201__description("SDIV32, non-zero reg divisor, check 8")
202__success __success_unpriv __retval(20)
203__naked void sdiv32_non_zero_reg_8(void)
204{
205 asm volatile (" \
206 w0 = 41; \
207 w1 = 2; \
208 w0 s/= w1; \
209 exit; \
210" ::: __clobber_all);
211}
212
213SEC("socket")
214__description("SDIV64, non-zero imm divisor, check 1")
215__success __success_unpriv __retval(-20)
216__naked void sdiv64_non_zero_imm_1(void)
217{
218 asm volatile (" \
219 r0 = -41; \
220 r0 s/= 2; \
221 exit; \
222" ::: __clobber_all);
223}
224
225SEC("socket")
226__description("SDIV64, non-zero imm divisor, check 2")
227__success __success_unpriv __retval(-20)
228__naked void sdiv64_non_zero_imm_2(void)
229{
230 asm volatile (" \
231 r0 = 41; \
232 r0 s/= -2; \
233 exit; \
234" ::: __clobber_all);
235}
236
237SEC("socket")
238__description("SDIV64, non-zero imm divisor, check 3")
239__success __success_unpriv __retval(20)
240__naked void sdiv64_non_zero_imm_3(void)
241{
242 asm volatile (" \
243 r0 = -41; \
244 r0 s/= -2; \
245 exit; \
246" ::: __clobber_all);
247}
248
249SEC("socket")
250__description("SDIV64, non-zero imm divisor, check 4")
251__success __success_unpriv __retval(-21)
252__naked void sdiv64_non_zero_imm_4(void)
253{
254 asm volatile (" \
255 r0 = -42; \
256 r0 s/= 2; \
257 exit; \
258" ::: __clobber_all);
259}
260
261SEC("socket")
262__description("SDIV64, non-zero imm divisor, check 5")
263__success __success_unpriv __retval(-21)
264__naked void sdiv64_non_zero_imm_5(void)
265{
266 asm volatile (" \
267 r0 = 42; \
268 r0 s/= -2; \
269 exit; \
270" ::: __clobber_all);
271}
272
273SEC("socket")
274__description("SDIV64, non-zero imm divisor, check 6")
275__success __success_unpriv __retval(21)
276__naked void sdiv64_non_zero_imm_6(void)
277{
278 asm volatile (" \
279 r0 = -42; \
280 r0 s/= -2; \
281 exit; \
282" ::: __clobber_all);
283}
284
285SEC("socket")
286__description("SDIV64, non-zero reg divisor, check 1")
287__success __success_unpriv __retval(-20)
288__naked void sdiv64_non_zero_reg_1(void)
289{
290 asm volatile (" \
291 r0 = -41; \
292 r1 = 2; \
293 r0 s/= r1; \
294 exit; \
295" ::: __clobber_all);
296}
297
298SEC("socket")
299__description("SDIV64, non-zero reg divisor, check 2")
300__success __success_unpriv __retval(-20)
301__naked void sdiv64_non_zero_reg_2(void)
302{
303 asm volatile (" \
304 r0 = 41; \
305 r1 = -2; \
306 r0 s/= r1; \
307 exit; \
308" ::: __clobber_all);
309}
310
311SEC("socket")
312__description("SDIV64, non-zero reg divisor, check 3")
313__success __success_unpriv __retval(20)
314__naked void sdiv64_non_zero_reg_3(void)
315{
316 asm volatile (" \
317 r0 = -41; \
318 r1 = -2; \
319 r0 s/= r1; \
320 exit; \
321" ::: __clobber_all);
322}
323
324SEC("socket")
325__description("SDIV64, non-zero reg divisor, check 4")
326__success __success_unpriv __retval(-21)
327__naked void sdiv64_non_zero_reg_4(void)
328{
329 asm volatile (" \
330 r0 = -42; \
331 r1 = 2; \
332 r0 s/= r1; \
333 exit; \
334" ::: __clobber_all);
335}
336
337SEC("socket")
338__description("SDIV64, non-zero reg divisor, check 5")
339__success __success_unpriv __retval(-21)
340__naked void sdiv64_non_zero_reg_5(void)
341{
342 asm volatile (" \
343 r0 = 42; \
344 r1 = -2; \
345 r0 s/= r1; \
346 exit; \
347" ::: __clobber_all);
348}
349
350SEC("socket")
351__description("SDIV64, non-zero reg divisor, check 6")
352__success __success_unpriv __retval(21)
353__naked void sdiv64_non_zero_reg_6(void)
354{
355 asm volatile (" \
356 r0 = -42; \
357 r1 = -2; \
358 r0 s/= r1; \
359 exit; \
360" ::: __clobber_all);
361}
362
363SEC("socket")
364__description("SMOD32, non-zero imm divisor, check 1")
365__success __success_unpriv __retval(-1)
366__naked void smod32_non_zero_imm_1(void)
367{
368 asm volatile (" \
369 w0 = -41; \
370 w0 s%%= 2; \
371 exit; \
372" ::: __clobber_all);
373}
374
375SEC("socket")
376__description("SMOD32, non-zero imm divisor, check 2")
377__success __success_unpriv __retval(1)
378__naked void smod32_non_zero_imm_2(void)
379{
380 asm volatile (" \
381 w0 = 41; \
382 w0 s%%= -2; \
383 exit; \
384" ::: __clobber_all);
385}
386
387SEC("socket")
388__description("SMOD32, non-zero imm divisor, check 3")
389__success __success_unpriv __retval(-1)
390__naked void smod32_non_zero_imm_3(void)
391{
392 asm volatile (" \
393 w0 = -41; \
394 w0 s%%= -2; \
395 exit; \
396" ::: __clobber_all);
397}
398
399SEC("socket")
400__description("SMOD32, non-zero imm divisor, check 4")
401__success __success_unpriv __retval(0)
402__naked void smod32_non_zero_imm_4(void)
403{
404 asm volatile (" \
405 w0 = -42; \
406 w0 s%%= 2; \
407 exit; \
408" ::: __clobber_all);
409}
410
411SEC("socket")
412__description("SMOD32, non-zero imm divisor, check 5")
413__success __success_unpriv __retval(0)
414__naked void smod32_non_zero_imm_5(void)
415{
416 asm volatile (" \
417 w0 = 42; \
418 w0 s%%= -2; \
419 exit; \
420" ::: __clobber_all);
421}
422
423SEC("socket")
424__description("SMOD32, non-zero imm divisor, check 6")
425__success __success_unpriv __retval(0)
426__naked void smod32_non_zero_imm_6(void)
427{
428 asm volatile (" \
429 w0 = -42; \
430 w0 s%%= -2; \
431 exit; \
432" ::: __clobber_all);
433}
434
435SEC("socket")
436__description("SMOD32, non-zero reg divisor, check 1")
437__success __success_unpriv __retval(-1)
438__naked void smod32_non_zero_reg_1(void)
439{
440 asm volatile (" \
441 w0 = -41; \
442 w1 = 2; \
443 w0 s%%= w1; \
444 exit; \
445" ::: __clobber_all);
446}
447
448SEC("socket")
449__description("SMOD32, non-zero reg divisor, check 2")
450__success __success_unpriv __retval(1)
451__naked void smod32_non_zero_reg_2(void)
452{
453 asm volatile (" \
454 w0 = 41; \
455 w1 = -2; \
456 w0 s%%= w1; \
457 exit; \
458" ::: __clobber_all);
459}
460
461SEC("socket")
462__description("SMOD32, non-zero reg divisor, check 3")
463__success __success_unpriv __retval(-1)
464__naked void smod32_non_zero_reg_3(void)
465{
466 asm volatile (" \
467 w0 = -41; \
468 w1 = -2; \
469 w0 s%%= w1; \
470 exit; \
471" ::: __clobber_all);
472}
473
474SEC("socket")
475__description("SMOD32, non-zero reg divisor, check 4")
476__success __success_unpriv __retval(0)
477__naked void smod32_non_zero_reg_4(void)
478{
479 asm volatile (" \
480 w0 = -42; \
481 w1 = 2; \
482 w0 s%%= w1; \
483 exit; \
484" ::: __clobber_all);
485}
486
487SEC("socket")
488__description("SMOD32, non-zero reg divisor, check 5")
489__success __success_unpriv __retval(0)
490__naked void smod32_non_zero_reg_5(void)
491{
492 asm volatile (" \
493 w0 = 42; \
494 w1 = -2; \
495 w0 s%%= w1; \
496 exit; \
497" ::: __clobber_all);
498}
499
500SEC("socket")
501__description("SMOD32, non-zero reg divisor, check 6")
502__success __success_unpriv __retval(0)
503__naked void smod32_non_zero_reg_6(void)
504{
505 asm volatile (" \
506 w0 = -42; \
507 w1 = -2; \
508 w0 s%%= w1; \
509 exit; \
510" ::: __clobber_all);
511}
512
513SEC("socket")
514__description("SMOD64, non-zero imm divisor, check 1")
515__success __success_unpriv __retval(-1)
516__naked void smod64_non_zero_imm_1(void)
517{
518 asm volatile (" \
519 r0 = -41; \
520 r0 s%%= 2; \
521 exit; \
522" ::: __clobber_all);
523}
524
525SEC("socket")
526__description("SMOD64, non-zero imm divisor, check 2")
527__success __success_unpriv __retval(1)
528__naked void smod64_non_zero_imm_2(void)
529{
530 asm volatile (" \
531 r0 = 41; \
532 r0 s%%= -2; \
533 exit; \
534" ::: __clobber_all);
535}
536
537SEC("socket")
538__description("SMOD64, non-zero imm divisor, check 3")
539__success __success_unpriv __retval(-1)
540__naked void smod64_non_zero_imm_3(void)
541{
542 asm volatile (" \
543 r0 = -41; \
544 r0 s%%= -2; \
545 exit; \
546" ::: __clobber_all);
547}
548
549SEC("socket")
550__description("SMOD64, non-zero imm divisor, check 4")
551__success __success_unpriv __retval(0)
552__naked void smod64_non_zero_imm_4(void)
553{
554 asm volatile (" \
555 r0 = -42; \
556 r0 s%%= 2; \
557 exit; \
558" ::: __clobber_all);
559}
560
561SEC("socket")
562__description("SMOD64, non-zero imm divisor, check 5")
563__success __success_unpriv __retval(-0)
564__naked void smod64_non_zero_imm_5(void)
565{
566 asm volatile (" \
567 r0 = 42; \
568 r0 s%%= -2; \
569 exit; \
570" ::: __clobber_all);
571}
572
573SEC("socket")
574__description("SMOD64, non-zero imm divisor, check 6")
575__success __success_unpriv __retval(0)
576__naked void smod64_non_zero_imm_6(void)
577{
578 asm volatile (" \
579 r0 = -42; \
580 r0 s%%= -2; \
581 exit; \
582" ::: __clobber_all);
583}
584
585SEC("socket")
586__description("SMOD64, non-zero imm divisor, check 7")
587__success __success_unpriv __retval(0)
588__naked void smod64_non_zero_imm_7(void)
589{
590 asm volatile (" \
591 r0 = 42; \
592 r0 s%%= 2; \
593 exit; \
594" ::: __clobber_all);
595}
596
597SEC("socket")
598__description("SMOD64, non-zero imm divisor, check 8")
599__success __success_unpriv __retval(1)
600__naked void smod64_non_zero_imm_8(void)
601{
602 asm volatile (" \
603 r0 = 41; \
604 r0 s%%= 2; \
605 exit; \
606" ::: __clobber_all);
607}
608
609SEC("socket")
610__description("SMOD64, non-zero reg divisor, check 1")
611__success __success_unpriv __retval(-1)
612__naked void smod64_non_zero_reg_1(void)
613{
614 asm volatile (" \
615 r0 = -41; \
616 r1 = 2; \
617 r0 s%%= r1; \
618 exit; \
619" ::: __clobber_all);
620}
621
622SEC("socket")
623__description("SMOD64, non-zero reg divisor, check 2")
624__success __success_unpriv __retval(1)
625__naked void smod64_non_zero_reg_2(void)
626{
627 asm volatile (" \
628 r0 = 41; \
629 r1 = -2; \
630 r0 s%%= r1; \
631 exit; \
632" ::: __clobber_all);
633}
634
635SEC("socket")
636__description("SMOD64, non-zero reg divisor, check 3")
637__success __success_unpriv __retval(-1)
638__naked void smod64_non_zero_reg_3(void)
639{
640 asm volatile (" \
641 r0 = -41; \
642 r1 = -2; \
643 r0 s%%= r1; \
644 exit; \
645" ::: __clobber_all);
646}
647
648SEC("socket")
649__description("SMOD64, non-zero reg divisor, check 4")
650__success __success_unpriv __retval(0)
651__naked void smod64_non_zero_reg_4(void)
652{
653 asm volatile (" \
654 r0 = -42; \
655 r1 = 2; \
656 r0 s%%= r1; \
657 exit; \
658" ::: __clobber_all);
659}
660
661SEC("socket")
662__description("SMOD64, non-zero reg divisor, check 5")
663__success __success_unpriv __retval(0)
664__naked void smod64_non_zero_reg_5(void)
665{
666 asm volatile (" \
667 r0 = 42; \
668 r1 = -2; \
669 r0 s%%= r1; \
670 exit; \
671" ::: __clobber_all);
672}
673
674SEC("socket")
675__description("SMOD64, non-zero reg divisor, check 6")
676__success __success_unpriv __retval(0)
677__naked void smod64_non_zero_reg_6(void)
678{
679 asm volatile (" \
680 r0 = -42; \
681 r1 = -2; \
682 r0 s%%= r1; \
683 exit; \
684" ::: __clobber_all);
685}
686
687SEC("socket")
688__description("SMOD64, non-zero reg divisor, check 7")
689__success __success_unpriv __retval(0)
690__naked void smod64_non_zero_reg_7(void)
691{
692 asm volatile (" \
693 r0 = 42; \
694 r1 = 2; \
695 r0 s%%= r1; \
696 exit; \
697" ::: __clobber_all);
698}
699
700SEC("socket")
701__description("SMOD64, non-zero reg divisor, check 8")
702__success __success_unpriv __retval(1)
703__naked void smod64_non_zero_reg_8(void)
704{
705 asm volatile (" \
706 r0 = 41; \
707 r1 = 2; \
708 r0 s%%= r1; \
709 exit; \
710" ::: __clobber_all);
711}
712
713SEC("socket")
714__description("SDIV32, zero divisor")
715__success __success_unpriv __retval(0)
716__naked void sdiv32_zero_divisor(void)
717{
718 asm volatile (" \
719 w0 = 42; \
720 w1 = 0; \
721 w2 = -1; \
722 w2 s/= w1; \
723 w0 = w2; \
724 exit; \
725" ::: __clobber_all);
726}
727
728SEC("socket")
729__description("SDIV64, zero divisor")
730__success __success_unpriv __retval(0)
731__naked void sdiv64_zero_divisor(void)
732{
733 asm volatile (" \
734 r0 = 42; \
735 r1 = 0; \
736 r2 = -1; \
737 r2 s/= r1; \
738 r0 = r2; \
739 exit; \
740" ::: __clobber_all);
741}
742
743SEC("socket")
744__description("SMOD32, zero divisor")
745__success __success_unpriv __retval(-1)
746__naked void smod32_zero_divisor(void)
747{
748 asm volatile (" \
749 w0 = 42; \
750 w1 = 0; \
751 w2 = -1; \
752 w2 s%%= w1; \
753 w0 = w2; \
754 exit; \
755" ::: __clobber_all);
756}
757
758SEC("socket")
759__description("SMOD64, zero divisor")
760__success __success_unpriv __retval(-1)
761__naked void smod64_zero_divisor(void)
762{
763 asm volatile (" \
764 r0 = 42; \
765 r1 = 0; \
766 r2 = -1; \
767 r2 s%%= r1; \
768 r0 = r2; \
769 exit; \
770" ::: __clobber_all);
771}
772
773#else
774
775SEC("socket")
776__description("cpuv4 is not supported by compiler or jit, use a dummy test")
777__success
778int dummy_test(void)
779{
780 return 0;
781}
782
783#endif
784
785char _license[] SEC("license") = "GPL";