* [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
@ 2013-02-13 17:22 Nicolas Schichan
2013-02-13 17:30 ` Nicolas Schichan
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Schichan @ 2013-02-13 17:22 UTC (permalink / raw)
To: Mircea Gherzan, Russell King
Cc: Nicolas Schichan, David S. Miller, Daniel Borkmann,
linux-arm-kernel, linux-kernel
The original code was generating an lsl instructions using the value
of ARM_R8 (skb_headlen, possibly uninitialized if no skb_headlen
access was required) as a shift amount.
---
arch/arm/net/bpf_jit_32.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index a34f1e2..6828ef6 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/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+ */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-13 17:22 [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+ Nicolas Schichan
@ 2013-02-13 17:30 ` Nicolas Schichan
2013-02-13 19:02 ` David Miller
2013-02-13 21:32 ` Mircea Gherzan
0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Schichan @ 2013-02-13 17:30 UTC (permalink / raw)
To: Mircea Gherzan, Russell King
Cc: Nicolas Schichan, David S. Miller, Daniel Borkmann,
linux-arm-kernel, linux-kernel
The original code was generating an lsl instructions using the value
of ARM_R8 (skb_headlen, possibly uninitialized if no skb_headlen
access was required) as a shift amount.
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
---
Resent due to missing Signed-off-by
arch/arm/net/bpf_jit_32.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
index a34f1e2..6828ef6 100644
--- a/arch/arm/net/bpf_jit_32.c
+++ b/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+ */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-13 17:30 ` Nicolas Schichan
@ 2013-02-13 19:02 ` David Miller
2013-02-13 21:32 ` Mircea Gherzan
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2013-02-13 19:02 UTC (permalink / raw)
To: nschichan
Cc: mgherzan, linux, daniel.borkmann, linux-arm-kernel, linux-kernel
From: Nicolas Schichan <nschichan@freebox.fr>
Date: Wed, 13 Feb 2013 18:30:39 +0100
> The original code was generating an lsl instructions using the value
> of ARM_R8 (skb_headlen, possibly uninitialized if no skb_headlen
> access was required) as a shift amount.
>
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
ARM folks do you want to pick this up or would you like me to
apply it to the 'net' tree?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-13 17:30 ` Nicolas Schichan
2013-02-13 19:02 ` David Miller
@ 2013-02-13 21:32 ` Mircea Gherzan
2013-02-14 13:40 ` Nicolas Schichan
1 sibling, 1 reply; 7+ messages in thread
From: Mircea Gherzan @ 2013-02-13 21:32 UTC (permalink / raw)
To: Nicolas Schichan
Cc: Russell King, David S. Miller, Daniel Borkmann, linux-arm-kernel,
linux-kernel
Am 13.02.2013 18:30, schrieb Nicolas Schichan:
> The original code was generating an lsl instructions using the value
> of ARM_R8 (skb_headlen, possibly uninitialized if no skb_headlen
> access was required) as a shift amount.
>
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
> ---
> Resent due to missing Signed-off-by
>
> arch/arm/net/bpf_jit_32.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> index a34f1e2..6828ef6 100644
> --- a/arch/arm/net/bpf_jit_32.c
> +++ b/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+ */
Acked-by: Mircea Gherzan <mgherzan@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-13 21:32 ` Mircea Gherzan
@ 2013-02-14 13:40 ` Nicolas Schichan
2013-02-14 15:09 ` Russell King - ARM Linux
0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Schichan @ 2013-02-14 13:40 UTC (permalink / raw)
To: Mircea Gherzan
Cc: Russell King, David S. Miller, Daniel Borkmann, linux-arm-kernel,
linux-kernel
On 02/13/2013 10:32 PM, Mircea Gherzan wrote:
[...]
> Acked-by: Mircea Gherzan <mgherzan@gmail.com>
Hi,
Thanks Mircea. Russel, David, do you have any preference as to which path this
patch should take (net tree or ARM tree) ?
Regards,
--
Nicolas Schichan
Freebox SAS
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-14 13:40 ` Nicolas Schichan
@ 2013-02-14 15:09 ` Russell King - ARM Linux
2013-02-14 18:27 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux @ 2013-02-14 15:09 UTC (permalink / raw)
To: Nicolas Schichan
Cc: Mircea Gherzan, David S. Miller, Daniel Borkmann,
linux-arm-kernel, linux-kernel
On Thu, Feb 14, 2013 at 02:40:09PM +0100, Nicolas Schichan wrote:
> On 02/13/2013 10:32 PM, Mircea Gherzan wrote:
> [...]
>> Acked-by: Mircea Gherzan <mgherzan@gmail.com>
>
> Hi,
>
> Thanks Mircea. Russel, David, do you have any preference as to which path
> this patch should take (net tree or ARM tree) ?
I'm happy for either - I'm under the weather at the moment, so I'd be
greatful if David could pick this one up this time around.
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+.
2013-02-14 15:09 ` Russell King - ARM Linux
@ 2013-02-14 18:27 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2013-02-14 18:27 UTC (permalink / raw)
To: linux
Cc: nschichan, mgherzan, daniel.borkmann, linux-arm-kernel, linux-kernel
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
Date: Thu, 14 Feb 2013 15:09:25 +0000
> On Thu, Feb 14, 2013 at 02:40:09PM +0100, Nicolas Schichan wrote:
>> On 02/13/2013 10:32 PM, Mircea Gherzan wrote:
>> [...]
>>> Acked-by: Mircea Gherzan <mgherzan@gmail.com>
>>
>> Hi,
>>
>> Thanks Mircea. Russel, David, do you have any preference as to which path
>> this patch should take (net tree or ARM tree) ?
>
> I'm happy for either - I'm under the weather at the moment, so I'd be
> greatful if David could pick this one up this time around.
>
> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Applied to 'net', thanks everyone.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-02-14 18:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13 17:22 [PATCH] ARM: net: bpf_jit: fix emit_swap16() for non ARMv6+ Nicolas Schichan
2013-02-13 17:30 ` Nicolas Schichan
2013-02-13 19:02 ` David Miller
2013-02-13 21:32 ` Mircea Gherzan
2013-02-14 13:40 ` Nicolas Schichan
2013-02-14 15:09 ` Russell King - ARM Linux
2013-02-14 18:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).