@@ -599,9 +599,20 @@ static inline void emit_a32_mov_i(const s8 dst, const u32 val,
599
599
}
600
600
}
601
601
602
+ static void emit_a32_mov_i64 (const s8 dst [], u64 val , struct jit_ctx * ctx )
603
+ {
604
+ const s8 * tmp = bpf2a32 [TMP_REG_1 ];
605
+ const s8 * rd = is_stacked (dst_lo ) ? tmp : dst ;
606
+
607
+ emit_mov_i (rd [1 ], (u32 )val , ctx );
608
+ emit_mov_i (rd [0 ], val >> 32 , ctx );
609
+
610
+ arm_bpf_put_reg64 (dst , rd , ctx );
611
+ }
612
+
602
613
/* Sign extended move */
603
- static inline void emit_a32_mov_i64 (const bool is64 , const s8 dst [],
604
- const u32 val , struct jit_ctx * ctx ) {
614
+ static inline void emit_a32_mov_se_i64 (const bool is64 , const s8 dst [],
615
+ const u32 val , struct jit_ctx * ctx ) {
605
616
u32 hi = 0 ;
606
617
607
618
if (is64 && (val & (1 <<31 )))
@@ -1309,7 +1320,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1309
1320
break ;
1310
1321
case BPF_K :
1311
1322
/* Sign-extend immediate value to destination reg */
1312
- emit_a32_mov_i64 (is64 , dst , imm , ctx );
1323
+ emit_a32_mov_se_i64 (is64 , dst , imm , ctx );
1313
1324
break ;
1314
1325
}
1315
1326
break ;
@@ -1358,7 +1369,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1358
1369
* value into temporary reg and then it would be
1359
1370
* safe to do the operation on it.
1360
1371
*/
1361
- emit_a32_mov_i64 (is64 , tmp2 , imm , ctx );
1372
+ emit_a32_mov_se_i64 (is64 , tmp2 , imm , ctx );
1362
1373
emit_a32_alu_r64 (is64 , dst , tmp2 , ctx , BPF_OP (code ));
1363
1374
break ;
1364
1375
}
@@ -1454,7 +1465,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1454
1465
* reg then it would be safe to do the operation
1455
1466
* on it.
1456
1467
*/
1457
- emit_a32_mov_i64 (is64 , tmp2 , imm , ctx );
1468
+ emit_a32_mov_se_i64 (is64 , tmp2 , imm , ctx );
1458
1469
emit_a32_mul_r64 (dst , tmp2 , ctx );
1459
1470
break ;
1460
1471
}
@@ -1506,12 +1517,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1506
1517
/* dst = imm64 */
1507
1518
case BPF_LD | BPF_IMM | BPF_DW :
1508
1519
{
1509
- const struct bpf_insn insn1 = insn [1 ];
1510
- u32 hi , lo = imm ;
1520
+ u64 val = (u32 )imm | (u64 )insn [1 ].imm << 32 ;
1511
1521
1512
- hi = insn1 .imm ;
1513
- emit_a32_mov_i (dst_lo , lo , ctx );
1514
- emit_a32_mov_i (dst_hi , hi , ctx );
1522
+ emit_a32_mov_i64 (dst , val , ctx );
1515
1523
1516
1524
return 1 ;
1517
1525
}
@@ -1531,7 +1539,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1531
1539
switch (BPF_SIZE (code )) {
1532
1540
case BPF_DW :
1533
1541
/* Sign-extend immediate value into temp reg */
1534
- emit_a32_mov_i64 (true, tmp2 , imm , ctx );
1542
+ emit_a32_mov_se_i64 (true, tmp2 , imm , ctx );
1535
1543
emit_str_r (dst_lo , tmp2 [1 ], off , ctx , BPF_W );
1536
1544
emit_str_r (dst_lo , tmp2 [0 ], off + 4 , ctx , BPF_W );
1537
1545
break ;
@@ -1620,7 +1628,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
1620
1628
rm = tmp2 [0 ];
1621
1629
rn = tmp2 [1 ];
1622
1630
/* Sign-extend immediate value */
1623
- emit_a32_mov_i64 (true, tmp2 , imm , ctx );
1631
+ emit_a32_mov_se_i64 (true, tmp2 , imm , ctx );
1624
1632
go_jmp :
1625
1633
/* Setup destination register */
1626
1634
rd = arm_bpf_get_reg64 (dst , tmp , ctx );
0 commit comments