aarch64: Enable TRBE for the non-secure world
PATCH 1/1 aarch64: Enable TRBE for the non-secure world
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset MDCR_EL3 register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.
--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/aarch64/boot.S +8 -0
@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1 +1: mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3 mrs x0, id_aa64pfr0_el1
Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Anshuman,
Quoted 20 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)arch/aarch64/boot.S +1
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1 +1: mrs x1, id_aa64dfr0_el1
arch/aarch64/boot.S _start: · line 84
Quoted 10 lines
arch/aarch64/boot.S +7
-0+ ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3 mrs x0, id_aa64pfr0_el1
That's strange, I'm looking at ARM DDI 0487G.a and bits [44:47] from ID_AA64DFR0_EL1 are RES0 and there is no TraceBuffer field; bits [24:25] of MDCR_EL3 are also RES0 and I searched the entire file for the NSTB field, could not find it. Do I have an outdated version of the architecture?
Thanks,
Alex
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 32 lines · Alexandru Elisei
Hello Anshuman,
Quoted 29 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)arch/aarch64/boot.S +8
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1 +1: mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3
Quoted 6 lines
arch/aarch64/boot.S _start: · line 84
Quoted 1 line
arch/aarch64/boot.S +0
-0mrs x0, id_aa64pfr0_el1That's strange, I'm looking at ARM DDI 0487G.a and bits [44:47] from
ID_AA64DFR0_EL1are RES0 and there is no TraceBuffer field; bits [24:25] ofMDCR_EL3are also RES0 and I searched the entire file for the NSTB field, could not find it. Do I have an outdated version of the architecture?
They are not in the Arm ARM. These are part of the Future Architecture technology changes, for which the register defintions are available here :
https://developer.arm.com/documentation/ddi0601/2020-12/AArch64-Registers/
Cheers
Suzuki
Quoted 5 lines
Thanks,
Alex
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi,
Quoted 38 lines · Suzuki K Poulose
Quoted 28 lines · Alexandru Elisei
Hello Anshuman,
Quoted 25 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>---
arch/aarch64/boot.S| 8 ++++++++1 file changed, 8 insertions(+)arch/aarch64/boot.S +0
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12)orr x0, x0, x1
+1: mrs x1,id_aa64dfr0_el1
+ ubfx x1, x1, #44, #4
+ cbz x1, 1f
+
+ // Enable TRBE for the non-secure world.
+ ldr x1, =(0x3 << 24)
+ orr x0, x0, x1Quoted 8 lines
Quoted 3 lines
+
1: msrmdcr_el3, x0 // Disable traps to EL3 mrs x0,id_aa64pfr0_el1That's strange, I'm looking at ARM DDI 0487G.a and bits [44:47] from
ID_AA64DFR0_EL1are RES0 and there is no TraceBuffer field; bits [24:25] ofMDCR_EL3are also RES0 and I searched the entire file for the NSTB field, could not find it. Do I have an outdated version of the architecture?
Quoted 4 lines
They are not in the Arm ARM. These are part of the Future Architecture technology changes, for which the register defintions are available here :
https://developer.arm.com/documentation/ddi0601/2020-12/AArch64-Registers/
That worked, thanks!
Thanks,
Alex
Quoted 10 lines
Cheers
SuzukiQuoted 5 lines
Thanks,
Alex
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello,
Quoted 16 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)arch/aarch64/boot.S +0
-0
arch/aarch64/boot.S _start: · line 74
Quoted 4 lines
arch/aarch64/boot.S +1
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1 +1: mrs x1, id_aa64dfr0_el1
Nitpick: we could change the first read of ID_AA64DFR0_EL1 to use x2 as the destination register, to avoid this second read.
arch/aarch64/boot.S _start: · line 82
Quoted 8 lines
arch/aarch64/boot.S +7
-0+ ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3
Looked at [1] for the field definitions, and the patch indeed does what it says. 0b11 for MDCR_EL3.NSTB means that the buffer owning regime is the non-secure state, and accesses to the buffer control registers from the *secure state* are trapped to EL3, which is what we want.
With or without the destination register change:
[1] https://developer.arm.com/documentation/ddi0601/2020-12/AArch64-Registers/
Thanks,
Alex
arch/aarch64/boot.S _start: · line 84
Quoted 2 lines
arch/aarch64/boot.S +0
-0mrs x0, id_aa64pfr0_el1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 22 lines · Alexandru Elisei
Hello,
Quoted 19 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)arch/aarch64/boot.S +0
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1
Quoted 4 lines
arch/aarch64/boot.S _start: · line 74
Quoted 1 line
arch/aarch64/boot.S +1
-0+1: mrs x1, id_aa64dfr0_el1Nitpick: we could change the first read of
ID_AA64DFR0_EL1to use x2 as the destination register, to avoid this second read.
I've kept this as-is for now; my general preference is to keep things such that each of the feature enables can be read indepdendently, even if that requires some redundant work.
Quoted 14 lines
arch/aarch64/boot.S _start: · line 82
Quoted 8 lines
arch/aarch64/boot.S +7
-0+ ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3Looked at [1] for the field definitions, and the patch indeed does what it says. 0b11 for MDCR_EL3.NSTB means that the buffer owning regime is the non-secure state, and accesses to the buffer control registers from the *secure state* are trapped to EL3, which is what we want.
Quoted 3 lines
With or without the destination register change:
Reviewed-by Alexandru Elisei <[email protected]>
Thanks for the review -- I folded your tag in.
Mark.
Quoted 9 lines
[1] https://developer.arm.com/documentation/ddi0601/2020-12/AArch64-Registers/
Thanks,
Alex
Quoted 2 lines
arch/aarch64/boot.S +0
-0mrs x0, id_aa64pfr0_el1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
AppliedQuoted 7 lines · Anshuman Khandual
MDCR_EL3.NSTB resets to an UNKNOWN value. Configure it to allow the trace buffer to use non-secure memory and to permit direct register accesses from the non-secure world. Before that, just check AA64DFR0_EL1.TraceBuffer and make sure TRBE is implemented. We still continue to reset
MDCR_EL3register to zero with the exception of MDCR_EL3.NSPB and MDCR_EL3.NSTB.Signed-off-by Anshuman Khandual <[email protected]>
Applied, thanks!
Mark.
Quoted 26 lines
--- arch/aarch64/boot.S | 8 ++++++++ 1 file changed, 8 insertions(+)arch/aarch64/boot.S +8
-0@@ -71,6 +71,14 @@ _start: ldr x1, =(0x3 << 12) orr x0, x0, x1 +1: mrs x1, id_aa64dfr0_el1 + ubfx x1, x1, #44, #4 + cbz x1, 1f + + // Enable TRBE for the non-secure world. + ldr x1, =(0x3 << 24) + orr x0, x0, x1 + 1: msr mdcr_el3, x0 // Disable traps to EL3 mrs x0, id_aa64pfr0_el1Signature · 1 line
2.7.4
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel