OSDN Git Service

tcg/arm: Don't emit UNPREDICTABLE LDRD with Rm == Rt or Rt+1
authorRichard Henderson <richard.henderson@linaro.org>
Fri, 11 Mar 2022 07:38:47 +0000 (23:38 -0800)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 14 Mar 2022 17:31:51 +0000 (10:31 -0700)
commit76cff100beeae8d3676bb658cccd45ef5ced8aa9
treec1988135ad8645ebba6cde349647d13cb5c8d312
parent6e591a8569b24309f0b602042cce630524c03c0e
tcg/arm: Don't emit UNPREDICTABLE LDRD with Rm == Rt or Rt+1

The LDRD (register) instruction is UNPREDICTABLE if the Rm register
is the same as either Rt or Rt+1 (the two registers being loaded to).
We weren't making sure we avoided this, with the result that on some
host CPUs like the Cortex-A7 we would get a SIGILL because the CPU
chooses to UNDEF for this particular UNPREDICTABLE case.

Since we've already checked that datalo is aligned, we can simplify
the test vs the Rm operand by aligning it before comparison.  Check
for the two orderings before falling back to two ldr instructions.

We don't bother to do anything similar for tcg_out_ldrd_rwb(),
because it is only used in tcg_out_tlb_read() with a fixed set of
registers which don't overlap.

There is no equivalent UNPREDICTABLE case for STRD.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/896
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tcg/arm/tcg-target.c.inc