linux-user: Use restrictive mask when calling cpsr_write()

When linux-user code is calling cpsr_write(), use a restrictive
mask to ensure we are limiting the set of CPSR bits we update.
In particular, don't allow the mode bits to be changed.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1455556977-3644-5-git-send-email-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2016-02-23 15:36:43 +00:00
parent f8c88bbcda
commit ae08792301
2 changed files with 3 additions and 2 deletions

View File

@ -4446,7 +4446,8 @@ int main(int argc, char **argv, char **envp)
#elif defined(TARGET_ARM) #elif defined(TARGET_ARM)
{ {
int i; int i;
cpsr_write(env, regs->uregs[16], 0xffffffff, CPSRWriteByInstr); cpsr_write(env, regs->uregs[16], CPSR_USER | CPSR_EXEC,
CPSRWriteByInstr);
for(i = 0; i < 16; i++) { for(i = 0; i < 16; i++) {
env->regs[i] = regs->uregs[i]; env->regs[i] = regs->uregs[i];
} }

View File

@ -1611,7 +1611,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
env->regs[13] = frame_addr; env->regs[13] = frame_addr;
env->regs[14] = retcode; env->regs[14] = retcode;
env->regs[15] = handler & (thumb ? ~1 : ~3); env->regs[15] = handler & (thumb ? ~1 : ~3);
cpsr_write(env, cpsr, 0xffffffff, CPSRWriteByInstr); cpsr_write(env, cpsr, CPSR_IT | CPSR_T, CPSRWriteByInstr);
} }
static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env)