Coresight for Kernel panic and watchdog reset
v3 cover Coresight for Kernel panic and watchdog reset
This RFC v3 patch series is rebased on v6.5-rc7 and is dependent on the below two patches.
- coresight: tmc: Make etr buffer mode user configurable from sysfs[1]
- coresight: Fix run time warnings while reusing ETR buffer[2]
Changelog from v2:
* ETR reserved buffer mode can be selected only through the new sysfs buffer mode and not by default. This would avoid any conflicts with normal usage.
* ETR buffer size in reserved mode is now always fixed to the maximum size of the reserved buffer and not user configurable. This avoids any conflicts with the default buffer size used in other ETR buffer modes.
* Introduced new ops called prevboot_ops to factor out common code in tmc_etr_prepare_prevboot() and tmc_etb_prepare_prevboot(). spin_lock/unlock invocations tmc_read_prepare_* are now in a single function.
* Added more stringent checks for selecting READ_PREVBOOT mode
Other misc changes:
* Added more details to DT bindings documentation
* Fixed unhandled case error in etm4_disable with CONFIG_WERROR
* TMC register saving now uses standard accessor functions
* Added panic notifier unregistration
* memremap of reserved and metadata buffers are now with _WB attributes
* Cover letter title has been shortened.
Changelog from v1:
* V2 is a complete patchset with kernel panic trace tested on Linux 6.4. Details on testing with relevant console logs has been added for reference.
* Two additional patches(patch 6 & 7) has been included to manage stopping of trace at the time of kernel panic.
* Few bug fixes.
RFC v1 is posted here:
https://lists.linaro.org/archives/list/[email protected]/thread/6FANLYCCSZROLJMERS2MVCKFBBZOMGHJ/
Using Coresight for Kernel panic and Watchdog reset
===================================================
This RFC is about extending Linux coresight driver support to address kernel panic and watchdog reset scenarios. This would help coresight users to debug kernel panic and watchdog reset with the help of coresight trace data.
Coresight trace capture: Kernel panic
-------------------------------------
From the coresight driver point of view, addressing the kernel panic situation has four main requirements.
a. Support for allocation of trace buffer pages from reserved memory area.
Platform can advertise this using a new device tree property added to relevant coresight nodes.
b. Support for stopping coresight blocks at the time of panic
c. Saving required metadata in the specified format
d. Support for reading trace data captured at the time of panic
Allocation of trace buffer pages from reserved RAM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A new optional device tree property "memory-region" is added to the ETR/ETF device nodes, that would give the base address and size of trace buffer.
Static allocation of trace buffers would ensure that both IOMMU enabled and disabled cases are handled. Also, platforms that support persistent RAM will allow users to read trace data in the subsequent boot without booting the crashdump kernel.
Note:
For ETR sink devices, this reserved region will be used for both trace capture and trace data retrieval.
For ETF sink devices, internal SRAM would be used for trace capture, and they would be synced to reserved region for retrieval.
Note: Patches 1 & 2 adds support for this.
Disabling coresight blocks at the time of panic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to avoid the situation of losing relevant trace data after a kernel panic, it would be desirable to stop the coresight blocks at the time of panic.
This can be achieved by configuring the comparator, CTI and sink devices as below,
Comparator(triggers on kernel panic) --->External out --->CTI --
| ETR/ETF stop <------External In <--------------
Note:
* Patch 6 provides the necessary ETR configuration.
* Patch 7 provides the necessary ETM configuration.
Saving metadata at the time of kernel panic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Coresight metadata involves all additional data that are required for a successful trace decode in addition to the trace data. This involves ETR/ETF, ETE register snapshot etc.
A new optional device property "memory-region" is added to the ETR/ETF/ETE device nodes for this.
Note: Patches 3 & 4 adds support for this.
Reading trace data captured at the time of panic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Trace data captured at the time of panic, can be read from rebooted kernel or from crashdump kernel using the below mentioned interface.
Note: Patch 5 adds support for this.
Steps for reading trace data captured in previous boot
++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. cd /sys/bus/coresight/devices/tmc_etrXX/
2. Change to special mode called, read_prevboot.
#echo 1 > read_prevboot
3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
4. Reset back to normal mode
#echo 0 > read_prevboot
General flow of trace capture and decode incase of kernel panic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Enable source and sink on all the cores using the sysfs interface. ETR sink will have trace buffers allocated from reserved memory, by selecting "resrv" buffer mode from sysfs.
2. Run relevant tests.
3. On a kernel panic, all coresight blocks are disabled, necessary metadata is synced by kernel panic handler.
System would eventually reboot or boot a crashdump kernel.
4. For platforms that supports crashdump kernel, raw trace data can be dumped using the coresight sysfs interface from the crashdump kernel itself. Persistent RAM is not a requirement in this case.
5. For platforms that supports persistent RAM, trace data can be dumped using the coresight sysfs interface in the subsequent Linux boot. Crashdump kernel is not a requirement in this case. Persistent RAM ensures that trace data is intact across reboot.
Coresight trace capture: Watchdog reset
---------------------------------------
The main difference between addressing the watchdog reset and kernel panic case are below,
a. Saving coresight metadata need to be taken care by the
SCP(system control processor) firmware in the specified format, instead of kernel.
b. Reserved memory region given by firmware for trace buffer and metadata
has to be in persistent RAM.
Note: This is a requirement for watchdog reset case but optional in kernel panic case.
Watchdog reset can be supported only on platforms that meet the above two requirements.
Testing Kernel panic on Linux 6.5
---------------------------------
1. Configure CTI using sysfs interface
#./cti_setup.sh
#cat cti_setup.sh
cd /sys/bus/coresight/devices/
ap_cti_config () {
#ETM trig out[0] trigger to Channel 0
echo 0 4 > channels/trigin_attach
}
etf_cti_config () {
#ETF Flush in trigger from Channel 0
echo 0 1 > channels/trigout_attach
echo 1 > channels/trig_filter_enable
}
etr_cti_config () {
#ETR Flush in from Channel 0
echo 0 1 > channels/trigout_attach
echo 1 > channels/trig_filter_enable
}
ctidevs=find . -name "cti*"
for i in $ctidevs
do
cd $i
connection=find . -name "ete*"
if [ ! -z "$connection" ]
then
echo "AP CTI config for $i"
ap_cti_config
fi
connection=find . -name "tmc_etf*"
if [ ! -z "$connection" ]
then
echo "ETF CTI config for $i"
etf_cti_config
fi
connection=find . -name "tmc_etr*"
if [ ! -z "$connection" ]
then
echo "ETR CTI config for $i"
etr_cti_config
fi
cd ..
done
Note: CTI connections are SOC specific and hence the above script is added just for reference.
2. Start Coresight tracing on cores 1 and 2 using sysfs interface
3. Run some application on core 1
#taskset -c 1 dd if=/dev/urandom of=/dev/null &
4. Invoke kernel panic on core 2
#echo 1 > /proc/sys/kernel/panic
#taskset -c 2 echo c > /proc/sysrq-trigger
5. From rebooted kernel, enable previous boot mode
#echo 1 > /sys/bus/coresight/devices/tmc_etr0/read_prevboot
6. Read trace data
#dd if=/dev/tmc_etr0 of=/trace/cstrace.bin
7. Run opencsd decoder tools/scripts to generate the instruction trace.
Core 1 instruction trace dump:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 1 line
Quoted 1 line
A etm4_enable_hw: ffff800008ae1dd4 CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 I etm4_enable_hw: ffff800008ae1dd4:
d503201f nop
I etm4_enable_hw: ffff800008ae1dd8:d503201f nop
I etm4_enable_hw: ffff800008ae1ddc:d503201f nop
I etm4_enable_hw: ffff800008ae1de0:d503201f nop
I etm4_enable_hw: ffff800008ae1de4:d503201f nop
I etm4_enable_hw: ffff800008ae1de8:d503233f paciasp
I etm4_enable_hw: ffff800008ae1dec:a9be7bfd stp x29, x30, [sp, #-32]!
I etm4_enable_hw: ffff800008ae1df0:910003fd mov x29, sp
I etm4_enable_hw: ffff800008ae1df4:a90153f3 stp x19, x20, [sp, #16]
I etm4_enable_hw: ffff800008ae1df8:2a0003f4 mov w20, w0
I etm4_enable_hw: ffff800008ae1dfc:900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48>
I etm4_enable_hw: ffff800008ae1e00:910f4273 add x19, x19, #0x3d0
I etm4_enable_hw: ffff800008ae1e04:f8747a60 ldr x0, [x19, x20, lsl #3]
E etm4_enable_hw: ffff800008ae1e08:b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50>
I 149.039572921 etm4_enable_hw: ffff800008ae1e30:a94153f3 ldp x19, x20, [sp, #16]
I 149.039572921 etm4_enable_hw: ffff800008ae1e34:
52800000 mov w0, #0x0 // #0
I 149.039572921 etm4_enable_hw: ffff800008ae1e38:a8c27bfd ldp x29, x30, [sp], #32
..snip
149.052324811 chacha_block_generic: ffff800008642d80:
9100a3e0 add x0,
I 149.052324811 chacha_block_generic: ffff800008642d84:b86178a2 ldr w2, [x5, x1, lsl #2]
I 149.052324811 chacha_block_generic: ffff800008642d88:8b010803 add x3, x0, x1, lsl #2
I 149.052324811 chacha_block_generic: ffff800008642d8c:b85fc063 ldur w3, [x3, #-4]
I 149.052324811 chacha_block_generic: ffff800008642d90:0b030042 add w2, w2, w3
I 149.052324811 chacha_block_generic: ffff800008642d94:b8217882 str w2, [x4, x1, lsl #2]
I 149.052324811 chacha_block_generic: ffff800008642d98:
91000421 add x1, x1, #0x1
I 149.052324811 chacha_block_generic: ffff800008642d9c:f100443f cmp x1, #0x11
Core 2 instruction trace dump(kernel panic triggered core):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A etm4_enable_hw: ffff800008ae1dd4 CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 I etm4_enable_hw: ffff800008ae1dd4:
d503201f nop
I etm4_enable_hw: ffff800008ae1dd8:d503201f nop
I etm4_enable_hw: ffff800008ae1ddc:d503201f nop
I etm4_enable_hw: ffff800008ae1de0:d503201f nop
I etm4_enable_hw: ffff800008ae1de4:d503201f nop
I etm4_enable_hw: ffff800008ae1de8:d503233f paciasp
I etm4_enable_hw: ffff800008ae1dec:a9be7bfd stp x29, x30, [sp, #-32]!
I etm4_enable_hw: ffff800008ae1df0:910003fd mov x29, sp
I etm4_enable_hw: ffff800008ae1df4:a90153f3 stp x19, x20, [sp, #16]
I etm4_enable_hw: ffff800008ae1df8:2a0003f4 mov w20, w0
I etm4_enable_hw: ffff800008ae1dfc:900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48>
I etm4_enable_hw: ffff800008ae1e00:910f4273 add x19, x19, #0x3d0
I etm4_enable_hw: ffff800008ae1e04:f8747a60 ldr x0, [x19, x20, lsl #3]
E etm4_enable_hw: ffff800008ae1e08:b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50>
I 149.046243445 etm4_enable_hw: ffff800008ae1e30:a94153f3 ldp x19, x20, [sp, #16]
I 149.046243445 etm4_enable_hw: ffff800008ae1e34:
52800000 mov w0, #0x0 // #0
I 149.046243445 etm4_enable_hw: ffff800008ae1e38:a8c27bfd ldp x29, x30, [sp], #32
I 149.046243445 etm4_enable_hw: ffff800008ae1e3c:d50323bf autiasp
E 149.046243445 etm4_enable_hw: ffff800008ae1e40:d65f03c0 ret
A ete_sysreg_write: ffff800008adfa18
..snip
I 149.05422547 panic: ffff800008096300:a90363f7 stp x23, x24, [sp, #48]
I 149.05422547 panic: ffff800008096304:6b00003f cmp w1, w0
I 149.05422547 panic: ffff800008096308:3a411804 ccmn w0, #0x1, #0x4, ne // ne = any
N 149.05422547 panic: ffff80000809630c:540001e0 b.eq ffff800008096348 <panic+0xe0> // b.none
I 149.05422547 panic: ffff800008096310:f90023f9 str x25, [sp, #64]
E 149.05422547 panic: ffff800008096314:97fe44ef bl ffff8000080276d0 <panic_smp_self_stop>
A panic: ffff80000809634c
I 149.05422547 panic: ffff80000809634c:910102d5 add x21, x22, #0x40
I 149.05422547 panic: ffff800008096350:
52800020 mov w0, #0x1 // #1
E 149.05422547 panic: ffff800008096354:94166b8b bl ffff800008631180 <bust_spinlocks>
N 149.054225518 bust_spinlocks: ffff800008631180:340000c0 cbz w0, ffff800008631198 <bust_spinlocks+0x18>
I 149.054225518 bust_spinlocks: ffff800008631184:f000a321 adrp x1, ffff800009a98000 <pbufs.0+0xbb8>
I 149.054225518 bust_spinlocks: ffff800008631188:b9405c20 ldr w0, [x1, #92]
I 149.054225518 bust_spinlocks: ffff80000863118c:
11000400 add w0, w0, #0x1
I 149.054225518 bust_spinlocks: ffff800008631190:b9005c20 str w0, [x1, #92]
E 149.054225518 bust_spinlocks: ffff800008631194:d65f03c0 ret
A panic: ffff800008096358
TODO
----
* Change ETM configuration done in patch #7 to new system configuration manager profile
* Change CTI sysfs script to system configuration manager profile
* Reading tracedata from crashdump kernel is not tested.
* Perf based trace capture and decode is not tested.
Linu Cherian (8):
dt-bindings: arm: coresight-tmc: Add "memory-region" property
coresight: tmc-etr: Add support to use reserved trace memory
coresight: core: Add provision for panic callbacks
coresight: tmc: Enable panic sync handling
coresight: tmc: Add support for reading tracedata from previous boot
coresight: tmc: Stop trace capture on FlIn
coresight: etm4x: Configure ETM to trigger on panic
coresight: cti: Add CTI id for Neoverse N2 core CTI
.../bindings/arm/arm,coresight-tmc.yaml | 13 + drivers/hwtracing/coresight/coresight-core.c | 32 ++ .../hwtracing/coresight/coresight-cti-core.c | 1 + .../coresight/coresight-etm4x-core.c | 18 +- drivers/hwtracing/coresight/coresight-etm4x.h | 26 ++ .../hwtracing/coresight/coresight-tmc-core.c | 146 +++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 126 +++++++- .../hwtracing/coresight/coresight-tmc-etr.c | 274 +++++++++++++++++- drivers/hwtracing/coresight/coresight-tmc.h | 48 +++ include/linux/coresight.h | 25 ++ 10 files changed, 701 insertions(+), 8 deletions(-)
Links:
1. https://lore.kernel.org/linux-arm-kernel/[email protected]/
2. https://lore.kernel.org/linux-arm-kernel/[email protected]/T/
Signature · 1 line
2.41.0
RFC PATCH v3 1/7 dt-bindings: arm: coresight-tmc: Add "memory-region" property
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
--- .../devicetree/bindings/arm/arm,coresight-tmc.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml +13 -0
@@ -101,6 +101,17 @@ properties: and ETF configurations. $ref: /schemas/graph.yaml#/properties/port + memory-region: + items: + - description: Reserved trace buffer memory for ETR and ETF sinks. + For ETR, this reserved memory region is used for trace data capture. + Same region is used for trace data retention as well after a panic + or watchdog reset. + For ETF, this reserved memory region is used for retention of trace + data synced from internal SRAM after a panic or watchdog reset. + + - description: Reserved meta data memory. Used for ETR and ETF sinks. + required: - compatible - reg
@@ -115,6 +126,8 @@ examples: etr@20070000 { compatible = "arm,coresight-tmc", "arm,primecell"; reg = <0x20070000 0x1000>; + memory-region = <&etr_trace_mem_reserved>, + <&etr_mdata_mem_reserved>; clocks = <&oscclk6a>; clock-names = "apb_pclk";
Signature · 1 line
2.41.0
Rob Herring
maintainerRe: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property
Quoted 12 lines · Linu Cherian
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
memory-region 1: Reserved meta data memory
Quoted 9 lines
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
Signed-off-by Linu Cherian <[email protected]>--- .../devicetree/bindings/arm/arm,coresight-tmc.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4: [error] syntax error: expected <block end>, but found '<block mapping start>' (syntax) ./Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:105:5: [warning] wrong indentation: expected 5 but found 4 (indentation)
dtschema/dtc warnings/errors:
make[2]: *** Deleting file 'Documentation/devicetree/bindings/arm/arm,coresight-tmc.example.dts' Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4: did not find expected key
make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/arm/arm,coresight-tmc.example.dts] Error 1 make[2]: *** Waiting for unfinished jobs...../Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4: did not find expected key /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml: ignoring, error parsing file make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1500: dt_binding_check] Error 2
make: *** [Makefile:234: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
RE: [EXT] Re: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property
Hi Rob,
Quoted 89 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Monday, September 4, 2023 11:53 AM
To: Linu Cherian <[email protected]>
Cc: [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; George Cherian <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" propertyExternal Email
----------------------------------------------------------------------
Quoted 16 lines · Linu Cherian
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
Quoted 6 lines
Signed-off-by Linu Cherian <[email protected]>--- .../devicetree/bindings/arm/arm,coresight-tmc.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)My bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check'
on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
./Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4:
[error] syntax error: expected <block end>, but found '<block mapping start>' (syntax)./Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:105:5:
[warning] wrong indentation: expected 5 but found 4 (indentation)dtschema/dtc warnings/errors:
make[2]: *** Deleting file 'Documentation/devicetree/bindings/arm/arm,coresight-tmc.example.dts'Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4: did not find expected key
make[2]: *** [Documentation/devicetree/bindings/Makefile:26:Documentation/devicetree/bindings/arm/arm,coresight-tmc.example.dts] Error 1
make[2]: *** Waiting for unfinished jobs...../Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:104:4:
did not find expected key
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml:
ignoring, error parsing file
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1500:dt_binding_check] Error 2
make: *** [Makefile:234: __sub-make] Error 2doc reference errors (make refcheckdocs):
See https://urldefense.proofpoint.com/v2/url?u=https-
3A__patchwork.ozlabs.org_project_devicetree- 2Dbindings_patch_20230904050548.28047-2D2-2Dlcherian- 40marvell.com&d=DwIDaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=DI9kird_6lFtBC VoGa5ogk3dJwsUlHLjLlgu0r46iU4&m=_ay- WtrQlhIwxRafvVeVQHuS8jVWvIzZWMmn3Kp2yAVpxITz- rjWiL4cMybMomHi&s=zvUJitULz2sVzal1I78gUQ3sBBTSAZmwDziKSNJbxwM& e=The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
Quoted 6 lines
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that
DT_SCHEMA_FILEScan be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Ack. Will fix this in next version.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Suzuki K Poulose
maintainerRe: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property
In reply to Linu CherianQuoted 10 lines · Linu Cherian
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
Quoted 5 lines
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
Instead of having to use a number to map the memory regions, could we use
memory-region-names property to describe the index ? That way it is much easier to read and is less error prone.
Names could be something like:
tmc-reserved-trace
tmc-reserved-metadata
Suzuki
Quoted 37 lines
Signed-off-by Linu Cherian <[email protected]>--- .../devicetree/bindings/arm/arm,coresight-tmc.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml +13
-0@@ -101,6 +101,17 @@ properties: and ETF configurations. $ref: /schemas/graph.yaml#/properties/port + memory-region: + items: + - description: Reserved trace buffer memory for ETR and ETF sinks. + For ETR, this reserved memory region is used for trace data capture. + Same region is used for trace data retention as well after a panic + or watchdog reset. + For ETF, this reserved memory region is used for retention of trace + data synced from internal SRAM after a panic or watchdog reset. + + - description: Reserved meta data memory. Used for ETR and ETF sinks. + required: - compatible - reg@@ -115,6 +126,8 @@ examples: etr@20070000 { compatible = "arm,coresight-tmc", "arm,primecell"; reg = <0x20070000 0x1000>; + memory-region = <&etr_trace_mem_reserved>, + <&etr_mdata_mem_reserved>; clocks = <&oscclk6a>; clock-names = "apb_pclk";
Rob Herring
maintainerRe: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property
Quoted 17 lines · Suzuki K Poulose
Quoted 10 lines · Linu Cherian
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
Quoted 5 lines
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
Quoted 5 lines
Instead of having to use a number to map the memory regions, could we use
memory-region-names property to describe the index ? That way it is much easier to read and is less error prone.
You can, but the order should still be defined.
Quoted 4 lines
Names could be something like:
tmc-reserved-trace
tmc-reserved-metadata
Names are local to the binding. So 'tmc' is redundant. And everything is a reserved region for 'memory-region', so that's redundant too.
Rob
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [EXT] Re: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" property
In reply to Suzuki K PouloseHi Suzuki,
Quoted 35 lines
-----Original Message-----
From: Suzuki K Poulose <[email protected]>
Sent: Monday, September 4, 2023 1:57 PM
To: Linu Cherian <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; George Cherian <[email protected]>
Subject: [EXT] Re: [RFC PATCH v3 1/7] dt-bindings: arm: coresight-tmc: Add "memory-region" propertyExternal Email
----------------------------------------------------------------------
Quoted 10 lines · Linu Cherian
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
Quoted 5 lines
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
Instead of having to use a number to map the memory regions, could we use
Quoted 8 lines
memory-region-names property to describe the index ? That way it is much easier to read and is less error prone.
Names could be something like:
tmc-reserved-trace
tmc-reserved-metadata
Ack. Will use names in the next version. Will take care of the suggestions from Rob.
Quoted 40 lines
Suzuki
Quoted 4 lines
Signed-off-by Linu Cherian <[email protected]>--- .../devicetree/bindings/arm/arm,coresight-tmc.yaml | 13+++++++++++++
Quoted 33 lines
1 file changed, 13 insertions(+)diff --git
a/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yamlb/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yamlindexcb8dceaca70e..dce54978554a100644Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml +13
-0@@ -101,6 +101,17 @@ properties: and ETF configurations. $ref: /schemas/graph.yaml#/properties/port + memory-region: + items: + - description: Reserved trace buffer memory for ETR and ETF sinks. + For ETR, this reserved memory region is used for trace data capture. + Same region is used for trace data retention as well after a panic + or watchdog reset. + For ETF, this reserved memory region is used for retention of trace + data synced from internal SRAM after a panic or watchdog reset. + + - description: Reserved meta data memory. Used for ETR and ETF sinks. + required: - compatible - reg@@ -115,6 +126,8 @@ examples: etr@20070000 { compatible = "arm,coresight-tmc", "arm,primecell"; reg = <0x20070000 0x1000>; + memory-region = <&etr_trace_mem_reserved>, + <&etr_mdata_mem_reserved>;
Quoted 2 lines
Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml examples: · line 133
Quoted 2 lines
Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml +0
-0clocks = <&oscclk6a>; clock-names = "apb_pclk";
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RFC PATCH v3 2/7 coresight: tmc-etr: Add support to use reserved trace memory
In reply to Linu CherianAdd support to use reserved memory for coresight ETR trace buffer.
Introduce a new ETR buffer mode called ETR_MODE_RESRV, which becomes available when ETR device tree node is supplied with a valid reserved memory region.
ETR_MODE_RESRV can be selected only by explicit user request.
$ echo resrv >/sys/bus/coresight/devices/tmc_etr<N>/buf_mode_preferred
--- .../hwtracing/coresight/coresight-tmc-core.c | 39 ++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 74 ++++++++++++++++++- drivers/hwtracing/coresight/coresight-tmc.h | 24 ++++++ 3 files changed, 136 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-core.c +39 -0
@@ -22,6 +22,7 @@#include <linux/spinlock.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/coresight.h> #include <linux/amba/bus.h>
@@ -370,6 +371,42 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)return (auth &TMC_AUTH_NSID_MASK ) ==0x3 ; } +static void tmc_get_reserved_region (struct device *parent) +{ +struct tmc_drvdata *drvdata =dev_get_drvdata (parent); +struct device_node *node; +struct resource res; +int rc; + + node =of_parse_phandle (parent->of_node,"memory-region" ,0 ); +if (!node) { +dev_dbg (parent,"No reserved trace buffer specified\n" ); + goto out; + } + + rc =of_address_to_resource (node,0 , &res); +of_node_put (node); +if (rc || res.start ==0 ||resource_size (&res) ==0 ) { +dev_err (parent,"Reserved trace buffer memory is invalid\n" ); + goto out; + } + + drvdata->resrv_buf.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WB ); +if (IS_ERR (drvdata->resrv_buf.vaddr)) { +dev_err (parent,"Reserved trace buffer mapping failed\n" ); + rc =PTR_ERR (drvdata->resrv_buf.vaddr); + goto out; + } + + drvdata->resrv_buf.paddr = res.start; + drvdata->resrv_buf.size =resource_size (&res); + +out: +return ; +} +/* Detect and initialise the capabilities of a TMC ETR */ static int tmc_etr_setup_caps (struct device *parent,u32 devid,void *dev_caps) {
@@ -482,6 +519,8 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) drvdata->size =readl_relaxed (drvdata->base +TMC_RSZ ) *4 ; } +tmc_get_reserved_region (dev); + desc.dev = dev;switch (drvdata->config_type) {
drivers/hwtracing/coresight/coresight-tmc-etr.c +73 -1
140 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +24 -0
@@ -135,6 +135,7 @@ enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */ ETR_MODE_CATU ,/* Use SG mechanism in CATU */ +ETR_MODE_RESRV ,/* Use reserved region contiguous buffer */ ETR_MODE_AUTO, /* Use the default mechanism */ };
@@ -164,6 +165,17 @@ struct etr_buf {void *private; }; +/** +* @paddr : Start address of reserved memory region. +* @vaddr : Corresponding CPU virtual address. +* @size : Size of reserved memory region. +*/ +struct tmc_resrv_buf { +phys_addr_t paddr; +void *vaddr; +size_t size; +}; +/** * struct tmc_drvdata - specifics associated to an TMC component * @base: memory mapped base address for this component.
@@ -188,6 +200,7 @@ struct etr_buf {* @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. +* @resrv_buf: Reserved Memory for trace data buffer. Used by ETR/ETF. */ struct tmc_drvdata {void __iomem *base;
@@ -213,6 +226,7 @@ struct tmc_drvdata {struct mutex idr_mutex;struct etr_buf *sysfs_buf;struct etr_buf *perf_buf; +struct tmc_resrv_buf resrv_buf; };struct etr_buf_operations {
@@ -330,6 +344,16 @@ tmc_sg_table_buf_size(struct tmc_sg_table *sg_table)return sg_table->data_pages.nr_pages <<PAGE_SHIFT ; } +static inline bool is_tmc_reserved_region_valid (struct device *dev) +{ +struct tmc_drvdata *drvdata =dev_get_drvdata (dev); + +if (drvdata->resrv_buf.paddr && + drvdata->resrv_buf.size) +return true; +return false; +} +struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata);void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu);
Signature · 1 line
2.41.0
RFC PATCH v3 3/7 coresight: core: Add provision for panic callbacks
In reply to Linu CherianPanic callback handlers allows coresight device drivers to sync relevant trace data and trace metadata to reserved memory regions so that they can be retrieved later in the subsequent boot or in the crashdump kernel.
--- drivers/hwtracing/coresight/coresight-core.c | 32 ++++++++++++++++++++ include/linux/coresight.h | 12 ++++++++ 2 files changed, 44 insertions(+)
drivers/hwtracing/coresight/coresight-core.c +32 -0
@@ -20,6 +20,7 @@#include <linux/of_platform.h> #include <linux/delay.h> #include <linux/pm_runtime.h> +#include <linux/panic_notifier.h> #include "coresight-etm-perf.h" #include "coresight-priv.h"
@@ -1800,6 +1801,31 @@ struct bus_type coresight_bustype = { .name = "coresight", }; +static int coresight_panic_sync (struct device *dev,void *data) +{ + + struct coresight_device *csdev = container_of(dev, struct coresight_device, dev); + +/* Run through panic sync handlers for all enabled devices */ +if (csdev->enable &&panic_ops (csdev)) +panic_ops (csdev)->sync (csdev); + +return 0 ; +} + +static int coresight_panic_cb (struct notifier_block *self, +unsigned long v,void *p) +{ +bus_for_each_dev (&coresight_bustype,NULL ,NULL , + coresight_panic_sync); + +return 0 ; +} + +static struct notifier_block coresight_notifier = { + .notifier_call = coresight_panic_cb, +}; +static int __init coresight_init (void ) {int ret;
@@ -1812,6 +1838,10 @@ static int __init coresight_init(void)if (ret) goto exit_bus_unregister; +/* Register function to be called for panic */ + ret =atomic_notifier_chain_register (&panic_notifier_list, + &coresight_notifier); +/* initialise the coresight syscfg API */ ret =cscfg_init ();if (!ret)
@@ -1826,6 +1856,8 @@ static int __init coresight_init(void) static void __exit coresight_exit(void) {cscfg_exit (); +atomic_notifier_chain_unregister (&panic_notifier_list, + &coresight_notifier);etm_perf_exit ();bus_unregister (&coresight_bustype); }
include/linux/coresight.h +12 -0
@@ -299,6 +299,7 @@ enum cs_mode {#define link_ops (csdev) csdev->ops->link_ops#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops +#define panic_ops (csdev) csdev->ops->panic_ops/** * struct coresight_ops_sink - basic operations for a sink
@@ -368,11 +369,22 @@ struct coresight_ops_helper {int (*disable)(struct coresight_device *csdev,void *data); }; + +/** +* struct coresight_ops_panic - Generic device ops for panic handing +* +* @sync : Sync the device register state/trace data +*/ +struct coresight_ops_panic { +int (*sync)(struct coresight_device *csdev); +}; +struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops; +const struct coresight_ops_panic *panic_ops; };#if IS_ENABLED (CONFIG_CORESIGHT )
Signature · 1 line
2.41.0
RFC PATCH v3 4/7 coresight: tmc: Enable panic sync handling
In reply to Linu Cherian- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.
--- .../hwtracing/coresight/coresight-tmc-core.c | 26 +++++++++ .../hwtracing/coresight/coresight-tmc-etf.c | 56 +++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 52 +++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 19 ++++++- 4 files changed, 152 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-core.c +26 -0
@@ -403,6 +403,32 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); +/* Metadata region */ + node =of_parse_phandle (parent->of_node,"memory-region" ,1 ); +if (!node) { +dev_dbg (parent,"No metadata memory-region specified\n" ); + goto out; + } + + rc =of_address_to_resource (node,0 , &res); +of_node_put (node); +if (rc || res.start ==0 ||resource_size (&res) ==0 ) { +dev_err (parent,"Metadata memory is invalid\n" ); + goto out; + } + + drvdata->metadata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WB ); +if (IS_ERR (drvdata->metadata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); + rc =PTR_ERR (drvdata->metadata.vaddr); + goto out; + } + + drvdata->metadata.paddr = res.start; + drvdata->metadata.size =resource_size (&res); + out:return ; }
drivers/hwtracing/coresight/coresight-tmc-etf.c +56 -0
74 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc-etr.c +52 -0
66 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +18 -1
@@ -131,6 +131,19 @@ enum tmc_mem_intf_width {#define CORESIGHT_SOC_600_ETR_CAPS \ (TMC_ETR_SAVE_RESTORE | TMC_ETR_AXI_ARCACHE) +/* TMC metadata region for ETR and ETF configurations */ +struct tmc_register_snapshot { +uint32_t valid;/* Indicate if this ETF/ETR was enabled */ +uint32_t size;/* Size of trace data */ +uint32_t sts;/* Status register */ +uint32_t reserved32[3 ]; +uint64_t rrp;/* Read pointer */ +uint64_t rwp;/* Write pointer */ +uint64_t dba;/* Data buffer address */ +uint64_t trc_paddr;/* Phys address of trace buffer */ +uint64_t reserved64[3 ]; +}; +enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */
@@ -201,6 +214,7 @@ struct tmc_resrv_buf {* @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. * @resrv_buf: Reserved Memory for trace data buffer. Used by ETR/ETF. +* @metadata: Reserved memory for metadata. Used by ETR/ETF. */ struct tmc_drvdata {void __iomem *base;
@@ -227,6 +241,7 @@ struct tmc_drvdata {struct etr_buf *sysfs_buf;struct etr_buf *perf_buf;struct tmc_resrv_buf resrv_buf; +struct tmc_resrv_buf metadata; };struct etr_buf_operations {
@@ -349,7 +364,9 @@ static inline bool is_tmc_reserved_region_valid(struct device *dev)struct tmc_drvdata *drvdata =dev_get_drvdata (dev);if (drvdata->resrv_buf.paddr && - drvdata->resrv_buf.size) + drvdata->resrv_buf.size && + drvdata->metadata.paddr && + drvdata->metadata.size)return true;return false; }
Signature · 1 line
2.41.0
RFC PATCH v3 5/7 coresight: tmc: Add support for reading tracedata from previous boot
In reply to Linu Cherian* Introduce a new mode CS_MODE_READ_PREVBOOT for reading tracedata captured in previous boot.
* Add special handlers for preparing ETR/ETF for this special mode
* User can read the trace data as below
For example, for reading trace data from tmc_etf sink
1. cd /sys/bus/coresight/devices/tmc_etfXX/
2. Change mode to READ_PREVBOOT
#echo 1 > read_prevboot
3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
4. Reset back to normal mode
#echo 0 > read_prevboot
--- .../coresight/coresight-etm4x-core.c | 1 + .../hwtracing/coresight/coresight-tmc-core.c | 81 +++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 62 ++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 140 +++++++++++++++++- drivers/hwtracing/coresight/coresight-tmc.h | 6 + include/linux/coresight.h | 13 ++ 6 files changed, 301 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +1 -0
@@ -1001,6 +1001,7 @@ static void etm4_disable(struct coresight_device *csdev,switch (mode) {case CS_MODE_DISABLED : +case CS_MODE_READ_PREVBOOT :break ;case CS_MODE_SYSFS :etm4_disable_sysfs (csdev);
drivers/hwtracing/coresight/coresight-tmc-core.c +80 -1
108 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc-etf.c +62 -0
100 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc-etr.c +139 -1
185 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +6 -0
@@ -213,6 +213,9 @@ struct tmc_resrv_buf {* @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. +* @prevboot_buf: Previous boot buffer for ETR. This is a special purpose +* buffer that is used only for mapping the trace buffer from +* previous boot and not for capturing trace. * @resrv_buf: Reserved Memory for trace data buffer. Used by ETR/ETF. * @metadata: Reserved memory for metadata. Used by ETR/ETF. */
@@ -240,6 +243,7 @@ struct tmc_drvdata {struct mutex idr_mutex;struct etr_buf *sysfs_buf;struct etr_buf *perf_buf; +struct etr_buf *prevboot_buf;struct tmc_resrv_buf resrv_buf;struct tmc_resrv_buf metadata; };
@@ -291,6 +295,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata);void tmc_enable_hw (struct tmc_drvdata *drvdata);void tmc_disable_hw (struct tmc_drvdata *drvdata);u32 tmc_get_memwidth_mask (struct tmc_drvdata *drvdata); +int tmc_read_prepare_prevboot (struct tmc_drvdata *drvdata); +int tmc_read_unprepare_prevboot (struct tmc_drvdata *drvdata);/* ETB/ETF functions */ int tmc_read_prepare_etb (struct tmc_drvdata *drvdata);
include/linux/coresight.h +13 -0
@@ -292,6 +292,7 @@ enum cs_mode {CS_MODE_DISABLED ,CS_MODE_SYSFS ,CS_MODE_PERF , + CS_MODE_READ_PREVBOOT, /* Trace data from previous boot */ };#define source_ops (csdev) csdev->ops->source_ops
@@ -300,6 +301,7 @@ enum cs_mode {#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops#define panic_ops (csdev) csdev->ops->panic_ops +#define prevboot_ops (csdev) csdev->ops->prevboot_ops/** * struct coresight_ops_sink - basic operations for a sink
@@ -379,12 +381,23 @@ struct coresight_ops_panic {int (*sync)(struct coresight_device *csdev); }; +/** +* struct coresight_ops_prevboot - Generic device ops for prevboot mode +* +* @prepare : Preparation for prevboot mode +*/ +struct coresight_ops_prevboot { +int (*prepare)(struct coresight_device *csdev); +int (*unprepare)(struct coresight_device *csdev); +}; +struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops;const struct coresight_ops_panic *panic_ops; +const struct coresight_ops_prevboot *prevboot_ops; };#if IS_ENABLED (CONFIG_CORESIGHT )
Signature · 1 line
2.41.0
RFC PATCH v3 6/7 coresight: tmc: Stop trace capture on FlIn
In reply to Linu CherianConfigure TMC ETR and ETF to flush and stop trace capture on FlIn event. As a side effect, do manual flush only if auto flush fails.
--- drivers/hwtracing/coresight/coresight-tmc-etf.c | 10 ++++++++-- drivers/hwtracing/coresight/coresight-tmc-etr.c | 10 ++++++++-- drivers/hwtracing/coresight/coresight-tmc.h | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-tmc-etf.c +8 -2
@@ -34,7 +34,7 @@ static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata)writel_relaxed (TMC_MODE_CIRCULAR_BUFFER , drvdata->base +TMC_MODE );writel_relaxed (TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI |TMC_FFCR_FON_FLIN |TMC_FFCR_FON_TRIG_EVT | -TMC_FFCR_TRIGON_TRIGIN , +TMC_FFCR_TRIGON_TRIGIN |TMC_FFCR_STOP_ON_FLUSH , drvdata->base +TMC_FFCR );writel_relaxed (drvdata->trigger_cntr, drvdata->base +TMC_TRG );
@@ -613,7 +613,13 @@ static int tmc_panic_sync_etf(struct coresight_device *csdev)if (val !=TMC_MODE_CIRCULAR_BUFFER ) goto out; -tmc_flush_and_stop (drvdata); + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__); +tmc_flush_and_stop (drvdata); + }/* Sync registers from hardware to metadata region */ tmc->sts =csdev_access_relaxed_read32 (csa,TMC_STS );
drivers/hwtracing/coresight/coresight-tmc-etr.c +8 -2
@@ -1098,7 +1098,7 @@ static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata)writel_relaxed (TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI |TMC_FFCR_FON_FLIN |TMC_FFCR_FON_TRIG_EVT | -TMC_FFCR_TRIGON_TRIGIN , +TMC_FFCR_TRIGON_TRIGIN |TMC_FFCR_STOP_ON_FLUSH , drvdata->base +TMC_FFCR );writel_relaxed (drvdata->trigger_cntr, drvdata->base +TMC_TRG );tmc_enable_hw (drvdata);
@@ -1829,7 +1829,13 @@ static int tmc_panic_sync_etr(struct coresight_device *csdev)if (!(val &TMC_CTL_CAPT_EN )) goto out; -tmc_flush_and_stop (drvdata); + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__); +tmc_flush_and_stop (drvdata); + }/* Sync registers from hardware to metadata region */ tmc->size =csdev_access_relaxed_read32 (csa,TMC_RSZ );
drivers/hwtracing/coresight/coresight-tmc.h +3 -0
@@ -76,6 +76,9 @@#define TMC_AXICTL_AXCACHE_OS (0xf << 2)#define TMC_AXICTL_ARCACHE_OS (0xf << 16) +/* TMC_FFSR - 0x300 */ +#define TMC_FFSR_FT_STOPPED BIT(1) +/* TMC_FFCR - 0x304 */ #define TMC_FFCR_FLUSHMAN_BIT 6#define TMC_FFCR_EN_FMT BIT(0)
Signature · 1 line
2.41.0
RFC PATCH v3 7/7 coresight: etm4x: Configure ETM to trigger on panic
In reply to Linu CherianConfigure ETM to generate a trigger on Ext out [0] on panic. This is achieved by configuring a single address comparator with the address of "panic" and by configuring Ext out [0] to trigger on the comparator event.
This trigger can be used by the sinks to stop capture on panic.
--- .../coresight/coresight-etm4x-core.c | 17 +++++++++--- drivers/hwtracing/coresight/coresight-etm4x.h | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +14 -3
@@ -62,6 +62,7 @@ static void etm4_set_default_config(struct etmv4_config *config);static int etm4_set_event_filters (struct etmv4_drvdata *drvdata,struct perf_event *event);static u64 etm4_get_access_type (struct etmv4_config *config); +static u64 etm4_get_comparator_access_type (struct etmv4_config *config);static enum cpuhp_state hp_online;
@@ -1291,9 +1292,8 @@ static void etm4_set_victlr_access(struct etmv4_config *config)static void etm4_set_default_config (struct etmv4_config *config) { -/* disable all events tracing */ - config->eventctrl0 =0x0 ; - config->eventctrl1 =0x0 ; +int rselector =2 ;/* 0 and 1 are reserved */ +int comp_idx =0 ;/* disable stalling */ config->stall_ctrl =0x0 ;
@@ -1309,6 +1309,17 @@ static void etm4_set_default_config(struct etmv4_config *config)/* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */ etm4_set_victlr_access (config); + +/* Configure the comparator with kernel panic address */ + config->addr_val[comp_idx] = (u64 )panic; + config->addr_acc[comp_idx] =etm4_get_comparator_access_type (config); + config->addr_type[comp_idx] =ETM_ADDR_TYPE_STOP ; + config->res_ctrl[rselector] =ETM_RESGRP_SADDRCMP <<16 |BIT (comp_idx); + +/* Connect external output [0] with comparator out */ + config->eventctrl0 =0x0 <<7 | rselector; + + config->eventctrl1 =0x0 ; }static u64 etm4_get_ns_access_type (struct etmv4_config *config)
drivers/hwtracing/coresight/coresight-etm4x.h +26 -0
@@ -612,6 +612,32 @@#define ETM_CNTR_MAX_VAL 0xFFFF#define ETM_TRACEID_MASK 0x3f +/* ETM resource group encoding */ +#define ETM_RESGRP_EXTIN 0x0 +#define ETM_RESGRP_PECMP 0x1 +#define ETM_RESGRP_CNTRSEQ 0x2 +#define ETM_RESGRP_SSCMP 0x3 +#define ETM_RESGRP_SADDRCMP 0x4 +#define ETM_RESGRP_ADDRRANGECMP 0x5 +#define ETM_RESGRP_CIDCMP 0x6 +#define ETM_RESGRP_VCIDCMP 0x7 + +#define ETM_EXTIN_0 0x0 + + +/* ETM resource group encoding */ +#define ETM_RESGRP_EXTIN 0x0 +#define ETM_RESGRP_PECMP 0x1 +#define ETM_RESGRP_CNTRSEQ 0x2 +#define ETM_RESGRP_SSCMP 0x3 +#define ETM_RESGRP_SADDRCMP 0x4 +#define ETM_RESGRP_ADDRRANGECMP 0x5 +#define ETM_RESGRP_CIDCMP 0x6 +#define ETM_RESGRP_VCIDCMP 0x7 + +#define ETM_EXTIN_0 0x0 + +/* ETMv4 programming modes */ #define ETM_MODE_EXCLUDE BIT(0)#define ETM_MODE_LOAD BIT(1)
Signature · 1 line
2.41.0
Quoted 2 lines · Linu Cherian
This RFC v3 patch series is rebased on v6.5-rc7 and is dependent on the below two patches.
[...]
Quoted 5 lines
Steps for reading trace data captured in previous boot
++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. cd/sys/bus/coresight/devices/tmc_etrXX/
Quoted 7 lines
2. Change to special mode called,
read_prevboot.#echo 1 >
read_prevboot3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
Hi Linu,
I left this comment on V2, but I tested it again and get the same result. Instead of linking it I'll just re-paste it here:
I made a reserved region, but when I run this command I get "Unable to handle kernel paging request at virtual address 001f1921ed10ffae".
Is there an extra step involved if there was no trace captured from a previous panic? I thought I'd just be able to read out uninitialised data. Or is it the uninitialised metadata that's causing this issue?
Also that's without KASAN or lockdep turned on. If I have a kernel with either of those things I get a different warning for each one. I expect the lockdep one would happen even in the working scenario though?
Quoted 5 lines
4. Reset back to normal mode
#echo 0 >
read_prevboot
Hi James,
Quoted 43 lines
-----Original Message-----
From: James Clark <[email protected]>
Sent: Friday, September 15, 2023 7:20 PM
To: Linu Cherian <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; George Cherian <[email protected]>
Subject: [EXT] Re: [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog resetExternal Email
----------------------------------------------------------------------
Quoted 2 lines · Linu Cherian
This RFC v3 patch series is rebased on v6.5-rc7 and is dependent on the below two patches.
[...]
Quoted 5 lines
Steps for reading trace data captured in previous boot
++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. cd/sys/bus/coresight/devices/tmc_etrXX/Quoted 7 lines
2. Change to special mode called,
read_prevboot.#echo 1 >
read_prevboot3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
Hi Linu,
I left this comment on V2, but I tested it again and get the same result. Instead of linking it I'll just re-paste it here:
I made a reserved region, but when I run this command I get "Unable to handle kernel paging request at virtual address
001f1921ed10ffae".
Quoted 7 lines
Is there an extra step involved if there was no trace captured from a previous panic? I thought I'd just be able to read out uninitialised data. Or is it the uninitialised metadata that's causing this issue?
Also that's without KASAN or lockdep turned on. If I have a kernel with either of those things I get a different warning for each one. I expect the lockdep one would happen even in the working scenario though?
Somehow I missed this comment on V2.
I retried the above steps on my board and I do not see issues either with KASAN OR lockdep enabled configs. Please see logs below.
a. Lockdep enabled config
~# cd /sys/bus/coresight/devices/tmc_etr0
tmc_etr0# echo 1 > read_prevboot
tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in
12324+1 records out
6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.122883 s, 51.3 MB/s
# zcat /proc/config.gz | grep LOCKDEP CONFIG_LOCKDEP_SUPPORT=y CONFIG_LOCKDEP=y CONFIG_LOCKDEP_BITS=15 CONFIG_LOCKDEP_CHAINS_BITS=16 CONFIG_LOCKDEP_STACK_TRACE_BITS=19 CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=14 CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=12 # CONFIG_DEBUG_LOCKDEP is not set
b. KASAN enabled config
# cd /sys/bus/coresight/devices/tmc_etr0/ tmc_etr0# ls buf_mode_preferred connections power trigger_cntr buf_modes_available enable_sink read_prevboot uevent buffer_size mgmt subsystem waiting_for_supplier tmc_etr0# echo 1 > read_prevboot tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in 12324+1 records out 6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.0940671 s, 67.1 MB/s
~# zcat /proc/config.gz | grep -i kasanCONFIG_KASAN_SHADOW_OFFSET=0xdfff800000000000CONFIG_HAVE_ARCH_KASAN=yCONFIG_HAVE_ARCH_KASAN_SW_TAGS=yCONFIG_HAVE_ARCH_KASAN_HW_TAGS=yCONFIG_HAVE_ARCH_KASAN_VMALLOC=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_CC_HAS_KASAN_SW_TAGS=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=y
# CONFIG_KASAN_SW_TAGS is not set
# CONFIG_KASAN_HW_TAGS is not setCONFIG_KASAN_OUTLINE=y
# CONFIG_KASAN_INLINE is not setCONFIG_KASAN_STACK=yCONFIG_KASAN_VMALLOC=y
# CONFIG_KASAN_MODULE_TEST is not set
But then I am able to trigger kernel crash with bad metadata(corrupted rwp and rrp) with below stack trace.
[ 107.442991] __arch_copy_to_user+0x180/0x240 [ 107.447254] vfs_read+0xc8/0x2a8 [ 107.450476] ksys_read+0x74/0x110 [ 107.453783] __arm64_sys_read+0x24/0x38 [ 107.457611] invoke_syscall.constprop.0+0x58/0xf8 [ 107.462309] do_el0_svc+0x6c/0x158 [ 107.465704] el0_svc+0x54/0x1c0 [ 107.468839] el0t_64_sync_handler+0x100/0x130 [ 107.473188] el0t_64_sync+0x190/0x198 [ 107.476843] Code: d503201f d503201f d503201f d503201f (a8c12027)
Does your stack trace looks similar ? Then its very likely due to bad metadata. If not, kindly please share yours.
For example, if we have bad values for rwp and rrp, offset can get messed up resulting in above crash. Will add more validation checks while setting up the prevboot buffer, so as to avoid processing with bogus metadata values in the next patch version.
Thanks James for trying this out.
Quoted 6 lines
Quoted 6 lines
4. Reset back to normal mode
#echo 0 >
read_prevboot
Quoted 120 lines · Linu Cherian
Hi James,
Quoted 43 lines
-----Original Message-----
From: James Clark <[email protected]>
Sent: Friday, September 15, 2023 7:20 PM
To: Linu Cherian <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; George Cherian <[email protected]>
Subject: [EXT] Re: [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog resetExternal Email
----------------------------------------------------------------------
Quoted 2 lines · Linu Cherian
This RFC v3 patch series is rebased on v6.5-rc7 and is dependent on the below two patches.
[...]
Quoted 5 lines
Steps for reading trace data captured in previous boot
++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. cd/sys/bus/coresight/devices/tmc_etrXX/Quoted 7 lines
2. Change to special mode called,
read_prevboot.#echo 1 >
read_prevboot3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
Hi Linu,
I left this comment on V2, but I tested it again and get the same result. Instead of linking it I'll just re-paste it here:
I made a reserved region, but when I run this command I get "Unable to handle kernel paging request at virtual address
001f1921ed10ffae".Quoted 7 lines
Is there an extra step involved if there was no trace captured from a previous panic? I thought I'd just be able to read out uninitialised data. Or is it the uninitialised metadata that's causing this issue?
Also that's without KASAN or lockdep turned on. If I have a kernel with either of those things I get a different warning for each one. I expect the lockdep one would happen even in the working scenario though?
Somehow I missed this comment on V2.
I retried the above steps on my board and I do not see issues either with KASAN OR lockdep enabled configs. Please see logs below.
a. Lockdep enabled config
~# cd/sys/bus/coresight/devices/tmc_etr0
tmc_etr0# echo 1 >read_prevboot
tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in
12324+1 records out
6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.122883 s, 51.3 MB/s# zcat /proc/config.gz | grep LOCKDEP CONFIG_LOCKDEP_SUPPORT=y CONFIG_LOCKDEP=y CONFIG_LOCKDEP_BITS=15 CONFIG_LOCKDEP_CHAINS_BITS=16 CONFIG_LOCKDEP_STACK_TRACE_BITS=19 CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=14 CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=12 # CONFIG_DEBUG_LOCKDEP is not setb. KASAN enabled config
# cd /sys/bus/coresight/devices/tmc_etr0/ tmc_etr0# ls buf_mode_preferred connections power trigger_cntr buf_modes_available enable_sink read_prevboot uevent buffer_size mgmt subsystem waiting_for_supplier tmc_etr0# echo 1 > read_prevboot tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in 12324+1 records out 6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.0940671 s, 67.1 MB/s~# zcat
/proc/config.gz| grep -i kasanCONFIG_KASAN_SHADOW_OFFSET=0xdfff800000000000CONFIG_HAVE_ARCH_KASAN=yCONFIG_HAVE_ARCH_KASAN_SW_TAGS=yCONFIG_HAVE_ARCH_KASAN_HW_TAGS=yCONFIG_HAVE_ARCH_KASAN_VMALLOC=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_CC_HAS_KASAN_SW_TAGS=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=y
#CONFIG_KASAN_SW_TAGSis not set
#CONFIG_KASAN_HW_TAGSis not setCONFIG_KASAN_OUTLINE=y
#CONFIG_KASAN_INLINEis not setCONFIG_KASAN_STACK=yCONFIG_KASAN_VMALLOC=y
#CONFIG_KASAN_MODULE_TESTis not setBut then I am able to trigger kernel crash with bad metadata(corrupted rwp and rrp) with below stack trace.
[ 107.442991] __arch_copy_to_user+0x180/0x240 [ 107.447254] vfs_read+0xc8/0x2a8 [ 107.450476] ksys_read+0x74/0x110 [ 107.453783] __arm64_sys_read+0x24/0x38 [ 107.457611] invoke_syscall.constprop.0+0x58/0xf8 [ 107.462309] do_el0_svc+0x6c/0x158 [ 107.465704] el0_svc+0x54/0x1c0 [ 107.468839] el0t_64_sync_handler+0x100/0x130 [ 107.473188] el0t_64_sync+0x190/0x198 [ 107.476843] Code: d503201f d503201f d503201f d503201f (a8c12027)
Quoted 10 lines
Does your stack trace looks similar ? Then its very likely due to bad metadata. If not, kindly please share yours.
For example, if we have bad values for rwp and rrp, offset can get messed up resulting in above crash. Will add more validation checks while setting up the prevboot buffer, so as to avoid processing with bogus metadata values in the next patch version.
Thanks James for trying this out.
I think it must be bad metadata because I didn't try it with a previous crash saved yet. I suppose we do need some kind of validation then if it's possible for bad metadata to cause a crash.
I will try after filling in the metadata and see if that was the issue.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
4. Reset back to normal mode
#echo 0 >
read_prevboot
Hi James,
Quoted 153 lines
-----Original Message-----
From: James Clark <[email protected]>
Sent: Tuesday, September 19, 2023 6:41 PM
To: Linu Cherian <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; George Cherian <[email protected]>
Subject: Re: [EXT] Re: [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog resetQuoted 53 lines · Linu Cherian
Hi James,
Quoted 51 lines
-----Original Message-----
From: James Clark <[email protected]>
Sent: Friday, September 15, 2023 7:20 PM
To: Linu Cherian <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; George Cherian <[email protected]>
Subject: [EXT] Re: [RFC PATCH v3 0/8] Coresight for Kernel panic and watchdog resetExternal Email
---------------------------------------------------------------------
-Quoted 2 lines · Linu Cherian
This RFC v3 patch series is rebased on v6.5-rc7 and is dependent on the below two patches.
[...]
Quoted 5 lines
Steps for reading trace data captured in previous boot
++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. cd/sys/bus/coresight/devices/tmc_etrXX/Quoted 7 lines
2. Change to special mode called,
read_prevboot.#echo 1 >
read_prevboot3. Dump trace buffer data to a file,
#dd if=/dev/tmc_etrXX of=~/cstrace.bin
Hi Linu,
I left this comment on V2, but I tested it again and get the same result. Instead of linking it I'll just re-paste it here:
I made a reserved region, but when I run this command I get "Unable to handle kernel paging request at virtual address
001f1921ed10ffae".Is there an extra step involved if there was no trace captured from a previous panic? I thought I'd just be able to read out uninitialised data. Or is it the uninitialised metadata that's causing this issue?
Also that's without KASAN or lockdep turned on. If I have a kernel with either of those things I get a different warning for each one. I expect the lockdep one would happen even in the working scenario
though?
Quoted 4 lines
Somehow I missed this comment on V2.
I retried the above steps on my board and I do not see issues either with
KASAN OR lockdep enabled configs.
Quoted 51 lines
Please see logs below.
a. Lockdep enabled config
~# cd/sys/bus/coresight/devices/tmc_etr0
tmc_etr0# echo 1 >read_prevboot
tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in
12324+1 records out
6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.122883 s, 51.3 MB/s# zcat /proc/config.gz | grep LOCKDEP CONFIG_LOCKDEP_SUPPORT=y CONFIG_LOCKDEP=y CONFIG_LOCKDEP_BITS=15 CONFIG_LOCKDEP_CHAINS_BITS=16 CONFIG_LOCKDEP_STACK_TRACE_BITS=19 CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=14 CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=12 # CONFIG_DEBUG_LOCKDEP is not setb. KASAN enabled config
# cd /sys/bus/coresight/devices/tmc_etr0/ tmc_etr0# ls buf_mode_preferred connections power trigger_cntr buf_modes_available enable_sink read_prevboot uevent buffer_size mgmt subsystem waiting_for_supplier tmc_etr0# echo 1 > read_prevboot tmc_etr0# dd if=/dev/tmc_etr0 of=~/cstrace.bin 12324+1 records in 12324+1 records out 6310032 bytes (6.3 MB, 6.0 MiB) copied, 0.0940671 s, 67.1 MB/s~# zcat
/proc/config.gz| grep -i kasanCONFIG_KASAN_SHADOW_OFFSET=0xdfff800000000000CONFIG_HAVE_ARCH_KASAN=yCONFIG_HAVE_ARCH_KASAN_SW_TAGS=yCONFIG_HAVE_ARCH_KASAN_HW_TAGS=yCONFIG_HAVE_ARCH_KASAN_VMALLOC=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_CC_HAS_KASAN_SW_TAGS=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=y
#CONFIG_KASAN_SW_TAGSis not set
#CONFIG_KASAN_HW_TAGSis not setCONFIG_KASAN_OUTLINE=y
#CONFIG_KASAN_INLINEis not setCONFIG_KASAN_STACK=yCONFIG_KASAN_VMALLOC=y
#CONFIG_KASAN_MODULE_TESTis not setQuoted 1 line
But then I am able to trigger kernel crash with bad metadata(corrupted rwp
and rrp) with below stack trace.
Quoted 9 lines
[ 107.442991] __arch_copy_to_user+0x180/0x240 [ 107.447254] vfs_read+0xc8/0x2a8 [ 107.450476] ksys_read+0x74/0x110 [ 107.453783] __arm64_sys_read+0x24/0x38 [ 107.457611] invoke_syscall.constprop.0+0x58/0xf8 [ 107.462309] do_el0_svc+0x6c/0x158 [ 107.465704] el0_svc+0x54/0x1c0 [ 107.468839] el0t_64_sync_handler+0x100/0x130 [ 107.473188] el0t_64_sync+0x190/0x198 [ 107.476843] Code: d503201f d503201fQuoted 3 lines
d503201fd503201f(a8c12027)Does your stack trace looks similar ? Then its very likely due to bad
metadata.
Quoted 3 lines
If not, kindly please share yours.
For example, if we have bad values for rwp and rrp, offset can get messed
up resulting in above crash.
Quoted 2 lines
Will add more validation checks while setting up the prevboot buffer, so as to avoid processing with bogus metadata values in the next patch
version.
Quoted 4 lines
Thanks James for trying this out.
Quoted 5 lines
I think it must be bad metadata because I didn't try it with a previous crash saved yet. I suppose we do need some kind of validation then if it's possible for bad metadata to cause a crash.
I will try after filling in the metadata and see if that was the issue.
Found a regression in this series. Below is the fix.
@@ -1840,7 +1853,7 @@ static int tmc_panic_sync_etr(struct coresight_device *csdev)
/* Sync registers from hardware to metadata region */
tmc->size = csdev_access_relaxed_read32(csa, TMC_RSZ);- tmc->sts = csdev_access_relaxed_read32(csa, TMC_RSZ);
+ tmc->sts = csdev_access_relaxed_read32(csa, TMC_STS);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
4. Reset back to normal mode
#echo 0 >
read_prevboot