]> git.baikalelectronics.ru Git - kernel.git/commit
s390/bpf,jit: fix 32 bit divisions, use unsigned divide instructions
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 17 Jan 2014 08:37:15 +0000 (09:37 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 18 Jan 2014 02:54:49 +0000 (18:54 -0800)
commit44c4168bf43cf53442ca6ab86eee3a2a29068f73
treee19b729126d28efa4f4325b21f834100d981e5bf
parent1e7e4e995a270a49a8647157de0021b1d9313ead
s390/bpf,jit: fix 32 bit divisions, use unsigned divide instructions

The s390 bpf jit compiler emits the signed divide instructions "dr" and "d"
for unsigned divisions.
This can cause problems: the dividend will be zero extended to a 64 bit value
and the divisor is the 32 bit signed value as specified A or X accumulator,
even though A and X are supposed to be treated as unsigned values.

The divide instrunctions will generate an exception if the result cannot be
expressed with a 32 bit signed value.
This is the case if e.g. the dividend is 0xffffffff and the divisor either 1
or also 0xffffffff (signed: -1).

To avoid all these issues simply use unsigned divide instructions.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/s390/net/bpf_jit_comp.c