]> git.proxmox.com Git - mirror_qemu.git/commit
target/arm: Enforce that M-profile SP low 2 bits are always zero
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 23 Jul 2021 16:21:41 +0000 (17:21 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 27 Jul 2021 09:57:39 +0000 (10:57 +0100)
commit888f470f123521b4fc9974d2dd1cc48629d73adc
tree0a190f32375fa6be8d6d38601f3ad978efa49323
parent953558291ec319476355900655fa53aa84ab99f0
target/arm: Enforce that M-profile SP low 2 bits are always zero

For M-profile, unlike A-profile, the low 2 bits of SP are defined to be
RES0H, which is to say that they must be hardwired to zero so that
guest attempts to write non-zero values to them are ignored.

Implement this behaviour by masking out the low bits:
 * for writes to r13 by the gdbstub
 * for writes to any of the various flavours of SP via MSR
 * for writes to r13 via store_reg() in generated code

Note that all the direct uses of cpu_R[] in translate.c are in places
where the register is definitely not r13 (usually because that has
been checked for as an UNDEFINED or UNPREDICTABLE case and handled as
UNDEF).

All the other writes to regs[13] in C code are either:
 * A-profile only code
 * writes of values we can guarantee to be aligned, such as
   - writes of previous-SP-value plus or minus a 4-aligned constant
   - writes of the value in an SP limit register (which we already
     enforce to be aligned)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210723162146.5167-2-peter.maydell@linaro.org
target/arm/gdbstub.c
target/arm/m_helper.c
target/arm/translate.c