]> xenbits.xensource.com Git - qemu-xen.git/commit
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)
committerMichael Roth <michael.roth@amd.com>
Tue, 14 Dec 2021 14:56:25 +0000 (08:56 -0600)
commit3054f772de9c2e97e7c196d4f3e70d58aca1e807
tree1dedd1e9b53e046d6360e7b997fed280af4d24f8
parentaa77e375a5b1b91d7646d8b5f8683778f53fbbd3
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
(cherry picked from commit b62ceeaf8096fdbbbfdc6087da0028bc4a4dd77e)
Signed-off-by: Michael Roth <michael.roth@amd.com>
target/arm/cpu.c