Skip to contentSkip to conversation

target/arm: add RAZ/WI handling for DBGDTR[TX|RX]

RFC PATCH Applied Alex Bennée 3 participants 5 messages May 16, 2023 – May 18, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/arm: add RAZ/WI handling for DBGDTR[TX|RX]

The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console".

Extend the registers we RAZ/WI set to avoid this.

Cc Anders Roxell <[email protected]>
Cc Evgeny Iakovlev <[email protected]>
---
 target/arm/debug_helper.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
target/arm/debug_helper.c +9 -2
index dfc8b2a1a5..d41cc643b1 100644
@@ -949,8 +949,10 @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
       .access = PL0_R, .accessfn = access_tdcc,
       .type = ARM_CP_CONST, .resetvalue = 0 },
     /*
-     * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0.
-     * It is a component of the Debug Communications Channel, which is not implemented.
+     * These registers belong to the Debug Communications Channel,
+     * which is not implemented. However we implement RAZ/WI behaviour
+     * with trapping to prevent spurious SIGILLs if the guest OS does
+     * access them as the support cannot be probed for.
      */
     { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
       .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2,
@@ -960,6 +962,11 @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
       .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2,
       .access = PL1_RW, .accessfn = access_tdcc,
       .type = ARM_CP_CONST, .resetvalue = 0 },
+    /* DBGDTRTX_EL0/DBGDTRRX_EL0 depend on direction */
+    { .name = "DBGDTR_EL0", .state = ARM_CP_STATE_BOTH, .cp = 14,
+      .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 5, .opc2 = 0,
+      .access = PL0_RW, .accessfn = access_tdcc,
+      .type = ARM_CP_CONST, .resetvalue = 0 },
     /*
      * OSECCR_EL1 provides a mechanism for an operating system
      * to access the contents of EDECCR. EDECCR is not implemented though,
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Alex Bennée

The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console".

Quoted 8 lines

Extend the registers we RAZ/WI set to avoid this.

Cc Anders Roxell<[email protected]>
Cc Evgeny Iakovlev<[email protected]>
---
  target/arm/debug_helper.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)

r~

#2 lore raw
In reply to Alex Bennée
Quoted 7 lines · Alex Bennée

The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console".

Extend the registers we RAZ/WI set to avoid this.

Applied to target-arm.next, thanks.

(In theory we could implement the DCC and wire it up to a chardev, which might be a cute way of getting early debug.)

-- PMM

#3 lore raw
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Alex Bennée

The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console".

Quoted 6 lines
Quoted 1 line

Extend the registers we RAZ/WI set to avoid this.

Applied to target-arm.next, thanks.

(In theory we could implement the DCC and wire it up to a chardev, which might be a cute way of getting early debug.)

I wondered about that - does DCC give you anything that you can't get with semihosting (which I think also can support earlycon)?

I found it a little unclear if this is an always available feature. Should you expect any modern Cortex/Arm chip to support DCC when attached to jtag?

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#4 lore raw
Quoted 13 lines · Alex Bennée
Quoted 9 lines · Peter Maydell
Quoted 7 lines · Alex Bennée

The commit b3aa2f2128 (target/arm: provide stubs for more external debug registers) was added to handle HyperV's unconditional usage of Debug Communications Channel. It turns out that Linux will similarly break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console".

Extend the registers we RAZ/WI set to avoid this.

Quoted 7 lines
Quoted 4 lines

Applied to target-arm.next, thanks.

(In theory we could implement the DCC and wire it up to a chardev, which might be a cute way of getting early debug.)

I wondered about that - does DCC give you anything that you can't get with semihosting (which I think also can support earlycon)?

It gets you a debug console without having to trust the guest not to scribble all over your host filesystem :-) I'm not sure this really justifies the effort of the implementation, though. (Also, as usual the awkward part is the UI and how you'd let the user specify the chardev to connect up.)

Quoted 3 lines

I found it a little unclear if this is an always available feature. Should you expect any modern Cortex/Arm chip to support DCC when attached to jtag?

My guess is if you can attach to it over jtag at all then the DCC channel will be there.

-- PMM