Skip to content

Commit b18bea2

Browse files
Russell Kingborkmann
Russell King
authored andcommitted
ARM: net: bpf: improve 64-bit ALU implementation
Improbe the 64-bit ALU implementation from: movw r8, #65532 movt r8, #65535 movw r9, #65535 movt r9, #65535 ldr r7, [fp, #-44] adds r7, r7, r8 str r7, [fp, #-44] ldr r7, [fp, #-40] adc r7, r7, r9 str r7, [fp, #-40] to: movw r8, #65532 movt r8, #65535 movw r9, #65535 movt r9, #65535 ldrd r6, [fp, #-44] adds r6, r6, r8 adc r7, r7, r9 strd r6, [fp, #-44] Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent c5eae69 commit b18bea2

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

arch/arm/net/bpf_jit_32.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,30 @@ static inline void emit_a32_alu_r(const s8 dst, const s8 src,
716716
static inline void emit_a32_alu_r64(const bool is64, const s8 dst[],
717717
const s8 src[], struct jit_ctx *ctx,
718718
const u8 op) {
719-
emit_a32_alu_r(dst_lo, src_lo, ctx, is64, false, op);
720-
if (is64)
721-
emit_a32_alu_r(dst_hi, src_hi, ctx, is64, true, op);
722-
else
723-
emit_a32_mov_i(dst_hi, 0, ctx);
719+
const s8 *tmp = bpf2a32[TMP_REG_1];
720+
const s8 *tmp2 = bpf2a32[TMP_REG_2];
721+
const s8 *rd;
722+
723+
rd = arm_bpf_get_reg64(dst, tmp, ctx);
724+
if (is64) {
725+
const s8 *rs;
726+
727+
rs = arm_bpf_get_reg64(src, tmp2, ctx);
728+
729+
/* ALU operation */
730+
emit_alu_r(rd[1], rs[1], true, false, op, ctx);
731+
emit_alu_r(rd[0], rs[0], true, true, op, ctx);
732+
} else {
733+
s8 rs;
734+
735+
rs = arm_bpf_get_reg32(src_lo, tmp2[1], ctx);
736+
737+
/* ALU operation */
738+
emit_alu_r(rd[1], rs, true, false, op, ctx);
739+
emit_a32_mov_i(rd[0], 0, ctx);
740+
}
741+
742+
arm_bpf_put_reg64(dst, rd, ctx);
724743
}
725744

726745
/* dst = src (4 bytes)*/

0 commit comments

Comments
 (0)