linux-stable/drivers/hwtracing/coresight
Suzuki K Poulose 88f11864cf coresight: etm-perf: Support PID tracing for kernel at EL2
When the kernel is running at EL2, the PID is stored in CONTEXTIDR_EL2.
So, tracing CONTEXTIDR_EL1 doesn't give us the pid of the process.
Thus we should trace the VMID with VMIDOPT set to trace CONTEXTIDR_EL2
instead of CONTEXTIDR_EL1.  Given that we have an existing config
option "contextid" and this will be useful for tracing virtual machines
(when we get to support virtualization).

So instead, this patch extends option CTXTID with an extra bit
ETM_OPT_CTXTID2 (bit 15), thus on an EL2 kernel, we will have another
bit available for the perf tool: ETM_OPT_CTXTID is for kernel running in
EL1, ETM_OPT_CTXTID2 is used when kernel runs in EL2 with VHE enabled.

The tool must be backward compatible for users, i.e, "contextid" today
traces PID and that should remain the same; for this purpose, the perf
tool is updated to automatically set corresponding bit for the
"contextid" config, therefore, the user doesn't have to bother which EL
the kernel is running.

  i.e, perf record -e cs_etm/contextid/u --

will always do the "pid" tracing, independent of the kernel EL.

The driver parses the format "contextid", which traces CONTEXTIDR_EL1
for ETM_OPT_CTXTID (on EL1 kernel) and traces CONTEXTIDR_EL2 for
ETM_OPT_CTXTID2 (on EL2 kernel).

Besides the enhancement for format "contexid", extra two formats are
introduced: "contextid1" and "contextid2".  This considers to support
tracing both CONTEXTIDR_EL1 and CONTEXTIDR_EL2 when the kernel is
running at EL2.  Finally, the PMU formats are defined as follow:

  "contextid1": Available on both EL1 kernel and EL2 kernel.  When the
                kernel is running at EL1, "contextid1" enables the PID
		tracing; when the kernel is running at EL2, this enables
		tracing the PID of guest applications.

  "contextid2": Only usable when the kernel is running at EL2.  When
                selected, enables PID tracing on EL2 kernel.

  "contextid":  Will be an alias for the option that enables PID
                tracing.  I.e,
                contextid == contextid1, on EL1 kernel.
                contextid == contextid2, on EL2 kernel.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Al Grant <al.grant@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
[ Added two config formats: contextid1, contextid2 ]
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20210206150833.42120-4-leo.yan@linaro.org
Link: https://lore.kernel.org/r/20210211172038.2483517-3-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-11 18:31:48 +01:00
..
coresight-catu.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-catu.h coresight: tmc-etr: Add function to register catu ops 2020-09-28 19:47:42 +02:00
coresight-core.c coresight: Convert claim/disclaim operations to use access wrappers 2021-02-04 17:00:32 +01:00
coresight-cpu-debug.c amba: Make the remove callback return void 2021-02-02 14:25:50 +01:00
coresight-cti-core.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-cti-platform.c coresight: cti: Reduce scope for the variable 'cs_fwnode' in cti_plat_create_connection() 2021-02-04 17:00:32 +01:00
coresight-cti-sysfs.c coresight: cti: Initialize dynamic sysfs attributes 2020-10-29 20:10:25 +01:00
coresight-cti.h coresight: Include required headers in C files 2020-05-19 16:31:18 +02:00
coresight-etb10.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-etm-cp14.c coresight: Moving framework and drivers to SPDX identifier 2018-05-14 16:19:59 +02:00
coresight-etm-perf.c coresight: etm-perf: Support PID tracing for kernel at EL2 2021-02-11 18:31:48 +01:00
coresight-etm-perf.h coresight: core: Allow the coresight core driver to be built as a module 2020-09-28 19:47:42 +02:00
coresight-etm.h coresight: etm: Clean up device specific data 2019-06-19 20:29:14 +02:00
coresight-etm3x-core.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-etm3x-sysfs.c coresight: etm: Clean up device specific data 2019-06-19 20:29:14 +02:00
coresight-etm4x-core.c coresight: etm-perf: Support PID tracing for kernel at EL2 2021-02-11 18:31:48 +01:00
coresight-etm4x-sysfs.c coresight: etm4x: Handle accesses to TRCSTALLCTLR 2021-02-04 17:00:34 +01:00
coresight-etm4x.h coresight: etm4x: Handle ETM architecture version 2021-02-04 17:00:33 +01:00
coresight-funnel.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-platform.c coresight: cti: Allow cti to be built as a module 2020-09-28 19:47:42 +02:00
coresight-priv.h coresight: tmc-etf: Fix NULL ptr dereference in tmc_enable_etf_sink_perf() 2020-11-27 20:23:12 +01:00
coresight-replicator.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-stm.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-sysfs.c coresight: Export global symbols 2020-09-28 19:47:40 +02:00
coresight-tmc-core.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
coresight-tmc-etf.c coresight: Convert claim/disclaim operations to use access wrappers 2021-02-04 17:00:32 +01:00
coresight-tmc-etr.c coresight: Convert claim/disclaim operations to use access wrappers 2021-02-04 17:00:32 +01:00
coresight-tmc.h coresight: tmc-etr: Add function to register catu ops 2020-09-28 19:47:42 +02:00
coresight-tpiu.c Merge branch 'devel-stable' of git://git.armlinux.org.uk/~rmk/linux-arm into char-misc-next 2021-02-05 11:15:43 +01:00
Kconfig coresight: etm4x: Modify core-commit to avoid HiSilicon ETM overflow 2020-12-08 19:57:19 +01:00
Makefile coresight: core: Allow the coresight core driver to be built as a module 2020-09-28 19:47:42 +02:00