From 265eb91951c48e20b3f636c4a4546a355b55c8bb Mon Sep 17 00:00:00 2001 From: Nicolas Schichan Date: Wed, 13 Feb 2013 17:30:39 +0000 Subject: [PATCH] --- yaml --- r: 352761 b: refs/heads/master c: 462738f4f04febe16bf366925559c267130c88f0 h: refs/heads/master i: 352759: 9b8960fdf6415856aaebdd1f680b2f8118deac57 v: v3 --- [refs] | 2 +- trunk/arch/arm/net/bpf_jit_32.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index b9ccc8a6eec2..fdc1683639e9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3e55f8b306cf305832a4ac78aa82e1b40e818ece +refs/heads/master: 462738f4f04febe16bf366925559c267130c88f0 diff --git a/trunk/arch/arm/net/bpf_jit_32.c b/trunk/arch/arm/net/bpf_jit_32.c index a34f1e214116..6828ef6ce80e 100644 --- a/trunk/arch/arm/net/bpf_jit_32.c +++ b/trunk/arch/arm/net/bpf_jit_32.c @@ -341,10 +341,17 @@ static void emit_load_be16(u8 cond, u8 r_res, u8 r_addr, struct jit_ctx *ctx) static inline void emit_swap16(u8 r_dst, u8 r_src, struct jit_ctx *ctx) { - emit(ARM_LSL_R(ARM_R1, r_src, 8), ctx); - emit(ARM_ORR_S(r_dst, ARM_R1, r_src, SRTYPE_LSL, 8), ctx); - emit(ARM_LSL_I(r_dst, r_dst, 8), ctx); - emit(ARM_LSL_R(r_dst, r_dst, 8), ctx); + /* r_dst = (r_src << 8) | (r_src >> 8) */ + emit(ARM_LSL_I(ARM_R1, r_src, 8), ctx); + emit(ARM_ORR_S(r_dst, ARM_R1, r_src, SRTYPE_LSR, 8), ctx); + + /* + * we need to mask out the bits set in r_dst[23:16] due to + * the first shift instruction. + * + * note that 0x8ff is the encoded immediate 0x00ff0000. + */ + emit(ARM_BIC_I(r_dst, r_dst, 0x8ff), ctx); } #else /* ARMv6+ */