CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Daniel Borkmann <[email protected]>
CC: Alexei Starovoitov <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   d4d016caa4b85b9aa98d7ec8c84e928621a614bc
commit: b24abcff918a5cbf44b0c982bd3477a93e8e4911 bpf, kconfig: Add consolidated 
menu entry for bpf with core options
date:   4 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 4 months ago
config: arm-randconfig-c002-20210917 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
c8b3d7d6d6de37af68b2f379d0e37304f78e115f)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b24abcff918a5cbf44b0c982bd3477a93e8e4911
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout b24abcff918a5cbf44b0c982bd3477a93e8e4911
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro 
'__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   arch/arm/net/bpf_jit_32.c:1169:2: note: Loop condition is false.  Exiting 
loop
           BUILD_BUG_ON(offsetof(struct bpf_array, map.max_entries) >
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro 
'__compiletime_assert'
           do {                                                            \
           ^
   arch/arm/net/bpf_jit_32.c:1172:12: note: 2nd function call argument is an 
uninitialized value
           r_array = arm_bpf_get_reg32(r2[1], tmp2[0], ctx);
                     ^                        ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1447:11: warning: 2nd function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
                   rd_lo = arm_bpf_get_reg32(dst_lo, tmp2[1], ctx);
                           ^                         ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 156:'  at 
line 1446
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1447:11: note: 2nd function call argument is an 
uninitialized value
                   rd_lo = arm_bpf_get_reg32(dst_lo, tmp2[1], ctx);
                           ^                         ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1602:8: warning: 2nd function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
                   rn = arm_bpf_get_reg32(src_lo, tmp2[1], ctx);
                        ^                         ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 121:'  at 
line 1601
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1602:8: note: 2nd function call argument is an 
uninitialized value
                   rn = arm_bpf_get_reg32(src_lo, tmp2[1], ctx);
                        ^                         ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1618:4: warning: 1st function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
                           emit_a32_mov_i(tmp2[1], imm, ctx);
                           ^              ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 114:'  at 
line 1608
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1610:3: note: Control jumps to 'case 16:'  at line 
1617
                   switch (BPF_SIZE(code)) {
                   ^
   arch/arm/net/bpf_jit_32.c:1618:4: note: 1st function call argument is an 
uninitialized value
                           emit_a32_mov_i(tmp2[1], imm, ctx);
                           ^              ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1669:8: warning: 2nd function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
                   rm = arm_bpf_get_reg32(src_hi, tmp2[0], ctx);
                        ^                         ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 222:'  at 
line 1667
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1669:8: note: 2nd function call argument is an 
uninitialized value
                   rm = arm_bpf_get_reg32(src_hi, tmp2[0], ctx);
                        ^                         ~~~~~~~
>> arch/arm/net/bpf_jit_32.c:1707:6: warning: Assigned value is garbage or 
>> undefined [clang-analyzer-core.uninitialized.Assign]
                   rm = tmp2[0];
                      ^ ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 214:'  at 
line 1704
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1705:7: note: Assuming 'off' is not equal to 0
                   if (off == 0)
                       ^~~~~~~~
   arch/arm/net/bpf_jit_32.c:1705:3: note: Taking false branch
                   if (off == 0)
                   ^
   arch/arm/net/bpf_jit_32.c:1707:6: note: Assigned value is garbage or 
undefined
                   rm = tmp2[0];
                      ^ ~~~~~~~
   arch/arm/net/bpf_jit_32.c:1787:3: warning: 1st function call argument is an 
uninitialized value [clang-analyzer-core.CallAndMessage]
                   emit_a32_mov_i(tmp[1], func, ctx);
                   ^              ~~~~~~
   arch/arm/net/bpf_jit_32.c:1354:20: note: Assuming the condition is false
           const bool is64 = BPF_CLASS(code) == BPF_ALU64;
                             ^
   include/uapi/linux/bpf_common.h:6:25: note: expanded from macro 'BPF_CLASS'
   #define BPF_CLASS(code) ((code) & 0x07)
                           ^
   arch/arm/net/bpf_jit_32.c:1369:2: note: Control jumps to 'case 133:'  at 
line 1771
           switch (code) {
           ^
   arch/arm/net/bpf_jit_32.c:1787:3: note: 1st function call argument is an 
uninitialized value
                   emit_a32_mov_i(tmp[1], func, ctx);
                   ^              ~~~~~~
   Suppressed 4 warnings (3 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   crypto/drbg.c:245:17: warning: Value stored to 'entropylen' during its 
initialization is never read [clang-analyzer-deadcode.DeadStores]
           unsigned short entropylen = drbg_sec_strength(drbg->core->flags);
                          ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/drbg.c:245:17: note: Value stored to 'entropylen' during its 
initialization is never read
           unsigned short entropylen = drbg_sec_strength(drbg->core->flags);
                          ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   crypto/drbg.c:442:40: warning: Division by zero 
[clang-analyzer-core.DivideZero]
           padlen = (inputlen + sizeof(L_N) + 1) % (drbg_blocklen(drbg));
                                                 ^
   crypto/drbg.c:599:12: note: Assuming '__UNIQUE_ID___x254' is >= 
'__UNIQUE_ID___y255'
           int len = min_t(int, buflen, INT_MAX);
                     ^
   include/linux/minmax.h:110:27: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:44:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:39:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:34:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^~~~~~~~~~
   crypto/drbg.c:599:12: note: '?' condition is false
           int len = min_t(int, buflen, INT_MAX);
                     ^
   include/linux/minmax.h:110:27: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ^
   include/linux/minmax.h:44:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^
   include/linux/minmax.h:39:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })

vim +1707 arch/arm/net/bpf_jit_32.c

39c13c204bb115 Shubham Bansal   2017-08-22  1368  
39c13c204bb115 Shubham Bansal   2017-08-22  1369        switch (code) {
39c13c204bb115 Shubham Bansal   2017-08-22  1370        /* ALU operations */
39c13c204bb115 Shubham Bansal   2017-08-22  1371  
39c13c204bb115 Shubham Bansal   2017-08-22  1372        /* dst = src */
39c13c204bb115 Shubham Bansal   2017-08-22  1373        case BPF_ALU | BPF_MOV 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1374        case BPF_ALU | BPF_MOV 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1375        case BPF_ALU64 | 
BPF_MOV | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1376        case BPF_ALU64 | 
BPF_MOV | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1377                switch 
(BPF_SRC(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1378                case BPF_X:
163541e6ba3426 Jiong Wang       2019-05-24  1379                        if (imm 
== 1) {
163541e6ba3426 Jiong Wang       2019-05-24  1380                                
/* Special mov32 for zext */
163541e6ba3426 Jiong Wang       2019-05-24  1381                                
emit_a32_mov_i(dst_hi, 0, ctx);
163541e6ba3426 Jiong Wang       2019-05-24  1382                                
break;
163541e6ba3426 Jiong Wang       2019-05-24  1383                        }
47b9c3bf416d80 Russell King     2018-07-11  1384                        
emit_a32_mov_r64(is64, dst, src, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1385                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1386                case BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1387                        /* 
Sign-extend immediate value to destination reg */
f9ff5018c13b49 Russell King     2018-07-12  1388                        
emit_a32_mov_se_i64(is64, dst, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1389                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1390                }
39c13c204bb115 Shubham Bansal   2017-08-22  1391                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1392        /* dst = dst + src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1393        /* dst = dst - src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1394        /* dst = dst | src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1395        /* dst = dst & src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1396        /* dst = dst ^ src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1397        /* dst = dst * src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1398        /* dst = dst << src */
39c13c204bb115 Shubham Bansal   2017-08-22  1399        /* dst = dst >> src */
39c13c204bb115 Shubham Bansal   2017-08-22  1400        case BPF_ALU | BPF_ADD 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1401        case BPF_ALU | BPF_ADD 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1402        case BPF_ALU | BPF_SUB 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1403        case BPF_ALU | BPF_SUB 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1404        case BPF_ALU | BPF_OR | 
BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1405        case BPF_ALU | BPF_OR | 
BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1406        case BPF_ALU | BPF_AND 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1407        case BPF_ALU | BPF_AND 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1408        case BPF_ALU | BPF_XOR 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1409        case BPF_ALU | BPF_XOR 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1410        case BPF_ALU | BPF_MUL 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1411        case BPF_ALU | BPF_MUL 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1412        case BPF_ALU | BPF_LSH 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1413        case BPF_ALU | BPF_RSH 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1414        case BPF_ALU | BPF_ARSH 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1415        case BPF_ALU64 | 
BPF_ADD | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1416        case BPF_ALU64 | 
BPF_ADD | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1417        case BPF_ALU64 | 
BPF_SUB | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1418        case BPF_ALU64 | 
BPF_SUB | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1419        case BPF_ALU64 | BPF_OR 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1420        case BPF_ALU64 | BPF_OR 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1421        case BPF_ALU64 | 
BPF_AND | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1422        case BPF_ALU64 | 
BPF_AND | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1423        case BPF_ALU64 | 
BPF_XOR | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1424        case BPF_ALU64 | 
BPF_XOR | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1425                switch 
(BPF_SRC(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1426                case BPF_X:
47b9c3bf416d80 Russell King     2018-07-11  1427                        
emit_a32_alu_r64(is64, dst, src, ctx, BPF_OP(code));
39c13c204bb115 Shubham Bansal   2017-08-22  1428                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1429                case BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1430                        /* Move 
immediate value to the temporary register
39c13c204bb115 Shubham Bansal   2017-08-22  1431                         * and 
then do the ALU operation on the temporary
39c13c204bb115 Shubham Bansal   2017-08-22  1432                         * 
register as this will sign-extend the immediate
39c13c204bb115 Shubham Bansal   2017-08-22  1433                         * 
value into temporary reg and then it would be
39c13c204bb115 Shubham Bansal   2017-08-22  1434                         * safe 
to do the operation on it.
24e737c1ebacf0 Nicolas Schichan 2015-05-07  1435                         */
f9ff5018c13b49 Russell King     2018-07-12  1436                        
emit_a32_mov_se_i64(is64, tmp2, imm, ctx);
47b9c3bf416d80 Russell King     2018-07-11  1437                        
emit_a32_alu_r64(is64, dst, tmp2, ctx, BPF_OP(code));
39c13c204bb115 Shubham Bansal   2017-08-22  1438                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1439                }
39c13c204bb115 Shubham Bansal   2017-08-22  1440                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1441        /* dst = dst / src(imm) 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1442        /* dst = dst % src(imm) 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1443        case BPF_ALU | BPF_DIV 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1444        case BPF_ALU | BPF_DIV 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1445        case BPF_ALU | BPF_MOD 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1446        case BPF_ALU | BPF_MOD 
| BPF_X:
a6eccac507e5e4 Russell King     2018-07-11  1447                rd_lo = 
arm_bpf_get_reg32(dst_lo, tmp2[1], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1448                switch 
(BPF_SRC(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1449                case BPF_X:
7a9870256361d4 Russell King     2018-07-11  1450                        rt = 
arm_bpf_get_reg32(src_lo, tmp2[0], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1451                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1452                case BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1453                        rt = 
tmp2[0];
47b9c3bf416d80 Russell King     2018-07-11  1454                        
emit_a32_mov_i(rt, imm, ctx);
47b9c3bf416d80 Russell King     2018-07-11  1455                        break;
47b9c3bf416d80 Russell King     2018-07-11  1456                default:
47b9c3bf416d80 Russell King     2018-07-11  1457                        rt = 
src_lo;
39c13c204bb115 Shubham Bansal   2017-08-22  1458                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1459                }
a6eccac507e5e4 Russell King     2018-07-11  1460                
emit_udivmod(rd_lo, rd_lo, rt, ctx, BPF_OP(code));
a6eccac507e5e4 Russell King     2018-07-11  1461                
arm_bpf_put_reg32(dst_lo, rd_lo, ctx);
163541e6ba3426 Jiong Wang       2019-05-24  1462                if 
(!ctx->prog->aux->verifier_zext)
47b9c3bf416d80 Russell King     2018-07-11  1463                        
emit_a32_mov_i(dst_hi, 0, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1464                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1465        case BPF_ALU64 | 
BPF_DIV | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1466        case BPF_ALU64 | 
BPF_DIV | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1467        case BPF_ALU64 | 
BPF_MOD | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1468        case BPF_ALU64 | 
BPF_MOD | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1469                goto notyet;
39c13c204bb115 Shubham Bansal   2017-08-22  1470        /* dst = dst << imm */
c648c9c7429e97 Luke Nelson      2020-04-30  1471        /* dst = dst >> imm */
c648c9c7429e97 Luke Nelson      2020-04-30  1472        /* dst = dst >> imm 
(signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1473        case BPF_ALU | BPF_LSH 
| BPF_K:
c648c9c7429e97 Luke Nelson      2020-04-30  1474        case BPF_ALU | BPF_RSH 
| BPF_K:
c648c9c7429e97 Luke Nelson      2020-04-30  1475        case BPF_ALU | BPF_ARSH 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1476                if 
(unlikely(imm > 31))
39c13c204bb115 Shubham Bansal   2017-08-22  1477                        return 
-EINVAL;
39c13c204bb115 Shubham Bansal   2017-08-22  1478                if (imm)
47b9c3bf416d80 Russell King     2018-07-11  1479                        
emit_a32_alu_i(dst_lo, imm, ctx, BPF_OP(code));
163541e6ba3426 Jiong Wang       2019-05-24  1480                if 
(!ctx->prog->aux->verifier_zext)
47b9c3bf416d80 Russell King     2018-07-11  1481                        
emit_a32_mov_i(dst_hi, 0, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1482                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1483        /* dst = dst << imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1484        case BPF_ALU64 | 
BPF_LSH | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1485                if 
(unlikely(imm > 63))
39c13c204bb115 Shubham Bansal   2017-08-22  1486                        return 
-EINVAL;
47b9c3bf416d80 Russell King     2018-07-11  1487                
emit_a32_lsh_i64(dst, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1488                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1489        /* dst = dst >> imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1490        case BPF_ALU64 | 
BPF_RSH | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1491                if 
(unlikely(imm > 63))
39c13c204bb115 Shubham Bansal   2017-08-22  1492                        return 
-EINVAL;
47b9c3bf416d80 Russell King     2018-07-11  1493                
emit_a32_rsh_i64(dst, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1494                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1495        /* dst = dst << src */
39c13c204bb115 Shubham Bansal   2017-08-22  1496        case BPF_ALU64 | 
BPF_LSH | BPF_X:
47b9c3bf416d80 Russell King     2018-07-11  1497                
emit_a32_lsh_r64(dst, src, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1498                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1499        /* dst = dst >> src */
39c13c204bb115 Shubham Bansal   2017-08-22  1500        case BPF_ALU64 | 
BPF_RSH | BPF_X:
47b9c3bf416d80 Russell King     2018-07-11  1501                
emit_a32_rsh_r64(dst, src, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1502                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1503        /* dst = dst >> src 
(signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1504        case BPF_ALU64 | 
BPF_ARSH | BPF_X:
47b9c3bf416d80 Russell King     2018-07-11  1505                
emit_a32_arsh_r64(dst, src, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1506                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1507        /* dst = dst >> imm 
(signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1508        case BPF_ALU64 | 
BPF_ARSH | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1509                if 
(unlikely(imm > 63))
39c13c204bb115 Shubham Bansal   2017-08-22  1510                        return 
-EINVAL;
47b9c3bf416d80 Russell King     2018-07-11  1511                
emit_a32_arsh_i64(dst, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1512                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1513        /* dst = ~dst */
39c13c204bb115 Shubham Bansal   2017-08-22  1514        case BPF_ALU | BPF_NEG:
47b9c3bf416d80 Russell King     2018-07-11  1515                
emit_a32_alu_i(dst_lo, 0, ctx, BPF_OP(code));
163541e6ba3426 Jiong Wang       2019-05-24  1516                if 
(!ctx->prog->aux->verifier_zext)
47b9c3bf416d80 Russell King     2018-07-11  1517                        
emit_a32_mov_i(dst_hi, 0, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1518                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1519        /* dst = ~dst (64 bit) 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1520        case BPF_ALU64 | 
BPF_NEG:
47b9c3bf416d80 Russell King     2018-07-11  1521                
emit_a32_neg64(dst, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1522                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1523        /* dst = dst * src/imm 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1524        case BPF_ALU64 | 
BPF_MUL | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1525        case BPF_ALU64 | 
BPF_MUL | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1526                switch 
(BPF_SRC(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1527                case BPF_X:
47b9c3bf416d80 Russell King     2018-07-11  1528                        
emit_a32_mul_r64(dst, src, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1529                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1530                case BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1531                        /* Move 
immediate value to the temporary register
39c13c204bb115 Shubham Bansal   2017-08-22  1532                         * and 
then do the multiplication on it as this
39c13c204bb115 Shubham Bansal   2017-08-22  1533                         * will 
sign-extend the immediate value into temp
39c13c204bb115 Shubham Bansal   2017-08-22  1534                         * reg 
then it would be safe to do the operation
39c13c204bb115 Shubham Bansal   2017-08-22  1535                         * on 
it.
39c13c204bb115 Shubham Bansal   2017-08-22  1536                         */
f9ff5018c13b49 Russell King     2018-07-12  1537                        
emit_a32_mov_se_i64(is64, tmp2, imm, ctx);
47b9c3bf416d80 Russell King     2018-07-11  1538                        
emit_a32_mul_r64(dst, tmp2, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1539                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1540                }
39c13c204bb115 Shubham Bansal   2017-08-22  1541                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1542        /* dst = htole(dst) */
39c13c204bb115 Shubham Bansal   2017-08-22  1543        /* dst = htobe(dst) */
39c13c204bb115 Shubham Bansal   2017-08-22  1544        case BPF_ALU | BPF_END 
| BPF_FROM_LE:
39c13c204bb115 Shubham Bansal   2017-08-22  1545        case BPF_ALU | BPF_END 
| BPF_FROM_BE:
a6eccac507e5e4 Russell King     2018-07-11  1546                rd = 
arm_bpf_get_reg64(dst, tmp, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1547                if 
(BPF_SRC(code) == BPF_FROM_LE)
39c13c204bb115 Shubham Bansal   2017-08-22  1548                        goto 
emit_bswap_uxt;
39c13c204bb115 Shubham Bansal   2017-08-22  1549                switch (imm) {
39c13c204bb115 Shubham Bansal   2017-08-22  1550                case 16:
a6eccac507e5e4 Russell King     2018-07-11  1551                        
emit_rev16(rd[1], rd[1], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1552                        goto 
emit_bswap_uxt;
39c13c204bb115 Shubham Bansal   2017-08-22  1553                case 32:
a6eccac507e5e4 Russell King     2018-07-11  1554                        
emit_rev32(rd[1], rd[1], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1555                        goto 
emit_bswap_uxt;
39c13c204bb115 Shubham Bansal   2017-08-22  1556                case 64:
a6eccac507e5e4 Russell King     2018-07-11  1557                        
emit_rev32(ARM_LR, rd[1], ctx);
a6eccac507e5e4 Russell King     2018-07-11  1558                        
emit_rev32(rd[1], rd[0], ctx);
a6eccac507e5e4 Russell King     2018-07-11  1559                        
emit(ARM_MOV_R(rd[0], ARM_LR), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1560                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1561                }
39c13c204bb115 Shubham Bansal   2017-08-22  1562                goto exit;
39c13c204bb115 Shubham Bansal   2017-08-22  1563  emit_bswap_uxt:
39c13c204bb115 Shubham Bansal   2017-08-22  1564                switch (imm) {
39c13c204bb115 Shubham Bansal   2017-08-22  1565                case 16:
39c13c204bb115 Shubham Bansal   2017-08-22  1566                        /* 
zero-extend 16 bits into 64 bits */
39c13c204bb115 Shubham Bansal   2017-08-22  1567  #if __LINUX_ARM_ARCH__ < 6
47b9c3bf416d80 Russell King     2018-07-11  1568                        
emit_a32_mov_i(tmp2[1], 0xffff, ctx);
a6eccac507e5e4 Russell King     2018-07-11  1569                        
emit(ARM_AND_R(rd[1], rd[1], tmp2[1]), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1570  #else /* ARMv6+ */
a6eccac507e5e4 Russell King     2018-07-11  1571                        
emit(ARM_UXTH(rd[1], rd[1]), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1572  #endif
163541e6ba3426 Jiong Wang       2019-05-24  1573                        if 
(!ctx->prog->aux->verifier_zext)
a6eccac507e5e4 Russell King     2018-07-11  1574                                
emit(ARM_EOR_R(rd[0], rd[0], rd[0]), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1575                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1576                case 32:
39c13c204bb115 Shubham Bansal   2017-08-22  1577                        /* 
zero-extend 32 bits into 64 bits */
163541e6ba3426 Jiong Wang       2019-05-24  1578                        if 
(!ctx->prog->aux->verifier_zext)
a6eccac507e5e4 Russell King     2018-07-11  1579                                
emit(ARM_EOR_R(rd[0], rd[0], rd[0]), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1580                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1581                case 64:
39c13c204bb115 Shubham Bansal   2017-08-22  1582                        /* nop 
*/
39c13c204bb115 Shubham Bansal   2017-08-22  1583                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1584                }
39c13c204bb115 Shubham Bansal   2017-08-22  1585  exit:
a6eccac507e5e4 Russell King     2018-07-11  1586                
arm_bpf_put_reg64(dst, rd, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1587                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1588        /* dst = imm64 */
39c13c204bb115 Shubham Bansal   2017-08-22  1589        case BPF_LD | BPF_IMM | 
BPF_DW:
39c13c204bb115 Shubham Bansal   2017-08-22  1590        {
f9ff5018c13b49 Russell King     2018-07-12  1591                u64 val = 
(u32)imm | (u64)insn[1].imm << 32;
39c13c204bb115 Shubham Bansal   2017-08-22  1592  
f9ff5018c13b49 Russell King     2018-07-12  1593                
emit_a32_mov_i64(dst, val, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1594  
39c13c204bb115 Shubham Bansal   2017-08-22  1595                return 1;
39c13c204bb115 Shubham Bansal   2017-08-22  1596        }
39c13c204bb115 Shubham Bansal   2017-08-22  1597        /* LDX: dst = *(size 
*)(src + off) */
39c13c204bb115 Shubham Bansal   2017-08-22  1598        case BPF_LDX | BPF_MEM 
| BPF_W:
39c13c204bb115 Shubham Bansal   2017-08-22  1599        case BPF_LDX | BPF_MEM 
| BPF_H:
39c13c204bb115 Shubham Bansal   2017-08-22  1600        case BPF_LDX | BPF_MEM 
| BPF_B:
39c13c204bb115 Shubham Bansal   2017-08-22  1601        case BPF_LDX | BPF_MEM 
| BPF_DW:
7a9870256361d4 Russell King     2018-07-11  1602                rn = 
arm_bpf_get_reg32(src_lo, tmp2[1], ctx);
47b9c3bf416d80 Russell King     2018-07-11  1603                emit_ldx_r(dst, 
rn, off, ctx, BPF_SIZE(code));
39c13c204bb115 Shubham Bansal   2017-08-22  1604                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1605        /* ST: *(size *)(dst + 
off) = imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1606        case BPF_ST | BPF_MEM | 
BPF_W:
39c13c204bb115 Shubham Bansal   2017-08-22  1607        case BPF_ST | BPF_MEM | 
BPF_H:
39c13c204bb115 Shubham Bansal   2017-08-22  1608        case BPF_ST | BPF_MEM | 
BPF_B:
39c13c204bb115 Shubham Bansal   2017-08-22  1609        case BPF_ST | BPF_MEM | 
BPF_DW:
39c13c204bb115 Shubham Bansal   2017-08-22  1610                switch 
(BPF_SIZE(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1611                case BPF_DW:
39c13c204bb115 Shubham Bansal   2017-08-22  1612                        /* 
Sign-extend immediate value into temp reg */
f9ff5018c13b49 Russell King     2018-07-12  1613                        
emit_a32_mov_se_i64(true, tmp2, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1614                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1615                case BPF_W:
39c13c204bb115 Shubham Bansal   2017-08-22  1616                case BPF_H:
39c13c204bb115 Shubham Bansal   2017-08-22  1617                case BPF_B:
47b9c3bf416d80 Russell King     2018-07-11  1618                        
emit_a32_mov_i(tmp2[1], imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1619                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1620                }
c5eae692571d6c Russell King     2018-07-12  1621                
emit_str_r(dst_lo, tmp2, off, ctx, BPF_SIZE(code));
39c13c204bb115 Shubham Bansal   2017-08-22  1622                break;
91c960b0056672 Brendan Jackman  2021-01-14  1623        /* Atomic ops */
91c960b0056672 Brendan Jackman  2021-01-14  1624        case BPF_STX | 
BPF_ATOMIC | BPF_W:
91c960b0056672 Brendan Jackman  2021-01-14  1625        case BPF_STX | 
BPF_ATOMIC | BPF_DW:
39c13c204bb115 Shubham Bansal   2017-08-22  1626                goto notyet;
39c13c204bb115 Shubham Bansal   2017-08-22  1627        /* STX: *(size *)(dst + 
off) = src */
39c13c204bb115 Shubham Bansal   2017-08-22  1628        case BPF_STX | BPF_MEM 
| BPF_W:
39c13c204bb115 Shubham Bansal   2017-08-22  1629        case BPF_STX | BPF_MEM 
| BPF_H:
39c13c204bb115 Shubham Bansal   2017-08-22  1630        case BPF_STX | BPF_MEM 
| BPF_B:
39c13c204bb115 Shubham Bansal   2017-08-22  1631        case BPF_STX | BPF_MEM 
| BPF_DW:
a6eccac507e5e4 Russell King     2018-07-11  1632                rs = 
arm_bpf_get_reg64(src, tmp2, ctx);
c5eae692571d6c Russell King     2018-07-12  1633                
emit_str_r(dst_lo, rs, off, ctx, BPF_SIZE(code));
39c13c204bb115 Shubham Bansal   2017-08-22  1634                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1635        /* PC += off if dst == 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1636        /* PC += off if dst > 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1637        /* PC += off if dst >= 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1638        /* PC += off if dst < 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1639        /* PC += off if dst <= 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1640        /* PC += off if dst != 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1641        /* PC += off if dst > 
src (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1642        /* PC += off if dst >= 
src (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1643        /* PC += off if dst < 
src (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1644        /* PC += off if dst <= 
src (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1645        /* PC += off if dst & 
src */
39c13c204bb115 Shubham Bansal   2017-08-22  1646        case BPF_JMP | BPF_JEQ 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1647        case BPF_JMP | BPF_JGT 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1648        case BPF_JMP | BPF_JGE 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1649        case BPF_JMP | BPF_JNE 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1650        case BPF_JMP | BPF_JSGT 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1651        case BPF_JMP | BPF_JSGE 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1652        case BPF_JMP | BPF_JSET 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1653        case BPF_JMP | BPF_JLE 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1654        case BPF_JMP | BPF_JLT 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1655        case BPF_JMP | BPF_JSLT 
| BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1656        case BPF_JMP | BPF_JSLE 
| BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1657        case BPF_JMP32 | 
BPF_JEQ | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1658        case BPF_JMP32 | 
BPF_JGT | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1659        case BPF_JMP32 | 
BPF_JGE | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1660        case BPF_JMP32 | 
BPF_JNE | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1661        case BPF_JMP32 | 
BPF_JSGT | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1662        case BPF_JMP32 | 
BPF_JSGE | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1663        case BPF_JMP32 | 
BPF_JSET | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1664        case BPF_JMP32 | 
BPF_JLE | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1665        case BPF_JMP32 | 
BPF_JLT | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1666        case BPF_JMP32 | 
BPF_JSLT | BPF_X:
b85062ac0df33a Jiong Wang       2019-01-26  1667        case BPF_JMP32 | 
BPF_JSLE | BPF_X:
39c13c204bb115 Shubham Bansal   2017-08-22  1668                /* Setup source 
registers */
7a9870256361d4 Russell King     2018-07-11  1669                rm = 
arm_bpf_get_reg32(src_hi, tmp2[0], ctx);
7a9870256361d4 Russell King     2018-07-11  1670                rn = 
arm_bpf_get_reg32(src_lo, tmp2[1], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1671                goto go_jmp;
39c13c204bb115 Shubham Bansal   2017-08-22  1672        /* PC += off if dst == 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1673        /* PC += off if dst > 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1674        /* PC += off if dst >= 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1675        /* PC += off if dst < 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1676        /* PC += off if dst <= 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1677        /* PC += off if dst != 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1678        /* PC += off if dst > 
imm (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1679        /* PC += off if dst >= 
imm (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1680        /* PC += off if dst < 
imm (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1681        /* PC += off if dst <= 
imm (signed) */
39c13c204bb115 Shubham Bansal   2017-08-22  1682        /* PC += off if dst & 
imm */
39c13c204bb115 Shubham Bansal   2017-08-22  1683        case BPF_JMP | BPF_JEQ 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1684        case BPF_JMP | BPF_JGT 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1685        case BPF_JMP | BPF_JGE 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1686        case BPF_JMP | BPF_JNE 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1687        case BPF_JMP | BPF_JSGT 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1688        case BPF_JMP | BPF_JSGE 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1689        case BPF_JMP | BPF_JSET 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1690        case BPF_JMP | BPF_JLT 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1691        case BPF_JMP | BPF_JLE 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1692        case BPF_JMP | BPF_JSLT 
| BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1693        case BPF_JMP | BPF_JSLE 
| BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1694        case BPF_JMP32 | 
BPF_JEQ | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1695        case BPF_JMP32 | 
BPF_JGT | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1696        case BPF_JMP32 | 
BPF_JGE | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1697        case BPF_JMP32 | 
BPF_JNE | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1698        case BPF_JMP32 | 
BPF_JSGT | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1699        case BPF_JMP32 | 
BPF_JSGE | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1700        case BPF_JMP32 | 
BPF_JSET | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1701        case BPF_JMP32 | 
BPF_JLT | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1702        case BPF_JMP32 | 
BPF_JLE | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1703        case BPF_JMP32 | 
BPF_JSLT | BPF_K:
b85062ac0df33a Jiong Wang       2019-01-26  1704        case BPF_JMP32 | 
BPF_JSLE | BPF_K:
39c13c204bb115 Shubham Bansal   2017-08-22  1705                if (off == 0)
39c13c204bb115 Shubham Bansal   2017-08-22  1706                        break;
39c13c204bb115 Shubham Bansal   2017-08-22 @1707                rm = tmp2[0];
39c13c204bb115 Shubham Bansal   2017-08-22  1708                rn = tmp2[1];
39c13c204bb115 Shubham Bansal   2017-08-22  1709                /* Sign-extend 
immediate value */
f9ff5018c13b49 Russell King     2018-07-12  1710                
emit_a32_mov_se_i64(true, tmp2, imm, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1711  go_jmp:
39c13c204bb115 Shubham Bansal   2017-08-22  1712                /* Setup 
destination register */
a6eccac507e5e4 Russell King     2018-07-11  1713                rd = 
arm_bpf_get_reg64(dst, tmp, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1714  
39c13c204bb115 Shubham Bansal   2017-08-22  1715                /* Check for 
the condition */
b85062ac0df33a Jiong Wang       2019-01-26  1716                
emit_ar_r(rd[0], rd[1], rm, rn, ctx, BPF_OP(code),
b85062ac0df33a Jiong Wang       2019-01-26  1717                          
BPF_CLASS(code) == BPF_JMP);
39c13c204bb115 Shubham Bansal   2017-08-22  1718  
39c13c204bb115 Shubham Bansal   2017-08-22  1719                /* Setup JUMP 
instruction */
39c13c204bb115 Shubham Bansal   2017-08-22  1720                jmp_offset = 
bpf2a32_offset(i+off, i, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1721                switch 
(BPF_OP(code)) {
39c13c204bb115 Shubham Bansal   2017-08-22  1722                case BPF_JNE:
39c13c204bb115 Shubham Bansal   2017-08-22  1723                case BPF_JSET:
39c13c204bb115 Shubham Bansal   2017-08-22  1724                        
_emit(ARM_COND_NE, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1725                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1726                case BPF_JEQ:
39c13c204bb115 Shubham Bansal   2017-08-22  1727                        
_emit(ARM_COND_EQ, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1728                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1729                case BPF_JGT:
39c13c204bb115 Shubham Bansal   2017-08-22  1730                        
_emit(ARM_COND_HI, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1731                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1732                case BPF_JGE:
39c13c204bb115 Shubham Bansal   2017-08-22  1733                        
_emit(ARM_COND_CS, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1734                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1735                case BPF_JSGT:
39c13c204bb115 Shubham Bansal   2017-08-22  1736                        
_emit(ARM_COND_LT, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1737                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1738                case BPF_JSGE:
39c13c204bb115 Shubham Bansal   2017-08-22  1739                        
_emit(ARM_COND_GE, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1740                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1741                case BPF_JLE:
39c13c204bb115 Shubham Bansal   2017-08-22  1742                        
_emit(ARM_COND_LS, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1743                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1744                case BPF_JLT:
39c13c204bb115 Shubham Bansal   2017-08-22  1745                        
_emit(ARM_COND_CC, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1746                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1747                case BPF_JSLT:
39c13c204bb115 Shubham Bansal   2017-08-22  1748                        
_emit(ARM_COND_LT, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1749                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1750                case BPF_JSLE:
39c13c204bb115 Shubham Bansal   2017-08-22  1751                        
_emit(ARM_COND_GE, ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1752                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1753                }
39c13c204bb115 Shubham Bansal   2017-08-22  1754                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1755        /* JMP OFF */
39c13c204bb115 Shubham Bansal   2017-08-22  1756        case BPF_JMP | BPF_JA:
39c13c204bb115 Shubham Bansal   2017-08-22  1757        {
39c13c204bb115 Shubham Bansal   2017-08-22  1758                if (off == 0)
39c13c204bb115 Shubham Bansal   2017-08-22  1759                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1760                jmp_offset = 
bpf2a32_offset(i+off, i, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1761                
check_imm24(jmp_offset);
39c13c204bb115 Shubham Bansal   2017-08-22  1762                
emit(ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1763                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1764        }
39c13c204bb115 Shubham Bansal   2017-08-22  1765        /* tail call */
39c13c204bb115 Shubham Bansal   2017-08-22  1766        case BPF_JMP | 
BPF_TAIL_CALL:
39c13c204bb115 Shubham Bansal   2017-08-22  1767                if 
(emit_bpf_tail_call(ctx))
39c13c204bb115 Shubham Bansal   2017-08-22  1768                        return 
-EFAULT;
39c13c204bb115 Shubham Bansal   2017-08-22  1769                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1770        /* function call */
39c13c204bb115 Shubham Bansal   2017-08-22  1771        case BPF_JMP | BPF_CALL:
39c13c204bb115 Shubham Bansal   2017-08-22  1772        {
1c35ba122d4a4e Russell King     2018-07-11  1773                const s8 *r0 = 
bpf2a32[BPF_REG_0];
1c35ba122d4a4e Russell King     2018-07-11  1774                const s8 *r1 = 
bpf2a32[BPF_REG_1];
1c35ba122d4a4e Russell King     2018-07-11  1775                const s8 *r2 = 
bpf2a32[BPF_REG_2];
1c35ba122d4a4e Russell King     2018-07-11  1776                const s8 *r3 = 
bpf2a32[BPF_REG_3];
1c35ba122d4a4e Russell King     2018-07-11  1777                const s8 *r4 = 
bpf2a32[BPF_REG_4];
1c35ba122d4a4e Russell King     2018-07-11  1778                const s8 *r5 = 
bpf2a32[BPF_REG_5];
39c13c204bb115 Shubham Bansal   2017-08-22  1779                const u32 func 
= (u32)__bpf_call_base + (u32)imm;
39c13c204bb115 Shubham Bansal   2017-08-22  1780  
47b9c3bf416d80 Russell King     2018-07-11  1781                
emit_a32_mov_r64(true, r0, r1, ctx);
47b9c3bf416d80 Russell King     2018-07-11  1782                
emit_a32_mov_r64(true, r1, r2, ctx);
96cced4e774a27 Russell King     2018-07-11  1783                
emit_push_r64(r5, ctx);
96cced4e774a27 Russell King     2018-07-11  1784                
emit_push_r64(r4, ctx);
96cced4e774a27 Russell King     2018-07-11  1785                
emit_push_r64(r3, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1786  
47b9c3bf416d80 Russell King     2018-07-11  1787                
emit_a32_mov_i(tmp[1], func, ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1788                
emit_blx_r(tmp[1], ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1789  
39c13c204bb115 Shubham Bansal   2017-08-22  1790                
emit(ARM_ADD_I(ARM_SP, ARM_SP, imm8m(24)), ctx); // callee clean
39c13c204bb115 Shubham Bansal   2017-08-22  1791                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1792        }
39c13c204bb115 Shubham Bansal   2017-08-22  1793        /* function return */
39c13c204bb115 Shubham Bansal   2017-08-22  1794        case BPF_JMP | BPF_EXIT:
39c13c204bb115 Shubham Bansal   2017-08-22  1795                /* 
Optimization: when last instruction is EXIT
39c13c204bb115 Shubham Bansal   2017-08-22  1796                 * simply 
fallthrough to epilogue.
39c13c204bb115 Shubham Bansal   2017-08-22  1797                 */
39c13c204bb115 Shubham Bansal   2017-08-22  1798                if (i == 
ctx->prog->len - 1)
39c13c204bb115 Shubham Bansal   2017-08-22  1799                        break;
39c13c204bb115 Shubham Bansal   2017-08-22  1800                jmp_offset = 
epilogue_offset(ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1801                
check_imm24(jmp_offset);
39c13c204bb115 Shubham Bansal   2017-08-22  1802                
emit(ARM_B(jmp_offset), ctx);
39c13c204bb115 Shubham Bansal   2017-08-22  1803                break;
39c13c204bb115 Shubham Bansal   2017-08-22  1804  notyet:
39c13c204bb115 Shubham Bansal   2017-08-22  1805                
pr_info_once("*** NOT YET: opcode %02x ***\n", code);
39c13c204bb115 Shubham Bansal   2017-08-22  1806                return -EFAULT;
39c13c204bb115 Shubham Bansal   2017-08-22  1807        default:
39c13c204bb115 Shubham Bansal   2017-08-22  1808                
pr_err_once("unknown opcode %02x\n", code);
39c13c204bb115 Shubham Bansal   2017-08-22  1809                return -EINVAL;
ddecdfcea0ae89 Mircea Gherzan   2012-03-16  1810        }
0b59d8806a31bb Nicolas Schichan 2015-05-07  1811  
0b59d8806a31bb Nicolas Schichan 2015-05-07  1812        if (ctx->flags & 
FLAG_IMM_OVERFLOW)
0b59d8806a31bb Nicolas Schichan 2015-05-07  1813                /*
0b59d8806a31bb Nicolas Schichan 2015-05-07  1814                 * this 
instruction generated an overflow when
0b59d8806a31bb Nicolas Schichan 2015-05-07  1815                 * trying to 
access the literal pool, so
0b59d8806a31bb Nicolas Schichan 2015-05-07  1816                 * delegate 
this filter to the kernel interpreter.
0b59d8806a31bb Nicolas Schichan 2015-05-07  1817                 */
0b59d8806a31bb Nicolas Schichan 2015-05-07  1818                return -1;
39c13c204bb115 Shubham Bansal   2017-08-22  1819        return 0;
39c13c204bb115 Shubham Bansal   2017-08-22  1820  }
39c13c204bb115 Shubham Bansal   2017-08-22  1821  

:::::: The code at line 1707 was first introduced by commit
:::::: 39c13c204bb1150d401e27d41a9d8b332be47c49 arm: eBPF JIT compiler

:::::: TO: Shubham Bansal <[email protected]>
:::::: CC: David S. Miller <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to