Skip to contentSkip to conversation

target-arm: implement arm_debug_target_el()

PATCH Applied Sergey Fedorov 3 participants 8 messages Sep 14, 2015 – Oct 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-arm: implement arm_debug_target_el()

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

---
 target-arm/cpu.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
target-arm/cpu.h +16 -1
index 31825d3..84d38b1 100644
@@ -1692,7 +1692,22 @@ static inline int cpu_mmu_index(CPUARMState *env)
  */
 static inline int arm_debug_target_el(CPUARMState *env)
 {
-    return 1;
+    bool secure = arm_is_secure(env);
+    bool route_to_el2 = false;
+
+    if (arm_feature(env, ARM_FEATURE_EL2) && !secure) {
+        route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
+                       env->cp15.mdcr_el2 & (1 << 8);
+    }
+
+    if (route_to_el2) {
+        return 2;
+    } else if (arm_feature(env, ARM_FEATURE_EL3) &&
+               !arm_el_is_aa64(env, 3) && secure) {
+        return 3;
+    } else {
+        return 1;
+    }
 }
 
 static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Applied to target-arm.next, thanks.

-- PMM

#2 lore raw
Quoted 9 lines · Peter Maydell
Quoted 4 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2. Presumably there's some other patch this depends on which you haven't submitted yet?

thanks
-- PMM

#3 lore raw
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2. Presumably there's some other patch this depends on which you haven't submitted yet?

Hm... I'll check it :)

Best,
Sergey

#4 lore raw
Quoted 6 lines · Sergey Fedorov
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2. Presumably there's some other patch this depends on which you haven't submitted yet?

Hm... I'll check it :)

Sorry, I forgot to check that, but actually this patch depends on another two patches in my local repository. Should I prepare MDCR_EL2 patch suitable for mainline or I can just remove this check from arm_debug_target_el()?

Best,
Sergey

#5 lore raw
Quoted 14 lines · Sergey Fedorov
Quoted 13 lines · Sergey Fedorov
Quoted 12 lines · Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 4 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2. Presumably there's some other patch this depends on which you haven't submitted yet?

Quoted 6 lines
Quoted 1 line

Hm... I'll check it :)

Sorry, I forgot to check that, but actually this patch depends on another two patches in my local repository. Should I prepare MDCR_EL2 patch suitable for mainline or I can just remove this check from arm_debug_target_el()?

Edgar, do you have a MDCR_EL2 implementation in your tree?

Otherwise, yes, Sergey, you should provide an MDCR_EL2/HDCR patch for mainline I think. It should be fairly easy as it just needs to be readable/writable and have the correct access checks. Don't forget to provide the AArch32 interface as well as the AArch64 one, and the "RES0 if EL3 but not EL2" version.
(See Edgar's recent patches in master for VMPIDR_EL2, VTCR_EL2, etc for examples.)

thanks
-- PMM

#6 lore raw
Quoted 24 lines · Peter Maydell
Quoted 14 lines · Sergey Fedorov
Quoted 13 lines · Sergey Fedorov
Quoted 12 lines · Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 4 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2. Presumably there's some other patch this depends on which you haven't submitted yet?

Quoted 6 lines
Quoted 1 line

Hm... I'll check it :)

Sorry, I forgot to check that, but actually this patch depends on another two patches in my local repository. Should I prepare MDCR_EL2 patch suitable for mainline or I can just remove this check from arm_debug_target_el()?

Edgar, do you have a MDCR_EL2 implementation in your tree?

Quoted 7 lines

Otherwise, yes, Sergey, you should provide an MDCR_EL2/HDCR patch for mainline I think. It should be fairly easy as it just needs to be readable/writable and have the correct access checks. Don't forget to provide the AArch32 interface as well as the AArch64 one, and the "RES0 if EL3 but not EL2" version.
(See Edgar's recent patches in master for VMPIDR_EL2, VTCR_EL2, etc for examples.)

Hi,

Sorry, no, I only have a dummy for MDCR_EL2.. Would be great if Sergey has something ready.

Best regards,
Edgar

#7 lore raw
In reply to Peter Maydell
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Sergey Fedorov

Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Applied to target-arm.next, thanks.

...except it doesn't compile, because we don't have an env->cp15.mdcr_el2.

Reapplied, now we have an mdcr_el2 for it to use.

-- PMM