mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 11:23:43 +08:00
target-arm: Drop CPUARMState* argument from bank_number()
Drop the CPUARMState* argument from bank_number(), since we only use it for passing to cpu_abort(). Use hw_error() instead. This avoids propagating further interfaces using env pointers. In the long term this function's callers need auditing to fix problems where badly behaved guests can pass invalid bank numbers. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
eadd0e4413
commit
f5206413af
@ -1617,7 +1617,7 @@ uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
#else
|
||||
|
||||
/* Map CPU modes onto saved register banks. */
|
||||
static inline int bank_number(CPUARMState *env, int mode)
|
||||
static inline int bank_number(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case ARM_CPU_MODE_USR:
|
||||
@ -1634,8 +1634,7 @@ static inline int bank_number(CPUARMState *env, int mode)
|
||||
case ARM_CPU_MODE_FIQ:
|
||||
return 5;
|
||||
}
|
||||
cpu_abort(env, "Bad mode %x\n", mode);
|
||||
return -1;
|
||||
hw_error("bank number requested for bad CPSR mode value 0x%x\n", mode);
|
||||
}
|
||||
|
||||
void switch_mode(CPUARMState *env, int mode)
|
||||
@ -1655,12 +1654,12 @@ void switch_mode(CPUARMState *env, int mode)
|
||||
memcpy (env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
i = bank_number(env, old_mode);
|
||||
i = bank_number(old_mode);
|
||||
env->banked_r13[i] = env->regs[13];
|
||||
env->banked_r14[i] = env->regs[14];
|
||||
env->banked_spsr[i] = env->spsr;
|
||||
|
||||
i = bank_number(env, mode);
|
||||
i = bank_number(mode);
|
||||
env->regs[13] = env->banked_r13[i];
|
||||
env->regs[14] = env->banked_r14[i];
|
||||
env->spsr = env->banked_spsr[i];
|
||||
@ -2530,7 +2529,7 @@ void HELPER(set_r13_banked)(CPUARMState *env, uint32_t mode, uint32_t val)
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
env->regs[13] = val;
|
||||
} else {
|
||||
env->banked_r13[bank_number(env, mode)] = val;
|
||||
env->banked_r13[bank_number(mode)] = val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2539,7 +2538,7 @@ uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
return env->regs[13];
|
||||
} else {
|
||||
return env->banked_r13[bank_number(env, mode)];
|
||||
return env->banked_r13[bank_number(mode)];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user