From: nschichan@freebox.fr (Nicolas Schichan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction.
Date: Mon, 04 May 2015 18:16:30 +0200 [thread overview]
Message-ID: <55479B5E.2070901@freebox.fr> (raw)
In-Reply-To: <20150501173721.GO12732@n2100.arm.linux.org.uk>
On 05/01/2015 07:37 PM, Russell King - ARM Linux wrote:
> On Wed, Apr 29, 2015 at 03:37:37PM +0200, Nicolas Schichan wrote:
[...]
>> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
>> index b5f470d..ffaf311 100644
>> --- a/arch/arm/net/bpf_jit_32.c
>> +++ b/arch/arm/net/bpf_jit_32.c
>> @@ -449,10 +449,10 @@ static inline void emit_udiv(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx)
>> return;
>> }
>> #endif
>> - if (rm != ARM_R0)
>> - emit(ARM_MOV_R(ARM_R0, rm), ctx);
>> if (rn != ARM_R1)
>> emit(ARM_MOV_R(ARM_R1, rn), ctx);
>> + if (rm != ARM_R0)
>> + emit(ARM_MOV_R(ARM_R0, rm), ctx);
>
> I don't think you've thought enough about this. What if rm is ARM_R1?
> What if rn = ARM_R0 and rm = ARM_R1?
>
> How about:
>
> if (rn == ARM_R0 && rm == ARM_R1) {
> emit(ARM_MOV_R(ARM_R3, rn), ctx); // r3 <- r0(rn)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- r1(rm)
> emit(ARM_MOV_R(ARM_R1, ARM_R3), ctx); // r1 <- r3
> } else if (rn == ARM_R0) {
> emit(ARM_MOV_R(ARM_R1, rn), ctx); // r1 <- rn
> if (rm != ARM_R0)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- rm
> } else {
> if (rm != ARM_R0)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- rm
> if (rn != ARM_R1)
> emit(ARM_MOV_R(ARM_R1, rn), ctx); // r1 <- rn
> }
>
Hello Russell,
In the current JIT, emit_udiv() is only being called with:
- rm = ARM_R4 (r_A) and rn = ARM_R0 (r_scrach) for BPF_ALU | BPF_DIV | BPF_K
- rm = ARM_R4 (r_A) and rn = ARM_R5 (r_X) for BPF_ALU | BPF_DIV | BPF_X
so it should not cause any issue in the current code state.
But yes, I'll rework the patch to avoid any other nasty surprises should the
code change.
Thanks,
--
Nicolas Schichan
Freebox SAS
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Schichan <nschichan@freebox.fr>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: "David S. Miller" <davem@davemloft.net>,
Alexei Starovoitov <ast@plumgrid.com>,
Daniel Borkmann <dborkman@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction.
Date: Mon, 04 May 2015 18:16:30 +0200 [thread overview]
Message-ID: <55479B5E.2070901@freebox.fr> (raw)
In-Reply-To: <20150501173721.GO12732@n2100.arm.linux.org.uk>
On 05/01/2015 07:37 PM, Russell King - ARM Linux wrote:
> On Wed, Apr 29, 2015 at 03:37:37PM +0200, Nicolas Schichan wrote:
[...]
>> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
>> index b5f470d..ffaf311 100644
>> --- a/arch/arm/net/bpf_jit_32.c
>> +++ b/arch/arm/net/bpf_jit_32.c
>> @@ -449,10 +449,10 @@ static inline void emit_udiv(u8 rd, u8 rm, u8 rn, struct jit_ctx *ctx)
>> return;
>> }
>> #endif
>> - if (rm != ARM_R0)
>> - emit(ARM_MOV_R(ARM_R0, rm), ctx);
>> if (rn != ARM_R1)
>> emit(ARM_MOV_R(ARM_R1, rn), ctx);
>> + if (rm != ARM_R0)
>> + emit(ARM_MOV_R(ARM_R0, rm), ctx);
>
> I don't think you've thought enough about this. What if rm is ARM_R1?
> What if rn = ARM_R0 and rm = ARM_R1?
>
> How about:
>
> if (rn == ARM_R0 && rm == ARM_R1) {
> emit(ARM_MOV_R(ARM_R3, rn), ctx); // r3 <- r0(rn)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- r1(rm)
> emit(ARM_MOV_R(ARM_R1, ARM_R3), ctx); // r1 <- r3
> } else if (rn == ARM_R0) {
> emit(ARM_MOV_R(ARM_R1, rn), ctx); // r1 <- rn
> if (rm != ARM_R0)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- rm
> } else {
> if (rm != ARM_R0)
> emit(ARM_MOV_R(ARM_R0, rm), ctx); // r0 <- rm
> if (rn != ARM_R1)
> emit(ARM_MOV_R(ARM_R1, rn), ctx); // r1 <- rn
> }
>
Hello Russell,
In the current JIT, emit_udiv() is only being called with:
- rm = ARM_R4 (r_A) and rn = ARM_R0 (r_scrach) for BPF_ALU | BPF_DIV | BPF_K
- rm = ARM_R4 (r_A) and rn = ARM_R5 (r_X) for BPF_ALU | BPF_DIV | BPF_X
so it should not cause any issue in the current code state.
But yes, I'll rework the patch to avoid any other nasty surprises should the
code change.
Thanks,
--
Nicolas Schichan
Freebox SAS
next prev parent reply other threads:[~2015-05-04 16:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 13:37 [PATCH 0/4] Seccomp filter JIT support on ARM Nicolas Schichan
2015-04-29 13:37 ` Nicolas Schichan
2015-04-29 13:37 ` [PATCH 1/4] net: filter: make bpf_migrate_filter available outside of net/core/filter.c Nicolas Schichan
2015-04-29 13:37 ` [PATCH 2/4] seccomp: rework seccomp_prepare_filter() Nicolas Schichan
2015-04-29 17:12 ` Daniel Borkmann
2015-04-30 12:27 ` Nicolas Schichan
2015-04-30 12:46 ` Daniel Borkmann
2015-04-30 14:12 ` Nicolas Schichan
2015-04-29 13:37 ` [PATCH 3/4] ARM: net: add JIT support for loads from struct seccomp_data Nicolas Schichan
2015-04-29 13:37 ` Nicolas Schichan
2015-04-29 13:37 ` [PATCH 4/4] ARM: net fix emit_udiv() for BPF_ALU | BPF_DIV | BPF_K intruction Nicolas Schichan
2015-04-29 13:37 ` Nicolas Schichan
2015-05-01 17:37 ` Russell King - ARM Linux
2015-05-01 17:37 ` Russell King - ARM Linux
2015-05-04 16:16 ` Nicolas Schichan [this message]
2015-05-04 16:16 ` Nicolas Schichan
2015-05-04 17:57 ` Russell King - ARM Linux
2015-05-04 17:57 ` Russell King - ARM Linux
2015-04-29 16:37 ` [PATCH 0/4] Seccomp filter JIT support on ARM Daniel Borkmann
2015-04-29 16:37 ` Daniel Borkmann
2015-04-30 12:35 ` Nicolas Schichan
2015-04-30 12:35 ` Nicolas Schichan
2015-04-30 12:51 ` Daniel Borkmann
2015-04-30 12:51 ` Daniel Borkmann
2015-04-30 17:17 ` Alexei Starovoitov
2015-04-30 17:17 ` Alexei Starovoitov
2015-04-29 16:46 ` Alexei Starovoitov
2015-04-29 16:46 ` Alexei Starovoitov
2015-04-29 16:46 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55479B5E.2070901@freebox.fr \
--to=nschichan@freebox.fr \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.