target-arm: Add write_type argument to cpsr_write()
Add an argument to cpsr_write() to indicate what kind of CPSR write is being requested, since the exact behaviour should differ for the different cases. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com> Message-id: 1455556977-3644-3-git-send-email-peter.maydell@linaro.org
This commit is contained in:
parent
235ea1f5c8
commit
50866ba5a2
@ -105,7 +105,7 @@ static inline void writeRegister(unsigned int x, unsigned int y)
|
||||
|
||||
static inline void writeConditionCodes(unsigned int x)
|
||||
{
|
||||
cpsr_write(user_registers,x,CPSR_NZCV);
|
||||
cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr);
|
||||
}
|
||||
|
||||
#define ARM_REG_PC 15
|
||||
|
@ -513,7 +513,7 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env)
|
||||
env->regs[0] = -1;
|
||||
cpsr &= ~CPSR_C;
|
||||
}
|
||||
cpsr_write(env, cpsr, CPSR_C);
|
||||
cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
|
||||
end_exclusive();
|
||||
return;
|
||||
|
||||
@ -562,7 +562,7 @@ do_kernel_trap(CPUARMState *env)
|
||||
env->regs[0] = -1;
|
||||
cpsr &= ~CPSR_C;
|
||||
}
|
||||
cpsr_write(env, cpsr, CPSR_C);
|
||||
cpsr_write(env, cpsr, CPSR_C, CPSRWriteByInstr);
|
||||
end_exclusive();
|
||||
break;
|
||||
case 0xffff0fe0: /* __kernel_get_tls */
|
||||
@ -4446,7 +4446,7 @@ int main(int argc, char **argv, char **envp)
|
||||
#elif defined(TARGET_ARM)
|
||||
{
|
||||
int i;
|
||||
cpsr_write(env, regs->uregs[16], 0xffffffff);
|
||||
cpsr_write(env, regs->uregs[16], 0xffffffff, CPSRWriteByInstr);
|
||||
for(i = 0; i < 16; i++) {
|
||||
env->regs[i] = regs->uregs[i];
|
||||
}
|
||||
|
@ -1611,7 +1611,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka,
|
||||
env->regs[13] = frame_addr;
|
||||
env->regs[14] = retcode;
|
||||
env->regs[15] = handler & (thumb ? ~1 : ~3);
|
||||
cpsr_write(env, cpsr, 0xffffffff);
|
||||
cpsr_write(env, cpsr, 0xffffffff, CPSRWriteByInstr);
|
||||
}
|
||||
|
||||
static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env)
|
||||
@ -1843,7 +1843,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc)
|
||||
__get_user(env->regs[15], &sc->arm_pc);
|
||||
#ifdef TARGET_CONFIG_CPU_32
|
||||
__get_user(cpsr, &sc->arm_cpsr);
|
||||
cpsr_write(env, cpsr, CPSR_USER | CPSR_EXEC);
|
||||
cpsr_write(env, cpsr, CPSR_USER | CPSR_EXEC, CPSRWriteByInstr);
|
||||
#endif
|
||||
|
||||
err |= !valid_user_regs(env);
|
||||
|
@ -718,8 +718,17 @@ static inline void pstate_write(CPUARMState *env, uint32_t val)
|
||||
|
||||
/* Return the current CPSR value. */
|
||||
uint32_t cpsr_read(CPUARMState *env);
|
||||
/* Set the CPSR. Note that some bits of mask must be all-set or all-clear. */
|
||||
void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask);
|
||||
|
||||
typedef enum CPSRWriteType {
|
||||
CPSRWriteByInstr = 0, /* from guest MSR or CPS */
|
||||
CPSRWriteExceptionReturn = 1, /* from guest exception return insn */
|
||||
CPSRWriteRaw = 2, /* trust values, do not switch reg banks */
|
||||
CPSRWriteByGDBStub = 3, /* from the GDB stub */
|
||||
} CPSRWriteType;
|
||||
|
||||
/* Set the CPSR. Note that some bits of mask must be all-set or all-clear.*/
|
||||
void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
|
||||
CPSRWriteType write_type);
|
||||
|
||||
/* Return the current xPSR value. */
|
||||
static inline uint32_t xpsr_read(CPUARMState *env)
|
||||
|
@ -94,7 +94,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
||||
return 4;
|
||||
case 25:
|
||||
/* CPSR */
|
||||
cpsr_write(env, tmp, 0xffffffff);
|
||||
cpsr_write(env, tmp, 0xffffffff, CPSRWriteByGDBStub);
|
||||
return 4;
|
||||
}
|
||||
/* Unknown register. */
|
||||
|
@ -5233,7 +5233,8 @@ uint32_t cpsr_read(CPUARMState *env)
|
||||
| (env->GE << 16) | (env->daif & CPSR_AIF);
|
||||
}
|
||||
|
||||
void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
|
||||
void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
|
||||
CPSRWriteType write_type)
|
||||
{
|
||||
uint32_t changed_daif;
|
||||
|
||||
|
@ -428,7 +428,7 @@ int kvm_arch_get_registers(CPUState *cs)
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
cpsr_write(env, cpsr, 0xffffffff);
|
||||
cpsr_write(env, cpsr, 0xffffffff, CPSRWriteRaw);
|
||||
|
||||
/* Make sure the current mode regs are properly set */
|
||||
mode = env->uncached_cpsr & CPSR_M;
|
||||
|
@ -723,7 +723,7 @@ int kvm_arch_get_registers(CPUState *cs)
|
||||
pstate_write(env, val);
|
||||
} else {
|
||||
env->uncached_cpsr = val & CPSR_M;
|
||||
cpsr_write(env, val, 0xffffffff);
|
||||
cpsr_write(env, val, 0xffffffff, CPSRWriteRaw);
|
||||
}
|
||||
|
||||
/* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the
|
||||
|
@ -175,7 +175,7 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size)
|
||||
|
||||
/* Avoid mode switch when restoring CPSR */
|
||||
env->uncached_cpsr = val & CPSR_M;
|
||||
cpsr_write(env, val, 0xffffffff);
|
||||
cpsr_write(env, val, 0xffffffff, CPSRWriteRaw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -422,13 +422,13 @@ uint32_t HELPER(cpsr_read)(CPUARMState *env)
|
||||
|
||||
void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask)
|
||||
{
|
||||
cpsr_write(env, val, mask);
|
||||
cpsr_write(env, val, mask, CPSRWriteByInstr);
|
||||
}
|
||||
|
||||
/* Write the CPSR for a 32-bit exception return */
|
||||
void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val)
|
||||
{
|
||||
cpsr_write(env, val, CPSR_ERET_MASK);
|
||||
cpsr_write(env, val, CPSR_ERET_MASK, CPSRWriteExceptionReturn);
|
||||
}
|
||||
|
||||
/* Access to user mode registers from privileged modes. */
|
||||
@ -780,7 +780,7 @@ void HELPER(exception_return)(CPUARMState *env)
|
||||
if (!return_to_aa64) {
|
||||
env->aarch64 = 0;
|
||||
env->uncached_cpsr = spsr & CPSR_M;
|
||||
cpsr_write(env, spsr, ~0);
|
||||
cpsr_write(env, spsr, ~0, CPSRWriteRaw);
|
||||
if (!arm_singlestep_active(env)) {
|
||||
env->uncached_cpsr &= ~PSTATE_SS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user