]> git.proxmox.com Git - mirror_qemu.git/commit
target/arm: Record correct opcode fields in cpreg for E2H aliases
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 9 Jan 2024 14:43:46 +0000 (14:43 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 9 Jan 2024 14:43:46 +0000 (14:43 +0000)
commit6f53b1267bb68b55bde65248212bcc071a15848f
treec9d09e78f7c837236b982881decca5bde1752587
parent29a15a61679dd35d8e2f4ea2c5fca77e476324db
target/arm: Record correct opcode fields in cpreg for E2H aliases

For FEAT_VHE, we define a set of register aliases, so that for instance:
 * the SCTLR_EL1 either accesses the real SCTLR_EL1, or (if E2H is 1)
   SCTLR_EL2
 * a new SCTLR_EL12 register accesses SCTLR_EL1 if E2H is 1

However when we create the 'new_reg' cpreg struct for the SCTLR_EL12
register, we duplicate the information in the SCTLR_EL1 cpreg, which
means the opcode fields are those of SCTLR_EL1, not SCTLR_EL12.  This
is a problem for code which looks at the cpreg opcode fields to
determine behaviour (e.g.  in access_check_cp_reg()). In practice
the current checks we do there don't intersect with the *_EL12
registers, but for FEAT_NV this will become a problem.

Write the correct values from the encoding into the new_reg struct.
This restores the invariant that the cpreg that you get back
from the hashtable has opcode fields that match the key you used
to retrieve it.

When we call the readfn or writefn for the target register, we
pass it the cpreg struct for that target register, not the one
for the alias, in case the readfn/writefn want to look at the
opcode fields to determine behaviour. This means we need to
interpose custom read/writefns for the e12 aliases.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Miguel Luis <miguel.luis@oracle.com>
target/arm/helper.c