2015-06-04 11:56:16 +01:00
/ *
* bpf_ j i b _ a s m . S : P a c k e t / h e a d e r a c c e s s h e l p e r f u n c t i o n s f o r M I P S / M I P S 6 4 B P F
* compiler.
*
* Copyright ( C ) 2 0 1 5 I m a g i n a t i o n T e c h n o l o g i e s L t d .
* Author : Markos C h a n d r a s < m a r k o s . c h a n d r a s @imgtec.com>
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify it
* under t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s p u b l i s h e d b y t h e
* Free S o f t w a r e F o u n d a t i o n ; version 2 of the License.
* /
# include < a s m / a s m . h >
# include < a s m / r e g d e f . h >
# include " b p f _ j i t . h "
/ * ABI
*
* r_ s k b _ h l s k b h e a d e r l e n g t h
* r_ s k b _ d a t a s k b d a t a
* r_ o f f ( a1 ) o f f s e t r e g i s t e r
* r_ A B P F r e g i s t e r A
* r_ X P F r e g i s t e r X
* r_ s k b ( a0 ) * s k b
* r_ M * s c r a t c h m e m o r y
* r_ s k b _ l e s k b l e n g t h
* r_ s0 S c r a t c h r e g i s t e r 0
* r_ s1 S c r a t c h r e g i s t e r 1
*
* On e n t r y :
* a0 : * skb
* a1 : offset ( i m m o r i m m + X )
*
* All n o n - B P F - A B I r e g i s t e r s a r e f r e e f o r u s e . O n r e t u r n , w e o n l y
* care a b o u t r _ r e t . T h e B P F - A B I r e g i s t e r s a r e a s s u m e d t o r e m a i n
* unmodified d u r i n g t h e e n t i r e f i l t e r o p e r a t i o n .
* /
# define s k b a0
# define o f f s e t a1
# define S K F _ L L _ O F F ( - 0 x20 0 0 0 0 ) / * C a n ' t i n c l u d e l i n u x / f i l t e r . h i n a s s e m b l y * /
/* We know better :) so prevent assembler reordering etc */
.set noreorder
# define i s _ o f f s e t _ n e g a t i v e ( T Y P E ) \
/* If offset is negative we have more work to do */ \
slti t 0 , o f f s e t , 0 ; \
bgtz t 0 , b p f _ s l o w _ p a t h _ ## T Y P E # # _ n e g ; \
/* Be careful what follows in DS. */
# define i s _ o f f s e t _ i n _ h e a d e r ( S I Z E , T Y P E ) \
/* Reading from header? */ \
addiu $ r _ s0 , $ r _ s k b _ h l , - S I Z E ; \
slt t 0 , $ r _ s0 , o f f s e t ; \
bgtz t 0 , b p f _ s l o w _ p a t h _ ## T Y P E ; \
LEAF( s k _ l o a d _ w o r d )
is_ o f f s e t _ n e g a t i v e ( w o r d )
2015-10-01 15:45:44 +02:00
FEXPORT( s k _ l o a d _ w o r d _ p o s i t i v e )
2015-06-04 11:56:16 +01:00
is_ o f f s e t _ i n _ h e a d e r ( 4 , w o r d )
/* Offset within header boundaries */
PTR_ A D D U t 1 , $ r _ s k b _ d a t a , o f f s e t
2015-10-02 09:48:57 +02:00
.set reorder
2015-06-04 11:56:16 +01:00
lw $ r _ A , 0 ( t 1 )
2015-10-02 09:48:57 +02:00
.set noreorder
2015-06-04 11:56:16 +01:00
# ifdef C O N F I G _ C P U _ L I T T L E _ E N D I A N
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# if d e f i n e d ( _ _ m i p s _ i s a _ r e v ) & & ( _ _ m i p s _ i s a _ r e v > = 2 )
2015-06-04 11:56:16 +01:00
wsbh t 0 , $ r _ A
rotr $ r _ A , t 0 , 1 6
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# else
sll t 0 , $ r _ A , 2 4
srl t 1 , $ r _ A , 2 4
srl t 2 , $ r _ A , 8
or t 0 , t 0 , t 1
andi t 2 , t 2 , 0 x f f00
andi t 1 , $ r _ A , 0 x f f00
or t 0 , t 0 , t 2
sll t 1 , t 1 , 8
or $ r _ A , t 0 , t 1
# endif
2015-06-04 11:56:16 +01:00
# endif
jr $ r _ r a
move $ r _ r e t , z e r o
END( s k _ l o a d _ w o r d )
LEAF( s k _ l o a d _ h a l f )
is_ o f f s e t _ n e g a t i v e ( h a l f )
2015-10-01 15:45:44 +02:00
FEXPORT( s k _ l o a d _ h a l f _ p o s i t i v e )
2015-06-04 11:56:16 +01:00
is_ o f f s e t _ i n _ h e a d e r ( 2 , h a l f )
/* Offset within header boundaries */
PTR_ A D D U t 1 , $ r _ s k b _ d a t a , o f f s e t
2015-10-02 09:48:57 +02:00
.set reorder
2015-06-04 11:56:16 +01:00
lh $ r _ A , 0 ( t 1 )
2015-10-02 09:48:57 +02:00
.set noreorder
2015-06-04 11:56:16 +01:00
# ifdef C O N F I G _ C P U _ L I T T L E _ E N D I A N
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# if d e f i n e d ( _ _ m i p s _ i s a _ r e v ) & & ( _ _ m i p s _ i s a _ r e v > = 2 )
2015-06-04 11:56:16 +01:00
wsbh t 0 , $ r _ A
seh $ r _ A , t 0
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# else
sll t 0 , $ r _ A , 2 4
andi t 1 , $ r _ A , 0 x f f00
sra t 0 , t 0 , 1 6
srl t 1 , t 1 , 8
or $ r _ A , t 0 , t 1
# endif
2015-06-04 11:56:16 +01:00
# endif
jr $ r _ r a
move $ r _ r e t , z e r o
END( s k _ l o a d _ h a l f )
LEAF( s k _ l o a d _ b y t e )
is_ o f f s e t _ n e g a t i v e ( b y t e )
2015-10-01 15:45:44 +02:00
FEXPORT( s k _ l o a d _ b y t e _ p o s i t i v e )
2015-06-04 11:56:16 +01:00
is_ o f f s e t _ i n _ h e a d e r ( 1 , b y t e )
/* Offset within header boundaries */
PTR_ A D D U t 1 , $ r _ s k b _ d a t a , o f f s e t
lb $ r _ A , 0 ( t 1 )
jr $ r _ r a
move $ r _ r e t , z e r o
END( s k _ l o a d _ b y t e )
/ *
* call s k b _ c o p y _ b i t s :
* ( prototype i n l i n u x / s k b u f f . h )
*
* int s k b _ c o p y _ b i t s ( s k _ b u f f * s k b , i n t o f f s e t , v o i d * t o , i n t l e n )
*
* o3 2 m a n d a t e s w e l e a v e 4 s p a c e s f o r a r g u m e n t r e g i s t e r s i n c a s e
* the c a l l e e n e e d s t o u s e t h e m . E v e n t h o u g h w e d o n ' t c a r e a b o u t
* the a r g u m e n t r e g i s t e r s o u r s e l v e s , w e n e e d t o a l l o c a t e t h a t s p a c e
* to r e m a i n A B I c o m p l i a n t s i n c e t h e c a l l e e m a y w a n t t o u s e t h a t s p a c e .
* We a l s o a l l o c a t e 2 m o r e s p a c e s f o r $ r _ r a a n d o u r r e t u r n r e g i s t e r ( * t o ) .
*
* n6 4 i s a b i t d i f f e r e n t . T h e * c a l l e r * w i l l a l l o c a t e t h e s p a c e t o p r e s e r v e
* the a r g u m e n t s . S o i n 6 4 - b i t k e r n e l s , w e a l l o c a t e t h e 4 - a r g s p a c e f o r n o
* good r e a s o n b u t i t d o e s n o t m a t t e r t h a t m u c h r e a l l y .
*
* ( void * t o ) i s r e t u r n e d i n r _ s0
*
* /
# define b p f _ s l o w _ p a t h _ c o m m o n ( S I Z E ) \
/* Quick check. Are we within reasonable boundaries? */ \
LONG_ A D D I U $ r _ s1 , $ r _ s k b _ l e n , - S I Z E ; \
sltu $ r _ s0 , o f f s e t , $ r _ s1 ; \
beqz $ r _ s0 , f a u l t ; \
/* Load 4th argument in DS */ \
LONG_ A D D I U a3 , z e r o , S I Z E ; \
PTR_ A D D I U $ r _ s p , $ r _ s p , - ( 6 * S Z R E G ) ; \
PTR_ L A t 0 , s k b _ c o p y _ b i t s ; \
PTR_ S $ r _ r a , ( 5 * S Z R E G ) ( $ r _ s p ) ; \
/* Assign low slot to a2 */ \
move a2 , $ r _ s p ; \
jalr t 0 ; \
/* Reset our destination slot (DS but it's ok) */ \
INT_ S z e r o , ( 4 * S Z R E G ) ( $ r _ s p ) ; \
/ * \
* skb_ c o p y _ b i t s r e t u r n s 0 o n s u c c e s s a n d - E F A U L T \
* on e r r o r . O u r d a t a l i v e i n a2 . D o n o t b o t h e r w i t h \
* our d a t a i f a n e r r o r h a s b e e n r e t u r n e d . \
* / \
/* Restore our frame */ \
PTR_ L $ r _ r a , ( 5 * S Z R E G ) ( $ r _ s p ) ; \
INT_ L $ r _ s0 , ( 4 * S Z R E G ) ( $ r _ s p ) ; \
bltz v0 , f a u l t ; \
PTR_ A D D I U $ r _ s p , $ r _ s p , 6 * S Z R E G ; \
move $ r _ r e t , z e r o ; \
NESTED( b p f _ s l o w _ p a t h _ w o r d , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ s l o w _ p a t h _ c o m m o n ( 4 )
# ifdef C O N F I G _ C P U _ L I T T L E _ E N D I A N
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# if d e f i n e d ( _ _ m i p s _ i s a _ r e v ) & & ( _ _ m i p s _ i s a _ r e v > = 2 )
2015-06-04 11:56:16 +01:00
wsbh t 0 , $ r _ s0
jr $ r _ r a
rotr $ r _ A , t 0 , 1 6
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# else
sll t 0 , $ r _ s0 , 2 4
srl t 1 , $ r _ s0 , 2 4
srl t 2 , $ r _ s0 , 8
or t 0 , t 0 , t 1
andi t 2 , t 2 , 0 x f f00
andi t 1 , $ r _ s0 , 0 x f f00
or t 0 , t 0 , t 2
sll t 1 , t 1 , 8
jr $ r _ r a
or $ r _ A , t 0 , t 1
# endif
2015-09-05 18:46:56 +02:00
# else
2015-06-04 11:56:16 +01:00
jr $ r _ r a
2015-09-05 18:46:56 +02:00
move $ r _ A , $ r _ s0
# endif
2015-06-04 11:56:16 +01:00
END( b p f _ s l o w _ p a t h _ w o r d )
NESTED( b p f _ s l o w _ p a t h _ h a l f , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ s l o w _ p a t h _ c o m m o n ( 2 )
# ifdef C O N F I G _ C P U _ L I T T L E _ E N D I A N
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# if d e f i n e d ( _ _ m i p s _ i s a _ r e v ) & & ( _ _ m i p s _ i s a _ r e v > = 2 )
2015-06-04 11:56:16 +01:00
jr $ r _ r a
wsbh $ r _ A , $ r _ s0
MIPS: BPF: Fix build on pre-R2 little endian CPUs
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.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: stable@vger.kernel.org # v4.2+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/11098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2015-09-05 18:46:57 +02:00
# else
sll t 0 , $ r _ s0 , 8
andi t 1 , $ r _ s0 , 0 x f f00
andi t 0 , t 0 , 0 x f f00
srl t 1 , t 1 , 8
jr $ r _ r a
or $ r _ A , t 0 , t 1
# endif
2015-09-05 18:46:56 +02:00
# else
2015-06-04 11:56:16 +01:00
jr $ r _ r a
move $ r _ A , $ r _ s0
2015-09-05 18:46:56 +02:00
# endif
2015-06-04 11:56:16 +01:00
END( b p f _ s l o w _ p a t h _ h a l f )
NESTED( b p f _ s l o w _ p a t h _ b y t e , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ s l o w _ p a t h _ c o m m o n ( 1 )
jr $ r _ r a
move $ r _ A , $ r _ s0
END( b p f _ s l o w _ p a t h _ b y t e )
/ *
* Negative e n t r y p o i n t s
* /
.macro bpf_is_end_of_data
li t 0 , S K F _ L L _ O F F
/* Reading link layer data? */
slt t 1 , o f f s e t , t 0
bgtz t 1 , f a u l t
/* Be careful what follows in DS. */
.endm
/ *
* call s k b _ c o p y _ b i t s :
* ( prototype i n l i n u x / f i l t e r . h )
*
* void * b p f _ i n t e r n a l _ l o a d _ p o i n t e r _ n e g _ h e l p e r ( c o n s t s t r u c t s k _ b u f f * s k b ,
* int k , u n s i g n e d i n t s i z e )
*
* see a b o v e ( b p f _ s l o w _ p a t h _ c o m m o n ) f o r A B I r e s t r i c t i o n s
* /
# define b p f _ n e g a t i v e _ c o m m o n ( S I Z E ) \
PTR_ A D D I U $ r _ s p , $ r _ s p , - ( 6 * S Z R E G ) ; \
PTR_ L A t 0 , b p f _ i n t e r n a l _ l o a d _ p o i n t e r _ n e g _ h e l p e r ; \
PTR_ S $ r _ r a , ( 5 * S Z R E G ) ( $ r _ s p ) ; \
jalr t 0 ; \
li a2 , S I Z E ; \
PTR_ L $ r _ r a , ( 5 * S Z R E G ) ( $ r _ s p ) ; \
/* Check return pointer */ \
beqz v0 , f a u l t ; \
PTR_ A D D I U $ r _ s p , $ r _ s p , 6 * S Z R E G ; \
/* Preserve our pointer */ \
move $ r _ s0 , v0 ; \
/* Set return value */ \
move $ r _ r e t , z e r o ; \
bpf_slow_path_word_neg :
bpf_ i s _ e n d _ o f _ d a t a
NESTED( s k _ l o a d _ w o r d _ n e g a t i v e , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ n e g a t i v e _ c o m m o n ( 4 )
jr $ r _ r a
lw $ r _ A , 0 ( $ r _ s0 )
END( s k _ l o a d _ w o r d _ n e g a t i v e )
bpf_slow_path_half_neg :
bpf_ i s _ e n d _ o f _ d a t a
NESTED( s k _ l o a d _ h a l f _ n e g a t i v e , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ n e g a t i v e _ c o m m o n ( 2 )
jr $ r _ r a
lhu $ r _ A , 0 ( $ r _ s0 )
END( s k _ l o a d _ h a l f _ n e g a t i v e )
bpf_slow_path_byte_neg :
bpf_ i s _ e n d _ o f _ d a t a
NESTED( s k _ l o a d _ b y t e _ n e g a t i v e , ( 6 * S Z R E G ) , $ r _ s p )
bpf_ n e g a t i v e _ c o m m o n ( 1 )
jr $ r _ r a
lbu $ r _ A , 0 ( $ r _ s0 )
END( s k _ l o a d _ b y t e _ n e g a t i v e )
fault :
jr $ r _ r a
addiu $ r _ r e t , z e r o , 1