target/arm: Fix big-endian host handling of VTCR
commitafbb181c2deb4584666be17adfbc49532fc90ace
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 14 Jul 2022 13:23:00 +0000 (14 14:23 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 18 Jul 2022 12:20:13 +0000 (18 13:20 +0100)
treecdb538bef72f51684f8962020cc58fb37e309d65
parentc1547bba7eead64575a662acd95a986ac2956213
target/arm: Fix big-endian host handling of VTCR

We have a bug in our handling of accesses to the AArch32 VTCR
register on big-endian hosts: we were not adjusting the part of the
uint64_t field within TCR that the generated code would access.  That
can be done with offsetoflow32(), by using an ARM_CP_STATE_BOTH cpreg
struct, or by defining a full set of read/write/reset functions --
the various other TCR cpreg structs used one or another of those
strategies, but for VTCR we did not, so on a big-endian host VTCR
accesses would touch the wrong half of the register.

Use offsetoflow32() in the VTCR register struct.  This works even
though the field in the CPU struct is currently a struct TCR, because
the first field in that struct is the uint64_t raw_tcr.

None of the other TCR registers have this bug -- either they are
AArch64 only, or else they define resetfn, writefn, etc, and
expect to be passed the full struct pointer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220714132303.1287193-5-peter.maydell@linaro.org
target/arm/helper.c