]> git.proxmox.com Git - mirror_qemu.git/commit
target-arm: A64: Fix handling of rotate in logic_imm_decode_wmask
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 13 Feb 2015 05:46:09 +0000 (05:46 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 13 Feb 2015 05:46:09 +0000 (05:46 +0000)
commite167adc9d9f5df4f8109aecd4552c407fdce094a
tree085305c3fd3312e3dfc1aed8797d95be29d84178
parent1743d55c8b38bcee632cf6eb2de81131635bb3d2
target-arm: A64: Fix handling of rotate in logic_imm_decode_wmask

The code in logic_imm_decode_wmask attempts to rotate a mask
value within the bottom 'e' bits of the value with
    mask = (mask >> r) | (mask << (e - r));
This has two issues:
 * if the element size is 64 then a rotate by zero results
   in a shift left by 64, which is undefined behaviour
 * if the element size is smaller than 64 then this will
   leave junk in the value at bit 'e' and above, which is
   not valid input to bitfield_replicate(). As it happens,
   the bits at bit 'e' to '2e - r' are exactly the ones
   which bitfield_replicate is going to copy in there,
   so this isn't a "wrong code generated" bug, but it's
   confusing and if we ever put an assert in
   bitfield_replicate it would fire on valid guest code.

Fix the former by not doing anything if r is zero, and
the latter by masking with bitmask64(e).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1423233250-15853-3-git-send-email-peter.maydell@linaro.org
target-arm/translate-a64.c