]> git.proxmox.com Git - mirror_qemu.git/commit - target/arm/cpu.c
target/arm: Don't skip M-profile reset entirely in user mode
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 20 Sep 2021 08:54:33 +0000 (09:54 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 20 Sep 2021 08:54:33 +0000 (09:54 +0100)
commitb62ceeaf8096fdbbbfdc6087da0028bc4a4dd77e
tree1a16f5102b8c04adf192170fe88a06ea2036e8a4
parentf015cbb546387e1132a15c29e6afacec4a6d2910
target/arm: Don't skip M-profile reset entirely in user mode

Currently all of the M-profile specific code in arm_cpu_reset() is
inside a !defined(CONFIG_USER_ONLY) ifdef block.  This is
unintentional: it happened because originally the only
M-profile-specific handling was the setup of the initial SP and PC
from the vector table, which is system-emulation only.  But then we
added a lot of other M-profile setup to the same "if (ARM_FEATURE_M)"
code block without noticing that it was all inside a not-user-mode
ifdef.  This has generally been harmless, but with the addition of
v8.1M low-overhead-loop support we ran into a problem: the reset of
FPSCR.LTPSIZE to 4 was only being done for system emulation mode, so
if a user-mode guest tried to execute the LE instruction it would
incorrectly take a UsageFault.

Adjust the ifdefs so only the really system-emulation specific parts
are covered.  Because this means we now run some reset code that sets
up initial values in the FPCCR and similar FPU related registers,
explicitly set up the registers controlling FPU context handling in
user-emulation mode so that the FPU works by design and not by
chance.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/613
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210914120725.24992-2-peter.maydell@linaro.org
target/arm/cpu.c