MIPS: BPF: Fix multiple problems in JIT skb access helpers.
o Socket data is unsigned, so use unsigned accessors instructions. o Fix path result pointer generation arithmetic. o Fix half-word byte swapping code for unsigned semantics. Signed-off-by: David Daney <david.daney@cavium.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Steven J. Hill <steven.hill@cavium.com> Cc: linux-mips@linux-mips.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/15747/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
1ef0910cfd
commit
a81507c79f
|
@ -90,18 +90,14 @@ FEXPORT(sk_load_half_positive)
|
||||||
is_offset_in_header(2, half)
|
is_offset_in_header(2, half)
|
||||||
/* Offset within header boundaries */
|
/* Offset within header boundaries */
|
||||||
PTR_ADDU t1, $r_skb_data, offset
|
PTR_ADDU t1, $r_skb_data, offset
|
||||||
.set reorder
|
lhu $r_A, 0(t1)
|
||||||
lh $r_A, 0(t1)
|
|
||||||
.set noreorder
|
|
||||||
#ifdef CONFIG_CPU_LITTLE_ENDIAN
|
#ifdef CONFIG_CPU_LITTLE_ENDIAN
|
||||||
# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
|
# if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
|
||||||
wsbh t0, $r_A
|
wsbh $r_A, $r_A
|
||||||
seh $r_A, t0
|
|
||||||
# else
|
# else
|
||||||
sll t0, $r_A, 24
|
sll t0, $r_A, 8
|
||||||
andi t1, $r_A, 0xff00
|
srl t1, $r_A, 8
|
||||||
sra t0, t0, 16
|
andi t0, t0, 0xff00
|
||||||
srl t1, t1, 8
|
|
||||||
or $r_A, t0, t1
|
or $r_A, t0, t1
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,7 +111,7 @@ FEXPORT(sk_load_byte_positive)
|
||||||
is_offset_in_header(1, byte)
|
is_offset_in_header(1, byte)
|
||||||
/* Offset within header boundaries */
|
/* Offset within header boundaries */
|
||||||
PTR_ADDU t1, $r_skb_data, offset
|
PTR_ADDU t1, $r_skb_data, offset
|
||||||
lb $r_A, 0(t1)
|
lbu $r_A, 0(t1)
|
||||||
jr $r_ra
|
jr $r_ra
|
||||||
move $r_ret, zero
|
move $r_ret, zero
|
||||||
END(sk_load_byte)
|
END(sk_load_byte)
|
||||||
|
@ -139,6 +135,11 @@ FEXPORT(sk_load_byte_positive)
|
||||||
* (void *to) is returned in r_s0
|
* (void *to) is returned in r_s0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#ifdef CONFIG_CPU_LITTLE_ENDIAN
|
||||||
|
#define DS_OFFSET(SIZE) (4 * SZREG)
|
||||||
|
#else
|
||||||
|
#define DS_OFFSET(SIZE) ((4 * SZREG) + (4 - SIZE))
|
||||||
|
#endif
|
||||||
#define bpf_slow_path_common(SIZE) \
|
#define bpf_slow_path_common(SIZE) \
|
||||||
/* Quick check. Are we within reasonable boundaries? */ \
|
/* Quick check. Are we within reasonable boundaries? */ \
|
||||||
LONG_ADDIU $r_s1, $r_skb_len, -SIZE; \
|
LONG_ADDIU $r_s1, $r_skb_len, -SIZE; \
|
||||||
|
@ -150,7 +151,7 @@ FEXPORT(sk_load_byte_positive)
|
||||||
PTR_LA t0, skb_copy_bits; \
|
PTR_LA t0, skb_copy_bits; \
|
||||||
PTR_S $r_ra, (5 * SZREG)($r_sp); \
|
PTR_S $r_ra, (5 * SZREG)($r_sp); \
|
||||||
/* Assign low slot to a2 */ \
|
/* Assign low slot to a2 */ \
|
||||||
move a2, $r_sp; \
|
PTR_ADDIU a2, $r_sp, DS_OFFSET(SIZE); \
|
||||||
jalr t0; \
|
jalr t0; \
|
||||||
/* Reset our destination slot (DS but it's ok) */ \
|
/* Reset our destination slot (DS but it's ok) */ \
|
||||||
INT_S zero, (4 * SZREG)($r_sp); \
|
INT_S zero, (4 * SZREG)($r_sp); \
|
||||||
|
|
Loading…
Reference in New Issue