All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian
@ 2015-09-05 16:46 Aurelien Jarno
  2015-09-05 16:46 ` [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs Aurelien Jarno
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Aurelien Jarno @ 2015-09-05 16:46 UTC (permalink / raw)
  To: linux-mips; +Cc: Aurelien Jarno, Ralf Baechle, Markos Chandras

On little endian, avoid generating the big endian version of the code
by using #else in addition to #ifdef #endif. Also fix one alignment
issue wrt delay slot.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 arch/mips/net/bpf_jit_asm.S | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
index e927260..4f54cb1 100644
--- a/arch/mips/net/bpf_jit_asm.S
+++ b/arch/mips/net/bpf_jit_asm.S
@@ -151,9 +151,10 @@ NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 	wsbh	t0, $r_s0
 	jr	$r_ra
 	 rotr	$r_A, t0, 16
-#endif
+#else
 	jr	$r_ra
-	move	$r_A, $r_s0
+	 move	$r_A, $r_s0
+#endif
 
 	END(bpf_slow_path_word)
 
@@ -162,9 +163,10 @@ NESTED(bpf_slow_path_half, (6 * SZREG), $r_sp)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
 	jr	$r_ra
 	 wsbh	$r_A, $r_s0
-#endif
+#else
 	jr	$r_ra
 	 move	$r_A, $r_s0
+#endif
 
 	END(bpf_slow_path_half)
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs
  2015-09-05 16:46 [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian Aurelien Jarno
@ 2015-09-05 16:46 ` Aurelien Jarno
  2015-09-07  9:33     ` Markos Chandras
  2015-09-07  8:29   ` Markos Chandras
  2015-09-07  9:48 ` Ralf Baechle
  2 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2015-09-05 16:46 UTC (permalink / raw)
  To: linux-mips; +Cc: Aurelien Jarno, Ralf Baechle, Markos Chandras

The rotr, seh and wsbh instructions have been introduced with the R2
ISA. Thus the current BPF code fails to build on pre-R2 little endian
CPUs:

    CC      arch/mips/net/bpf_jit.o
    AS      arch/mips/net/bpf_jit_asm.o
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S: Assembler messages:
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:67: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:68: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:83: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:84: Error: opcode not supported on this processor: mips32 (mips32) `seh $19,$8'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:151: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$12'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:153: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
  /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:164: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $19,$12'
  /home/aurel32/linux-4.2/scripts/Makefile.build:294: recipe for target 'arch/mips/net/bpf_jit_asm.o' failed

Fix that by providing equivalent code for these CPUs.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 arch/mips/net/bpf_jit_asm.S | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/mips/net/bpf_jit_asm.S b/arch/mips/net/bpf_jit_asm.S
index 4f54cb1..dabf417 100644
--- a/arch/mips/net/bpf_jit_asm.S
+++ b/arch/mips/net/bpf_jit_asm.S
@@ -64,8 +64,20 @@ sk_load_word_positive:
 	PTR_ADDU t1, $r_skb_data, offset
 	lw	$r_A, 0(t1)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
+# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
 	wsbh	t0, $r_A
 	rotr	$r_A, t0, 16
+# else
+	sll	t0, $r_A, 24
+	srl	t1, $r_A, 24
+	srl	t2, $r_A, 8
+	or	t0, t0, t1
+	andi	t2, t2, 0xff00
+	andi	t1, $r_A, 0xff00
+	or	t0, t0, t2
+	sll	t1, t1, 8
+	or	$r_A, t0, t1
+# endif
 #endif
 	jr	$r_ra
 	 move	$r_ret, zero
@@ -80,8 +92,16 @@ sk_load_half_positive:
 	PTR_ADDU t1, $r_skb_data, offset
 	lh	$r_A, 0(t1)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
+# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
 	wsbh	t0, $r_A
 	seh	$r_A, t0
+# else
+	sll	t0, $r_A, 24
+	andi	t1, $r_A, 0xff00
+	sra	t0, t0, 16
+	srl	t1, t1, 8
+	or	$r_A, t0, t1
+# endif
 #endif
 	jr	$r_ra
 	 move	$r_ret, zero
@@ -148,9 +168,22 @@ sk_load_byte_positive:
 NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(4)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
+# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
 	wsbh	t0, $r_s0
 	jr	$r_ra
 	 rotr	$r_A, t0, 16
+# else
+	sll	t0, $r_s0, 24
+	srl	t1, $r_s0, 24
+	srl	t2, $r_s0, 8
+	or	t0, t0, t1
+	andi	t2, t2, 0xff00
+	andi	t1, $r_s0, 0xff00
+	or	t0, t0, t2
+	sll	t1, t1, 8
+	jr	$r_ra
+	 or	$r_A, t0, t1
+# endif
 #else
 	jr	$r_ra
 	 move	$r_A, $r_s0
@@ -161,8 +194,17 @@ NESTED(bpf_slow_path_word, (6 * SZREG), $r_sp)
 NESTED(bpf_slow_path_half, (6 * SZREG), $r_sp)
 	bpf_slow_path_common(2)
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
+# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
 	jr	$r_ra
 	 wsbh	$r_A, $r_s0
+# else
+	sll	t0, $r_s0, 8
+	andi	t1, $r_s0, 0xff00
+	andi	t0, t0, 0xff00
+	srl	t1, t1, 8
+	jr	$r_ra
+	 or	$r_A, t0, t1
+# endif
 #else
 	jr	$r_ra
 	 move	$r_A, $r_s0
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian
@ 2015-09-07  8:29   ` Markos Chandras
  0 siblings, 0 replies; 7+ messages in thread
From: Markos Chandras @ 2015-09-07  8:29 UTC (permalink / raw)
  To: Aurelien Jarno, linux-mips; +Cc: Ralf Baechle

On 09/05/2015 05:46 PM, Aurelien Jarno wrote:
> On little endian, avoid generating the big endian version of the code
> by using #else in addition to #ifdef #endif. Also fix one alignment
> issue wrt delay slot.
> 
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Markos Chandras <markos.chandras@imgtec.com>
> Cc: stable@vger.kernel.org # v4.2+
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  arch/mips/net/bpf_jit_asm.S | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>

-- 
markos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian
@ 2015-09-07  8:29   ` Markos Chandras
  0 siblings, 0 replies; 7+ messages in thread
From: Markos Chandras @ 2015-09-07  8:29 UTC (permalink / raw)
  To: Aurelien Jarno, linux-mips; +Cc: Ralf Baechle

On 09/05/2015 05:46 PM, Aurelien Jarno wrote:
> On little endian, avoid generating the big endian version of the code
> by using #else in addition to #ifdef #endif. Also fix one alignment
> issue wrt delay slot.
> 
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Markos Chandras <markos.chandras@imgtec.com>
> Cc: stable@vger.kernel.org # v4.2+
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  arch/mips/net/bpf_jit_asm.S | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>

-- 
markos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs
@ 2015-09-07  9:33     ` Markos Chandras
  0 siblings, 0 replies; 7+ messages in thread
From: Markos Chandras @ 2015-09-07  9:33 UTC (permalink / raw)
  To: Aurelien Jarno, linux-mips; +Cc: Ralf Baechle

On 09/05/2015 05:46 PM, Aurelien Jarno wrote:
> The rotr, seh and wsbh instructions have been introduced with the R2
> ISA. Thus the current BPF code fails to build on pre-R2 little endian
> CPUs:
> 
>     CC      arch/mips/net/bpf_jit.o
>     AS      arch/mips/net/bpf_jit_asm.o
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S: Assembler messages:
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:67: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:68: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:83: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:84: Error: opcode not supported on this processor: mips32 (mips32) `seh $19,$8'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:151: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$12'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:153: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:164: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $19,$12'
>   /home/aurel32/linux-4.2/scripts/Makefile.build:294: recipe for target 'arch/mips/net/bpf_jit_asm.o' failed
> 
> Fix that by providing equivalent code for these CPUs.
> 
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Markos Chandras <markos.chandras@imgtec.com>
> Cc: stable@vger.kernel.org # v4.2+
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---

Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>

-- 
markos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs
@ 2015-09-07  9:33     ` Markos Chandras
  0 siblings, 0 replies; 7+ messages in thread
From: Markos Chandras @ 2015-09-07  9:33 UTC (permalink / raw)
  To: Aurelien Jarno, linux-mips; +Cc: Ralf Baechle

On 09/05/2015 05:46 PM, Aurelien Jarno wrote:
> The rotr, seh and wsbh instructions have been introduced with the R2
> ISA. Thus the current BPF code fails to build on pre-R2 little endian
> CPUs:
> 
>     CC      arch/mips/net/bpf_jit.o
>     AS      arch/mips/net/bpf_jit_asm.o
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S: Assembler messages:
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:67: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:68: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:83: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$19'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:84: Error: opcode not supported on this processor: mips32 (mips32) `seh $19,$8'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:151: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $8,$12'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:153: Error: opcode not supported on this processor: mips32 (mips32) `rotr $19,$8,16'
>   /home/aurel32/linux-4.2/arch/mips/net/bpf_jit_asm.S:164: Error: opcode not supported on this processor: mips32 (mips32) `wsbh $19,$12'
>   /home/aurel32/linux-4.2/scripts/Makefile.build:294: recipe for target 'arch/mips/net/bpf_jit_asm.o' failed
> 
> Fix that by providing equivalent code for these CPUs.
> 
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Markos Chandras <markos.chandras@imgtec.com>
> Cc: stable@vger.kernel.org # v4.2+
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---

Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>

-- 
markos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian
  2015-09-05 16:46 [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian Aurelien Jarno
  2015-09-05 16:46 ` [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs Aurelien Jarno
  2015-09-07  8:29   ` Markos Chandras
@ 2015-09-07  9:48 ` Ralf Baechle
  2 siblings, 0 replies; 7+ messages in thread
From: Ralf Baechle @ 2015-09-07  9:48 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: linux-mips, Markos Chandras

Thanks, both applied.

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-07  9:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-05 16:46 [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian Aurelien Jarno
2015-09-05 16:46 ` [PATCH 2/2 for-4.3] MIPS: BPF: Fix build on pre-R2 little endian CPUs Aurelien Jarno
2015-09-07  9:33   ` Markos Chandras
2015-09-07  9:33     ` Markos Chandras
2015-09-07  8:29 ` [PATCH 1/2 for-4.3] MIPS: BPF: Avoid unreachable code on little endian Markos Chandras
2015-09-07  8:29   ` Markos Chandras
2015-09-07  9:48 ` Ralf Baechle

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.