Commit fc83265
arm32, bpf: add support for sign-extension mov instruction
The cpuv4 added a new BPF_MOVSX instruction that sign extends the src before moving it to the destination. BPF_ALU | BPF_MOVSX sign extends 8-bit and 16-bit operands into 32-bit operands, and zeroes the remaining upper 32 bits. BPF_ALU64 | BPF_MOVSX sign extends 8-bit, 16-bit, and 32-bit operands into 64-bit operands. The offset field of the instruction is used to tell the number of bit to use for sign-extension. BPF_MOV and BPF_MOVSX have the same code but the former sets offset to 0 and the later one sets the offset to 8, 16 or 32 The behaviour of this instruction is dst = (s8,s16,s32)src On ARM32 the implementation uses LSH and ARSH to extend the 8/16 bits to a 32-bit register and then it is sign extended to the upper 32-bit register using ARSH. For 32-bit we just move it to the destination register and use ARSH to extend it to the upper 32-bit register. Signed-off-by: Puranjay Mohan <puranjay12@gmail.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/20230907230550.1417590-4-puranjay12@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent f9e6981 commit fc83265
1 file changed
+30
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
| 750 | + | |
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
755 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
756 | 760 | | |
757 | 761 | | |
758 | 762 | | |
| |||
761 | 765 | | |
762 | 766 | | |
763 | 767 | | |
764 | | - | |
| 768 | + | |
765 | 769 | | |
766 | 770 | | |
767 | 771 | | |
768 | 772 | | |
769 | 773 | | |
770 | 774 | | |
771 | | - | |
772 | | - | |
| 775 | + | |
| 776 | + | |
773 | 777 | | |
774 | 778 | | |
775 | 779 | | |
| |||
785 | 789 | | |
786 | 790 | | |
787 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
788 | 810 | | |
789 | 811 | | |
790 | 812 | | |
| |||
1450 | 1472 | | |
1451 | 1473 | | |
1452 | 1474 | | |
1453 | | - | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1454 | 1479 | | |
1455 | 1480 | | |
1456 | 1481 | | |
| |||
0 commit comments