aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-05-18 15:28:01 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-05-21 22:05:27 +0100
commit268b1b3dfbb92a9348406f728a33f39e3d8dcd8a (patch)
tree66ca86f3c6f1def287979330e0bc6f9d8a5e0d08 /linux-user
parente1f778596ebfa8782276f4dd4651f2b285d734ff (diff)
downloadqemu-268b1b3dfbb92a9348406f728a33f39e3d8dcd8a.zip
qemu-268b1b3dfbb92a9348406f728a33f39e3d8dcd8a.tar.gz
qemu-268b1b3dfbb92a9348406f728a33f39e3d8dcd8a.tar.bz2
target/arm: Allow user-mode code to write CPSR.E via MSR
Using the MSR instruction to write to CPSR.E is deprecated, but it is required to work from any mode including unprivileged code. We were incorrectly forbidding usermode code from writing it because CPSR_USER did not include the CPSR_E bit. We use CPSR_USER in only three places: * as the mask of what to allow userspace MSR to write to CPSR * when deciding what bits a linux-user signal-return should be able to write from the sigcontext structure * in target_user_copy_regs() when we set up the initial registers for the linux-user process In the first two cases not being able to update CPSR.E is a bug, and in the third case it doesn't matter because CPSR.E is always 0 there. So we can fix both bugs by adding CPSR_E to CPSR_USER. Because the cpsr_write() in restore_sigcontext() is now changing a CPSR bit which is cached in hflags, we need to add an arm_rebuild_hflags() call there; the callsite in target_user_copy_regs() was already rebuilding hflags for other reasons. (The recommended way to change CPSR.E is to use the 'SETEND' instruction, which we do correctly allow from usermode code.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20200518142801.20503-1-peter.maydell@linaro.org
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/arm/signal.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c
index d96fc27..8020c80 100644
--- a/linux-user/arm/signal.c
+++ b/linux-user/arm/signal.c
@@ -546,6 +546,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc)
#ifdef TARGET_CONFIG_CPU_32
__get_user(cpsr, &sc->arm_cpsr);
cpsr_write(env, cpsr, CPSR_USER | CPSR_EXEC, CPSRWriteByInstr);
+ arm_rebuild_hflags(env);
#endif
err |= !valid_user_regs(env);