qemu-e2k/linux-user
Peter Maydell 268b1b3dfb 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
2020-05-21 22:05:27 +01:00
..
aarch64 linux-user, aarch64: sync syscall numbers with kernel v5.5 2020-03-20 16:02:00 +01:00
alpha linux-user, alpha: add syscall table generation support 2020-03-20 16:02:00 +01:00
arm target/arm: Allow user-mode code to write CPSR.E via MSR 2020-05-21 22:05:27 +01:00
cris linux-user: Introduce cpu_clone_regs_parent 2019-11-06 13:43:25 +01:00
generic linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK 2019-07-02 16:56:46 +02:00
host linux-user: Add safe_syscall for riscv64 host 2018-12-26 06:40:02 +11:00
hppa linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
i386 linux-user/i386: Emulate x86_64 vsyscalls 2020-03-26 08:08:54 +01:00
m68k linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
microblaze linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
mips linux-user,mips: update syscall-args-o32.c.inc 2020-03-20 16:02:00 +01:00
mips64 linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
nios2 linux-user, nios2: sync syscall numbers with kernel v5.5 2020-03-20 16:02:00 +01:00
openrisc linux-user, openrisc: sync syscall numbers with kernel v5.5 2020-03-20 16:02:00 +01:00
ppc linux-user/ppc: Fix padding in mcontext_t for ppc64 2020-04-17 10:38:29 +10:00
riscv linux-user/riscv: fix up struct target_ucontext definition 2020-04-29 13:16:37 -07:00
s390x linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
sh4 linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
sparc linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
sparc64 linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
tilegx linux-user: Introduce cpu_clone_regs_parent 2019-11-06 13:43:25 +01:00
x86_64 linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
xtensa linux-user: update syscall.tbl from linux 0bf999f9c5e7 2020-03-20 16:02:00 +01:00
Makefile.objs linux-user, mips64: add syscall table generation support 2020-03-20 16:02:00 +01:00
cpu_loop-common.h cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
elfload.c linux-user: completely re-write init_guest_space 2020-05-15 15:25:16 +01:00
errno_defs.h Supply missing header guards 2019-06-12 13:20:21 +02:00
exit.c build: move TARGET_GPROF to config-host.mak 2020-02-12 16:29:27 +01:00
fd-trans.c linux-user: Use `qemu_log' for non-strace logging 2020-02-19 11:17:40 +01:00
fd-trans.h linux-user: move TargetFdTrans functions to their own file 2018-09-25 22:36:47 +02:00
flat.h Supply missing header guards 2019-06-12 13:20:21 +02:00
flatload.c linux-user: completely re-write init_guest_space 2020-05-15 15:25:16 +01:00
ioctls.h linux-user: Add support for selected alsa timer instructions using ioctls 2020-02-19 11:17:40 +01:00
linux_loop.h linux-user: Add loop control ioctls 2016-07-19 15:22:33 +03:00
linuxload.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
main.c exec/cpu-all: Use bool for have_guest_base 2020-05-15 15:25:16 +01:00
mmap.c linux-user: Update TASK_UNMAPPED_BASE for aarch64 2020-03-20 15:51:54 +01:00
qemu.h linux-user: completely re-write init_guest_space 2020-05-15 15:25:16 +01:00
safe-syscall.S linux-user: Provide safe_syscall for fixing races between signals and syscalls 2016-05-27 14:49:51 +03:00
signal-common.h linux-user: Make sigaltstack stacks per-thread 2019-07-26 19:24:33 +02:00
signal.c linux-user: Use `qemu_log' for strace 2020-02-19 11:17:40 +01:00
socket.h Supply missing header guards 2019-06-12 13:20:21 +02:00
strace.c linux-user: Protect more syscalls 2020-03-20 16:01:46 +01:00
strace.list linux-user/strace: Improve output of various syscalls 2020-02-19 11:17:40 +01:00
syscall.c linux-user/syscall.c: add target-to-host mapping for epoll_create1() 2020-04-16 09:24:22 +02:00
syscall_defs.h linux-user: Add support for selected alsa timer instructions using ioctls 2020-02-19 11:17:40 +01:00
syscall_types.h linux-user: Add support for getting/setting selected alsa timer parameters using ioctls 2020-02-19 11:17:40 +01:00
target_flat.h Supply missing header guards 2019-06-12 13:20:21 +02:00
trace-events linux-user: fix use of SIGRTMIN 2020-02-12 18:56:41 +01:00
uaccess.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
uname.c cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
uname.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
vm86.c linux-user: Use `qemu_log' for non-strace logging 2020-02-19 11:17:40 +01:00