Hi Christoph
On Thu, 11 Aug 2022 at 16:09, Christoph Hellwig <hch(a)lst.de> wrote:
>
> On Fri, Aug 05, 2022 at 03:15:53PM +0100, Mike Leach wrote:
> > You are correct - in this patchset we are adding the use of a binary
> > attribute to load and unload Coresight configurations and features -
> > which action has a side effect of adding and removing entries in
> > particular sub-directories in our configfs sub-system.
>
> I don't think configfs was designed to be that dynamic. Especially
> the fact that a write to a binary attribute, which is intended to
> be just for passthrough to hardware is a bit concerning.
>
configfs may not have originally been intended to be used in quite
this way, but the system is robust and well designed, and the APIs
work perfectly well in the this way.
The model of user programming a configuration item for kernel backed
elements that have a userspace lifetime (as described in configfs.rst)
is precisely the model we need to successfully leverage the coresight
subsystem. Our requirements are more complex than the ACPI tables or
USB gadget drivers that use configfs, as we are potentially
configuring multiple coresight devices. What the user sees in the
configfs directories for the configurations are only the user
adjustable features of these configurations. The rest of the
programming is set on the relevant devices.
> From your further description it sounds like this binary attribute
> is loading structured data interpreted by the kernel, which really
> isn't how binary attributes in configfs or sysfs are intended to
> be used.
If you look at the ACPI configfs, then this is in fact loading an ACPI
table structure into the kernel, through a binary attribute, that is
validated and added to a list of tables, if it passes the validation.
This is also an example of using a binary attribute to pass structured
data into the kernel for subsequent interpretation - and this example
is why I chose to use binary attributes in this way.
The data passed through the coresight 'load' binary attribute is
validated, and then only if valid loaded into the coresight subsystem
for use when coresight trace is activated and the user decides to use
the configuration. (coresight configurations are loaded, but are only
used if specifically selected during a trace session).
Regards
Mike
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Changes since v1:
* Keep existing signed offset value types until the very last commit
and then remove them all at once
* Also split out usages of read_pair() and read32() into separate
functions in the last commit
* Whitespace fixes
* Replaced any touched scnprintf() with sysfs_emit()
======
The intent of this change is to reduce the large number identical of
functions created by macros for sysfs accessors. It's possible to re-use
the same function but pass in the register to access as an argument.
This reduces the size of the coresight modules folder by 244KB.
The first two patches are refactors to simplify and remove some dead
code, and the second two are the changes to use a shared function.
Testing
=======
No changes in any of the outputs:
cat /sys/bus/coresight/devices/*/mgmt/* > before.txt
cat /sys/bus/coresight/devices/*/mgmt/* > after.txt
diff before.txt after.txt
With the following modules loaded:
ls /sys/bus/coresight/devices/
etm0 etm2 funnel0 funnel2 replicator0 tmc_etf0 tmc_etf2 tpiu0
etm1 etm3 funnel1 funnel3 stm0 tmc_etf1 tmc_etr0
James Clark (5):
coresight: Remove unused function parameter
coresight: Simplify sysfs accessors by using csdev_access abstraction
coresight: Re-use same function for similar sysfs register accessors
coresight: cti-sysfs: Re-use same functions for similar sysfs register
accessors
coresight: Make new csdev_access offsets unsigned
drivers/hwtracing/coresight/coresight-catu.c | 27 +--
drivers/hwtracing/coresight/coresight-catu.h | 8 +-
drivers/hwtracing/coresight/coresight-core.c | 28 +++
.../hwtracing/coresight/coresight-cti-sysfs.c | 213 +++++++-----------
drivers/hwtracing/coresight/coresight-etb10.c | 28 +--
.../coresight/coresight-etm3x-sysfs.c | 34 +--
drivers/hwtracing/coresight/coresight-priv.h | 74 +++---
.../coresight/coresight-replicator.c | 10 +-
drivers/hwtracing/coresight/coresight-stm.c | 40 +---
.../hwtracing/coresight/coresight-tmc-core.c | 48 ++--
drivers/hwtracing/coresight/coresight-tmc.h | 4 +-
include/linux/coresight.h | 23 ++
12 files changed, 227 insertions(+), 310 deletions(-)
--
2.28.0
On 26/08/2022 20:55, Mathieu Poirier wrote:
> On Tue, Aug 23, 2022 at 05:06:48PM +0100, James Clark wrote:
>> I've taken over this one from German because he's moved to a different
>> team. I gave it a quick check and bumped the version number in the docs
>> for the next release, but the month is an estimate.
>>
>> Thanks
>>
>> Changes since v2:
>>
>> * Rebased onto coresight/next (b99ee26a1a)
>> * Bumped release version to 6.1
>
> I have applied this set. Usually I'd let Suzuki handle it since he is already
> familiar with the work but 1) he is currently away and 2) the patchset is fairly
> simple.
Thanks Mathieu
>
> Thanks,
> Mathieu
>
>>
>> Changes since v1:
>>
>> * Inline etmv4_to_ts_source() function.
>> * Collect review tag from Leo.
>>
>> German Gomez (2):
>> coresight: etm4x: Expose default timestamp source in sysfs
>> coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
>> interface
>>
>> .../testing/sysfs-bus-coresight-devices-etm4x | 8 +++++
>> .../coresight/coresight-etm4x-reference.rst | 14 +++++++++
>> arch/arm64/include/asm/sysreg.h | 1 +
>> .../coresight/coresight-etm4x-sysfs.c | 29 +++++++++++++++++++
>> 4 files changed, 52 insertions(+)
>>
>> --
>> 2.28.0
>>
On 24/08/2022 03:54, Bagas Sanjaya wrote:
> On 8/23/22 23:06, James Clark wrote:
>> +:Example:
>> + ``$> cat ts_source``
>> +
>> + ``$> 1``
>> +
>
> Shouldn't literal code block be used instead for example snippet
> above?
>
It's consistent with the rest of the file. I think consistency for
something like this is more important than accuracy otherwise the new
entry would appear out of place.
Maybe they should all be changed to a different style, but that would be
a separate change unrelated to this set.
James
I've taken over this one from German because he's moved to a different
team. I gave it a quick check and bumped the version number in the docs
for the next release, but the month is an estimate.
Thanks
Changes since v2:
* Rebased onto coresight/next (b99ee26a1a)
* Bumped release version to 6.1
Changes since v1:
* Inline etmv4_to_ts_source() function.
* Collect review tag from Leo.
German Gomez (2):
coresight: etm4x: Expose default timestamp source in sysfs
coresight: etm4x: docs: Add documentation for 'ts_source' sysfs
interface
.../testing/sysfs-bus-coresight-devices-etm4x | 8 +++++
.../coresight/coresight-etm4x-reference.rst | 14 +++++++++
arch/arm64/include/asm/sysreg.h | 1 +
.../coresight/coresight-etm4x-sysfs.c | 29 +++++++++++++++++++
4 files changed, 52 insertions(+)
--
2.28.0
The current method for allocating trace source ID values to sources is
to use a fixed algorithm for CPU based sources of (cpu_num * 2 + 0x10).
The STM is allocated ID 0x1.
This fixed algorithm is used in both the CoreSight driver code, and by
perf when writing the trace metadata in the AUXTRACE_INFO record.
The method needs replacing as currently:-
1. It is inefficient in using available IDs.
2. Does not scale to larger systems with many cores and the algorithm
has no limits so will generate invalid trace IDs for cpu number > 44.
Additionally requirements to allocate additional system IDs on some
systems have been seen.
This patch set introduces an API that allows the allocation of trace IDs
in a dynamic manner.
Architecturally reserved IDs are never allocated, and the system is
limited to allocating only valid IDs.
Each of the current trace sources ETM3.x, ETM4.x and STM is updated to use
the new API.
For the ETMx.x devices IDs are allocated on certain events
a) When using sysfs, an ID will be allocated on hardware enable, or a read of
sysfs TRCTRACEID register and freed when the sysfs reset is written.
b) When using perf, ID is allocated on hardware enable, and freed on
hardware disable. IDs are communicated using the AUX_OUTPUT_HW_ID packet.
The ID allocator is notified when perf sessions start and stop
so CPU based IDs are kept constant throughout any perf session.
Note: This patchset breaks backward compatibility for perf record and
perf report.
Because the method for generating the AUXTRACE_INFO meta data has
changed, using an older perf record will result in metadata that
does not match the trace IDs used in the recorded trace data.
This mismatch will cause subsequent decode to fail.
The version of the AUXTRACE_INFO has been updated to reflect the fact that
the trace source IDs are no longer present in the metadata. This will
mean older versions of perf report cannot decode the file.
Applies to coresight/next [c06475910b52]
Tested on DB410c
Changes since v1:
(after feedback & discussion with Mathieu & Suzuki).
1) API has changed. The global trace ID map is managed internally, so it
is no longer passed in to the API functions.
2) perf record does not use sysfs to find the trace IDs. These are now
output as AUX_OUTPUT_HW_ID events. The drivers, perf record, and perf report
have been updated accordingly to generate and handle these events.
Mike Leach (13):
coresight: trace-id: Add API to dynamically assign Trace ID values
coresight: trace-id: update CoreSight core to use Trace ID API
coresight: stm: Update STM driver to use Trace ID API
coresight: etm4x: Update ETM4 driver to use Trace ID API
coresight: etm3x: Update ETM3 driver to use Trace ID API
coresight: etmX.X: stm: Remove unused legacy source Trace ID ops
coresight: perf: traceid: Add perf notifiers for Trace ID
perf: cs-etm: Move mapping of Trace ID and cpu into helper function
perf: cs-etm: Update record event to use new Trace ID protocol
kernel: events: Export perf_report_aux_output_id()
perf: cs-etm: Handle PERF_RECORD_AUX_OUTPUT_HW_ID packet
coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID
coresight: trace-id: Add debug & test macros to Trace ID allocation
drivers/hwtracing/coresight/Makefile | 2 +-
drivers/hwtracing/coresight/coresight-core.c | 49 +---
.../hwtracing/coresight/coresight-etm-perf.c | 17 ++
drivers/hwtracing/coresight/coresight-etm.h | 3 +-
.../coresight/coresight-etm3x-core.c | 85 +++---
.../coresight/coresight-etm3x-sysfs.c | 28 +-
.../coresight/coresight-etm4x-core.c | 65 ++++-
.../coresight/coresight-etm4x-sysfs.c | 32 ++-
drivers/hwtracing/coresight/coresight-etm4x.h | 3 +
drivers/hwtracing/coresight/coresight-stm.c | 49 +---
.../hwtracing/coresight/coresight-trace-id.c | 263 ++++++++++++++++++
.../hwtracing/coresight/coresight-trace-id.h | 65 +++++
include/linux/coresight-pmu.h | 31 ++-
include/linux/coresight.h | 3 -
kernel/events/core.c | 1 +
tools/include/linux/coresight-pmu.h | 31 ++-
tools/perf/arch/arm/util/cs-etm.c | 21 +-
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 9 +
tools/perf/util/cs-etm.c | 220 +++++++++++++--
tools/perf/util/cs-etm.h | 14 +-
20 files changed, 784 insertions(+), 207 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.c
create mode 100644 drivers/hwtracing/coresight/coresight-trace-id.h
--
2.17.1
Hey,
I want to restrict access to the Coresight registers to the secure world, so the normal world OS can not tamper with the tracing. Is this generally possible, and if yes, how? I already tried to use the address space controller (TZC-400) with the memory-addresses of the registers, but that didn’t work, because it is only for protecting DDR-memory regions, as I later found out.
Best regards
Finn
On 2022/8/17 2:00, Randy Dunlap wrote:
Hi Randy,
Thanks for your comments.
> Hi--
>
> On 8/16/22 06:16, Junhao He wrote:
>> diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig
>> index 514a9b8086e3..4380eb1a0a73 100644
>> --- a/drivers/hwtracing/coresight/Kconfig
>> +++ b/drivers/hwtracing/coresight/Kconfig
>> @@ -201,4 +201,14 @@ config CORESIGHT_TRBE
>>
>> To compile this driver as a module, choose M here: the module will be
>> called coresight-trbe.
> Please insert a blank line here like it is done elsewhere.
I will fix it in the next version.
Thanks.
>> +config ULTRASOC_SMB
>> + tristate "Ultrasoc system memory buffer drivers"
>> + depends on ACPI && ARM64 && CORESIGHT_LINKS_AND_SINKS
>> + help
>> + This driver provides support for the Ultrasoc system memory buffer (SMB).
>> + SMB is responsible for receiving the trace data from Coresight ETM devices
>> + and storing them to a system buffer.
>> +
>> + To compile this driver as a module, choose M here: the module will be
>> + called ultrasoc-smb.
>> endif
> thanks.
Regards,
Junhao.
Add support for UltraSoc System Memory Buffer.
Change since v7:
- Use the macros for register bit flags and numbers of resource.
- Fix punctuation.
- Update the Date tag and the KernelVersion tag in the document.
- Link: https://lore.kernel.org/lkml/20220712091353.34540-1-hejunhao3@huawei.com/
Change since v6:
- Modify the code style and driver description according to Suzuki's comment.
- Modify configuration of "drvdata->reading", to void problems in open/read
concurrency scenario.
- Rename the macro of "SMB_FLOW_MASK".
- Use the "handle->head" to determine the page number and offset.
- Link: https://lore.kernel.org/linux-arm-kernel/20220606130223.57354-1-liuqi115@hu…
Change since v5:
- Address the comments from Suzuki, add some comments in SMB document, and modify
configuration of "drvdata->reading", to void problems in multi-core concurrency scenario
- Link: https://lore.kernel.org/linux-arm-kernel/20220416083953.52610-1-liuqi115@hu…
Change since v4:
- Add a simple document of SMB driver according to Suzuki's comment.
- Address the comments from Suzuki.
- Link: https://lore.kernel.org/linux-arm-kernel/20220128061755.31909-1-liuqi115@hu…
Change since v3:
- Modify the file header according to community specifications.
- Address the comments from Mathieu.
- Link: https://lore.kernel.org/linux-arm-kernel/20211118110016.40398-1-liuqi115@hu…
Change since v2:
- Move ultrasoc driver to drivers/hwtracing/coresight.
- Link: https://lists.linaro.org/pipermail/coresight/2021-November/007310.html
Change since v1:
- Drop the document of UltraSoc according to Mathieu's comment.
- Add comments to explain some private hardware settings.
- Address the comments from Mathieu.
- Link: https://lists.linaro.org/pipermail/coresight/2021-August/006842.html
Change since RFC:
- Move driver to drivers/hwtracing/coresight/ultrasoc.
- Remove ultrasoc-axi-com.c, as AXI-COM doesn't need to be configured in
basic tracing function.
- Remove ultrasoc.c as SMB does not need to register with the ultrasoc core.
- Address the comments from Mathieu and Suzuki.
- Link: https://lists.linaro.org/pipermail/coresight/2021-June/006535.html
Qi Liu (2):
drivers/coresight: Add UltraSoc System Memory Buffer driver
Documentation: Add document for UltraSoc SMB drivers
.../sysfs-bus-coresight-devices-ultra_smb | 31 +
.../trace/coresight/ultrasoc-smb.rst | 80 +++
drivers/hwtracing/coresight/Kconfig | 10 +
drivers/hwtracing/coresight/Makefile | 1 +
drivers/hwtracing/coresight/ultrasoc-smb.c | 636 ++++++++++++++++++
drivers/hwtracing/coresight/ultrasoc-smb.h | 115 ++++
6 files changed, 873 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-bus-coresight-devices-ultra_smb
create mode 100644 Documentation/trace/coresight/ultrasoc-smb.rst
create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.c
create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.h
--
2.33.0