hw/net/rocker: Avoid undefined shifts with more than 31 ports
commit7cf745dd9c25f0740dc1009598b58dd8dd989876
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 29 Jul 2022 15:59:32 +0000 (29 16:59 +0100)
committerJason Wang <jasowang@redhat.com>
Tue, 9 Aug 2022 09:02:18 +0000 (9 17:02 +0800)
tree5deb3cbed74bac7d5c31a24390af269476e459ae
parentca5f3d4df1b47d7f66a109cdb504e83dfd7ec433
hw/net/rocker: Avoid undefined shifts with more than 31 ports

In rocker_port_phys_link_status() and rocker_port_phys_enable_read()
we construct a 64-bit value with one bit per front-panel port.
However we accidentally do the shift as 32-bit arithmetic, which
means that if there are more than 31 front-panel ports this is
undefined behaviour.

Fix the problem by ensuring we use 64-bit arithmetic for the whole
calculation. (We won't ever shift off the 64-bit value because
ROCKER_FP_PORTS_MAX is 62.)

Resolves: Coverity CID 14871211487160
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/rocker/rocker.c