mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-23 06:25:12 +00:00
arm: fix aa64_generate_debug_exceptions to work with EL2
The test was incomplete and incorrectly caused debug exceptions to be generated when returning to EL2 after a failed attempt to single-step an EL1 instruction. Fix this while cleaning up the function a little. Backports commit 22af90255ec2100a44cbbb7f0460ba15eed79538 from qemu
This commit is contained in:
parent
2a3edfce37
commit
5b4c46eeab
|
@ -2713,23 +2713,35 @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
|
|||
return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0;
|
||||
}
|
||||
|
||||
/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
|
||||
static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
|
||||
{
|
||||
if (arm_is_secure(env)) {
|
||||
/* MDCR_EL3.SDD disables debug events from Secure state */
|
||||
if (extract32(env->cp15.mdcr_el3, 16, 1) != 0
|
||||
|| arm_current_el(env) == 3) {
|
||||
return false;
|
||||
}
|
||||
int cur_el = arm_current_el(env);
|
||||
int debug_el;
|
||||
|
||||
if (cur_el == 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arm_current_el(env) == arm_debug_target_el(env)) {
|
||||
if ((extract32(env->cp15.mdscr_el1, 13, 1) == 0)
|
||||
|| (env->daif & PSTATE_D)) {
|
||||
return false;
|
||||
}
|
||||
/* MDCR_EL3.SDD disables debug events from Secure state */
|
||||
if (arm_is_secure_below_el3(env)
|
||||
&& extract32(env->cp15.mdcr_el3, 16, 1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
/*
|
||||
* Same EL to same EL debug exceptions need MDSCR_KDE enabled
|
||||
* while not masking the (D)ebug bit in DAIF.
|
||||
*/
|
||||
debug_el = arm_debug_target_el(env);
|
||||
|
||||
if (cur_el == debug_el) {
|
||||
return extract32(env->cp15.mdscr_el1, 13, 1)
|
||||
&& !(env->daif & PSTATE_D);
|
||||
}
|
||||
|
||||
/* Otherwise the debug target needs to be a higher EL */
|
||||
return debug_el > cur_el;
|
||||
}
|
||||
|
||||
static inline bool aa32_generate_debug_exceptions(CPUARMState *env)
|
||||
|
|
Loading…
Reference in a new issue