[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/16] arm: fix aa64_generate_debug_exceptions to wor
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 11/16] arm: fix aa64_generate_debug_exceptions to work with EL2 |
Date: |
Mon, 12 Nov 2018 17:08:11 +0000 |
From: Alex Bennée <address@hidden>
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.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
target/arm/cpu.h | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 1efff21a18d..814ff69bc22 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2764,23 +2764,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)
@@ -2833,9 +2845,6 @@ static inline bool
aa32_generate_debug_exceptions(CPUARMState *env)
* since the pseudocode has it at all callsites except for the one in
* CheckSoftwareStep(), where it is elided because both branches would
* always return the same value.
- *
- * Parts of the pseudocode relating to EL2 and EL3 are omitted because we
- * don't yet implement those exception levels or their associated trap bits.
*/
static inline bool arm_generate_debug_exceptions(CPUARMState *env)
{
--
2.19.1
- [Qemu-devel] [PULL 00/16] target-arm queue, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 16/16] target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 14/16] target/arm: Correctly implement handling of HCR_EL2.{VI, VF}, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 15/16] target/arm: Hyp mode R14 is shared with User and System, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 12/16] Revert "target/arm: Implement HCR.VI and VF", Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 10/16] arm: use symbolic MDCR_TDE in arm_debug_target_el, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 13/16] target/arm: Track the state of our irq lines from the GIC explicitly, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 11/16] arm: fix aa64_generate_debug_exceptions to work with EL2,
Peter Maydell <=
- [Qemu-devel] [PULL 09/16] tests/guest-debug: fix scoping of failcount, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 07/16] target/arm64: hold BQL when calling do_interrupt(), Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 08/16] target/arm64: kvm debug set target_el when passing exception to guest, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 06/16] target/arm64: properly handle DBGVR RESS bits, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 05/16] target/arm: Fix typo in tlbi_aa64_vmalle1_write, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 04/16] hw/arm/sysbus-fdt: Only call match_fn callback if the type matches, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 03/16] MAINTAINERS: Add an entry for the 'collie' machine, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 02/16] target/arm: Remove antique TODO comment, Peter Maydell, 2018/11/12
- [Qemu-devel] [PULL 01/16] target/arm: Remove workaround for small SAU regions, Peter Maydell, 2018/11/12